merb 0.3.7 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. data/README +25 -26
  2. data/Rakefile +48 -36
  3. data/app_generators/merb/USAGE +5 -0
  4. data/app_generators/merb/merb_generator.rb +107 -0
  5. data/app_generators/merb/templates/Rakefile +99 -0
  6. data/{examples/skeleton/dist → app_generators/merb/templates}/app/controllers/application.rb +1 -1
  7. data/app_generators/merb/templates/app/controllers/exceptions.rb +13 -0
  8. data/{examples/skeleton/dist → app_generators/merb/templates}/app/helpers/global_helper.rb +0 -0
  9. data/{examples/skeleton/dist/app/mailers → app_generators/merb/templates/app/mailers/views}/layout/application.erb +0 -0
  10. data/app_generators/merb/templates/app/views/exceptions/internal_server_error.html.erb +207 -0
  11. data/app_generators/merb/templates/app/views/exceptions/not_acceptable.html.erb +38 -0
  12. data/app_generators/merb/templates/app/views/exceptions/not_found.html.erb +40 -0
  13. data/app_generators/merb/templates/app/views/layout/application.html.erb +11 -0
  14. data/app_generators/merb/templates/config/boot.rb +11 -0
  15. data/app_generators/merb/templates/config/dependencies.rb +41 -0
  16. data/{examples/skeleton/dist/conf → app_generators/merb/templates/config}/environments/development.rb +0 -0
  17. data/{examples/skeleton/dist/conf → app_generators/merb/templates/config}/environments/production.rb +0 -0
  18. data/{examples/skeleton/dist/conf → app_generators/merb/templates/config}/environments/test.rb +0 -0
  19. data/app_generators/merb/templates/config/merb.yml +64 -0
  20. data/app_generators/merb/templates/config/merb_init.rb +16 -0
  21. data/app_generators/merb/templates/config/plugins.yml +1 -0
  22. data/app_generators/merb/templates/config/router.rb +32 -0
  23. data/{lib/merb/core_ext/merb_array.rb → app_generators/merb/templates/config/upload.conf} +0 -0
  24. data/app_generators/merb/templates/public/images/merb.jpg +0 -0
  25. data/app_generators/merb/templates/public/merb.fcgi +6 -0
  26. data/app_generators/merb/templates/public/stylesheets/master.css +119 -0
  27. data/app_generators/merb/templates/script/destroy +28 -0
  28. data/app_generators/merb/templates/script/generate +28 -0
  29. data/{examples/skeleton → app_generators/merb/templates}/script/stop_merb +0 -0
  30. data/app_generators/merb/templates/script/win_script.cmd +1 -0
  31. data/app_generators/merb/templates/spec/spec.opts +6 -0
  32. data/app_generators/merb/templates/spec/spec_helper.rb +10 -0
  33. data/app_generators/merb/templates/test/test_helper.rb +13 -0
  34. data/app_generators/merb_plugin/USAGE +5 -0
  35. data/app_generators/merb_plugin/merb_plugin_generator.rb +64 -0
  36. data/app_generators/merb_plugin/templates/LICENSE +20 -0
  37. data/app_generators/merb_plugin/templates/README +4 -0
  38. data/app_generators/merb_plugin/templates/Rakefile +35 -0
  39. data/app_generators/merb_plugin/templates/TODO +5 -0
  40. data/app_generators/merb_plugin/templates/merbtasks.rb +6 -0
  41. data/app_generators/merb_plugin/templates/sampleplugin.rb +10 -0
  42. data/app_generators/merb_plugin/templates/sampleplugin_spec.rb +7 -0
  43. data/app_generators/merb_plugin/templates/spec_helper.rb +2 -0
  44. data/bin/merb +1 -1
  45. data/lib/autotest/discover.rb +3 -0
  46. data/lib/autotest/merb_rspec.rb +79 -0
  47. data/lib/merb.rb +72 -93
  48. data/lib/merb/{merb_abstract_controller.rb → abstract_controller.rb} +28 -5
  49. data/lib/merb/caching/action_cache.rb +65 -29
  50. data/lib/merb/caching/fragment_cache.rb +9 -4
  51. data/lib/merb/caching/store/file_cache.rb +22 -14
  52. data/lib/merb/caching/store/memory_cache.rb +26 -8
  53. data/lib/merb/{merb_constants.rb → constants.rb} +9 -7
  54. data/lib/merb/controller.rb +178 -0
  55. data/lib/merb/core_ext.rb +13 -11
  56. data/lib/merb/core_ext/array.rb +0 -0
  57. data/lib/merb/core_ext/{merb_class.rb → class.rb} +0 -0
  58. data/lib/merb/core_ext/{merb_enumerable.rb → enumerable.rb} +0 -0
  59. data/lib/merb/core_ext/get_args.rb +52 -0
  60. data/lib/merb/core_ext/{merb_hash.rb → hash.rb} +40 -11
  61. data/lib/merb/core_ext/{merb_inflections.rb → inflections.rb} +0 -0
  62. data/lib/merb/core_ext/{merb_inflector.rb → inflector.rb} +1 -1
  63. data/lib/merb/core_ext/{merb_kernel.rb → kernel.rb} +56 -3
  64. data/lib/merb/core_ext/mash.rb +88 -0
  65. data/lib/merb/core_ext/{merb_module.rb → module.rb} +0 -0
  66. data/lib/merb/core_ext/{merb_numeric.rb → numeric.rb} +0 -0
  67. data/lib/merb/core_ext/{merb_object.rb → object.rb} +10 -47
  68. data/lib/merb/core_ext/string.rb +56 -0
  69. data/lib/merb/core_ext/{merb_symbol.rb → symbol.rb} +0 -0
  70. data/lib/merb/dispatcher.rb +109 -0
  71. data/lib/merb/{merb_drb_server.rb → drb_server.rb} +0 -0
  72. data/lib/merb/erubis_ext.rb +10 -0
  73. data/lib/merb/exceptions.rb +173 -0
  74. data/lib/merb/generators/merb_app/merb_app.rb +5 -25
  75. data/lib/merb/generators/merb_generator_helpers.rb +317 -0
  76. data/lib/merb/generators/merb_plugin.rb +19 -0
  77. data/lib/merb/logger.rb +65 -0
  78. data/lib/merb/{merb_mail_controller.rb → mail_controller.rb} +102 -49
  79. data/lib/merb/{merb_mailer.rb → mailer.rb} +31 -27
  80. data/lib/merb/mixins/{basic_authentication_mixin.rb → basic_authentication.rb} +3 -3
  81. data/lib/merb/mixins/{controller_mixin.rb → controller.rb} +131 -112
  82. data/lib/merb/mixins/{erubis_capture_mixin.rb → erubis_capture.rb} +12 -21
  83. data/lib/merb/mixins/{form_control_mixin.rb → form_control.rb} +6 -12
  84. data/lib/merb/mixins/render.rb +401 -0
  85. data/lib/merb/mixins/responder.rb +378 -0
  86. data/lib/merb/mixins/{view_context_mixin.rb → view_context.rb} +65 -10
  87. data/lib/merb/mixins/web_controller.rb +29 -0
  88. data/lib/merb/{merb_handler.rb → mongrel_handler.rb} +59 -38
  89. data/lib/merb/part_controller.rb +19 -0
  90. data/lib/merb/plugins.rb +16 -0
  91. data/lib/merb/rack_adapter.rb +37 -0
  92. data/lib/merb/request.rb +421 -0
  93. data/lib/merb/router.rb +576 -0
  94. data/lib/merb/{merb_server.rb → server.rb} +275 -71
  95. data/lib/merb/session.rb +10 -10
  96. data/lib/merb/session/cookie_store.rb +125 -0
  97. data/lib/merb/session/{merb_mem_cache_session.rb → mem_cache_session.rb} +22 -9
  98. data/lib/merb/session/{merb_memory_session.rb → memory_session.rb} +15 -11
  99. data/lib/merb/template.rb +35 -8
  100. data/lib/merb/template/erubis.rb +16 -10
  101. data/lib/merb/template/haml.rb +33 -20
  102. data/lib/merb/template/markaby.rb +16 -14
  103. data/lib/merb/template/xml_builder.rb +8 -4
  104. data/lib/merb/test/{merb_fake_request.rb → fake_request.rb} +11 -5
  105. data/lib/merb/test/helper.rb +31 -0
  106. data/lib/merb/test/hpricot.rb +136 -0
  107. data/lib/merb/test/{merb_multipart.rb → multipart.rb} +1 -1
  108. data/lib/merb/test/rspec.rb +93 -0
  109. data/lib/merb/{merb_upload_handler.rb → upload_handler.rb} +5 -6
  110. data/lib/merb/{merb_upload_progress.rb → upload_progress.rb} +1 -1
  111. data/lib/merb/{merb_view_context.rb → view_context.rb} +27 -42
  112. data/lib/{merb_tasks.rb → tasks.rb} +0 -0
  113. data/lib/tasks/merb.rake +21 -11
  114. data/merb_default_generators/model/USAGE +0 -0
  115. data/merb_default_generators/model/model_generator.rb +16 -0
  116. data/merb_default_generators/model/templates/new_model_template.erb +5 -0
  117. data/merb_default_generators/resource_controller/USAGE +0 -0
  118. data/merb_default_generators/resource_controller/resource_controller_generator.rb +26 -0
  119. data/merb_default_generators/resource_controller/templates/controller.rb +30 -0
  120. data/merb_default_generators/resource_controller/templates/edit.html.erb +1 -0
  121. data/merb_default_generators/resource_controller/templates/helper.rb +5 -0
  122. data/merb_default_generators/resource_controller/templates/index.html.erb +1 -0
  123. data/merb_default_generators/resource_controller/templates/new.html.erb +1 -0
  124. data/merb_default_generators/resource_controller/templates/show.html.erb +1 -0
  125. data/merb_generators/controller/USAGE +5 -0
  126. data/merb_generators/controller/controller_generator.rb +16 -0
  127. data/merb_generators/controller/templates/controller.rb +8 -0
  128. data/merb_generators/controller/templates/helper.rb +5 -0
  129. data/merb_generators/controller/templates/index.html.erb +3 -0
  130. data/merb_generators/resource/USAGE +0 -0
  131. data/merb_generators/resource/resource_generator.rb +60 -0
  132. data/rspec_generators/merb_controller_test/merb_controller_test_generator.rb +67 -0
  133. data/rspec_generators/merb_controller_test/templates/controller_spec.rb +8 -0
  134. data/rspec_generators/merb_controller_test/templates/edit_spec.rb +12 -0
  135. data/rspec_generators/merb_controller_test/templates/helper_spec.rb +5 -0
  136. data/rspec_generators/merb_controller_test/templates/index_spec.rb +12 -0
  137. data/rspec_generators/merb_controller_test/templates/new_spec.rb +12 -0
  138. data/rspec_generators/merb_controller_test/templates/show_spec.rb +5 -0
  139. data/rspec_generators/merb_model_test/merb_model_test_generator.rb +26 -0
  140. data/rspec_generators/merb_model_test/templates/model_spec_template.erb +7 -0
  141. data/script/destroy +14 -0
  142. data/script/generate +14 -0
  143. data/test_unit_generators/merb_controller_test/merb_controller_test_generator.rb +53 -0
  144. data/test_unit_generators/merb_controller_test/templates/functional_test.rb +17 -0
  145. data/test_unit_generators/merb_controller_test/templates/helper_test.rb +9 -0
  146. data/test_unit_generators/merb_model_test/merb_model_test_generator.rb +29 -0
  147. data/test_unit_generators/merb_model_test/templates/model_test_unit_template.erb +9 -0
  148. metadata +172 -94
  149. data/examples/README_EXAMPLES +0 -10
  150. data/examples/skeleton/Rakefile +0 -68
  151. data/examples/skeleton/dist/app/views/layout/application.herb +0 -12
  152. data/examples/skeleton/dist/conf/database.yml +0 -23
  153. data/examples/skeleton/dist/conf/merb.yml +0 -57
  154. data/examples/skeleton/dist/conf/merb_init.rb +0 -24
  155. data/examples/skeleton/dist/conf/router.rb +0 -22
  156. data/examples/skeleton/dist/conf/upload.conf +0 -5
  157. data/examples/skeleton/dist/schema/migrations/001_add_sessions_table.rb +0 -14
  158. data/examples/skeleton/script/new_migration +0 -21
  159. data/lib/merb/core_ext/merb_string.rb +0 -18
  160. data/lib/merb/merb_controller.rb +0 -206
  161. data/lib/merb/merb_dispatcher.rb +0 -87
  162. data/lib/merb/merb_exceptions.rb +0 -319
  163. data/lib/merb/merb_part_controller.rb +0 -42
  164. data/lib/merb/merb_plugins.rb +0 -293
  165. data/lib/merb/merb_request.rb +0 -165
  166. data/lib/merb/merb_router.rb +0 -309
  167. data/lib/merb/merb_yaml_store.rb +0 -31
  168. data/lib/merb/mixins/render_mixin.rb +0 -283
  169. data/lib/merb/mixins/responder_mixin.rb +0 -159
  170. data/lib/merb/session/merb_ar_session.rb +0 -131
  171. data/lib/merb/vendor/paginator/README.txt +0 -84
  172. data/lib/merb/vendor/paginator/paginator.rb +0 -124
  173. data/lib/tasks/db.rake +0 -55
