merb-gen 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. data/LICENSE +20 -0
  2. data/README +10 -0
  3. data/Rakefile +47 -0
  4. data/TODO +4 -0
  5. data/app_generators/merb/USAGE +0 -0
  6. data/app_generators/merb/merb_generator.rb +36 -0
  7. data/app_generators/merb/templates/Rakefile +126 -0
  8. data/app_generators/merb/templates/app/controllers/application.rb +2 -0
  9. data/app_generators/merb/templates/app/controllers/exceptions.rb +13 -0
  10. data/app_generators/merb/templates/app/helpers/global_helpers.rb +5 -0
  11. data/app_generators/merb/templates/app/views/exceptions/internal_server_error.html.erb +216 -0
  12. data/app_generators/merb/templates/app/views/exceptions/not_acceptable.html.erb +55 -0
  13. data/app_generators/merb/templates/app/views/exceptions/not_found.html.erb +39 -0
  14. data/app_generators/merb/templates/app/views/layout/application.html.erb +11 -0
  15. data/app_generators/merb/templates/autotest/discover.rb +1 -0
  16. data/app_generators/merb/templates/autotest/merb.rb +149 -0
  17. data/app_generators/merb/templates/autotest/merb_rspec.rb +202 -0
  18. data/app_generators/merb/templates/config/environments/development.rb +6 -0
  19. data/app_generators/merb/templates/config/environments/production.rb +5 -0
  20. data/app_generators/merb/templates/config/environments/rake.rb +7 -0
  21. data/app_generators/merb/templates/config/environments/test.rb +5 -0
  22. data/app_generators/merb/templates/config/init.rb +58 -0
  23. data/app_generators/merb/templates/config/rack.rb +1 -0
  24. data/app_generators/merb/templates/config/router.rb +35 -0
  25. data/app_generators/merb/templates/public/images/merb.jpg +0 -0
  26. data/app_generators/merb/templates/public/merb.fcgi +22 -0
  27. data/app_generators/merb/templates/public/stylesheets/master.css +119 -0
  28. data/app_generators/merb/templates/spec/spec.opts +0 -0
  29. data/app_generators/merb/templates/spec/spec_helper.rb +11 -0
  30. data/app_generators/merb/templates/test/test_helper.rb +14 -0
  31. data/app_generators/merb_flat/merb_flat_generator.rb +22 -0
  32. data/app_generators/merb_flat/templates/README.txt +10 -0
  33. data/app_generators/merb_flat/templates/application.rb +15 -0
  34. data/app_generators/merb_flat/templates/config/framework.rb +5 -0
  35. data/app_generators/merb_flat/templates/config/init.rb +19 -0
  36. data/app_generators/merb_flat/templates/views/foo.html.erb +3 -0
  37. data/app_generators/merb_plugin/merb_plugin_generator.rb +22 -0
  38. data/app_generators/merb_plugin/templates/LICENSE +20 -0
  39. data/app_generators/merb_plugin/templates/README +4 -0
  40. data/app_generators/merb_plugin/templates/Rakefile +44 -0
  41. data/app_generators/merb_plugin/templates/TODO +5 -0
  42. data/app_generators/merb_plugin/templates/lib/%base_name%.rb +18 -0
  43. data/app_generators/merb_plugin/templates/lib/%base_name%/merbtasks.rb +6 -0
  44. data/app_generators/merb_plugin/templates/spec/%base_name%_spec.rb +7 -0
  45. data/app_generators/merb_plugin/templates/spec/spec_helper.rb +2 -0
  46. data/app_generators/merb_plugin/templates/test/%base_name%_test.rb +0 -0
  47. data/app_generators/merb_plugin/templates/test/test_helper.rb +2 -0
  48. data/app_generators/merb_very_flat/merb_very_flat_generator.rb +37 -0
  49. data/app_generators/merb_very_flat/templates/%app_file_name%.rb +15 -0
  50. data/app_generators/merb_very_flat/templates/README.txt +9 -0
  51. data/bin/merb-gen +103 -0
  52. data/lib/merb-gen.rb +38 -0
  53. data/lib/merb-gen/base.rb +62 -0
  54. data/lib/merb-gen/helpers.rb +108 -0
  55. data/merb_default_generators/model/USAGE +0 -0
  56. data/merb_default_generators/model/model_generator.rb +40 -0
  57. data/merb_default_generators/model/templates/app/models/%model_file_name%.rb +5 -0
  58. data/merb_default_generators/resource_controller/USAGE +0 -0
  59. data/merb_default_generators/resource_controller/resource_controller_generator.rb +74 -0
  60. data/merb_default_generators/resource_controller/templates/app/controllers/%controller_file_name%.rb +46 -0
  61. data/merb_default_generators/resource_controller/templates/app/helpers/%controller_file_name%_helper.rb +16 -0
  62. data/merb_default_generators/resource_controller/templates/app/views/%controller_file_name%/delete.html.erb +3 -0
  63. data/merb_default_generators/resource_controller/templates/app/views/%controller_file_name%/edit.html.erb +3 -0
  64. data/merb_default_generators/resource_controller/templates/app/views/%controller_file_name%/index.html.erb +3 -0
  65. data/merb_default_generators/resource_controller/templates/app/views/%controller_file_name%/new.html.erb +3 -0
  66. data/merb_default_generators/resource_controller/templates/app/views/%controller_file_name%/show.html.erb +3 -0
  67. data/merb_generators/controller/USAGE +0 -0
  68. data/merb_generators/controller/controller_generator.rb +59 -0
  69. data/merb_generators/controller/templates/app/controllers/%controller_file_name%.rb +18 -0
  70. data/merb_generators/controller/templates/app/helpers/%controller_file_name%_helper.rb +16 -0
  71. data/merb_generators/controller/templates/app/views/%controller_file_name%/index.html.erb +1 -0
  72. data/merb_generators/freezer/USAGE +0 -0
  73. data/merb_generators/freezer/freezer_generator.rb +25 -0
  74. data/merb_generators/freezer/templates/script/frozen-merb +43 -0
  75. data/merb_generators/part_controller/USAGE +0 -0
  76. data/merb_generators/part_controller/part_controller_generator.rb +58 -0
  77. data/merb_generators/part_controller/templates/app/helpers/%controller_file_name%_part_helper.rb +16 -0
  78. data/merb_generators/part_controller/templates/app/parts/%controller_file_name%_part.rb +18 -0
  79. data/merb_generators/part_controller/templates/app/parts/views/%controller_file_name%_part/index.html.erb +3 -0
  80. data/merb_generators/resource/USAGE +0 -0
  81. data/merb_generators/resource/resource_generator.rb +48 -0
  82. data/rspec_generators/merb_controller_test/merb_controller_test_generator.rb +49 -0
  83. data/rspec_generators/merb_controller_test/templates/spec/controllers/%controller_full_file_path%_spec.rb +7 -0
  84. data/rspec_generators/merb_controller_test/templates/spec/helpers/%controller_full_file_path%_helper_spec.rb +5 -0
  85. data/rspec_generators/merb_model_test/merb_model_test_generator.rb +35 -0
  86. data/rspec_generators/merb_model_test/templates/spec/models/%model_file_name%_spec.rb +7 -0
  87. data/rspec_generators/merb_resource_controller_test/merb_resource_controller_test_generator.rb +49 -0
  88. data/rspec_generators/merb_resource_controller_test/templates/spec/controllers/%controller_full_file_path%_spec.rb +7 -0
  89. data/rspec_generators/merb_resource_controller_test/templates/spec/helpers/%controller_full_file_path%_helpers.rb +5 -0
  90. data/rspec_generators/merb_resource_controller_test/templates/spec/views/%controller_full_file_path%/delete.html.erb_spec.rb +1 -0
  91. data/rspec_generators/merb_resource_controller_test/templates/spec/views/%controller_full_file_path%/edit.html.erb_spec.rb +1 -0
  92. data/rspec_generators/merb_resource_controller_test/templates/spec/views/%controller_full_file_path%/index.html.erb_spec.rb +1 -0
  93. data/rspec_generators/merb_resource_controller_test/templates/spec/views/%controller_full_file_path%/new.html.erb_spec.rb +1 -0
  94. data/rspec_generators/merb_resource_controller_test/templates/spec/views/%controller_full_file_path%/show.html.erb_spec.rb +1 -0
  95. data/test_unit_generators/merb_controller_test/merb_controller_test_generator.rb +47 -0
  96. data/test_unit_generators/merb_controller_test/templates/test/functional/%controller_full_file_path%_test.rb +17 -0
  97. data/test_unit_generators/merb_model_test/merb_model_test_generator.rb +34 -0
  98. data/test_unit_generators/merb_model_test/templates/test/unit/%model_file_name%_test.rb +9 -0
  99. data/test_unit_generators/merb_resource_controller_test/merb_resource_controller_test_generator.rb +31 -0
  100. metadata +253 -0
