Commit a62342f3550843e6d66228e7f0e77d84588fcee0

Authored by Diego Camarinha
Committed by Diego Camarinha
1 parent 7aefdd4a

Split module name

plugins/mezuro/lib/kalibro/entities/module.rb
... ... @@ -2,4 +2,13 @@ class Kalibro::Entities::Module < Kalibro::Entities::Entity
2 2  
3 3 attr_accessor :name, :granularity
4 4  
5   -end
6 5 \ No newline at end of file
  6 + def ancestor_names
  7 + path = []
  8 + ancestors = []
  9 + @name.split(".").each do |token|
  10 + path << token
  11 + ancestors << path.join(".")
  12 + end
  13 + ancestors
  14 + end
  15 +end
... ...
plugins/mezuro/test/unit/kalibro/entities/module_test.rb
... ... @@ -17,4 +17,14 @@ class ModuleTest &lt; ActiveSupport::TestCase
17 17 assert_equal @hash, @module.to_hash
18 18 end
19 19  
20   -end
21 20 \ No newline at end of file
  21 + should 'list ancestor names' do
  22 + @module.name = "org.kalibro.core"
  23 + assert_equal ["org", "org.kalibro", "org.kalibro.core"], @module.ancestor_names
  24 + end
  25 +
  26 + should 'list ancestor with one name' do
  27 + @module.name = "org"
  28 + assert_equal ["org"], @module.ancestor_names
  29 + end
  30 +
  31 +end
... ...