data/README CHANGED
@@ -5,15 +5,22 @@
5
5
  Install these gems first:
6
6
 
7
7
  * mongrel
8
- * erubis
9
8
  * json
9
+ * json_pure
10
+ * erubis
10
11
  * mime-types
11
- * archive-tar-minitar
12
12
  * rspec
13
+ * hpricot
14
+ * mocha
15
+ * rubigen
16
+ * haml
17
+ * markaby
18
+ * mailfactory
19
+ * activerecord (if you want to store sessions in a database)
13
20
 
14
21
  Then you can build the merb gem from svn trunk like so:
15
22
 
16
- $ sudo gem install mongrel erubis json mime-types archive-tar-minitar rspec --include-dependencies
23
+ $ sudo gem install mongrel json json_pure erubis mime-types rspec hpricot mocha rubigen haml markaby mailfactory -y
17
24
  $ svn co http://svn.devjavu.com/merb/trunk merb
18
25
  $ cd merb
19
26
  $ rake install
@@ -61,8 +68,8 @@ The <tt>r.default_routes</tt> routes adds the standard routes:
61
68
  Classes with built in render method and template handling
62
69
  with instance vars available in the views automatically. Merb also supports
63
70
  layouts. It will look for a layout named after your controller class first and
64
- then fall back to application.herb if no layout exists named after your controller.
65
- You can use render <tt>:layout => :none</tt>.
71
+ then fall back to application.html.erb if no layout exists named after your
72
+ controller. You can use render <tt>:layout => :none</tt>.
66
73
 
