Skip to content

Commit

Permalink
fixed broken spec (now handling nil namespace correctly)
Browse files Browse the repository at this point in the history
  • Loading branch information
markryall committed Apr 6, 2012
1 parent 99ad4e8 commit 23b99e3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/blast_furnace/nodes.rb
@@ -1,7 +1,6 @@
class ClassNode < Struct.new :name class ClassNode < Struct.new :name
def eval context def eval context
context.namespace ||= '' path = build_path context.destination, context.namespace
path = "#{context.destination}/#{context.namespace}/#{name}.java"
FileUtils.mkdir_p File.dirname path FileUtils.mkdir_p File.dirname path
File.open(path, 'w') do |io| File.open(path, 'w') do |io|
io.puts <<EOF io.puts <<EOF
Expand All @@ -11,8 +10,14 @@ def eval context
end end
end end


def build_path destination, namespace
namespace ?
"#{destination}/#{namespace}/#{name}.java" :
"#{destination}/#{name}.java"
end

def package_declaration namespace def package_declaration namespace
namespace.empty? ? '' : <<EOF namespace ? <<EOF : ''
package #{namespace.gsub('/','.')}; package #{namespace.gsub('/','.')};
EOF EOF
Expand Down

0 comments on commit 23b99e3

Please sign in to comment.