@@ -0,0 +1,5 @@
1
+ TODO:
2
+ Fix LICENSE with your name
3
+ Fix Rakefile with your name and contact info
4
+ Add your code to lib/<%= base_name %>.rb
5
+ Add your Merb rake tasks to lib/<%= base_name %>/merbtasks.rb
@@ -0,0 +1,18 @@
1
+ # make sure we're running inside Merb
2
+ if defined?(Merb::Plugins)
3
+
4
+ # Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
5
+ Merb::Plugins.config[:<%= base_name %>] = {
6
+ :chickens => false
7
+ }
8
+
9
+ Merb::BootLoader.before_app_loads do
10
+ # require code that must be loaded before the application
11
+ end
12
+
13
+ Merb::BootLoader.after_app_loads do
14
+ # code that can be required after the application loads
15
+ end
16
+
17
+ Merb::Plugins.add_rakefiles "<%= base_name %>/merbtasks"
18
+ end
@@ -0,0 +1,6 @@
1
+ namespace :<%= base_name %> do
2
+ desc "Do something for <%= base_name %>"
3
+ task :default do
4
+ puts "<%= base_name %> doesn't do anything"
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "<%= base_name %>" do
4
+ it "should do nothing" do
5
+ true.should == true
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+ $TESTING=true
2
+ $:.push File.join(File.dirname(__FILE__), '..', 'lib')
@@ -0,0 +1,2 @@
1
+ $TESTING=true
2
+ $:.push File.join(File.dirname(__FILE__), '..', 'lib')
@@ -0,0 +1,37 @@
1
+ require "merb-gen/helpers"
2
+ require "merb-gen/base"
3
+
4
+ class MerbVeryFlatGenerator < Merb::GeneratorBase
5
+ attr_reader :app_file_name
6
+
7
+ def initialize(args, runtime_options = {})
8
+ @base = File.dirname(__FILE__)
9
+ @name = args.first
10
+ @app_file_name = File.basename(@name).snake_case
11
+ super
12
+ @destination_root = @name
13
+ end
14
+
15
+ def manifest
16
+ record do |m|
17
+
18
+ @m = m
19
+
20
+ @assigns = { :app_file_name => app_file_name }
21
+
22
+ FileUtils.mkdir_p @name
23
+ copy_dirs
24
+ copy_files
25
+ end
26
+ end
27
+
28
+ protected
29
+ def banner
30
+ <<-EOS.split("\n").map{|x| x.strip}.join("\n")
31
+ Creates a very flat Merb application stub.
32
+
33
+ USAGE: #{spec.name} path --very-flat"
34
+ EOS
35
+ end
36
+
37
+ end
@@ -0,0 +1,15 @@
1
+ Merb::Router.prepare do |r|
2
+ r.match('/').to(:controller => '<%= app_file_name %>', :action =>'index')
3
+ end
4
+
5
+ class <%= app_file_name.camel_case %> < Merb::Controller
6
+ def index
7
+ "hi"
8
+ end
9
+ end
10
+
11
+ Merb::Config.use { |c|
12
+ c[:framework] = {},
13
+ c[:session_store] = 'none',
14
+ c[:exception_details] = true
15
+ }
@@ -0,0 +1,9 @@
1
+ Merb Very Flat
2
+ ==============
3
+
4
+ An example of a single file Merb application.
5
+
6
+ Start with
7
+
8
+ merb -I <%= app_file_name %>.rb
9
+
@@ -0,0 +1,103 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ at_exit { exit }
4
+
5
+ command = ARGV.shift if %w(generate destroy update).include?(ARGV[0])
6
+
7
+ %w(rubygems merb-core).each do |file|
8
+ require file
9
+ end
10
+
11
+ # start merb
12
+ Merb.start :environment => 'development', :log_level => 'error'
13
+
14
+ # remove dependency
15
+ module Kernel
16
+ undef dependency if defined?(Kernel.dependency)
17
+ end
18
+
19
+ %w(rubigen rubigen/scripts/generate rubigen/scripts/destroy
20
+ rubigen/scripts/update fileutils find merb-gen).each do |file|
21
+ require file
22
+ end
23
+
24
+ app_help = <<-EOF
25
+ Application Generators:
26
+ To generate an application use one of the following
27
+ merb-gen app app_name (for a standard application)
28
+ merb-gen app app_name --flat (for a flattened application)
29
+ merb-gen app app_name --very-flat (for a single file application)
30
+ merb-gen frozen-merb (script to run from frozen gems/framework)
31
+ merb-gen plugin plugin_name (creates a plugin gem skeleton)
32
+
33
+ Other Generators:
34
+ merb-gen generators
35
+ with no args will display all availble generators for the current configuration.
36
+ EOF
37
+
38
+ # merb-gen || merb-gen help || merb-gen help app || merb-gen app
39
+ if ARGV.empty? || (ARGV[0] == "help" && ARGV.length == 1) ||
40
+ (ARGV[0] == "help" && ARGV[1] == "app") || (ARGV[0] == "app" && ARGV.length == 1)
41
+ puts app_help
42
+
43
+ # merb-gen generators
44
+ elsif ARGV[0] == "generators"
45
+ # List all the Available Generators
46
+ RubiGen::Base.use_component_sources! Merb.generator_scope
47
+ RubiGen::Scripts::Generate.new.run([])
48
+
49
+ # merb-gen help foo
50
+ elsif ARGV[0] && ARGV[0] == "help"
51
+ begin
52
+ RubiGen::Base.use_component_sources! Merb.generator_scope
53
+ RubiGen::Base.lookup(ARGV[1])
54
+ Merb::ComponentGenerator.run ARGV[1], ARGV[2..-1], ARGV[1], command || "generate"
55
+ rescue RubiGen::GeneratorError
56
+ # List all the Available Generators
57
+ RubiGen::Base.use_component_sources! Merb.generator_scope
58
+ RubiGen::Scripts::Generate.new.run([])
59
+ rescue => e
60
+ puts e.message
61
+ end
62
+
63
+ # merb-gen app myapp
64
+ elsif ARGV[0] && ARGV[0] == "app" && ARGV[1] && ARGV[1] !~ /^-/
65
+ app_type = case ARGV[2]
66
+ when "--flat"
67
+ "merb_flat"
68
+ when "--very-flat"
69
+ "merb_very_flat"
70
+ else
71
+ "merb"
72
+ end
73
+ Merb::ApplicationGenerator.run ARGV[1], ARGV[3..-1], app_type, command || "generate"
74
+
75
+ # merb-gen plugin foo
76
+ elsif ARGV[0] && ARGV[0] == "plugin"
77
+ Merb::ApplicationGenerator.run ARGV[1], ARGV[2..-1], "merb_plugin", command || "generate"
78
+
79
+ # merb-gen frozen-merb
80
+ elsif ARGV[0] && ARGV[0] == "frozen-merb"
81
+ Merb::ComponentGenerator.run "frozen-merb", ["frozen-merb"], "freezer", command || "generate"
82
+
83
+ # merb-gen controller foo
84
+ # merb-gen resource foo --test
85
+ elsif ARGV[1] && ARGV[1] !~ /^-/
86
+ Merb::ComponentGenerator.run ARGV[1], ARGV[1..-1], ARGV.first, command || "generate"
87
+
88
+ # catch all merb-gen -??? and display help instead of creating application in -???
89
+ elsif ARGV[0] && ARGV[0] =~ /^-/
90
+ puts app_help
91
+
92
+ else
93
+ begin
94
+ # May be a generator that takes no arguments.
95
+ RubiGen::Base.use_component_sources! Merb.generator_scope
96
+ RubiGen::Base.lookup(ARGV[0])
97
+ Merb::ComponentGenerator.run ARGV[0], ARGV[1..-1], ARGV.first, command || "generate"
98
+ rescue RubiGen::GeneratorError
99
+ puts app_help
100
+ rescue => e
101
+ puts e.message
102
+ end
103
+ end
@@ -0,0 +1,38 @@
1
+ require 'rubigen'
2
+ module Merb
3
+ require File.join(File.dirname(__FILE__), "merb-gen", "base")
4
+
5
+ class ApplicationGenerator
6
+ def self.run(path, argv, generator, command)
7
+ if command == "destroy"
8
+ puts "destroying app"
9
+ FileUtils.rm_rf(File.expand_path(path))
10
+ puts "done"
11
+ exit
12
+ end
13
+
14
+ source = RubiGen::PathSource.new(:application,
15
+ File.join(File.dirname(__FILE__), "..", "app_generators"))
16
+ RubiGen::Base.reset_sources
17
+ RubiGen::Base.append_sources source
18
+ puts RubiGen::Scripts.const_get(command.capitalize).inspect
19
+ RubiGen::Scripts.const_get(command.capitalize).new.run([File.expand_path(path), *argv], :generator => generator, :backtrace => true)
20
+ end
21
+ end
22
+
23
+ class ComponentGenerator
24
+ def self.run(name, argv, generator, command)
25
+ app_root = Dir.pwd
26
+
27
+ # Merb.start :environment => 'development'
28
+
29
+ Gem.clear_paths
30
+ Gem.path.unshift(app_root / "gems")
31
+
32
+ require "rubigen/scripts/#{command}"
33
+
34
+ RubiGen::Base.use_component_sources! Merb.generator_scope
35
+ RubiGen::Scripts.const_get(command.capitalize).new.run(argv, :generator => generator, :destination => app_root)
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,62 @@
1
+ require File.join(File.dirname(__FILE__), "helpers")
2
+
3
+ class Merb::GeneratorBase < RubiGen::Base
4
+ include Merb::GeneratorHelpers
5
+ attr_reader :name, :base, :choices, :assigns, :m
6
+
7
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
8
+ Config::CONFIG['ruby_install_name']) unless defined?(DEFAULT_SHEBANG)
9
+
10
+ default_options :shebang => DEFAULT_SHEBANG
11
+
12
+ def initialize(args, runtime_options = {})
13
+ super
14
+ usage if args.empty?
15
+ self.class.use_component_sources! Merb.generator_scope
16
+ @destination_root = Dir.pwd
17
+ @choices ||= []
18
+ end
19
+
20
+ def manifest
21
+ record do |m|
22
+ @m = m
23
+
24
+ options["spec"] = true unless options["test"]
25
+
26
+ # Set directories that should be optional based on command-line args
27
+ @choices = %w(test spec)
28
+
29
+ # Set the assigns that should be used for path-interpolation and building templates
30
+ @assigns = {:base_name => File.basename(@name), :test_type => options["spec"] ? "rspec" : "test_unit"}
31
+
32
+ FileUtils.mkdir_p @name
33
+ copy_dirs
34
+ copy_files
35
+
36
+ display_framework_selections
37
+ end
38
+ end
39
+
40
+ protected
41
+ def banner
42
+ <<-EOS.split("\n").map{|x| x.strip}.join("\n")
43
+ Creates a Merb plugin stub.
44
+
45
+ USAGE: #{spec.name} --generate-plugin path"
46
+ EOS
47
+ end
48
+
49
+ def add_options!(opts)
50
+ opts.on("-S", "--[no-]spec", "Generate with RSpec") {|s| @options["spec"] = true}
51
+ opts.on("-T", "--[no-]test", "Generate with Test::Unit") {|t| @options["test"] = true}
52
+ end
53
+
54
+ def display_framework_selections
55
+ puts
56
+ puts "Your app will use the #{@assigns[:test_type]} test framework."
57
+ if Gem.cache.search("merb_#{@assigns[:test_type]}").size == 0
58
+ puts "You need to install the merb_#{@assigns[:test_type]} gem."
59
+ end
60
+ puts
61
+ end
62
+ end
@@ -0,0 +1,108 @@
1
+ MAIN_BINDING = binding unless defined?(MAIN_BINDING)
2
+
3
+ module Merb::GeneratorHelpers
4
+
5
+ # Remove "template/" from a file name
6
+ #
7
+ # ==== Parameters
8
+ # +path+<String>:: the path to relative-ize
9
+ # +dir+<String>:: a prefix directory to add into the relative-ized path
10
+ #
11
+ # ==== Returns
12
+ # String:: a relative-ized path
13
+ def relative(path, dir = nil)
14
+ path.gsub(/^#{base}\/templates(\/#{dir ? dir + "/" : ""})?/, "")
15
+ end
16
+
17
+ def interpolate_path(path)
18
+ path.gsub(/%([^\}]*)%/) {|x| assigns[$1.to_sym]}
19
+ end
20
+
21
+ # Establishes the directories of the template layout
22
+ def copy_dirs
23
+ select_template_directories.map { |x| relative(x) }.each do |path|
24
+ m.directory interpolate_path(path)
25
+ end
26
+ end
27
+
28
+ # Copies all files within each directory of the template layout
29
+ def copy_files
30
+ select_template_directories(true).each do |file|
31
+ # Remove "template/" from the glob filename
32
+ dir = relative(file)
33
+
34
+ # Get all the files under the directory that are not directories or in
35
+ # the list of excluded templates above.
36
+ files = Dir["#{file.empty? ? "." : file}/*"].reject { |f| File.directory?(f) }
37
+
38
+ next if files.empty?
39
+
40
+ # We want to templatize any files that contain <% %> characters
41
+ #--
42
+ # This is old code, should we need it:
43
+ # templates, to_copy = files.partition {|file| !(file =~ /\.erb$/) && File.read(file) =~ /<%.*%>/}
44
+ templates, to_copy = files.partition { |file| File.read(file) =~ /<%.*%>/ }
45
+
46
+ # Make the paths relative to the directory we're inspecting
47
+ [to_copy, templates].each do |paths|
48
+ paths.map! { |f| relative(f, dir) }
49
+ end
50
+
51
+ # Copy the files over
52
+ to_copy.each do |filename|
53
+ m.file(
54
+ file_name(dir, filename),
55
+ file_name(interpolate_path(dir), filename)
56
+ )
57
+ end
58
+
59
+ # Copy the templates over
60
+ templates.each do |filename|
61
+ m.template(
62
+ file_name(dir, filename),
63
+ file_name(interpolate_path(dir), interpolate_path(filename))
64
+ )
65
+ end
66
+ end
67
+ end
68
+
69
+ private
70
+
71
+ # Selects all *directories* in the 'templates' folder. This accounts for
72
+ # +choices+ and +options+.
73
+ #
74
+ # ==== Arguments
75
+ # +with_root+<true,false>:: whether or not to include the base/templates
76
+ # directory
77
+ #
78
+ # ==== Returns
79
+ # Array:: all directories found in the 'templates' folder.
80
+ def select_template_directories(with_root=false)
81
+ selected = Dir["#{base}/templates/**/*"].compact.select do |f|
82
+ File.directory?(f) &&
83
+ (!choices.include?(relative(f)) || options[relative(f)])
84
+ end
85
+ selected += ["#{base}/templates"] if with_root
86
+ return selected
87
+ end
88
+
89
+ # This was extracted from +copy_files+. It appears to do the same thing as
90
+ # File.join, but it doesn't account for the OS.
91
+ #
92
+ # ==== Arguments
93
+ # +dir+<String>:: the directory to place the file in
94
+ # +name+<String>:: the name of said file
95
+ #
96
+ # ==== Returns
97
+ # String:: a string representing the path for some file
98
+ #
99
+ # ==== Examples
100
+ # > file_name("folder", "some_file.txt")
101
+ # => "folder/some_file.txt"
102
+ # > file_name("", "some_file.txt")
103
+ # => "some_file.txt"
104
+ def file_name(dir, name)
105
+ "#{dir}#{"/" unless dir.empty?}#{name}"
106
+ end
107
+
108
+ end
File without changes
@@ -0,0 +1,40 @@
1
+ class ModelGenerator < Merb::GeneratorBase
2
+ attr_reader :model_attributes, :model_class_name, :model_file_name
3
+
4
+ def initialize(args, runtime_args = {})
5
+ @base = File.dirname(__FILE__)
6
+ super
7
+ @model_file_name = args.shift.snake_case
8
+ @model_class_name = @model_file_name.to_const_string
9
+ @model_attributes = Hash[*(args.map{|a| a.split(":") }.flatten)]
10
+ end
11
+
12
+ def manifest
13
+ record do |m|
14
+
15
+ @m = m
16
+
17
+ @assigns = {
18
+ :model_file_name => model_file_name,
19
+ :model_attributes => model_attributes,
20
+ :model_class_name => model_class_name
21
+ }
22
+
23
+ copy_dirs
24
+ copy_files
25
+
26
+ m.dependency "merb_model_test", [model_file_name], @assigns
27
+
28
+ end
29
+ end
30
+
31
+ protected
32
+ def banner
33
+ <<-EOS.split("\n").map{|x| x.strip}.join("\n")
34
+ Creates a basic Merb model stub.
35
+
36
+ USAGE: #{spec.name} my_model property1:type property1:type
37
+ EOS
38
+ end
39
+
40
+ end