67
74
  Merb does not automatically render for you in your controller actions, you have
68
75
  to call render yourself. I consider this a big advantage over the way rails does
@@ -246,14 +253,14 @@ memory_session set to true. See generated app for migration too add session tabl
246
253
 
247
254
  === Helpers
248
255
 
249
- dist/app/helpers/global_helper.rb will be available to all of your views.
256
+ app/helpers/global_helper.rb will be available to all of your views.
250
257
  Helpers named after your controller plus _helper.rb will be included in the views
251
258
  for that controller only.
252
259
 
253
260
  === The +merb+ server
254
261
 
255
262
  right now you add your routes in
256
- the appdir/dist/conf/router.rb file. So by default it runs on port 4000
263
+ the appdir/config/router.rb file. So by default it runs on port 4000
257
264
 
258
265
  $ cd /path/to/your/merb/app
259
266
  $ merb
@@ -298,29 +305,21 @@ A file upload will have a hash of params like this:
298
305
 
299
306
  == Merb app layout
300
307
 
301
- A Merb app contains everything it needs to run in production in the
302
- MERB_ROOT/dist directory. So for deployment you only need to deploy the dist dir. This
303
- keeps your test code and development plugins separate from your main app and lets you
304
- not deploy them to the live server. You deal with two things with this setup, MERB_ROOT
305
- and DIST_ROOT. MERB_ROOT is the root of the whole tree. And DISTROOT is MERB_ROOT+/dist
306
- You will cd into MERB_ROOT to run the merb command line. ANd when you deploy live you
307
- will put the dist dir into another empty MERB_ROOT on the production server.
308
-
309
308
  merb_app:
309
+
310
+ app
311
+ controllers
312
+ models
313
+ views
314
+ parts
315
+ mailers
316
+ config
317
+ lib
318
+ public
319
+ schema
310
320
  Rakefile
311
- README
312
321
  scripts
313
322
  test
314
323
  spec
315
324
  unit
316
325
  plugins
317
- dist
318
- app
319
- controllers
320
- models
321
- views
322
- conf
323
- lib
324
- public
325
- plugins
326
- schema
data/Rakefile CHANGED
@@ -13,13 +13,11 @@ require __DIR__+'/tools/rakehelp'
13
13
  require __DIR__+'/tools/annotation_extract'
14
14
  include FileUtils
15
15
 
16
-
17
16
  NAME = "merb"
18
- VERS = "0.3.7"
17
+ VERS = "0.4.0"
19
18
  CLEAN.include ['**/.*.sw?', '*.gem', '.config']
20
19
 
21
- setup_clean [ "pkg", "lib/*.bundle", "*.gem",
22
- "doc", ".config", "examples/sample_app/dist/public/files/**/*", 'examples/sample_app/log/*', 'coverage']
20
+ setup_clean [ "pkg", "lib/*.bundle", "*.gem", "doc/rdoc", ".config", 'coverage', "cache"]
23
21
 
