| Path: | lib/tasks/generate.rb |
| Last Update: | Wed Oct 15 01:11:03 -0700 2008 |
Helper methods
# 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.
# File lib/tasks/generate.rb, line 58
58: def basetask(str)
59: str.split(":").last
60: end
# 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
# 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
# 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