generate.rb

Path: lib/tasks/generate.rb
Last Update: Wed Oct 15 01:11:03 -0700 2008

Methods

Public Instance methods

Helper methods

[Source]

    # File lib/tasks/generate.rb, line 37
37: def app_name
38:   ( ENV['app'] || Dir.pwd.split('/').last ).camel_case
39: end

Rake only pretends to namespace tasks, so to get what we think of as the task name, you must split and grab.

[Source]

    # File lib/tasks/generate.rb, line 58
58: def basetask(str)
59:   str.split(":").last
60: end

[Source]

    # File lib/tasks/generate.rb, line 62
62: def class_template(app_name, place, class_name)
63:   str = "module \#{app_name}\n  module \#{place}\n    class \#{class_name} < Default\n\n    end\n  end\nend\n"
64: end

[Source]

    # File lib/tasks/generate.rb, line 41
41: def constant_name
42:   str = ENV['name'].camel_case
43:   raise "Cannot generate Default yet" if str == 'Default'
44:   str
45: end

[Source]

    # File lib/tasks/generate.rb, line 47
47: def filename( kind )
48:   path = File.expand_path "#{kind}/#{ENV['name'].snake_case}.rb"
49:   if File.exist?(path)
50:     $stderr.puts "  Problem encountered:\n  #{path} already exists"
51:     exit
52:   end
53:   path
54: end

This method expects its block to return something usable as a string.

[Source]

    # File lib/tasks/generate.rb, line 76
76: def module_template(app_name, place, module_name, &block)
77:   str = "module \#{app_name}\n  module \#{place}\n    module \#{module_name}\n      \#{block.call if block}\n    end\n  end\nend\n"
78: end

[Validate]