24
22
 
25
23
  desc "Packages up Merb."
@@ -35,7 +33,7 @@ Rake::RDocTask.new do |rdoc|
35
33
  rdoc.main = "README" # page to start on
36
34
  rdoc.title = "Merb Docs"
37
35
  rdoc.template = __DIR__+"/tools/allison/allison.rb"
38
- rdoc.rdoc_dir = 'doc' # rdoc output folder
36
+ rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
39
37
  rdoc.options << '--line-numbers' << '--inline-source'
40
38
  end
41
39
 
@@ -58,11 +56,11 @@ spec = Gem::Specification.new do |s|
58
56
 
59
57
  s.add_dependency('mongrel')
60
58
  s.add_dependency('erubis')
61
- s.add_dependency('json')
62
59
  s.add_dependency('mime-types')
60
+ s.add_dependency('rubigen')
63
61
  s.required_ruby_version = '>= 1.8.4'
64
62
 
65
- s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{bin,test,lib,examples}/**/*")
63
+ s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{bin,test,lib,examples,app_generators,merb_generators,merb_default_generators,rspec_generators,test_unit_generators,script}/**/*")
66
64
 
67
65
  s.require_path = "lib"
68
66
  s.bindir = "bin"
@@ -75,64 +73,56 @@ end
75
73
 
76
74
  task :install do
77
75
  sh %{rake package}
