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,49 +0,0 @@
1
- module Enumerable
2
-
3
- # Abstract the common pattern of injecting a hash into a block to accumulate
4
- # and return the injected hash.
5
- #
6
- # Both of these are equivalent
7
- # [1,2,3].inject({}){|m,i| m[i] = i; m }
8
- # [1,2,3].injecting({}){|m,i| m[i] = i }
9
- # => {1=>1, 2=>2, 3=>3}
10
- #
11
- # The main difference is with injecting you do not have to end the block
12
- # with ;m to return the accumulated hash m. In this sense it is very much
13
- # like Object#returning
14
- def injecting(s)
15
- inject(s) do |k, i|
16
- yield(k, i); k
17
- end
18
- end
19
-
20
- # Look for any of an array of things inside another array (or any Enumerable).
21
- #
22
- # ['louie', 'bert'].include_any?('louie', 'chicken')
23
- # => true
24
- def include_any?(*args)
25
- args.any? {|arg| self.include?(arg) }
26
- end
27
-
28
-
29
- #
30
- # Returns a hash, which keys are evaluated result from the
31
- # block, and values are arrays of elements in <i>enum</i>
32
- # corresponding to the key.
33
- #
34
- # (1..6).group_by {|i| i%3} #=> {0=>[3, 6], 1=>[1, 4], 2=>[2, 5]}
35
- #
36
- # This is included in Ruby 1.9
37
- # http://www.ruby-doc.org/core-1.9/classes/Enumerable.html#M002672
38
- #
39
- # Implementation from Ruby on Rails:
40
- # trunk/activesupport/lib/active_support/core_ext/enumerable.rb
41
- # [rev 5334]
42
- #
43
- def group_by
44
- inject({}) do |groups, element|
45
- (groups[yield(element)] ||= []) << element
46
- groups
47
- end
48
- end if RUBY_VERSION < '1.9'
49
- end
@@ -1,76 +0,0 @@
1
- begin
2
- require 'ruby2ruby'
3
-
4
- class ParseTreeArray < Array #:nodoc:
5
- def self.translate(*args)
6
- self.new(ParseTree.translate(*args))
7
- end
8
-
9
- def deep_array_node(type = nil)
10
- each do |node|
11
- return ParseTreeArray.new(node) if node.is_a?(Array) && (!type || node[0] == type)
12
- next unless node.is_a?(Array)
13
- return ParseTreeArray.new(node).deep_array_node(type)
14
- end
15
- nil
16
- end
17
-
18
- def arg_nodes
19
- self[1..-1].inject([]) do |sum,item|
20
- sum << [item] unless item.is_a?(Array)
21
- sum
22
- end
23
- end
24
-
25
- def get_args
26
- arg_node = deep_array_node(:args)
27
- return nil unless arg_node
28
- args = arg_node.arg_nodes
29
- default_node = arg_node.deep_array_node(:block)
30
- return args unless default_node
31
- lasgns = default_node[1..-1]
32
- lasgns.each do |asgn|
33
- args.assoc(asgn[1]) << eval(RubyToRuby.new.process(asgn[2]))
34
- end
35
- args
36
- end
37
-
38
- end
39
-
40
- # Used in mapping controller arguments to the params hash.
41
- # NOTE: You must have the 'ruby2ruby' gem installed for this to work.
42
- # Example:
43
- # (In PostsController)
44
- # def show(id) #=> id is the same as params[:id]
45
-
46
- module GetArgs
47
-
48
- # Returns an array of method arguments and their default values
49
- # Example:
50
- # class Example
51
- # def hello(one,two="two",three)
52
- # end
53
- #
54
- # def goodbye
55
- # end
56
- # end
57
- #
58
- # Example.instance_method(:hello).get_args #=> [[:one], [:two, "two"], [:three, "three"]]
59
- # Example.instance_method(:goodbye).get_args #=> nil
60
- def get_args
61
- klass, meth = self.to_s.split(/ /).to_a[1][0..-2].split("#")
62
- # Remove stupidity for #<Method: Class(Object)#foo>
63
- klass = $` if klass =~ /\(/
64
- ParseTreeArray.translate(Object.const_get(klass), meth).get_args
65
- end
66
- end
67
-
68
- class UnboundMethod #:nodoc:
69
- include GetArgs
70
- end
71
-
72
- class Method #:nodoc:
73
- include GetArgs
74
- end
75
- rescue LoadError
76
- end
@@ -1,306 +0,0 @@
1
- # require 'hpricot'
2
-
3
- class Hash
4
- class << self
5
- # Converts valid XML into a Ruby Hash structure.
6
- # <tt>xml</tt>:: A string representation of valid XML
7
- #
8
- # == Typecasting
9
- # Typecasting is performed on elements that have a "<tt>type</tt>" attribute of
10
- # <tt>integer</tt>::
11
- # <tt>boolean</tt>:: anything other than "true" evaluates to false
12
- # <tt>datetime</tt>:: Returns a Time object. See +Time+ documentation for valid Time strings
13
- # <tt>date</tt>:: Returns a Date object. See +Date+ documentation for valid Date strings
14
- #
15
- # Keys are automatically converted to +snake_case+
16
- #
17
- # == Caveats
18
- # * Mixed content tags are assumed to be text and any xml tags are kept as a String
19
- # * Any attributes other than type on a node containing a text node will be discarded
20
- #
21
- # == Examples
22
- #
23
- # === Standard
24
- # <user gender='m'>
25
- # <age type='integer'>35</age>
26
- # <name>Home Simpson</name>
27
- # <dob type='date'>1988-01-01</dob>
28
- # <joined-at type='datetime'>2000-04-28 23:01</joined-at>
29
- # <is-cool type='boolean'>true</is-cool>
30
- # </user>
31
- #
32
- # evaluates to
33
- #
34
- # { "user" =>
35
- # { "gender" => "m",
36
- # "age" => 35,
37
- # "name" => "Home Simpson",
38
- # "dob" => DateObject( 1998-01-01 ),
39
- # "joined_at" => TimeObject( 2000-04-28 23:01),
40
- # "is_cool" => true
41
- # }
42
- # }
43
- #
44
- # === Mixed Content
45
- # <story>
46
- # A Quick <em>brown</em> Fox
47
- # </story>
48
- #
49
- # evaluates to
50
- # { "story" => "A Quick <em>brown</em> Fox" }
51
- #
52
- # === Attributes other than type on a node containing text
53
- # <story is-good='fasle'>
54
- # A Quick <em>brown</em> Fox
55
- # </story>
56
- #
57
- # evaluates to
58
- # { "story" => "A Quick <em>brown</em> Fox" }
59
- #
60
- # <bicep unit='inches' type='integer'>60</bicep>
61
- #
62
- # evaluates with a typecast to an integer. But ignores the unit attribute
63
- # { "bicep" => 60 }
64
- def from_xml( xml )
65
- ToHashParser.from_xml(xml)
66
- end
67
- end
68
-
69
- # convert this hash into a Mash for string or symbol key access
70
- def to_mash
71
- hash = Mash.new(self)
72
- hash.default = default
73
- hash
74
- end
75
-
76
- # Convert this hash to a query string:
77
- #
78
- # { :name => "Bob",
79
- # :address => {
80
- # :street => '111 Ruby Ave.',
81
- # :city => 'Ruby Central',
82
- # :phones => ['111-111-1111', '222-222-2222']
83
- # }
84
- # }.to_params
85
- # #=> "name=Bob&address[city]=Ruby Central&address[phones]=111-111-1111222-222-2222&address[street]=111 Ruby Ave."
86
- #
87
- def to_params
88
- params = ''
89
- stack = []
90
-
91
- each do |k, v|
92
- if v.is_a?(Hash)
93
- stack << [k,v]
94
- else
95
- params << "#{k}=#{v}&"
96
- end
97
- end
98
-
99
- stack.each do |parent, hash|
100
- hash.each do |k, v|
101
- if v.is_a?(Hash)
102
- stack << ["#{parent}[#{k}]", v]
103
- else
104
- params << "#{parent}[#{k}]=#{v}&"
105
- end
106
- end
107
- end
108
-
109
- params.chop! # trailing &
110
- params
111
- end
112
-
113
- # Returns a new Hash with only the selected keys:
114
- #
115
- # { :one => 1, :two => 2, :three => 3 }.only(:one)
116
- # #=> { :one => 1 }
117
- def only(*allowed)
118
- reject { |k,v| !allowed.include?(k) }
119
- end
120
-
121
- # Returns a new hash without the selected keys:
122
- #
123
- # { :one => 1, :two => 2, :three => 3 }.except(:one)
124
- # #=> { :two => 2, :three => 3 }
125
- #
126
- def except(*rejected)
127
- reject { |k,v| rejected.include?(k) }
128
- end
129
-
130
- # Converts the hash into xml attributes
131
- #
132
- # { :one => "ONE", "two"=>"TWO" }.to_xml_attributes
133
- # #=> 'one="ONE" two="TWO"'
134
- #
135
- def to_xml_attributes
136
- map do |k,v|
137
- %{#{k.to_s.camelize.sub(/^(.{1,1})/) { |m| m.downcase }}="#{v}"}
138
- end.join(' ')
139
- end
140
-
141
- alias_method :to_html_attributes, :to_xml_attributes
142
-
143
- # Adds the given class symbol or string to the hash in the
144
- # :class key. This will add a html class if there are already any existing
145
- # or create the key and add this as the first class
146
- #
147
- # @hash[:class] #=> nil
148
- # @hash.add_html_class!(:selected) #=> @hash[:class] == "selected"
149
- #
150
- # @hash.add_html_class!("class1 class2") #=> @hash[:class] == "selected class1 class2"
151
- #
152
- def add_html_class!(html_class)
153
- if self[:class]
154
- self[:class] = "#{self[:class]} #{html_class}"
155
- else
156
- self[:class] = html_class.to_s
157
- end
158
- end
159
-
160
- # Destructively convert all keys which respond_to?(:to_sym) to symbols.
161
- # Works recursively if given nested hashes.
162
- #
163
- # { 'one' => 1, 'two' => 2 }.symbolize_keys!
164
- # #=> { :one => 1, :two => 2 }
165
- #
166
- def symbolize_keys!
167
- each do |k,v|
168
- sym = k.respond_to?(:to_sym) ? k.to_sym : k
169
- self[sym] = Hash === v ? v.symbolize_keys! : v
170
- delete(k) unless k == sym
171
- end
172
- self
173
- end
174
-
175
- # Destructively and non-recursively convert each key to an uppercase string.
176
- #
177
- # { :name => "Bob", "age" => 12, "nick" => "Bobinator" }.environmentize_keys!
178
- # #=> { "NAME" => "Bob", "NICK" => "Bobinator", "AGE" => 12 }
179
- #
180
- def environmentize_keys!
181
- keys.each do |key|
182
- self[key.to_s.upcase] = delete(key)
183
- end
184
- self
185
- end
186
-
187
- def respond_to?(method, include_private = false)
188
- return true if keys.include?(method)
189
- super(method, include_private)
190
- end
191
- end
192
-
193
- require 'rexml/parsers/streamparser'
194
- require 'rexml/parsers/baseparser'
195
- require 'rexml/light/node'
196
-
197
- # This is a slighly modified version of the XMLUtilityNode from
198
- # http://merb.devjavu.com/projects/merb/ticket/95 (has.sox@gmail.com)
199
- # It's mainly just adding vowels, as I ht cd wth n vwls :)
200
- # This represents the hard part of the work, all I did was change the underlying
201
- # parser
202
- class REXMLUtilityNode # :nodoc:
203
- attr_accessor :name, :attributes, :children
204
-
205
- def initialize(name, attributes = {})
206
- @name = name.tr("-", "_")
207
- @attributes = undasherize_keys(attributes)
208
- @children = []
209
- @text = false
210
- end
211
-
212
- def add_node(node)
213
- @text = true if node.is_a? String
214
- @children << node
215
- end
216
-
217
- def to_hash
218
- if @text
219
- return { name => typecast_value( translate_xml_entities( inner_html ) ) }
220
- else
221
- #change repeating groups into an array
222
- # group by the first key of each element of the array to find repeating groups
223
- groups = @children.group_by{ |c| c.name }
224
-
225
- hash = {}
226
- groups.each do |key, values|
227
- if values.size == 1
228
- hash.merge! values.first
229
- else
230
- hash.merge! key => values.map { |element| element.to_hash[key] }
231
- end
232
- end
233
-
234
- # merge the arrays, including attributes
235
- hash.merge! attributes unless attributes.empty?
236
-
237
- { name => hash }
238
- end
239
- end
240
-
241
- def typecast_value(value)
242
- return value unless attributes["type"]
243
-
244
- case attributes["type"]
245
- when "integer" then value.to_i
246
- when "boolean" then value.strip == "true"
247
- when "datetime" then ::Time.parse(value).utc
248
- when "date" then ::Date.parse(value)
249
- else value
250
- end
251
- end
252
-
253
- def translate_xml_entities(value)
254
- value.gsub(/&lt;/, "<").
255
- gsub(/&gt;/, ">").
256
- gsub(/&quot;/, '"').
257
- gsub(/&apos;/, "'").
258
- gsub(/&amp;/, "&")
259
- end
260
-
261
- def undasherize_keys(params)
262
- params.keys.each do |key, vvalue|
263
- params[key.tr("-", "_")] = params.delete(key)
264
- end
265
- params
266
- end
267
-
268
- def inner_html
269
- @children.join
270
- end
271
-
272
- def to_html
273
- "<#{name}#{attributes.to_xml_attributes}>#{inner_html}</#{name}>"
274
- end
275
-
276
- def to_s
277
- to_html
278
- end
279
- end
280
-
281
- class ToHashParser # :nodoc:
282
- def self.from_xml(xml)
283
- stack = []
284
- parser = REXML::Parsers::BaseParser.new(xml)
285
-
286
- while true
287
- event = parser.pull
288
- case event[0]
289
- when :end_document
290
- break
291
- when :end_doctype, :start_doctype
292
- # do nothing
293
- when :start_element
294
- stack.push REXMLUtilityNode.new(event[1], event[2])
295
- when :end_element
296
- if stack.size > 1
297
- temp = stack.pop
298
- stack.last.add_node(temp)
299
- end
300
- when :text, :cdata
301
- stack.last.add_node(event[1]) unless event[1].strip.length == 0
302
- end
303
- end
304
- stack.pop.to_hash
305
- end
306
- end
@@ -1,112 +0,0 @@
1
- Inflector.inflections do |inflect|
2
- inflect.plural(/$/, 's')
3
- inflect.plural(/s$/i, 's')
4
- inflect.plural(/(ax|test)is$/i, '\1es')
5
- inflect.plural(/(octop|vir)us$/i, '\1i')
6
- inflect.plural(/(alias|status)$/i, '\1es')
7
- inflect.plural(/(bu)s$/i, '\1ses')
8
- inflect.plural(/(buffal|tomat)o$/i, '\1oes')
9
- inflect.plural(/([ti])um$/i, '\1a')
10
- inflect.plural(/sis$/i, 'ses')
11
- inflect.plural(/(?:([^f])fe|([lr])f)$/i, '\1\2ves')
12
- inflect.plural(/(hive)$/i, '\1s')
13
- inflect.plural(/([^aeiouy]|qu)y$/i, '\1ies')
14
- inflect.plural(/(x|ch|ss|sh)$/i, '\1es')
15
- inflect.plural(/(matr|vert|ind)ix|ex$/i, '\1ices')
16
- inflect.plural(/([m|l])ouse$/i, '\1ice')
17
- inflect.plural(/^(ox)$/i, '\1en')
18
- inflect.plural(/(quiz)$/i, '\1zes')
19
-
20
- inflect.singular(/s$/i, '')
21
- inflect.singular(/(n)ews$/i, '\1ews')
22
- inflect.singular(/([ti])a$/i, '\1um')
23
- inflect.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i, '\1\2sis')
24
- inflect.singular(/(^analy)ses$/i, '\1sis')
25
- inflect.singular(/([^f])ves$/i, '\1fe')
26
- inflect.singular(/(hive)s$/i, '\1')
27
- inflect.singular(/(tive)s$/i, '\1')
28
- inflect.singular(/([lr])ves$/i, '\1f')
29
- inflect.singular(/([^aeiouy]|qu)ies$/i, '\1y')
30
- inflect.singular(/(s)eries$/i, '\1eries')
31
- inflect.singular(/(m)ovies$/i, '\1ovie')
32
- inflect.singular(/(x|ch|ss|sh)es$/i, '\1')
33
- inflect.singular(/([m|l])ice$/i, '\1ouse')
34
- inflect.singular(/(bus)es$/i, '\1')
35
- inflect.singular(/(o)es$/i, '\1')
36
- inflect.singular(/(shoe)s$/i, '\1')
37
- inflect.singular(/(cris|ax|test)es$/i, '\1is')
38
- inflect.singular(/(octop|vir)i$/i, '\1us')
39
- inflect.singular(/(alias|status)es$/i, '\1')
40
- inflect.singular(/^(ox)en/i, '\1')
41
- inflect.singular(/(vert|ind)ices$/i, '\1ex')
42
- inflect.singular(/(matr)ices$/i, '\1ix')
43
- inflect.singular(/(quiz)zes$/i, '\1')
44
-
45
- inflect.irregular('person', 'people')
46
- inflect.irregular('man', 'men')
47
- inflect.irregular('child', 'children')
48
- inflect.irregular('sex', 'sexes')
49
- inflect.irregular('move', 'moves')
50
-
51
- inflect.uncountable(%w(equipment information rice money species series fish sheep))
52
- end
53
-
54
- module Inflections #:nodoc:
55
-
56
- def pluralize
57
- Inflector.pluralize(self)
58
- end
59
-
60
- def singularize
61
- Inflector.singularize(self)
62
- end
63
-
64
- def camelize(first_letter = :upper)
65
- case first_letter
66
- when :upper then Inflector.camelize(self, true)
67
- when :lower then Inflector.camelize(self, false)
68
- end
69
- end
70
- alias_method :camelcase, :camelize
71
-
72
- def titleize
73
- Inflector.titleize(self)
74
- end
75
- alias_method :titlecase, :titleize
76
-
77
- def underscore
78
- Inflector.underscore(self)
79
- end
80
-
81
- def dasherize
82
- Inflector.dasherize(self)
83
- end
84
-
85
- def demodulize
86
- Inflector.demodulize(self)
87
- end
88
-
89
- def tableize
90
- Inflector.tableize(self)
91
- end
92
-
93
- def classify
94
- Inflector.classify(self)
95
- end
96
-
97
- def humanize
98
- Inflector.humanize(self)
99
- end
100
-
101
- def foreign_key(separate_class_name_and_id_with_underscore = true)
102
- Inflector.foreign_key(self, separate_class_name_and_id_with_underscore)
103
- end
104
-
105
- def constantize
106
- Inflector.constantize(self)
107
- end
108
- end
109
-
110
- class String
111
- include Inflections
112
- end