merb 0.5.3 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (294) hide show
  1. data/LICENSE +0 -20
  2. data/README +0 -277
  3. data/Rakefile +80 -199
  4. data/TODO +0 -3
  5. metadata +19 -438
  6. data/SVN_REVISION +0 -1
  7. data/app_generators/merb/USAGE +0 -5
  8. data/app_generators/merb/merb_generator.rb +0 -108
  9. data/app_generators/merb/templates/Rakefile +0 -124
  10. data/app_generators/merb/templates/app/controllers/application.rb +0 -3
  11. data/app_generators/merb/templates/app/controllers/exceptions.rb +0 -13
  12. data/app_generators/merb/templates/app/helpers/global_helper.rb +0 -5
  13. data/app_generators/merb/templates/app/mailers/views/layout/application.html.erb +0 -1
  14. data/app_generators/merb/templates/app/mailers/views/layout/application.text.erb +0 -1
  15. data/app_generators/merb/templates/app/parts/views/layout/application.html.erb +0 -1
  16. data/app_generators/merb/templates/app/views/exceptions/internal_server_error.html.erb +0 -216
  17. data/app_generators/merb/templates/app/views/exceptions/not_acceptable.html.erb +0 -38
  18. data/app_generators/merb/templates/app/views/exceptions/not_found.html.erb +0 -40
  19. data/app_generators/merb/templates/app/views/layout/application.html.erb +0 -11
  20. data/app_generators/merb/templates/config/boot.rb +0 -11
  21. data/app_generators/merb/templates/config/dependencies.rb +0 -41
  22. data/app_generators/merb/templates/config/environments/development.rb +0 -1
  23. data/app_generators/merb/templates/config/environments/production.rb +0 -1
  24. data/app_generators/merb/templates/config/environments/test.rb +0 -1
  25. data/app_generators/merb/templates/config/merb.yml +0 -82
  26. data/app_generators/merb/templates/config/merb_init.rb +0 -17
  27. data/app_generators/merb/templates/config/plugins.yml +0 -1
  28. data/app_generators/merb/templates/config/router.rb +0 -35
  29. data/app_generators/merb/templates/config/upload.conf +0 -0
  30. data/app_generators/merb/templates/public/images/merb.jpg +0 -0
  31. data/app_generators/merb/templates/public/merb.fcgi +0 -6
  32. data/app_generators/merb/templates/public/stylesheets/master.css +0 -119
  33. data/app_generators/merb/templates/script/destroy +0 -32
  34. data/app_generators/merb/templates/script/generate +0 -32
  35. data/app_generators/merb/templates/script/stop_merb +0 -13
  36. data/app_generators/merb/templates/script/win_script.cmd +0 -1
  37. data/app_generators/merb/templates/spec/spec.opts +0 -6
  38. data/app_generators/merb/templates/spec/spec_helper.rb +0 -15
  39. data/app_generators/merb/templates/test/test_helper.rb +0 -14
  40. data/app_generators/merb_plugin/USAGE +0 -5
  41. data/app_generators/merb_plugin/merb_plugin_generator.rb +0 -68
  42. data/app_generators/merb_plugin/templates/LICENSE +0 -20
  43. data/app_generators/merb_plugin/templates/README +0 -4
  44. data/app_generators/merb_plugin/templates/Rakefile +0 -35
  45. data/app_generators/merb_plugin/templates/TODO +0 -5
  46. data/app_generators/merb_plugin/templates/merbtasks.rb +0 -6
  47. data/app_generators/merb_plugin/templates/sampleplugin.rb +0 -10
  48. data/app_generators/merb_plugin/templates/sampleplugin_spec.rb +0 -7
  49. data/app_generators/merb_plugin/templates/spec_helper.rb +0 -2
  50. data/bin/merb +0 -4
  51. data/lib/autotest/discover.rb +0 -3
  52. data/lib/autotest/merb_rspec.rb +0 -80
  53. data/lib/merb.rb +0 -188
  54. data/lib/merb/abstract_controller.rb +0 -399
  55. data/lib/merb/assets.rb +0 -160
  56. data/lib/merb/assets.rb.orig +0 -119
  57. data/lib/merb/boot_loader.rb +0 -286
  58. data/lib/merb/boot_loader.rb.orig +0 -235
  59. data/lib/merb/caching.rb +0 -5
  60. data/lib/merb/caching/action_cache.rb +0 -92
  61. data/lib/merb/caching/fragment_cache.rb +0 -39
  62. data/lib/merb/caching/store/file_cache.rb +0 -90
  63. data/lib/merb/caching/store/memory_cache.rb +0 -85
  64. data/lib/merb/config.rb +0 -290
  65. data/lib/merb/constants.rb +0 -50
  66. data/lib/merb/controller.rb +0 -220
  67. data/lib/merb/cookies.rb +0 -95
  68. data/lib/merb/core_ext.rb +0 -15
  69. data/lib/merb/core_ext/array.rb +0 -0
  70. data/lib/merb/core_ext/class.rb +0 -180
  71. data/lib/merb/core_ext/enumerable.rb +0 -49
  72. data/lib/merb/core_ext/get_args.rb +0 -76
  73. data/lib/merb/core_ext/hash.rb +0 -306
  74. data/lib/merb/core_ext/inflections.rb +0 -112
  75. data/lib/merb/core_ext/inflector.rb +0 -275
  76. data/lib/merb/core_ext/kernel.rb +0 -242
  77. data/lib/merb/core_ext/mash.rb +0 -88
  78. data/lib/merb/core_ext/module.rb +0 -67
  79. data/lib/merb/core_ext/numeric.rb +0 -72
  80. data/lib/merb/core_ext/object.rb +0 -183
  81. data/lib/merb/core_ext/string.rb +0 -53
  82. data/lib/merb/core_ext/symbol.rb +0 -6
  83. data/lib/merb/dispatcher.rb +0 -109
  84. data/lib/merb/drb_server.rb +0 -19
  85. data/lib/merb/erubis_ext.rb +0 -10
  86. data/lib/merb/exceptions.rb +0 -192
  87. data/lib/merb/generators/merb_app/merb_app.rb +0 -22
  88. data/lib/merb/generators/merb_generator_helpers.rb +0 -318
  89. data/lib/merb/generators/merb_plugin.rb +0 -22
  90. data/lib/merb/logger.rb +0 -78
  91. data/lib/merb/mail_controller.rb +0 -268
  92. data/lib/merb/mailer.rb +0 -87
  93. data/lib/merb/mixins/basic_authentication.rb +0 -35
  94. data/lib/merb/mixins/controller.rb +0 -160
  95. data/lib/merb/mixins/erubis_capture.rb +0 -68
  96. data/lib/merb/mixins/general_controller.rb +0 -253
  97. data/lib/merb/mixins/inline_partial.rb +0 -32
  98. data/lib/merb/mixins/render.rb +0 -465
  99. data/lib/merb/mixins/responder.rb +0 -449
  100. data/lib/merb/mixins/view_context.rb +0 -558
  101. data/lib/merb/mixins/web_controller.rb +0 -36
  102. data/lib/merb/mongrel_handler.rb +0 -168
  103. data/lib/merb/part_controller.rb +0 -29
  104. data/lib/merb/plugins.rb +0 -16
  105. data/lib/merb/rack_adapter.rb +0 -37
  106. data/lib/merb/request.rb +0 -465
  107. data/lib/merb/router.rb +0 -646
  108. data/lib/merb/server.rb +0 -169
  109. data/lib/merb/session.rb +0 -23
  110. data/lib/merb/session/cookie_store.rb +0 -118
  111. data/lib/merb/session/mem_cache_session.rb +0 -131
  112. data/lib/merb/session/memory_session.rb +0 -176
  113. data/lib/merb/template.rb +0 -37
  114. data/lib/merb/template/erubis.rb +0 -68
  115. data/lib/merb/template/haml.rb +0 -87
  116. data/lib/merb/template/markaby.rb +0 -59
  117. data/lib/merb/template/xml_builder.rb +0 -50
  118. data/lib/merb/test/fake_request.rb +0 -74
  119. data/lib/merb/test/helper.rb +0 -260
  120. data/lib/merb/test/hpricot.rb +0 -136
  121. data/lib/merb/test/multipart.rb +0 -66
  122. data/lib/merb/test/rspec.rb +0 -18
  123. data/lib/merb/test/rspec_matchers/controller_matchers.rb +0 -117
  124. data/lib/merb/test/rspec_matchers/markup_matchers.rb +0 -98
  125. data/lib/merb/upload_handler.rb +0 -80
  126. data/lib/merb/upload_progress.rb +0 -48
  127. data/lib/merb/version.rb +0 -49
  128. data/lib/merb/view_context.rb +0 -79
  129. data/lib/tasks.rb +0 -7
  130. data/lib/tasks/merb.rake +0 -54
  131. data/merb_default_generators/model/USAGE +0 -0
  132. data/merb_default_generators/model/model_generator.rb +0 -16
  133. data/merb_default_generators/model/templates/new_model_template.erb +0 -5
  134. data/merb_default_generators/resource_controller/USAGE +0 -0
  135. data/merb_default_generators/resource_controller/resource_controller_generator.rb +0 -26
  136. data/merb_default_generators/resource_controller/templates/controller.rb +0 -30
  137. data/merb_default_generators/resource_controller/templates/edit.html.erb +0 -1
  138. data/merb_default_generators/resource_controller/templates/helper.rb +0 -5
  139. data/merb_default_generators/resource_controller/templates/index.html.erb +0 -1
  140. data/merb_default_generators/resource_controller/templates/new.html.erb +0 -1
  141. data/merb_default_generators/resource_controller/templates/show.html.erb +0 -1
  142. data/merb_generators/controller/USAGE +0 -5
  143. data/merb_generators/controller/controller_generator.rb +0 -16
  144. data/merb_generators/controller/templates/controller.rb +0 -8
  145. data/merb_generators/controller/templates/helper.rb +0 -5
  146. data/merb_generators/controller/templates/index.html.erb +0 -3
  147. data/merb_generators/part_controller/USAGE +0 -5
  148. data/merb_generators/part_controller/part_controller_generator.rb +0 -27
  149. data/merb_generators/part_controller/templates/controller.rb +0 -8
  150. data/merb_generators/part_controller/templates/helper.rb +0 -5
  151. data/merb_generators/part_controller/templates/index.html.erb +0 -3
  152. data/merb_generators/resource/USAGE +0 -0
  153. data/merb_generators/resource/resource_generator.rb +0 -67
  154. data/rspec_generators/merb_controller_test/merb_controller_test_generator.rb +0 -67
  155. data/rspec_generators/merb_controller_test/templates/controller_spec.rb +0 -8
  156. data/rspec_generators/merb_controller_test/templates/edit_spec.rb +0 -12
  157. data/rspec_generators/merb_controller_test/templates/helper_spec.rb +0 -5
  158. data/rspec_generators/merb_controller_test/templates/index_spec.rb +0 -12
  159. data/rspec_generators/merb_controller_test/templates/new_spec.rb +0 -12
  160. data/rspec_generators/merb_controller_test/templates/show_spec.rb +0 -5
  161. data/rspec_generators/merb_model_test/merb_model_test_generator.rb +0 -26
  162. data/rspec_generators/merb_model_test/templates/model_spec_template.erb +0 -7
  163. data/script/destroy +0 -14
  164. data/script/generate +0 -14
  165. data/spec/fixtures/config/environments/environment_config_test.yml +0 -1
  166. data/spec/fixtures/config/merb.yml +0 -18
  167. data/spec/fixtures/controllers/dispatch_spec_controllers.rb +0 -235
  168. data/spec/fixtures/controllers/render_spec_controllers.rb +0 -184
  169. data/spec/fixtures/foo.rb +0 -3
  170. data/spec/fixtures/mailers/views/layout/application.html.erb +0 -3
  171. data/spec/fixtures/mailers/views/layout/application.text.erb +0 -3
  172. data/spec/fixtures/mailers/views/test_mail_controller/eighth.html.erb +0 -1
  173. data/spec/fixtures/mailers/views/test_mail_controller/eighth.text.erb +0 -1
  174. data/spec/fixtures/mailers/views/test_mail_controller/first.html.erb +0 -1
  175. data/spec/fixtures/mailers/views/test_mail_controller/first.text.erb +0 -1
  176. data/spec/fixtures/mailers/views/test_mail_controller/ninth.html.erb +0 -1
  177. data/spec/fixtures/mailers/views/test_mail_controller/ninth.text.erb +0 -1
  178. data/spec/fixtures/mailers/views/test_mail_controller/second.text.erb +0 -1
  179. data/spec/fixtures/mailers/views/test_mail_controller/third.html.erb +0 -1
  180. data/spec/fixtures/models/router_spec_models.rb +0 -30
  181. data/spec/fixtures/parts/views/layout/todo_part.html.erb +0 -3
  182. data/spec/fixtures/parts/views/layout/todo_part.xml.erb +0 -3
  183. data/spec/fixtures/parts/views/todo_part/formatted_output.html.erb +0 -1
  184. data/spec/fixtures/parts/views/todo_part/formatted_output.js.erb +0 -1
  185. data/spec/fixtures/parts/views/todo_part/formatted_output.xml.erb +0 -1
  186. data/spec/fixtures/parts/views/todo_part/list.html.erb +0 -3
  187. data/spec/fixtures/sample.txt +0 -1
  188. data/spec/fixtures/views/erubis.html.erb +0 -1
  189. data/spec/fixtures/views/examples/_erubis.html.erb +0 -1
  190. data/spec/fixtures/views/examples/_haml.html.haml +0 -1
  191. data/spec/fixtures/views/examples/_markaby.html.mab +0 -1
  192. data/spec/fixtures/views/examples/_throw_content.html.erb +0 -6
  193. data/spec/fixtures/views/examples/hello.xml.builder +0 -1
  194. data/spec/fixtures/views/examples/js.js.erb +0 -1
  195. data/spec/fixtures/views/examples/template_catch_content.html.erb +0 -15
  196. data/spec/fixtures/views/examples/template_catch_content_from_partial.html.erb +0 -6
  197. data/spec/fixtures/views/examples/template_throw_content.html.erb +0 -10
  198. data/spec/fixtures/views/examples/template_throw_content_without_block.html.erb +0 -3
  199. data/spec/fixtures/views/exceptions/admin_access_required.html.erb +0 -1
  200. data/spec/fixtures/views/extension_template_controller/_nested_js.js.erb +0 -1
  201. data/spec/fixtures/views/extension_template_controller/_nested_xml.xml.erb +0 -1
  202. data/spec/fixtures/views/extension_template_controller/_render_partial_multiple_times.html.erb +0 -1
  203. data/spec/fixtures/views/extension_template_controller/erubis_templates.html.erb +0 -1
  204. data/spec/fixtures/views/extension_template_controller/erubis_templates.js.erb +0 -1
  205. data/spec/fixtures/views/extension_template_controller/erubis_templates.rhtml +0 -1
  206. data/spec/fixtures/views/extension_template_controller/erubis_templates.xml.erb +0 -1
  207. data/spec/fixtures/views/extension_template_controller/haml_index.html.haml +0 -0
  208. data/spec/fixtures/views/extension_template_controller/haml_templates.html.haml +0 -1
  209. data/spec/fixtures/views/extension_template_controller/haml_templates.js.haml +0 -1
  210. data/spec/fixtures/views/extension_template_controller/haml_templates.xml.haml +0 -1
  211. data/spec/fixtures/views/extension_template_controller/index.html.erb +0 -0
  212. data/spec/fixtures/views/extension_template_controller/markaby_index.html.mab +0 -0
  213. data/spec/fixtures/views/extension_template_controller/markaby_templates.html.mab +0 -1
  214. data/spec/fixtures/views/extension_template_controller/markaby_templates.js.mab +0 -1
  215. data/spec/fixtures/views/extension_template_controller/markaby_templates.xml.mab +0 -1
  216. data/spec/fixtures/views/extension_template_controller/render_multiple_partials.html.erb +0 -4
  217. data/spec/fixtures/views/extension_template_controller/render_nested_js.js.erb +0 -1
  218. data/spec/fixtures/views/extension_template_controller/render_nested_xml.xml.erb +0 -1
  219. data/spec/fixtures/views/haml.html.haml +0 -1
  220. data/spec/fixtures/views/haml.xml.haml +0 -2
  221. data/spec/fixtures/views/layout/application.html.erb +0 -1
  222. data/spec/fixtures/views/layout/application.xml.erb +0 -1
  223. data/spec/fixtures/views/layout/nested/example.html.erb +0 -1
  224. data/spec/fixtures/views/markaby.html.mab +0 -1
  225. data/spec/fixtures/views/nested/example/test.html.erb +0 -1
  226. data/spec/fixtures/views/partials/_erubis.html.erb +0 -1
  227. data/spec/fixtures/views/partials/_erubis_collection.html.erb +0 -1
  228. data/spec/fixtures/views/partials/_erubis_collection_with_locals.html.erb +0 -1
  229. data/spec/fixtures/views/partials/_erubis_new.html.erb +0 -1
  230. data/spec/fixtures/views/partials/_haml.html.haml +0 -1
  231. data/spec/fixtures/views/partials/_haml_collection.html.haml +0 -1
  232. data/spec/fixtures/views/partials/_haml_collection_with_locals.html.haml +0 -1
  233. data/spec/fixtures/views/partials/_haml_new.html.haml +0 -1
  234. data/spec/fixtures/views/partials/_markaby.html.mab +0 -1
  235. data/spec/fixtures/views/partials/_markaby_collection.html.mab +0 -1
  236. data/spec/fixtures/views/partials/_markaby_collection_with_locals.html.mab +0 -1
  237. data/spec/fixtures/views/partials/_markaby_new.html.mab +0 -1
  238. data/spec/fixtures/views/render_object_controller/render_object_with_template.html.erb +0 -1
  239. data/spec/fixtures/views/render_object_controller/render_object_with_template.js.erb +0 -1
  240. data/spec/fixtures/views/render_object_controller/render_object_with_template.xml.erb +0 -1
  241. data/spec/fixtures/views/template_views/interface__buffer_erubis.html.erb +0 -4
  242. data/spec/fixtures/views/template_views/interface__buffer_haml.html.haml +0 -7
  243. data/spec/fixtures/views/template_views/interface__buffer_markaby.html.mab +0 -7
  244. data/spec/fixtures/views/template_views/interface_capture_erubis.html.erb +0 -15
  245. data/spec/fixtures/views/template_views/interface_capture_haml.html.haml +0 -15
  246. data/spec/fixtures/views/template_views/interface_capture_markaby.html.mab +0 -4
  247. data/spec/fixtures/views/template_views/interface_concat_erubis.html.erb +0 -12
  248. data/spec/fixtures/views/template_views/interface_concat_haml.html.haml +0 -11
  249. data/spec/fixtures/views/template_views/interface_concat_markaby.html.mab +0 -14
  250. data/spec/fixtures/views/test.dir/the_template.html.erb +0 -1
  251. data/spec/merb/abstract_controller_spec.rb +0 -38
  252. data/spec/merb/assets_spec.rb +0 -207
  253. data/spec/merb/caching_spec.rb +0 -102
  254. data/spec/merb/config_spec.rb +0 -29
  255. data/spec/merb/controller_filters_spec.rb +0 -253
  256. data/spec/merb/controller_spec.rb +0 -126
  257. data/spec/merb/cookie_store_spec.rb +0 -72
  258. data/spec/merb/cookies_spec.rb +0 -96
  259. data/spec/merb/core_ext/class_spec.rb +0 -97
  260. data/spec/merb/core_ext/enumerable_spec.rb +0 -27
  261. data/spec/merb/core_ext/hash_spec.rb +0 -251
  262. data/spec/merb/core_ext/inflector_spec.rb +0 -34
  263. data/spec/merb/core_ext/kernel_spec.rb +0 -25
  264. data/spec/merb/core_ext/numeric_spec.rb +0 -26
  265. data/spec/merb/core_ext/object_spec.rb +0 -47
  266. data/spec/merb/core_ext/string_spec.rb +0 -22
  267. data/spec/merb/core_ext/symbol_spec.rb +0 -7
  268. data/spec/merb/dependency_spec.rb +0 -22
  269. data/spec/merb/dispatch_spec.rb +0 -528
  270. data/spec/merb/fake_request_spec.rb +0 -80
  271. data/spec/merb/generator_spec.rb +0 -248
  272. data/spec/merb/handler_spec.rb +0 -169
  273. data/spec/merb/mail_controller_spec.rb +0 -177
  274. data/spec/merb/mailer_spec.rb +0 -87
  275. data/spec/merb/multipart_spec.rb +0 -50
  276. data/spec/merb/part_controller_spec.rb +0 -124
  277. data/spec/merb/plugins_spec.rb +0 -80
  278. data/spec/merb/render_spec.rb +0 -469
  279. data/spec/merb/request_spec.rb +0 -287
  280. data/spec/merb/responder_spec.rb +0 -562
  281. data/spec/merb/router_spec.rb +0 -900
  282. data/spec/merb/server_spec.rb +0 -19
  283. data/spec/merb/template_spec.rb +0 -41
  284. data/spec/merb/upload_handler_spec.rb +0 -108
  285. data/spec/merb/version_spec.rb +0 -33
  286. data/spec/merb/view_context_spec.rb +0 -366
  287. data/spec/spec_generator_helper.rb +0 -34
  288. data/spec/spec_helper.rb +0 -101
  289. data/spec/spec_helpers/url_shared_behaviour.rb +0 -112
  290. data/test_unit_generators/merb_controller_test/merb_controller_test_generator.rb +0 -53
  291. data/test_unit_generators/merb_controller_test/templates/functional_test.rb +0 -17
  292. data/test_unit_generators/merb_controller_test/templates/helper_test.rb +0 -9
  293. data/test_unit_generators/merb_model_test/merb_model_test_generator.rb +0 -29
  294. data/test_unit_generators/merb_model_test/templates/model_test_unit_template.erb +0 -9
