merb-gen 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. data/README +14 -2
  2. data/Rakefile +43 -27
  3. data/TODO +13 -0
  4. data/bin/merb-gen +5 -93
  5. data/lib/generators/controller.rb +44 -0
  6. data/lib/generators/freezer.rb +19 -0
  7. data/lib/generators/helper.rb +31 -0
  8. data/lib/generators/layout.rb +27 -0
  9. data/lib/generators/merb.rb +24 -0
  10. data/lib/generators/merb/merb_flat.rb +27 -0
  11. data/lib/generators/merb/merb_full.rb +35 -0
  12. data/lib/generators/merb/merb_very_flat.rb +29 -0
  13. data/lib/generators/merb_plugin.rb +29 -0
  14. data/lib/generators/migration.rb +54 -0
  15. data/lib/generators/model.rb +47 -0
  16. data/lib/generators/part_controller.rb +33 -0
  17. data/lib/generators/resource.rb +32 -0
  18. data/lib/generators/resource_controller.rb +78 -0
  19. data/lib/generators/session_migration.rb +34 -0
  20. data/lib/generators/templates/application/merb/Rakefile +75 -0
  21. data/{app_generators/merb/templates → lib/generators/templates/application/merb}/app/controllers/application.rb +0 -0
  22. data/{app_generators/merb/templates → lib/generators/templates/application/merb}/app/controllers/exceptions.rb +0 -0
  23. data/{app_generators/merb/templates → lib/generators/templates/application/merb}/app/helpers/global_helpers.rb +0 -0
  24. data/{app_generators/merb/templates → lib/generators/templates/application/merb}/app/views/exceptions/internal_server_error.html.erb +1 -1
  25. data/{app_generators/merb/templates → lib/generators/templates/application/merb}/app/views/exceptions/not_acceptable.html.erb +0 -0
  26. data/{app_generators/merb/templates → lib/generators/templates/application/merb}/app/views/exceptions/not_found.html.erb +0 -0
  27. data/{app_generators/merb/templates → lib/generators/templates/application/merb}/autotest/discover.rb +0 -0
  28. data/{app_generators/merb/templates → lib/generators/templates/application/merb}/autotest/merb.rb +2 -2
  29. data/lib/generators/templates/application/merb/autotest/merb_rspec.rb +166 -0
  30. data/{app_generators/merb/templates → lib/generators/templates/application/merb}/config/environments/development.rb +0 -0
  31. data/{app_generators/merb/templates → lib/generators/templates/application/merb}/config/environments/production.rb +0 -0
  32. data/{app_generators/merb/templates → lib/generators/templates/application/merb}/config/environments/rake.rb +0 -0
  33. data/{app_generators/merb/templates → lib/generators/templates/application/merb}/config/environments/test.rb +0 -0
  34. data/{app_generators/merb/templates → lib/generators/templates/application/merb}/config/init.rb +38 -27
  35. data/lib/generators/templates/application/merb/config/rack.rb +12 -0
  36. data/{app_generators/merb/templates → lib/generators/templates/application/merb}/config/router.rb +0 -0
  37. data/{app_generators/merb/templates → lib/generators/templates/application/merb}/public/images/merb.jpg +0 -0
  38. data/{app_generators/merb/templates → lib/generators/templates/application/merb}/public/merb.fcgi +0 -0
  39. data/{app_generators/merb/templates → lib/generators/templates/application/merb}/public/stylesheets/master.css +0 -0
  40. data/{app_generators/merb/templates → lib/generators/templates/application/merb}/spec/spec.opts +0 -0
  41. data/{app_generators/merb/templates → lib/generators/templates/application/merb}/spec/spec_helper.rb +3 -1
  42. data/{app_generators/merb/templates → lib/generators/templates/application/merb}/test/test_helper.rb +0 -0
  43. data/{app_generators/merb_flat/templates → lib/generators/templates/application/merb_flat}/README.txt +0 -0
  44. data/{app_generators/merb_flat/templates → lib/generators/templates/application/merb_flat}/application.rb +0 -0
  45. data/lib/generators/templates/application/merb_flat/config/framework.rb +7 -0
  46. data/{app_generators/merb_flat/templates → lib/generators/templates/application/merb_flat}/config/init.rb +0 -1
  47. data/{app_generators/merb_flat/templates → lib/generators/templates/application/merb_flat}/views/foo.html.erb +0 -0
  48. data/{app_generators/merb_plugin/templates → lib/generators/templates/application/merb_plugin}/LICENSE +0 -0
  49. data/{app_generators/merb_plugin/templates → lib/generators/templates/application/merb_plugin}/README +0 -0
  50. data/lib/generators/templates/application/merb_plugin/Rakefile +59 -0
  51. data/{app_generators/merb_plugin/templates → lib/generators/templates/application/merb_plugin}/TODO +0 -0
  52. data/{app_generators/merb_plugin/templates → lib/generators/templates/application/merb_plugin}/lib/%base_name%.rb +1 -1
  53. data/{app_generators/merb_plugin/templates → lib/generators/templates/application/merb_plugin}/lib/%base_name%/merbtasks.rb +1 -1
  54. data/{app_generators/merb_plugin/templates → lib/generators/templates/application/merb_plugin}/spec/%base_name%_spec.rb +0 -0
  55. data/{app_generators/merb_plugin/templates → lib/generators/templates/application/merb_plugin}/spec/spec_helper.rb +0 -0
  56. data/{app_generators/merb_plugin/templates → lib/generators/templates/application/merb_plugin}/test/%base_name%_test.rb +0 -0
  57. data/{app_generators/merb_plugin/templates → lib/generators/templates/application/merb_plugin}/test/test_helper.rb +0 -0
  58. data/lib/generators/templates/application/merb_very_flat/application.rbt +17 -0
  59. data/lib/generators/templates/component/controller/app/controllers/%file_name%.rb +11 -0
  60. data/lib/generators/templates/component/controller/app/views/%file_name%/index.html.erb +1 -0
  61. data/lib/generators/templates/component/controller/spec/controllers/%file_name%_spec.rb +7 -0
  62. data/lib/generators/templates/component/controller/test/controllers/%file_name%_test.rb +17 -0
  63. data/lib/generators/templates/component/freezer/script/frozen_merb +43 -0
  64. data/lib/generators/templates/component/helper/app/helpers/%file_name%_helper.rb +7 -0
  65. data/lib/generators/templates/component/helper/spec/helpers/%file_name%_helper_spec.rb +5 -0
  66. data/{app_generators/merb/templates/app/views/layout/application.html.erb → lib/generators/templates/component/layout/app/views/layout/%file_name%.html.erb} +0 -0
  67. data/lib/generators/templates/component/layout/spec/views/layout/%file_name%.html.erb_spec.rb +1 -0
  68. data/lib/generators/templates/component/model/app/models/%file_name%.rb +7 -0
  69. data/lib/generators/templates/component/model/spec/models/%file_name%_spec.rb +7 -0
  70. data/lib/generators/templates/component/model/test/models/%file_name%_test.rb +9 -0
  71. data/lib/generators/templates/component/part_controller/app/parts/%file_name%_part.rb +9 -0
  72. data/lib/generators/templates/component/part_controller/app/parts/views/%file_name%_part/index.html.erb +3 -0
  73. data/lib/generators/templates/component/resource_controller/app/controllers/%file_name%.rb +44 -0
  74. data/lib/generators/templates/component/resource_controller/app/views/%file_name%/edit.html.erb +3 -0
  75. data/lib/generators/templates/component/resource_controller/app/views/%file_name%/index.html.erb +3 -0
  76. data/lib/generators/templates/component/resource_controller/app/views/%file_name%/new.html.erb +3 -0
  77. data/lib/generators/templates/component/resource_controller/app/views/%file_name%/show.html.erb +3 -0
  78. data/lib/generators/templates/component/resource_controller/spec/controllers/%file_name%_spec.rb +7 -0
  79. data/lib/generators/templates/component/resource_controller/test/controllers/%file_name%_test.rb +17 -0
  80. data/lib/merb-gen.rb +34 -36
  81. data/lib/merb-gen/generator.rb +54 -0
  82. data/lib/merb-gen/named_generator.rb +33 -0
  83. data/lib/merb-gen/namespaced_generator.rb +47 -0
  84. data/lib/merb-gen/spec_helper.rb +65 -0
  85. data/spec/controller_spec.rb +106 -0
  86. data/spec/fixtures/results/no_modules.test +1 -0
  87. data/spec/fixtures/results/some_modules.test +5 -0
  88. data/spec/fixtures/templates/no_modules.test +3 -0
  89. data/spec/fixtures/templates/some_modules.test +3 -0
  90. data/spec/freezer_spec.rb +17 -0
  91. data/spec/generator_spec.rb +51 -0
  92. data/spec/helper_spec.rb +43 -0
  93. data/spec/layout_spec.rb +25 -0
  94. data/spec/merb_flat_spec.rb +21 -0
  95. data/spec/merb_full_spec.rb +31 -0
  96. data/spec/merb_plugin_spec.rb +21 -0
  97. data/spec/merb_spec.rb +20 -0
  98. data/spec/merb_very_flat_spec.rb +19 -0
  99. data/spec/migration_spec.rb +47 -0
  100. data/spec/model_spec.rb +66 -0
  101. data/spec/named_generator_spec.rb +11 -0
  102. data/spec/namespaced_generator_spec.rb +11 -0
  103. data/spec/part_controller_spec.rb +74 -0
  104. data/spec/resource_controller_spec.rb +102 -0
  105. data/spec/resource_spec.rb +18 -0
  106. data/spec/session_migration_spec.rb +15 -0
  107. data/spec/spec_helper.rb +271 -0
  108. metadata +246 -181
  109. data/app_generators/merb/USAGE +0 -0
  110. data/app_generators/merb/merb_generator.rb +0 -40
  111. data/app_generators/merb/templates/Rakefile +0 -34
  112. data/app_generators/merb/templates/autotest/merb_rspec.rb +0 -223
  113. data/app_generators/merb/templates/config/rack.rb +0 -1
  114. data/app_generators/merb_flat/merb_flat_generator.rb +0 -22
  115. data/app_generators/merb_flat/templates/config/framework.rb +0 -5
  116. data/app_generators/merb_plugin/merb_plugin_generator.rb +0 -22
  117. data/app_generators/merb_plugin/templates/Rakefile +0 -44
  118. data/app_generators/merb_very_flat/merb_very_flat_generator.rb +0 -37
  119. data/app_generators/merb_very_flat/templates/%app_file_name%.rb +0 -15
  120. data/app_generators/merb_very_flat/templates/README.txt +0 -9
  121. data/lib/merb-gen/base.rb +0 -66
  122. data/lib/merb-gen/helpers.rb +0 -108
  123. data/merb_default_generators/model/USAGE +0 -0
  124. data/merb_default_generators/model/model_generator.rb +0 -40
  125. data/merb_default_generators/model/templates/app/models/%model_file_name%.rb +0 -5
  126. data/merb_default_generators/resource_controller/USAGE +0 -0
  127. data/merb_default_generators/resource_controller/resource_controller_generator.rb +0 -74
  128. data/merb_default_generators/resource_controller/templates/app/controllers/%controller_file_name%.rb +0 -46
  129. data/merb_default_generators/resource_controller/templates/app/helpers/%controller_file_name%_helper.rb +0 -16
  130. data/merb_default_generators/resource_controller/templates/app/views/%controller_file_name%/delete.html.erb +0 -3
  131. data/merb_default_generators/resource_controller/templates/app/views/%controller_file_name%/edit.html.erb +0 -3
  132. data/merb_default_generators/resource_controller/templates/app/views/%controller_file_name%/index.html.erb +0 -3
  133. data/merb_default_generators/resource_controller/templates/app/views/%controller_file_name%/new.html.erb +0 -3
  134. data/merb_default_generators/resource_controller/templates/app/views/%controller_file_name%/show.html.erb +0 -3
  135. data/merb_generators/controller/USAGE +0 -0
  136. data/merb_generators/controller/controller_generator.rb +0 -59
  137. data/merb_generators/controller/templates/app/controllers/%controller_file_name%.rb +0 -18
  138. data/merb_generators/controller/templates/app/helpers/%controller_file_name%_helper.rb +0 -16
  139. data/merb_generators/controller/templates/app/views/%controller_file_name%/index.html.erb +0 -1
  140. data/merb_generators/part_controller/USAGE +0 -0
  141. data/merb_generators/part_controller/part_controller_generator.rb +0 -58
  142. data/merb_generators/part_controller/templates/app/helpers/%controller_file_name%_part_helper.rb +0 -16
  143. data/merb_generators/part_controller/templates/app/parts/%controller_file_name%_part.rb +0 -18
  144. data/merb_generators/part_controller/templates/app/parts/views/%controller_file_name%_part/index.html.erb +0 -3
  145. data/merb_generators/resource/USAGE +0 -0
  146. data/merb_generators/resource/resource_generator.rb +0 -48
  147. data/rspec_generators/merb_controller_test/merb_controller_test_generator.rb +0 -49
  148. data/rspec_generators/merb_controller_test/templates/spec/controllers/%controller_full_file_path%_spec.rb +0 -7
  149. data/rspec_generators/merb_controller_test/templates/spec/helpers/%controller_full_file_path%_helper_spec.rb +0 -5
  150. data/rspec_generators/merb_model_test/merb_model_test_generator.rb +0 -35
  151. data/rspec_generators/merb_model_test/templates/spec/models/%model_file_name%_spec.rb +0 -7
  152. data/rspec_generators/merb_resource_controller_test/merb_resource_controller_test_generator.rb +0 -49
  153. data/rspec_generators/merb_resource_controller_test/templates/spec/controllers/%controller_full_file_path%_spec.rb +0 -7
  154. data/rspec_generators/merb_resource_controller_test/templates/spec/helpers/%controller_full_file_path%_helpers.rb +0 -5
  155. data/rspec_generators/merb_resource_controller_test/templates/spec/views/%controller_full_file_path%/delete.html.erb_spec.rb +0 -1
  156. data/rspec_generators/merb_resource_controller_test/templates/spec/views/%controller_full_file_path%/edit.html.erb_spec.rb +0 -1
  157. data/rspec_generators/merb_resource_controller_test/templates/spec/views/%controller_full_file_path%/index.html.erb_spec.rb +0 -1
  158. data/rspec_generators/merb_resource_controller_test/templates/spec/views/%controller_full_file_path%/new.html.erb_spec.rb +0 -1
  159. data/rspec_generators/merb_resource_controller_test/templates/spec/views/%controller_full_file_path%/show.html.erb_spec.rb +0 -1
  160. data/test_unit_generators/merb_controller_test/merb_controller_test_generator.rb +0 -47
  161. data/test_unit_generators/merb_controller_test/templates/test/functional/%controller_full_file_path%_test.rb +0 -17
  162. data/test_unit_generators/merb_model_test/merb_model_test_generator.rb +0 -34
  163. data/test_unit_generators/merb_model_test/templates/test/unit/%model_file_name%_test.rb +0 -9
  164. data/test_unit_generators/merb_resource_controller_test/merb_resource_controller_test_generator.rb +0 -31
