Commit a62342f3550843e6d66228e7f0e77d84588fcee0
Committed by
Diego Camarinha
1 parent
7aefdd4a
Exists in
master
and in
23 other branches
Split module name
Showing
2 changed files
with
21 additions
and
2 deletions
Show diff stats
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 < 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 | ... | ... |