@@ -1,119 +0,0 @@
1
- module Merb
2
- module Assets
3
-
4
- # Returns true if assets should be bundled (e.g., production mode or
5
- # :bundle_assets is explicitly enabled), false if not.
6
- def self.bundle?
7
- (Merb::Config[:environment].to_s == 'production') ||
8
- (!!Merb::Config[:bundle_assets])
9
- end
10
-
11
- # Helpers for handling asset files.
12
- module AssetHelpers
13
- # :nodoc:
14
- ASSET_FILE_EXTENSIONS = {
15
- :javascript => ".js",
16
- :stylesheet => ".css"
17
- }
18
-
19
- # Returns the URI path to a particular asset file. If +local_path+ is
20
- # true, returns the path relative to the Merb.root, not the public
21
- # directory. Uses the path_prefix, if any is configured.
22
- #
23
- # asset_path(:javascript, :dingo) #=> "/javascripts/dingo.js"
24
- # asset_path(:javascript, :dingo, true) #=> "public/javascripts/dingo.js"
25
- def asset_path(asset_type, filename, local_path = false)
26
- filename = filename.to_s
27
- if filename !~ /#{'\\' + ASSET_FILE_EXTENSIONS[asset_type]}\Z/
28
- filename << ASSET_FILE_EXTENSIONS[asset_type]
29
- end
30
- filename = "/#{asset_type}s/#{filename}"
31
- if local_path
32
- return "public#{filename}"
33
- else
34
- return "#{Merb::Config[:path_prefix]}#{filename}"
35
- end
36
- end
37
- end
38
-
39
- # An abstract class for bundling text assets into single files.
40
- class AbstractAssetBundler
41
- class << self
42
-
43
- # Add a post-bundle callback, for example to run a Javascript or CSS
44
- # compressor on the bundled file:
45
- #
46
- # Merb::Assets::JavascriptAssetBundler.add_callback do |filename|
47
- # `yuicompressor #{filename}`
48
- # end
49
- def add_callback(&block)
50
- callbacks << block
51
- end
52
- alias_method :after_bundling, :add_callback
53
-
54
- # An array of any existing callbacks.
55
- def callbacks
56
- @callbacks ||= []
57
- return @callbacks
58
- end
59
-
60
- # The type of asset for which the bundler is responsible.
61
- def asset_type
62
- raise NotImplementedError, "should return a symbol for the first argument to be passed to asset_path"
63
- end
64
- end
65
-
66
- # Create a new asset bundler, which will produce a bundled file containing
67
- # the contents of +files+. If +name+ is +true+ (as in, is an instance of
68
- # +TrueClass+), the filename is written out as "all", otherwise +name+
69
- # is coerced into a string.
70
- def initialize(name, *files)
71
- @bundle_name = name == true ? :all : name
72
- @bundle_filename = asset_path(self.class.asset_type, @bundle_name, true)
73
- @files = files.map { |f| asset_path(self.class.asset_type, f, true) }
74
- end
75
-
76
- # Creates the new bundled file, executes all the callbacks, and returns
77
- # the name of the bundled file.
78
- def bundle!
79
- # TODO: Move this file check out into an in-memory cache. Also, push it out to the helper level so we don't have to create the helper object.
80
- unless File.exist?(@bundle_filename)
81
- bundle_files(@bundle_filename, *@files)
82
- self.class.callbacks.each { |c| c.call(@bundle_filename) }
83
- end
84
- return @bundle_name
85
- end
86
-
87
- protected
88
-
89
- include Merb::Assets::AssetHelpers # for asset_path
90
-
91
- # Bundle all the filenames in +files+ into +filename+.
92
- def bundle_files(filename, *files)
93
- File.open(filename, "w") do |f|
94
- files.each { |file| f.puts(File.read(file)) }
95
- end
96
- end
97
-
98
- end
99
-
100
- # Bundles javascripts into a single file:
101
- #
102
- # javascripts/#{name}.js
103
- class JavascriptAssetBundler < AbstractAssetBundler
104
- def self.asset_type
105
- :javascript
106
- end
107
- end
108
-
109
- # Bundles stylesheets into a single file:
110
- #
111
- # stylesheets/#{name}.css
112
- class StylesheetAssetBundler < AbstractAssetBundler
113
- def self.asset_type
114
- :stylesheet
115
- end
116
- end
117
-
118
- end
119
- end
@@ -1,286 +0,0 @@
1
- module Merb
2
- module GlobalHelper;end
3
-
4
- module BootLoader
5
- class << self
6
-
7
- def initialize_merb
8
- require 'merb'
9
- @mtime = Time.now if Merb::Config[:reloader] == true
10
- # Register session types before merb_init.rb so that any additional
11
- # session stores will be added to the end of the list and become the
12
- # default.
13
- register_session_type('memory',
14
- Merb.framework_root / "merb" / "session" / "memory_session",
15
- "Using in-memory sessions; sessions will be lost whenever the server stops.")
16
- register_session_type('mem_cache',
17
- Merb.framework_root / "merb" / "session" / "mem_cache_session",
18
- "Using MemCache distributed memory sessions")
19
- register_session_type('cookie', # Last session type becomes the default
20
- Merb.framework_root / "merb" / "session" / "cookie_store",
21
- "Using 'share-nothing' cookie sessions (4kb limit per client)")
22
- require Merb.root / 'config/merb_init.rb'
23
- add_controller_mixins
24
- end
25
-
26
- def max_mtime( files = [] )
27
- files.map{ |file| File.mtime(file) rescue @mtime }.max
28
- end
29
-
30
- def register_session_type(name, file, description = nil)
31
- @registered_session_types ||= YAML::Omap.new
32
- @registered_session_types[name] = {
33
- :file => file,
34
- :description => (description || "Using #{name} sessions")
35
- }
36
- end
37
-
38
- def add_controller_mixins
39
- types = @registered_session_types
40
- Merb::Controller.class_eval do
41
- lib = File.join(Merb.framework_root, 'merb')
42
- session_store = Merb::Config[:session_store].to_s
43
- if ["", "false"].include?(session_store)
44
- puts "Not Using Sessions"
45
- elsif reg = types[session_store]
46
- if session_store == "cookie"
47
- unless Merb::Config[:session_secret_key] && (Merb::Config[:session_secret_key].length >= 16)
48
- puts("You must specify a session_secret_key in your merb.yml, and it must be at least 16 characters\nbailing out...")
49
- exit!
50
- end
51
- Merb::Controller.session_secret_key = Merb::Config[:session_secret_key]
52
- end
53
- require reg[:file]
54
- include ::Merb::SessionMixin
55
- puts reg[:description]
56
- else
57
- puts "Session store not found, '#{Merb::Config[:session_store]}'."
58
- puts "Defaulting to CookieStore Sessions"
59
- unless Merb::Config[:session_secret_key] && (Merb::Config[:session_secret_key].length >= 16)
60
- puts("You must specify a session_secret_key in your merb.yml, and it must be at least 16 characters\nbailing out...")
61
- exit!
62
- end
63
- Merb::Controller.session_secret_key = Merb::Config[:session_secret_key]
64
- require types['cookie'][:file]
65
- include ::Merb::SessionMixin
66
- puts "(plugin not installed?)"
67
- end
68
-
69
- if Merb::Config[:basic_auth]
70
- require lib + "/mixins/basic_authentication"
71
- include ::Merb::AuthenticationMixin
72
- puts "Basic Authentication mixed in"
73
- end
74
- end
75
- end
76
-
77
- def after_app_loads(&block)
78
- @after_app_blocks ||= []
79
- @after_app_blocks << block
80
- end
81
-
82
- def app_loaded?
83
- @app_loaded
84
- end
85
-
86
- def load_action_arguments(klasses = Merb::Controller._subclasses)
87
- begin
88
- klasses.each do |controller|
89
- controller = Object.full_const_get(controller)
90
- controller.action_argument_list = {}
91
- controller.callable_actions.each do |action, bool|
92
- controller.action_argument_list[action.to_sym] = ParseTreeArray.translate(controller, action).get_args
93
- end
94
- end
95
- rescue
96
- klasses.each { |controller| Object.full_const_get(controller).action_argument_list = {} }
97
- end if defined?(ParseTreeArray)
98
- end
99
-
100
- def template_paths(type = "*[a-zA-Z]")
101
- # This gets all templates set in the controllers template roots
102
- template_paths = Merb::AbstractController._abstract_subclasses.map do |klass|
103
- Object.full_const_get(klass)._template_root
104
- end.uniq.map do |path|
105
- Dir["#{path}/**/#{type}"]
106
- end
107
-
108
- # This gets the templates that might be created outside controllers
109
- # template roots. eg app/views/shared/*
110
- template_paths << Dir["#{Merb.root}/app/views/**/*[a-zA-Z]"] if type == "*"
111
-
112
- template_paths.flatten.compact.uniq || []
113
- end
114
-
115
- def load_controller_template_path_cache
116
- Merb::AbstractController.reset_template_path_cache!
117
-
118
- template_paths.each do |template|
119
- Merb::AbstractController.add_path_to_template_cache(template)
120
- end
121
- end
122
-
123
- def load_inline_helpers
124
- partials = template_paths("_*.{erb,haml}")
125
-
126
- partials.each do |partial|
127
- case partial
128
- when /erb$/
129
- template = Erubis::Eruby.new(File.read(partial))
130
- template.def_method(Merb::GlobalHelper, partial.gsub(/[^\.a-zA-Z0-9]/, "__").gsub(/\./, "_"), partial)
131
- when /haml$/
132
- if Object.const_defined?(:Haml) and Haml::Engine.instance_methods.include?('def_method')
133
- template = Haml::Engine.new(File.read(partial), :filename => partial)
134
- template.def_method(Merb::GlobalHelper, partial.gsub(/[^\.a-zA-Z0-9]/, "__").gsub(/\./, "_"))
135
- end
136
- end
137
- end
138
- end
139
-
140
- def load_application
141
-
142
- #Magic Class Loading => Not failing on missing parent due to alphabetical loading
143
- # Does a reverse alphaebetical search if classes failed in first pass
144
- # Will continue to reverse the list of failures until the size does change between
145
- # two passes
146
-
147
- orphaned_paths = []
148
- $LOAD_PATH.unshift( File.join(Merb.root,'/app/models') )
149
- $LOAD_PATH.unshift( File.join(Merb.root,'/app/controllers') )
150
- $LOAD_PATH.unshift( File.join(Merb.root , '/lib') )
151
- Merb.load_paths.each do |glob|
152
- Dir[Merb.root + glob].each do |m|
153
- begin
154
- require m
155
- rescue NameError
156
- orphaned_paths.unshift(m)
157
- end
158
- end
159
- end
160
-
161
- load_classes_with_requirements(orphaned_paths)
162
-
163
- load_action_arguments
164
- load_controller_template_path_cache
165
- load_inline_helpers
166
- @app_loaded = true
167
- load_libraries
168
- (@after_app_blocks || []).each { |b| b.call }
169
- end
170
-
171
-
172
- def load_classes_with_requirements(orphaned_paths)
173
-
174
- #Make the list unique
175
- orphaned_paths.uniq!
176
-
177
- while orphaned_paths.size > 0
178
- #Take the size for comparison later
179
- size_at_start = orphaned_paths.size
180
-
181
- fail_list = [] #List of failures
182
-
183
- # Try to load each path again, this time the order is reversed
184
- (orphaned_paths).each do |m|
185
- # Remove the path from the list
186
- orphaned_paths.delete(m)
187
- begin
188
- require m
189
- rescue NameError
190
- # Add it back on if it failed to load due to NameError
191
- fail_list.push(m)
192
- end
193
- end
194
-
195
- orphaned_paths.concat(fail_list)
196
-
197
- # Stop processing if everything loaded (size == 0) or if the size didn't change
198
- # (ie something couldn't be loaded)
199
- break if(orphaned_paths.size == size_at_start || orphaned_paths.size == 0)
200
- end
201
-
202
- return orphaned_paths
203
- end
204
-
205
-
206
- def load_libraries
207
- # Load the Sass plugin of /public/stylesheets/sass exists
208
- begin
209
- require "sass/plugin" if File.directory?(Merb.root / "public" / "stylesheets" / "sass")
210
- rescue LoadError
211
- end
212
- # If you don't use the JSON gem, disable auto-parsing of json params too
213
- if Merb::Config[:disable_json_gem]
214
- Merb::Request::parse_json_params = false
215
- else
216
- begin
217
- require 'json/ext'
218
- rescue LoadError
219
- require 'json/pure'
220
- end
221
- end
222
- end
223
-
224
- def remove_constant(const)
225
- parts = const.to_s.split("::")
226
- base = parts.size == 1 ? Object : Object.full_const_get(parts[0..-2].join("::"))
227
- object = parts[-1].intern
228
- Merb.logger.info("Removing constant #{object} from #{base}")
229
- base.send(:remove_const, object) if object
230
- Merb::Controller._subclasses.delete(const)
231
- end
232
-
233
- def reload
234
- return if !Merb::Config[:reloader]
235
-
236
- # First we collect all files in the project (this will also grab newly added files)
237
- project_files = Merb.load_paths.map { |path| Dir[Merb.root + path] }.flatten.uniq
238
- partials = template_paths("_*.*").map { |path| Dir[path] }.flatten.uniq
239
- project_mtime = max_mtime(project_files + partials) # Latest changed time of all project files
240
-
241
- return if @mtime.nil? || @mtime >= project_mtime # Only continue if a file has changed
242
-
243
- project_files.each do |file|
244
- if File.mtime(file) >= @mtime
245
- # If the file has changed or been added since the last project reload time
246
- # remove any cannonical constants, based on what type of project file it is
247
- # and then reload the file
248
- begin
249
- constant = case file
250
- when %r[/app/(models|controllers|parts|mailers)/(.+)\.rb$]
251
- $2.to_const_string
252
- when %r[/app/(helpers)/(.+)\.rb$]
253
- "Merb::" + $2.to_const_string
254
- end
255
- remove_constant(constant)
256
- rescue NameError => e
257
- Merb.logger.warn "Couldn't remove constant #{constant}"
258
- end
259
-
260
- begin
261
- Merb.logger.info("Reloading file #{file}")
262
- old_subclasses = Merb::Controller._subclasses.dup
263
- load(file)
264
- loaded_classes = Merb::Controller._subclasses - old_subclasses
265
- load_action_arguments(loaded_classes)
266
- rescue Exception => e
267
- puts "Error reloading file #{file}: #{e}"
268
- Merb.logger.warn " Error: #{e}"
269
- end
270
-
271
- # constant = file =~ /\/(controllers|models|mailers|helpers|parts)\/(.*).rb/ ? $2.to_const_string : nil
272
- # remove_constant($2.to_const_string, ($1 == "helpers") ? Merb : nil)
273
- # load file and puts "loaded file: #{file}"
274
- end
275
- end
276
-
277
- # Rebuild the glob cache and erubis inline helpers
278
- load_controller_template_path_cache
279
- load_inline_helpers
280
-
281
- @mtime = project_mtime # As the last action, update the current @mtime
282
- end
283
-
284
- end # class << self
285
- end # BootLoader
286
- end # Merb
@@ -1,235 +0,0 @@
1
- module Merb
2
- module GlobalHelper;end
3
-
4
- module BootLoader
5
- class << self
6
-
7
- def initialize_merb
8
- require 'merb'
9
- @mtime = Time.now if Merb::Config[:reloader] == true
10
- # Register session types before merb_init.rb so that any additional
11
- # session stores will be added to the end of the list and become the
12
- # default.
13
- register_session_type('memory',
14
- Merb.framework_root / "merb" / "session" / "memory_session",
15
- "Using in-memory sessions; sessions will be lost whenever the server stops.")
16
- register_session_type('mem_cache',
17
- Merb.framework_root / "merb" / "session" / "mem_cache_session",
18
- "Using MemCache distributed memory sessions")
19
- register_session_type('cookie', # Last session type becomes the default
20
- Merb.framework_root / "merb" / "session" / "cookie_store",
21
- "Using 'share-nothing' cookie sessions (4kb limit per client)")
22
- require Merb.root / 'config/merb_init.rb'
23
- add_controller_mixins
24
- end
25
-
26
- def max_mtime( files = [] )
27
- files.map{ |file| File.mtime(file) rescue @mtime }.max
28
- end
29
-
30
- def register_session_type(name, file, description = nil)
31
- @registered_session_types ||= YAML::Omap.new
32
- @registered_session_types[name] = {
33
- :file => file,
34
- :description => (description || "Using #{name} sessions")
35
- }
36
- end
37
-
38
- def add_controller_mixins
39
- types = @registered_session_types
40
- Merb::Controller.class_eval do
41
- lib = File.join(Merb.framework_root, 'merb')
42
- session_store = Merb::Config[:session_store].to_s
43
- if ["", "false"].include?(session_store)
44
- puts "Not Using Sessions"
45
- elsif reg = types[session_store]
46
- if session_store == "cookie"
47
- unless Merb::Config[:session_secret_key] && (Merb::Config[:session_secret_key].length >= 16)
48
- puts("You must specify a session_secret_key in your merb.yml, and it must be at least 16 characters\nbailing out...")
49
- exit!
50
- end
51
- Merb::Controller.session_secret_key = Merb::Config[:session_secret_key]
52
- end
53
- require reg[:file]
54
- include ::Merb::SessionMixin
55
- puts reg[:description]
56
- else
57
- puts "Session store not found, '#{Merb::Config[:session_store]}'."
58
- puts "Defaulting to CookieStore Sessions"
59
- unless Merb::Config[:session_secret_key] && (Merb::Config[:session_secret_key].length >= 16)
60
- puts("You must specify a session_secret_key in your merb.yml, and it must be at least 16 characters\nbailing out...")
61
- exit!
62
- end
63
- Merb::Controller.session_secret_key = Merb::Config[:session_secret_key]
64
- require types['cookie'][:file]
65
- include ::Merb::SessionMixin
66
- puts "(plugin not installed?)"
67
- end
68
-
69
- if Merb::Config[:basic_auth]
70
- require lib + "/mixins/basic_authentication"
71
- include ::Merb::AuthenticationMixin
72
- puts "Basic Authentication mixed in"
73
- end
74
- end
75
- end
76
-
77
- def after_app_loads(&block)
78
- @after_app_blocks ||= []
79
- @after_app_blocks << block
80
- end
81
-
82
- def app_loaded?
83
- @app_loaded
84
- end
85
-
86
- def load_action_arguments(klasses = Merb::Controller._subclasses)
87
- begin
88
- klasses.each do |controller|
89
- controller = Object.full_const_get(controller)
90
- controller.action_argument_list = {}
91
- controller.callable_actions.each do |action, bool|
92
- controller.action_argument_list[action.to_sym] = ParseTreeArray.translate(controller, action).get_args
93
- end
94
- end
95
- rescue
96
- klasses.each { |controller| Object.full_const_get(controller).action_argument_list = {} }
97
- end if defined?(ParseTreeArray)
98
- end
99
-
100
- def template_paths(type = "*[a-zA-Z]")
101
- # This gets all templates set in the controllers template roots
102
- template_paths = Merb::AbstractController._abstract_subclasses.map do |klass|
103
- Object.full_const_get(klass)._template_root
104
- end.uniq.map do |path|
105
- Dir["#{path}/**/#{type}"]
106
- end
107
-
108
- # This gets the templates that might be created outside controllers
109
- # template roots. eg app/views/shared/*
110
- template_paths << Dir["#{Merb.root}/app/views/**/*[a-zA-Z]"] if type == "*"
111
-
112
- template_paths.flatten.compact.uniq || []
113
- end
114
-
115
- def load_controller_template_path_cache
116
- Merb::AbstractController.reset_template_path_cache!
117
-
118
- template_paths.each do |template|
119
- Merb::AbstractController.add_path_to_template_cache(template)
120
- end
121
- end
122
-
123
- def load_inline_helpers
124
- partials = template_paths("_*.{erb,haml}")
125
-
126
- partials.each do |partial|
127
- case partial
128
- when /erb$/
129
- template = Erubis::Eruby.new(File.read(partial))
130
- template.def_method(Merb::GlobalHelper, partial.gsub(/[^\.a-zA-Z0-9]/, "__").gsub(/\./, "_"), partial)
131
- when /haml$/
132
- if Object.const_defined?(:Haml) and Haml::Engine.instance_methods.include?('def_method')
133
- template = Haml::Engine.new(File.read(partial), :filename => partial)
134
- template.def_method(Merb::GlobalHelper, partial.gsub(/[^\.a-zA-Z0-9]/, "__").gsub(/\./, "_"))
135
- end
136
- end
137
- end
138
- end
139
-
140
- def load_application
141
- $LOAD_PATH.unshift( File.join(Merb.root , '/app/models') )
142
- $LOAD_PATH.unshift( File.join(Merb.root , '/app/controllers') )
143
- $LOAD_PATH.unshift( File.join(Merb.root , '/lib') )
144
- Merb.load_paths.each do |glob|
145
- Dir[Merb.root + glob].each { |m| require m }
146
- end
147
- load_action_arguments
148
- load_controller_template_path_cache
149
- load_inline_helpers
150
- @app_loaded = true
151
- load_libraries
152
- (@after_app_blocks || []).each { |b| b.call }
153
- end
154
-
155
- def load_libraries
156
- # Load the Sass plugin of /public/stylesheets/sass exists
157
- begin
158
- require "sass/plugin" if File.directory?(Merb.root / "public" / "stylesheets" / "sass")
159
- rescue LoadError
160
- end
161
- # If you don't use the JSON gem, disable auto-parsing of json params too
162
- if Merb::Config[:disable_json_gem]
163
- Merb::Request::parse_json_params = false
164
- else
165
- begin
166
- require 'json/ext'
167
- rescue LoadError
168
- require 'json/pure'
169
- end
170
- end
171
- end
172
-
173
- def remove_constant(const)
174
- parts = const.to_s.split("::")
175
- base = parts.size == 1 ? Object : Object.full_const_get(parts[0..-2].join("::"))
176
- object = parts[-1].intern
177
- Merb.logger.info("Removing constant #{object} from #{base}")
178
- base.send(:remove_const, object) if object
179
- Merb::Controller._subclasses.delete(const)
180
- end
181
-
182
- def reload
183
- return if !Merb::Config[:reloader]
184
-
185
- # First we collect all files in the project (this will also grab newly added files)
186
- project_files = Merb.load_paths.map { |path| Dir[Merb.root + path] }.flatten.uniq
187
- partials = template_paths("_*.*").map { |path| Dir[path] }.flatten.uniq
188
- project_mtime = max_mtime(project_files + partials) # Latest changed time of all project files
189
-
190
- return if @mtime.nil? || @mtime >= project_mtime # Only continue if a file has changed
191
-
192
- project_files.each do |file|
193
- if File.mtime(file) >= @mtime
194
- # If the file has changed or been added since the last project reload time
195
- # remove any cannonical constants, based on what type of project file it is
196
- # and then reload the file
197
- begin
198
- constant = case file
199
- when %r[/app/(models|controllers|parts|mailers)/(.+)\.rb$]
200
- $2.to_const_string
201
- when %r[/app/(helpers)/(.+)\.rb$]
202
- "Merb::" + $2.to_const_string
203
- end
204
- remove_constant(constant)
205
- rescue NameError => e
206
- Merb.logger.warn "Couldn't remove constant #{constant}"
207
- end
208
-
209
- begin
210
- Merb.logger.info("Reloading file #{file}")
211
- old_subclasses = Merb::Controller._subclasses.dup
212
- load(file)
213
- loaded_classes = Merb::Controller._subclasses - old_subclasses
214
- load_action_arguments(loaded_classes)
215
- rescue Exception => e
216
- puts "Error reloading file #{file}: #{e}"
217
- Merb.logger.warn " Error: #{e}"
218
- end
219
-
220
- # constant = file =~ /\/(controllers|models|mailers|helpers|parts)\/(.*).rb/ ? $2.to_const_string : nil
221
- # remove_constant($2.to_const_string, ($1 == "helpers") ? Merb : nil)
222
- # load file and puts "loaded file: #{file}"
223
- end
224
- end
225
-
226
- # Rebuild the glob cache and erubis inline helpers
227
- load_controller_template_path_cache
228
- load_inline_helpers
229
-
230
- @mtime = project_mtime # As the last action, update the current @mtime
231
- end
232
-
233
- end # class << self
234
- end # BootLoader
235
- end # Merb