@@ -9,7 +9,7 @@ class Autotest::Merb < Autotest
9
9
  # +fixtures_dir+:: the directory to find fixtures in
10
10
  attr_accessor :model_tests_dir, :controller_tests_dir, :view_tests_dir, :fixtures_dir
11
11
 
12
- def initialize # :nodoc:
12
+ def initialize
13
13
  super
14
14
 
15
15
  initialize_test_layout
@@ -127,7 +127,7 @@ private
127
127
  # => "login_controller_test.rb"
128
128
  # > test_for("form", :view)
129
129
  # => "form_view_spec.rb" # If you're running a RSpec-like suite
130
- def test_for(filename, kind_of_test) # :nodoc:
130
+ def test_for(filename, kind_of_test)
131
131
  name = [filename]
132
132
  name << kind_of_test.to_s if kind_of_test == :view
133
133
  name << "test"
@@ -0,0 +1,166 @@
1
+ # Adapted from Autotest::Rails, RSpec's autotest class, as well as merb-core's.
2
+ require 'autotest'
3
+
4
+ class RspecCommandError < StandardError; end
5
+
6
+ # This class maps your application's structure so Autotest can understand what
7
+ # specs to run when files change.
8
+ #
9
+ # Fixtures are _not_ covered by this class. If you change a fixture file, you
10
+ # will have to run your spec suite manually, or, better yet, provide your own
11
+ # Autotest map explaining how your fixtures are set up.
12
+ class Autotest::MerbRspec < Autotest
13
+ def initialize
14
+ super
15
+
16
+ # Ignore any happenings in these directories
17
+ add_exception %r%^\./(?:doc|log|public|tmp)%
18
+
19
+ # Ignore SCM directories and custom Autotest mappings
20
+ %w[.svn .hg .git .autotest].each { |exception| add_exception(exception) }
21
+
22
+ # Ignore any mappings that Autotest may have already set up
23
+ clear_mappings
24
+
25
+ # Anything in /lib could have a spec anywhere, if at all. So, look for
26
+ # files with roughly the same name as the file in /lib
27
+ add_mapping %r%^lib\/(.*)\.rb% do |_, m|
28
+ files_matching %r%^spec\/#{m[1]}%
29
+ end
30
+
31
+ add_mapping %r%^spec/(spec_helper|shared/.*)\.rb$% do
32
+ all_specs
33
+ end
34
+
35
+ # Changing a spec will cause it to run itself
36
+ add_mapping %r%^spec/.*\.rb$% do |filename, _|
37
+ filename
38
+ end
39
+
40
+ # Any change to a model will cause it's corresponding test to be run
41
+ add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
42
+ spec_for(m[1], 'model')
43
+ end
44
+
45
+ # Any change to global_helpers will result in all view and controller
46
+ # tests being run
47
+ add_mapping %r%^app/helpers/global_helpers\.rb% do
48
+ files_matching %r%^spec/(views|controllers|helpers)/.*_spec\.rb$%
49
+ end
50
+
51
+ # Any change to a helper will cause its spec to be run
52
+ add_mapping %r%^app/helpers/((.*)_helper(s)?)\.rb% do |_, m|
53
+ spec_for(m[1], 'helper')
54
+ end
55
+
56
+ # Changes to a view cause its spec to be run
57
+ add_mapping %r%^app/views/(.*)/% do |_, m|
58
+ spec_for(m[1], 'view')
59
+ end
60
+
61
+ # Changes to a controller result in its corresponding spec being run. If
62
+ # the controller is the exception or application controller, all
63
+ # controller specs are run.
64
+ add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
65
+ if ["application", "exception"].include?(m[1])
66
+ files_matching %r%^spec/controllers/.*_spec\.rb$%
67
+ else
68
+ spec_for(m[1], 'controller')
69
+ end
70
+ end
71
+
72
+ # If a change is made to the router, run controller, view and helper specs
73
+ add_mapping %r%^config/router.rb$% do
74
+ files_matching %r%^spec/(controllers|views|helpers)/.*_spec\.rb$%
75
+ end
76
+
77
+ # If any of the major files governing the environment are altered, run
78
+ # everything
79
+ add_mapping %r%^config/(init|rack|environments/test).*\.rb|database\.yml% do
80
+ all_specs
81
+ end
82
+ end
83
+
84
+ def failed_results(results)
85
+ results.scan(/^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m)
86
+ end
87
+
88
+ def handle_results(results)
89
+ @failures = failed_results(results)
90
+ @files_to_test = consolidate_failures(@failures)
91
+ @files_to_test.empty? && !$TESTING ? hook(:green) : hook(:red)
92
+ @tainted = !@files_to_test.empty?
93
+ end
94
+
95
+ def consolidate_failures(failed)
96
+ filters = Hash.new { |h,k| h[k] = [] }
97
+ failed.each do |spec, failed_trace|
98
+ if f = test_files_for(failed).find { |f| f =~ /spec\// }
99
+ filters[f] << spec
100
+ break
101
+ end
102
+ end
103
+ filters
104
+ end
105
+
106
+ def make_test_cmd(specs_to_runs)
107
+ [
108
+ ruby,
109
+ "-S",
110
+ spec_command,
111
+ add_options_if_present,
112
+ files_to_test.keys.flatten.join(' ')
113
+ ].join(' ')
114
+ end
115
+
116
+ def add_options_if_present
117
+ File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : ""
118
+ end
119
+
120
+ # Finds the proper spec command to use. Precendence is set in the
121
+ # lazily-evaluated method spec_commands. Alias + Override that in
122
+ # ~/.autotest to provide a different spec command then the default
123
+ # paths provided.
124
+ def spec_command(separator=File::ALT_SEPARATOR)
125
+ unless defined?(@spec_command)
126
+ @spec_command = spec_commands.find { |cmd| File.exists?(cmd) }
127
+
128
+ raise RspecCommandError, "No spec command could be found" unless @spec_command
129
+
130
+ @spec_command.gsub!(File::SEPARATOR, separator) if separator
131
+ end
132
+ @spec_command
133
+ end
134
+
135
+ # Autotest will look for spec commands in the following
136
+ # locations, in this order:
137
+ #
138
+ # * default spec bin/loader installed in Rubygems
139
+ # * any spec command found in PATH
140
+ def spec_commands
141
+ [File.join(Config::CONFIG['bindir'], 'spec'), 'spec']
142
+ end
143
+
144
+ private
145
+
146
+ # Runs +files_matching+ for all specs
147
+ def all_specs
148
+ files_matching %r%^spec/.*_spec\.rb$%
149
+ end
150
+
151
+ # Generates a path to some spec given its kind and the match from a mapping
152
+ #
153
+ # ==== Arguments
154
+ # match<String>:: the match from a mapping
155
+ # kind<String>:: the kind of spec that the match represents
156
+ #
157
+ # ==== Returns
158
+ # String
159
+ #
160
+ # ==== Example
161
+ # > spec_for('post', :view')
162
+ # => "spec/views/post_spec.rb"
163
+ def spec_for(match, kind)
164
+ File.join("spec", kind + 's', "#{match}_spec.rb")
165
+ end
166
+ end
@@ -10,11 +10,11 @@
10
10
  # ==== Set up load paths
11
11
  #
12
12
 
13
- # Make the app's "gems" directory a place where gems are loaded from.
14
- # Note that gems directory must have a structure RubyGems uses for
13
+ # Add the app's "gems" directory to the gem load path.
14
+ # Note that the gems directory must mirror the structure RubyGems uses for
15
15
  # directories under which gems are kept.
16
16
  #
17
- # To conveniently set it up use gem install -i <merb_app_root/gems>
17
+ # To conveniently set it up, use gem install -i <merb_app_root/gems>
18
18
  # when installing gems. This will set up the structure under /gems
19
19
  # automagically.
20
20
  #
@@ -24,10 +24,10 @@
24
24
  # application to be deployment environment independent. To do so,
25
25
  # install gems into merb_app_root/gems directory like this:
26
26
  #
27
- # gem install -i ~/dev/merbapp/gems activesupport-post-2.0.2gem activerecord-post-2.0.2.gem
27
+ # gem install -i merb_app_root/gems activesupport-post-2.0.2.gem activerecord-post-2.0.2.gem
28
28
  #
29
29
  # Since RubyGems will search merb_app_root/gems for dependencies, order
30
- # in statement above is important: we need to install ActiveSupport which
30
+ # in the statement above is important: we need to install ActiveSupport which
31
31
  # ActiveRecord depends on first.
32
32
  #
33
33
  # Remember that bundling of dependencies as gems with your application
@@ -41,15 +41,12 @@ Gem.path.unshift(Merb.root / "gems")
41
41
  # uncomment this.
42
42
  # Merb.push_path(:lib, Merb.root / "lib") # uses **/*.rb as path glob.
43
43
 
44
- <% require 'sha1' %>
45
-
46
-
47
44
  # ==== Dependencies
48
45
 
49
46
  # These are some examples of how you might specify dependencies.
50
- # Dependencies load is delayed to one of later Merb app
51
- # boot stages. It may be important when
52
- # later part of your configuration relies on libraries specified
47
+ # Dependency loading is delayed to a later Merb app
48
+ # boot stage, but it may be important when
49
+ # another part of your configuration relies on libraries specified
53
50
  # here.
54
51
  #
55
52
  # dependencies "RedCloth", "merb_helpers"
@@ -72,48 +69,62 @@ end
72
69
  # if you need a database.
73
70
 
74
71
  # Uncomment for DataMapper ORM
75
- <%= "# " unless default_orm?(:datamapper) %>use_orm :datamapper
72
+ <%= "# " unless orm == :datamapper %>use_orm :datamapper
76
73
 
77
74
  # Uncomment for ActiveRecord ORM
78
- <%= "# " unless default_orm?(:activerecord) %>use_orm :activerecord
75
+ <%= "# " unless orm == :activerecord %>use_orm :activerecord
79
76
 
80
77
  # Uncomment for Sequel ORM
81
- <%= "# " unless default_orm?(:sequel) %>use_orm :sequel
78
+ <%= "# " unless orm == :sequel %>use_orm :sequel
82
79
 
83
80
 
84
81
  #
85
82
  # ==== Pick what you test with
86
83
  #
87
84
 
88
- # This defines which test framework the generators will use
89
- # rspec is turned on by default
85
+ # This defines which test framework the generators will use.
86
+ # RSpec is turned on by default.
90
87
  #
91
- # Note that you need to install the merb_rspec if you want to ue
92
- # rspec and merb_test_unit if you want to use test_unit.
93
- # merb_rspec is installed by default if you did gem install
94
- # merb.
88
+ # To use Test::Unit, you need to install the merb_test_unit gem.
89
+ # To use RSpec, you don't have to install any additional gems, since
90
+ # merb-core provides support for RSpec.
95
91
  #
96
- <%= "# " unless default_test_suite?(:test) %>use_test :test_unit
97
- <%= "# " unless default_test_suite?(:spec) %>use_test :rspec
98
-
92
+ <%= "# " unless testing_framework == :test_unit %>use_test :test_unit
93
+ <%= "# " unless testing_framework == :rspec %>use_test :rspec
99
94
 
100
95
  #
101
96
  # ==== Set up your basic configuration
102
97
  #
98
+
99
+ # IMPORTANT:
100
+ #
101
+ # early on Merb boot init file is not yet loaded.
102
+ # Thus setting PORT, PID FILE and ADAPTER using init file does not
103
+ # make sense and only can lead to confusion because default settings
104
+ # will be used instead.
105
+ #
106
+ # Please use command line options for them.
107
+ # See http://wiki.merbivore.com/pages/merb-core-boot-process
108
+ # if you want to know more.
103
109
  Merb::Config.use do |c|
104
110
 
105
- # Sets up a custom session id key, if you want to piggyback sessions of other applications
106
- # with the cookie session store. If not specified, defaults to '_session_id'.
111
+ # Sets up a custom session id key which is used for the session persistence
112
+ # cookie name. If not specified, defaults to '_session_id'.
107
113
  # c[:session_id_key] = '_session_id'
108
-
114
+
115
+ # The session_secret_key is only required for the cookie session store.
109
116
  c[:session_secret_key] = '<%= SHA1.new(rand(100000000000).to_s).to_s %>'
117
+
118
+ # There are various options here, by default Merb comes with 'cookie',
119
+ # 'memory' or 'memcached'. You can of course use your favorite ORM
120
+ # instead: 'datamapper', 'sequel' or 'activerecord'.
110
121
  c[:session_store] = 'cookie'
111
122
  end
112
123
 
113
124
 
114
125
  # ==== Tune your inflector
115
126
 
116
- # To fine tune your inflector use word, singular_word and plural_word
127
+ # To fine tune your inflector use the word, singular_word and plural_word
117
128
  # methods of Language::English::Inflector module metaclass.
118
129
  #
119
130
  # Here we define erratum/errata exception case:
@@ -0,0 +1,12 @@
1
+
2
+ # use PathPrefix Middleware if :path_prefix is set in Merb::Config
3
+ if prefix = ::Merb::Config[:path_prefix]
4
+ use Merb::Rack::PathPrefix, prefix
5
+ end
6
+
7
+ # comment this out if you are running merb behind a load balancer
8
+ # that serves static files
9
+ use Merb::Rack::Static, Merb.dir_for(:public)
10
+
11
+ # this is our main merb application
12
+ run Merb::Rack::Application.new
@@ -1,7 +1,9 @@
1
1
  require 'rubygems'
2
2
  require 'merb-core'
3
- require 'spec' # Satiates Autotest and anyone else not using the Rake tasks
3
+ require 'spec' # Satisfies Autotest and anyone else not using the Rake tasks
4
4
 
5
+ # this loads all plugins required in your init file so don't add them
6
+ # here again, Merb will do it for you
5
7
  Merb.start_environment(:testing => true, :adapter => 'runner', :environment => ENV['MERB_ENV'] || 'test')
6
8
 
7
9
  Spec::Runner.configure do |config|
@@ -0,0 +1,7 @@
1
+ Merb::Config[:framework] = {
2
+ :application => Merb.root / "application.rb",
3
+ :config => [Merb.root / "config", nil],
4
+ :public => [Merb.root / "public", nil],
5
+ :view => Merb.root / "views"
6
+ }
7
+
@@ -4,7 +4,6 @@ Merb::Router.prepare do |r|
4
4
  r.default_routes
5
5
  end
6
6
 
7
- <% require 'sha1' %>
8
7
  Merb::Config.use { |c|
9
8
  c[:environment] = 'production',
10
9
  c[:framework] = {},
@@ -0,0 +1,59 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+ require 'rubygems/specification'
4
+ require 'date'
5
+ require 'merb-core/version'
6
+ require 'merb-core/tasks/merb_rake_helper'
7
+
8
+ NAME = "<%= base_name %>"
9
+ GEM_VERSION = "0.0.1"
10
+ AUTHOR = "Your Name"
11
+ EMAIL = "Your Email"
12
+ HOMEPAGE = "http://merbivore.com/"
13
+ SUMMARY = "Merb plugin that provides ..."
14
+
15
+ spec = Gem::Specification.new do |s|
16
+ s.rubyforge_project = 'merb'
17
+ s.name = NAME
18
+ s.version = GEM_VERSION
19
+ s.platform = Gem::Platform::RUBY
20
+ s.has_rdoc = true
21
+ s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
22
+ s.summary = SUMMARY
23
+ s.description = s.summary
24
+ s.author = AUTHOR
25
+ s.email = EMAIL
26
+ s.homepage = HOMEPAGE
27
+ s.add_dependency('merb', '>= <%= Merb::VERSION %>')
28
+ s.require_path = 'lib'
29
+ s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec<%= bin ? ',bin' : '' %>}/**/*")
30
+ <% if bin %>
31
+ s.bindir = "bin"
32
+ s.executables = [NAME]
33
+ <% end %>
34
+ end
35
+
36
+ Rake::GemPackageTask.new(spec) do |pkg|
37
+ pkg.gem_spec = spec
38
+ end
39
+
40
+ desc "install the plugin locally"
41
+ task :install => [:package] do
42
+ sh %{#{sudo} gem install #{install_home} pkg/#{NAME}-#{GEM_VERSION} --no-update-sources}
43
+ end
44
+
45
+ desc "create a gemspec file"
46
+ task :make_spec do
47
+ File.open("#{NAME}.gemspec", "w") do |file|
48
+ file.puts spec.to_ruby
49
+ end
50
+ end
51
+
52
+ namespace :jruby do
53
+
54
+ desc "Run :package and install the resulting .gem with jruby"
55
+ task :install => :package do
56
+ sh %{#{sudo} jruby -S gem install #{install_home} pkg/#{NAME}-#{GEM_VERSION}.gem --no-rdoc --no-ri}
57
+ end
58
+
59
+ end