78
- sh %{sudo gem install pkg/#{NAME}-#{VERS}}
76
+ sh %{sudo gem install pkg/#{NAME}-#{VERS} --no-rdoc --no-ri}
79
77
  end
80
78
 
81
79
  task :uninstall => [:clean] do
82
80
  sh %{sudo gem uninstall #{NAME}}
83
81
  end
84
82
 
83
+ desc "run webgen"
84
+ task :doc_webgen do
85
+ sh %{cd doc/site ; webgen}
86
+ end
87
+
85
88
  desc "rdoc to rubyforge"
86
89
  task :doc_rforge do
87
90
  sh %{rake doc}
91
+ sh %{rake doc_webgen}
88
92
  sh %{sudo chmod -R 755 doc}
89
- sh %{scp -r -p doc/* ezmobius@rubyforge.org:/var/www/gforge-projects/merb}
90
- end
91
-
92
- desc 'Run unit tests'
93
- Rake::TestTask.new('test_unit') do |t|
94
- t.libs << 'test'
95
- t.pattern = 'test/unit/*_test.rb'
96
- t.verbose = true
97
- end
98
-
99
- desc 'Run functional tests'
100
- Rake::TestTask.new('test_functional') do |t|
101
- t.libs << 'test'
102
- t.pattern = 'test/functional/*_test.rb'
103
- t.verbose = true
104
- end
105
-
106
- desc 'Run all tests'
107
- Rake::TestTask.new('test') do |t|
108
- t.libs << 'test'
109
- t.pattern = 'test/**/*_test.rb'
110
- t.verbose = true
93
+ sh %{scp -r -p doc/site/output/* ezmobius@rubyforge.org:/var/www/gforge-projects/merb}
94
+ sh %{scp -r -p doc/rdoc/* ezmobius@rubyforge.org:/var/www/gforge-projects/merb/rdoc}
111
95
  end
112
96
 
113
- desc 'Run all tests, specs and finish with rcov'
97
+ desc 'Run all specs and then rcov'
114
98
  task :aok do
115
99
  sh %{rake specs;rake rcov}
116
100
  end
117
101
 
118
102
  desc "Run all specs"
119
103
  Spec::Rake::SpecTask.new('specs') do |t|
120
- t.spec_opts = ["--format", "specdoc"]
104
+ t.spec_opts = ["--format", "specdoc", "--colour"]
105
+ t.spec_files = Dir['spec/**/*_spec.rb'].sort
106
+ end
107
+
108
+ desc "Run a specific spec with TASK=xxxx"
109
+ Spec::Rake::SpecTask.new('spec') do |t|
110
+ t.spec_opts = ["--format", "specdoc", "--colour"]
121
111
  t.libs = ['lib', 'server/lib' ]
122
- t.spec_files = Dir['specs/**/*_spec.rb'].sort
112
+ t.spec_files = ["spec/merb/#{ENV['TASK']}_spec.rb"]
123
113
  end
124
114
 
125
115
  desc "Run all specs output html"
126
116
  Spec::Rake::SpecTask.new('specs_html') do |t|
127
117
  t.spec_opts = ["--format", "html"]
128
118
  t.libs = ['lib', 'server/lib' ]
129
- t.spec_files = Dir['specs/**/*_spec.rb'].sort
119
+ t.spec_files = Dir['spec/**/*_spec.rb'].sort
130
120
  end
131
121
 
132
122
  desc "RCov"
133
123
  Spec::Rake::SpecTask.new('rcov') do |t|
134
- t.spec_opts = ["--format", "specdoc"]
135
- t.spec_files = Dir['specs/**/*_spec.rb'].sort
124
+ t.spec_opts = ["--format", "specdoc", "--colour"]
125
+ t.spec_files = Dir['spec/**/*_spec.rb'].sort
136
126
  t.libs = ['lib', 'server/lib' ]
137
127
  t.rcov = true
138
128
  end
@@ -158,3 +148,25 @@ desc "Add new files to subversion"
158
148
  task :svn_add do
159
149
  system "svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add"
160
150
  end
151
+
152
+
153
+ # Run specific tests or test files
154
+ #
155
+ # Based on a technique popularized by Geoffrey Grosenbach
156
+ rule "" do |t|
157
+ spec_cmd = (RUBY_PLATFORM =~ /java/) ? 'jruby -S spec' : 'spec'
158
+ # spec:spec_file:spec_name
159
+ if /spec:(.*)$/.match(t.name)
160
+ arguments = t.name.split(":")
161
+ file_name = arguments[1]
162
+ spec_name = arguments[2..-1]
163
+
164
+ if File.exist?("spec/merb/#{file_name}_spec.rb")
165
+ run_file_name = "spec/merb/#{file_name}_spec.rb"
166
+ end
167
+
168
+ example = !spec_name.empty? ? " -e '#{spec_name}'" : ""
169
+
170
+ sh "#{spec_cmd} #{run_file_name} --format specdoc --colour #{example}"
171
+ end
172
+ end
@@ -0,0 +1,5 @@
1
+ Description:
2
+
3
+
4
+ Usage:
5
+
@@ -0,0 +1,107 @@
1
+ class MerbGenerator < RubiGen::Base
2
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
3
+ Config::CONFIG['ruby_install_name']) unless defined? DEFAULT_SHEBANG
4
+
5
+ default_options :shebang => DEFAULT_SHEBANG
6
+
7
+ attr_reader :name
8
+
9
+ def initialize(runtime_args, runtime_options = {})
10
+ super
11
+ usage if args.empty?
12
+ @name = args.shift
13
+ @destination_root = File.expand_path(@name)
14
+ extract_options
15
+ end
16
+
17
+ def manifest
18
+ script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
19
+
20
+ record do |m|
21
+ # Ensure appropriate folder(s) exists
22
+ m.directory ''
23
+ BASEDIRS.each { |path| m.directory path }
24
+
25
+ # copy skeleton
26
+ m.file_copy_each %w( Rakefile )
27
+ m.file_copy_each %w( application.rb exceptions.rb ), "app/controllers"
28
+ m.file_copy_each %w( global_helper.rb ), "app/helpers"
29
+ m.file_copy_each %w( application.erb ), "app/mailers/views/layout"
30
+ m.file_copy_each %w( application.html.erb ), "app/views/layout"
31
+ m.file_copy_each %w( internal_server_error.html.erb not_found.html.erb not_acceptable.html.erb ), "app/views/exceptions"
32
+ m.file_copy_each %w( merb.jpg ), "public/images"
33
+ m.file_copy_each %w( master.css ), "public/stylesheets"
34
+ m.file_copy_each %w( merb.fcgi ), "public"
35
+ m.file_copy_each %w( boot.rb merb_init.rb router.rb upload.conf dependencies.rb), "config"
36
+ m.file_copy_each %w( development.rb production.rb test.rb ), "config/environments"
37
+ m.file_copy_each %w( spec_helper.rb ), "spec"
38
+ m.file_copy_each %w( test_helper.rb), "test"
39
+
40
+ # build default config
41
+ m.template "config/merb.yml", "config/merb.yml", :assigns => {:key => "#{@name.upcase}#{rand(9999)}"}
42
+
43
+ # build scripts
44
+ %w( stop_merb generate destroy ).each do |file|
45
+ m.file "script/#{file}", "script/#{file}", script_options
46
+ m.template "script/win_script.cmd", "script/#{file}.cmd", :assigns => { :filename => file } if windows
47
+ end
48
+ end
49
+ end
50
+
51
+ def windows
52
+ (RUBY_PLATFORM =~ /dos|win32|cygwin/i) || (RUBY_PLATFORM =~ /(:?mswin|mingw)/)
53
+ end
54
+
55
+ protected
56
+ def banner
57
+ <<-EOS
58
+ Creates a Merb application stub.
59
+
60
+ USAGE: #{spec.name} -g path"
61
+ EOS
62
+ end
63
+
64
+ def add_options!(opts)
65
+ # opts.separator ''
66
+ # opts.separator 'Options:'
67
+ # # For each option below, place the default
68
+ # # at the top of the file next to "default_options"
69
+ # opts.on("-r", "--ruby=path", String,
70
+ # "Path to the Ruby binary of your choice (otherwise scripts use env, dispatchers current path).",
71
+ # "Default: #{DEFAULT_SHEBANG}") { |options[:shebang]| }
72
+ # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
73
+ end
74
+
75
+ def extract_options
76
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
77
+ # Templates can access these value via the attr_reader-generated methods, but not the
78
+ # raw instance variable value.
79
+ # @author = options[:author]
80
+ end
81
+
82
+ # Installation skeleton. Intermediate directories are automatically
83
+ # created so don't sweat their absence here.
84
+ BASEDIRS = %w(
85
+ app/controllers
86
+ app/models
87
+ app/helpers
88
+ app/mailers/helpers
89
+ app/mailers/views
90
+ app/mailers/views/layout
91
+ app/parts
92
+ app/views/layout
93
+ app/views/exceptions
94
+ config/environments
95
+ lib
96
+ log
97
+ public/images
98
+ public/javascripts
99
+ public/stylesheets
100
+ script
101
+ spec/models
102
+ spec/controllers
103
+ test/unit
104
+ gems
105
+ )
106
+
107
+ end
@@ -0,0 +1,99 @@
1
+ require 'rake'
2
+ require 'rake/rdoctask'
3
+ require 'rake/testtask'
4
+ require 'spec/rake/spectask'
5
+ require 'fileutils'
6
+ require 'rubygems'
7
+
8
+ MERB_ENV = ENV['MERB_ENV'] if ENV['MERB_ENV']
9
+
10
+ if File.directory?( File.join(File.dirname(__FILE__), "framework"))
11
+ $:.unshift('framework')
12
+ require File.join(File.dirname(__FILE__), "framework/merb")
13
+ else
14
+ require 'merb'
15
+ end
16
+ require MERB_FRAMEWORK_ROOT+'/tasks'
17
+ MERB_ROOT = File.dirname(__FILE__)
18
+ include FileUtils
19
+
20
+ # Get Merb plugins and dependencies
21
+ require File.dirname(__FILE__)+'/config/dependencies.rb'
22
+ Merb::Plugins.rakefiles.each {|r| require r }
23
+
24
+ #desc "Packages up Merb."
25
+ #task :default => [:package]
26
+
27
+ desc "load merb_init.rb"
28
+ task :merb_init do
29
+ require 'merb'
30
+ require File.dirname(__FILE__)+'/config/merb_init.rb'
31
+ end
32
+
33
+ task :uninstall => [:clean] do
34
+ sh %{sudo gem uninstall #{NAME}}
35
+ end
36
+
37
+ desc 'Run unit tests'
38
+ Rake::TestTask.new('test_unit') do |t|
39
+ t.libs << 'test'
40
+ t.pattern = 'test/unit/*_test.rb'
41
+ t.verbose = true
42
+ end
43
+
44
+ desc 'Run functional tests'
45
+ Rake::TestTask.new('test_functional') do |t|
46
+ t.libs << 'test'
47
+ t.pattern = 'test/functional/*_test.rb'
48
+ t.verbose = true
49
+ end
50
+
51
+ desc 'Run all tests'
52
+ Rake::TestTask.new('test') do |t|
53
+ t.libs << 'test'
54
+ t.pattern = 'test/**/*_test.rb'
55
+ t.verbose = true
56
+ end
57
+
58
+ desc "Run all specs"
59
+ Spec::Rake::SpecTask.new('specs') do |t|
60
+ t.spec_opts = ["--format", "specdoc", "--colour"]
61
+ t.spec_files = Dir['spec/**/*_spec.rb'].sort
62
+ end
63
+
64
+ desc "Run a specific spec with TASK=xxxx"
65
+ Spec::Rake::SpecTask.new('spec') do |t|
66
+ t.spec_opts = ["--format", "specdoc", "--colour"]
67
+ t.libs = ['lib', 'server/lib' ]
68
+ t.spec_files = ["spec/merb/#{ENV['TASK']}_spec.rb"]
69
+ end
70
+
71
+ desc "Run all specs output html"
72
+ Spec::Rake::SpecTask.new('specs_html') do |t|
73
+ t.spec_opts = ["--format", "html"]
74
+ t.libs = ['lib', 'server/lib' ]
75
+ t.spec_files = Dir['spec/**/*_spec.rb'].sort
76
+ end
77
+
78
+ desc "RCov"
79
+ Spec::Rake::SpecTask.new('rcov') do |t|
80
+ t.spec_opts = ["--format", "specdoc", "--colour"]
81
+ t.spec_files = Dir['spec/**/*_spec.rb'].sort
82
+ t.libs = ['lib', 'server/lib' ]
83
+ t.rcov = true
84
+ end
85
+
86
+ desc 'Run all tests, specs and finish with rcov'
87
+ task :aok do
88
+ sh %{rake rcov}
89
+ sh %{rake spec}
90
+ end
91
+
92
+ ##############################################################################
93
+ # SVN
94
+ ##############################################################################
95
+
96
+ desc "Add new files to subversion"
97
+ task :svn_add do
98
+ system "svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add"
99
+ end