Permalink
Browse files

fixing a bug with module prefixes

  • Loading branch information...
1 parent e2bc2a4 commit 5991023e90a84fbe0d29f240f2529af403b74655 @tenderlove committed Aug 20, 2008
Showing with 12 additions and 3 deletions.
  1. +6 −0 History.txt
  2. +3 −1 lib/zomg/idl/nodes/node.rb
  3. +1 −1 lib/zomg/version.rb
  4. +2 −1 test/test_node.rb
View
@@ -1,3 +1,9 @@
+=== 1.0.1
+
+* 1 bugfix
+
+ * Prefix modules must be split
+
=== 1.0.0 / 2008-07-22
* 1 major enhancement
@@ -31,7 +31,9 @@ def to_ruby(prefix = nil)
r2r = Ruby2Ruby.new
ruby_code = r2r.process(to_ruby_sexp)
if prefix
- "module #{prefix}\n#{ruby_code}\nend"
+ modules = prefix.split(/::/).map { |m| "module #{m}\n" }
+ ends = modules.map { |m| "end" }.join("\n")
+ "#{modules}#{ruby_code}\n#{ends}"
else
ruby_code
end
View
@@ -1,3 +1,3 @@
module ZOMG
- VERSION = '1.0.0'
+ VERSION = '1.0.1'
end
View
@@ -10,6 +10,7 @@ def test_to_ruby
@tree.to_ruby
}
ruby_with_prefix = @tree.to_ruby('A::B')
- assert_match(/module A::B/, ruby_with_prefix)
+ assert_match(/module A/, ruby_with_prefix)
+ assert_match(/module B/, ruby_with_prefix)
end
end

0 comments on commit 5991023

Please sign in to comment.