Permalink
Browse files

fixed broken spec (now handling nil namespace correctly)

  • Loading branch information...
markryall committed Apr 6, 2012
1 parent 99ad4e8 commit 23b99e392caf2aebc62baa10eb30a7127f2bb215
Showing with 8 additions and 3 deletions.
  1. +8 −3 lib/blast_furnace/nodes.rb
View
@@ -1,7 +1,6 @@
class ClassNode < Struct.new :name
def eval context
- context.namespace ||= ''
- path = "#{context.destination}/#{context.namespace}/#{name}.java"
+ path = build_path context.destination, context.namespace
FileUtils.mkdir_p File.dirname path
File.open(path, 'w') do |io|
io.puts <<EOF
@@ -11,8 +10,14 @@ def eval context
end
end
+ def build_path destination, namespace
+ namespace ?
+ "#{destination}/#{namespace}/#{name}.java" :
+ "#{destination}/#{name}.java"
+ end
+
def package_declaration namespace
- namespace.empty? ? '' : <<EOF
+ namespace ? <<EOF : ''
package #{namespace.gsub('/','.')};
EOF

0 comments on commit 23b99e3

Please sign in to comment.