thorero 0.9.4.4 → 0.9.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (298) hide show
  1. data/LICENSE +1 -1
  2. data/README +21 -0
  3. data/Rakefile +275 -108
  4. data/TODO +0 -0
  5. data/bin/merb +12 -0
  6. data/bin/merb-specs +5 -0
  7. data/docs/bootloading.dox +58 -0
  8. data/docs/documentation_standards +40 -0
  9. data/docs/merb-core-call-stack-diagram.mmap +0 -0
  10. data/docs/merb-core-call-stack-diagram.pdf +0 -0
  11. data/docs/merb-core-call-stack-diagram.png +0 -0
  12. data/docs/new_render_api +51 -0
  13. data/lib/merb-core.rb +603 -0
  14. data/lib/merb-core/autoload.rb +32 -0
  15. data/lib/merb-core/bootloader.rb +708 -0
  16. data/lib/merb-core/config.rb +303 -0
  17. data/lib/merb-core/constants.rb +43 -0
  18. data/lib/merb-core/controller/abstract_controller.rb +578 -0
  19. data/lib/merb-core/controller/exceptions.rb +302 -0
  20. data/lib/merb-core/controller/merb_controller.rb +256 -0
  21. data/lib/merb-core/controller/mime.rb +106 -0
  22. data/lib/merb-core/controller/mixins/authentication.rb +87 -0
  23. data/lib/merb-core/controller/mixins/controller.rb +290 -0
  24. data/lib/merb-core/controller/mixins/render.rb +481 -0
  25. data/lib/merb-core/controller/mixins/responder.rb +472 -0
  26. data/lib/merb-core/controller/template.rb +254 -0
  27. data/lib/merb-core/core_ext.rb +8 -0
  28. data/lib/merb-core/core_ext/kernel.rb +319 -0
  29. data/lib/merb-core/dispatch/cookies.rb +91 -0
  30. data/lib/merb-core/dispatch/dispatcher.rb +278 -0
  31. data/lib/merb-core/dispatch/exceptions.html.erb +303 -0
  32. data/lib/merb-core/dispatch/request.rb +603 -0
  33. data/lib/merb-core/dispatch/router.rb +179 -0
  34. data/lib/merb-core/dispatch/router/behavior.rb +867 -0
  35. data/lib/merb-core/dispatch/router/cached_proc.rb +52 -0
  36. data/lib/merb-core/dispatch/router/route.rb +321 -0
  37. data/lib/merb-core/dispatch/session.rb +78 -0
  38. data/lib/merb-core/dispatch/session/cookie.rb +168 -0
  39. data/lib/merb-core/dispatch/session/memcached.rb +184 -0
  40. data/lib/merb-core/dispatch/session/memory.rb +241 -0
  41. data/lib/merb-core/dispatch/worker.rb +28 -0
  42. data/lib/merb-core/gem_ext/erubis.rb +77 -0
  43. data/lib/{extlib → merb-core}/logger.rb +2 -2
  44. data/lib/merb-core/plugins.rb +59 -0
  45. data/lib/merb-core/rack.rb +21 -0
  46. data/lib/merb-core/rack/adapter.rb +44 -0
  47. data/lib/merb-core/rack/adapter/ebb.rb +25 -0
  48. data/lib/merb-core/rack/adapter/evented_mongrel.rb +26 -0
  49. data/lib/merb-core/rack/adapter/fcgi.rb +17 -0
  50. data/lib/merb-core/rack/adapter/irb.rb +118 -0
  51. data/lib/merb-core/rack/adapter/mongrel.rb +26 -0
  52. data/lib/merb-core/rack/adapter/runner.rb +28 -0
  53. data/lib/merb-core/rack/adapter/swiftiplied_mongrel.rb +26 -0
  54. data/lib/merb-core/rack/adapter/thin.rb +39 -0
  55. data/lib/merb-core/rack/adapter/thin_turbo.rb +24 -0
  56. data/lib/merb-core/rack/adapter/webrick.rb +36 -0
  57. data/lib/merb-core/rack/application.rb +18 -0
  58. data/lib/merb-core/rack/handler/mongrel.rb +97 -0
  59. data/lib/merb-core/rack/middleware.rb +26 -0
  60. data/lib/merb-core/rack/middleware/path_prefix.rb +31 -0
  61. data/lib/merb-core/rack/middleware/profiler.rb +19 -0
  62. data/lib/merb-core/rack/middleware/static.rb +45 -0
  63. data/lib/merb-core/server.rb +252 -0
  64. data/lib/merb-core/tasks/audit.rake +68 -0
  65. data/lib/merb-core/tasks/merb.rb +1 -0
  66. data/lib/merb-core/tasks/merb_rake_helper.rb +12 -0
  67. data/lib/merb-core/test.rb +11 -0
  68. data/lib/merb-core/test/helpers.rb +9 -0
  69. data/lib/merb-core/test/helpers/controller_helper.rb +8 -0
  70. data/lib/merb-core/test/helpers/multipart_request_helper.rb +175 -0
  71. data/lib/merb-core/test/helpers/request_helper.rb +344 -0
  72. data/lib/merb-core/test/helpers/route_helper.rb +33 -0
  73. data/lib/merb-core/test/helpers/view_helper.rb +121 -0
  74. data/lib/merb-core/test/matchers.rb +9 -0
  75. data/lib/merb-core/test/matchers/controller_matchers.rb +319 -0
  76. data/lib/merb-core/test/matchers/route_matchers.rb +136 -0
  77. data/lib/merb-core/test/matchers/view_matchers.rb +335 -0
  78. data/lib/merb-core/test/run_specs.rb +47 -0
  79. data/lib/merb-core/test/tasks/spectasks.rb +68 -0
  80. data/lib/merb-core/test/test_ext/hpricot.rb +32 -0
  81. data/lib/merb-core/test/test_ext/object.rb +14 -0
  82. data/lib/merb-core/test/test_ext/string.rb +14 -0
  83. data/lib/merb-core/vendor/facets.rb +2 -0
  84. data/lib/merb-core/vendor/facets/dictionary.rb +433 -0
  85. data/lib/merb-core/vendor/facets/inflect.rb +345 -0
  86. data/lib/merb-core/version.rb +11 -0
  87. data/spec/private/config/adapter_spec.rb +32 -0
  88. data/spec/private/config/config_spec.rb +202 -0
  89. data/spec/private/config/environment_spec.rb +13 -0
  90. data/spec/private/config/spec_helper.rb +1 -0
  91. data/spec/private/core_ext/kernel_spec.rb +169 -0
  92. data/spec/private/dispatch/bootloader_spec.rb +24 -0
  93. data/spec/private/dispatch/cookies_spec.rb +107 -0
  94. data/spec/private/dispatch/dispatch_spec.rb +35 -0
  95. data/spec/private/dispatch/fixture/app/controllers/application.rb +4 -0
  96. data/spec/private/dispatch/fixture/app/controllers/exceptions.rb +27 -0
  97. data/spec/private/dispatch/fixture/app/controllers/foo.rb +21 -0
  98. data/spec/private/dispatch/fixture/app/helpers/global_helpers.rb +8 -0
  99. data/spec/private/dispatch/fixture/app/views/exeptions/client_error.html.erb +37 -0
  100. data/spec/private/dispatch/fixture/app/views/exeptions/internal_server_error.html.erb +216 -0
  101. data/spec/private/dispatch/fixture/app/views/exeptions/not_acceptable.html.erb +38 -0
  102. data/spec/private/dispatch/fixture/app/views/exeptions/not_found.html.erb +40 -0
  103. data/spec/private/dispatch/fixture/app/views/foo/bar.html.erb +0 -0
  104. data/spec/private/dispatch/fixture/app/views/layout/application.html.erb +11 -0
  105. data/spec/private/dispatch/fixture/config/black_hole.rb +12 -0
  106. data/spec/private/dispatch/fixture/config/environments/development.rb +6 -0
  107. data/spec/private/dispatch/fixture/config/environments/production.rb +5 -0
  108. data/spec/private/dispatch/fixture/config/environments/test.rb +6 -0
  109. data/spec/private/dispatch/fixture/config/init.rb +45 -0
  110. data/spec/private/dispatch/fixture/config/rack.rb +11 -0
  111. data/spec/private/dispatch/fixture/config/router.rb +35 -0
  112. data/spec/private/dispatch/fixture/log/merb_test.log +1874 -0
  113. data/spec/private/dispatch/fixture/public/images/merb.jpg +0 -0
  114. data/spec/private/dispatch/fixture/public/merb.fcgi +4 -0
  115. data/spec/private/dispatch/fixture/public/stylesheets/master.css +119 -0
  116. data/spec/private/dispatch/route_params_spec.rb +24 -0
  117. data/spec/private/dispatch/session_mixin_spec.rb +47 -0
  118. data/spec/private/dispatch/spec_helper.rb +1 -0
  119. data/spec/private/plugins/plugin_spec.rb +166 -0
  120. data/spec/private/rack/application_spec.rb +49 -0
  121. data/spec/private/router/behavior_spec.rb +60 -0
  122. data/spec/private/router/fixture/log/merb_test.log +139 -0
  123. data/spec/private/router/route_spec.rb +414 -0
  124. data/spec/private/router/router_spec.rb +175 -0
  125. data/spec/private/vendor/facets/plural_spec.rb +564 -0
  126. data/spec/private/vendor/facets/singular_spec.rb +489 -0
  127. data/spec/public/DEFINITIONS +11 -0
  128. data/spec/public/abstract_controller/controllers/alt_views/layout/application.erb +1 -0
  129. data/spec/public/abstract_controller/controllers/alt_views/layout/merb/test/fixtures/abstract/render_string_controller_layout.erb +1 -0
  130. data/spec/public/abstract_controller/controllers/alt_views/layout/merb/test/fixtures/abstract/render_template_controller_layout.erb +1 -0
  131. data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/display_object_with_multiple_roots/index.erb +1 -0
  132. data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/display_object_with_multiple_roots/show.erb +1 -0
  133. data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/render_template_multiple_roots/index.erb +1 -0
  134. data/spec/public/abstract_controller/controllers/alt_views/partial/basic_partial_with_multiple_roots/_partial.erb +1 -0
  135. data/spec/public/abstract_controller/controllers/alt_views/render_template_multiple_roots_and_custom_location/index.erb +1 -0
  136. data/spec/public/abstract_controller/controllers/alt_views/render_template_multiple_roots_inherited/index.erb +1 -0
  137. data/spec/public/abstract_controller/controllers/cousins.rb +41 -0
  138. data/spec/public/abstract_controller/controllers/display.rb +54 -0
  139. data/spec/public/abstract_controller/controllers/filters.rb +193 -0
  140. data/spec/public/abstract_controller/controllers/helpers.rb +41 -0
  141. data/spec/public/abstract_controller/controllers/partial.rb +121 -0
  142. data/spec/public/abstract_controller/controllers/render.rb +113 -0
  143. data/spec/public/abstract_controller/controllers/views/helpers/capture/index.erb +1 -0
  144. data/spec/public/abstract_controller/controllers/views/helpers/capture_eq/index.erb +1 -0
  145. data/spec/public/abstract_controller/controllers/views/helpers/capture_with_args/index.erb +1 -0
  146. data/spec/public/abstract_controller/controllers/views/helpers/concat/index.erb +1 -0
  147. data/spec/public/abstract_controller/controllers/views/layout/alt.erb +1 -0
  148. data/spec/public/abstract_controller/controllers/views/layout/custom.erb +1 -0
  149. data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/display_object/index.erb +1 -0
  150. data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/display_object_with_action/new.erb +1 -0
  151. data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template/index.erb +1 -0
  152. data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_app_layout/index.erb +0 -0
  153. data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_custom_layout/index.erb +1 -0
  154. data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_multiple_roots/index.erb +1 -0
  155. data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_multiple_roots/show.erb +1 -0
  156. data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_two_throw_contents/index.erb +1 -0
  157. data/spec/public/abstract_controller/controllers/views/partial/another_directory/_partial.erb +1 -0
  158. data/spec/public/abstract_controller/controllers/views/partial/basic_partial/_partial.erb +1 -0
  159. data/spec/public/abstract_controller/controllers/views/partial/basic_partial/index.erb +1 -0
  160. data/spec/public/abstract_controller/controllers/views/partial/basic_partial_with_multiple_roots/index.erb +1 -0
  161. data/spec/public/abstract_controller/controllers/views/partial/nested_partial/_first.erb +1 -0
  162. data/spec/public/abstract_controller/controllers/views/partial/nested_partial/_second.erb +1 -0
  163. data/spec/public/abstract_controller/controllers/views/partial/nested_partial/index.erb +1 -0
  164. data/spec/public/abstract_controller/controllers/views/partial/partial_in_another_directory/index.erb +1 -0
  165. data/spec/public/abstract_controller/controllers/views/partial/partial_with_both/_collection.erb +1 -0
  166. data/spec/public/abstract_controller/controllers/views/partial/partial_with_both/index.erb +1 -0
  167. data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections/_collection.erb +1 -0
  168. data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections/index.erb +1 -0
  169. data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_as/_collection.erb +1 -0
  170. data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_as/index.erb +1 -0
  171. data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_counter/_collection.erb +1 -0
  172. data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_counter/index.erb +1 -0
  173. data/spec/public/abstract_controller/controllers/views/partial/partial_with_locals/_variables.erb +1 -0
  174. data/spec/public/abstract_controller/controllers/views/partial/partial_with_locals/index.erb +1 -0
  175. data/spec/public/abstract_controller/controllers/views/partial/partial_with_with_and_locals/_both.erb +1 -0
  176. data/spec/public/abstract_controller/controllers/views/partial/partial_with_with_and_locals/index.erb +1 -0
  177. data/spec/public/abstract_controller/controllers/views/partial/with_absolute_partial/_partial.erb +1 -0
  178. data/spec/public/abstract_controller/controllers/views/partial/with_absolute_partial/index.erb +1 -0
  179. data/spec/public/abstract_controller/controllers/views/partial/with_as_partial/_with_partial.erb +1 -0
  180. data/spec/public/abstract_controller/controllers/views/partial/with_as_partial/index.erb +1 -0
  181. data/spec/public/abstract_controller/controllers/views/partial/with_nil_partial/_with_partial.erb +1 -0
  182. data/spec/public/abstract_controller/controllers/views/partial/with_nil_partial/index.erb +1 -0
  183. data/spec/public/abstract_controller/controllers/views/partial/with_partial/_with_partial.erb +1 -0
  184. data/spec/public/abstract_controller/controllers/views/partial/with_partial/index.erb +1 -0
  185. data/spec/public/abstract_controller/controllers/views/test_display/foo.html.erb +1 -0
  186. data/spec/public/abstract_controller/controllers/views/test_render/foo.html.erb +0 -0
  187. data/spec/public/abstract_controller/controllers/views/wonderful/index.erb +1 -0
  188. data/spec/public/abstract_controller/display_spec.rb +33 -0
  189. data/spec/public/abstract_controller/filter_spec.rb +106 -0
  190. data/spec/public/abstract_controller/helper_spec.rb +21 -0
  191. data/spec/public/abstract_controller/partial_spec.rb +61 -0
  192. data/spec/public/abstract_controller/render_spec.rb +90 -0
  193. data/spec/public/abstract_controller/spec_helper.rb +31 -0
  194. data/spec/public/boot_loader/boot_loader_spec.rb +33 -0
  195. data/spec/public/boot_loader/spec_helper.rb +1 -0
  196. data/spec/public/controller/authentication_spec.rb +103 -0
  197. data/spec/public/controller/base_spec.rb +36 -0
  198. data/spec/public/controller/controllers/authentication.rb +45 -0
  199. data/spec/public/controller/controllers/base.rb +36 -0
  200. data/spec/public/controller/controllers/display.rb +118 -0
  201. data/spec/public/controller/controllers/redirect.rb +30 -0
  202. data/spec/public/controller/controllers/responder.rb +93 -0
  203. data/spec/public/controller/controllers/url.rb +7 -0
  204. data/spec/public/controller/controllers/views/layout/custom.html.erb +1 -0
  205. data/spec/public/controller/controllers/views/layout/custom_arg.html.erb +1 -0
  206. data/spec/public/controller/controllers/views/layout/custom_arg.json.erb +1 -0
  207. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_and_local_provides/index.html.erb +1 -0
  208. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_and_local_provides/index.xml.erb +1 -0
  209. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_provides/index.html.erb +1 -0
  210. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_provides/index.xml.erb +1 -0
  211. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template/index.html.erb +1 -0
  212. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template/no_layout.html.erb +1 -0
  213. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template_argument/index.html.erb +1 -0
  214. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/html_default/index.html.erb +1 -0
  215. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/layout/custom.html.erb +1 -0
  216. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/local_provides/index.html.erb +1 -0
  217. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/local_provides/index.xml.erb +1 -0
  218. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/multi_provides/index.html.erb +1 -0
  219. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/multi_provides/index.js.erb +1 -0
  220. data/spec/public/controller/display_spec.rb +84 -0
  221. data/spec/public/controller/redirect_spec.rb +27 -0
  222. data/spec/public/controller/responder_spec.rb +163 -0
  223. data/spec/public/controller/spec_helper.rb +11 -0
  224. data/spec/public/controller/url_spec.rb +180 -0
  225. data/spec/public/core/merb_core_spec.rb +45 -0
  226. data/spec/public/core_ext/class_spec.rb +91 -0
  227. data/spec/public/core_ext/fixtures/core_ext_dependency.rb +2 -0
  228. data/spec/public/core_ext/kernel_spec.rb +9 -0
  229. data/spec/public/core_ext/spec_helper.rb +1 -0
  230. data/spec/public/directory_structure/directory/app/controllers/application.rb +3 -0
  231. data/spec/public/directory_structure/directory/app/controllers/base.rb +13 -0
  232. data/spec/public/directory_structure/directory/app/controllers/custom.rb +19 -0
  233. data/spec/public/directory_structure/directory/app/views/base/template.html.erb +1 -0
  234. data/spec/public/directory_structure/directory/app/views/wonderful/template.erb +1 -0
  235. data/spec/public/directory_structure/directory/config/router.rb +3 -0
  236. data/spec/public/directory_structure/directory/log/merb_test.log +562 -0
  237. data/spec/public/directory_structure/directory_spec.rb +44 -0
  238. data/spec/public/logger/logger_spec.rb +181 -0
  239. data/spec/public/logger/spec_helper.rb +1 -0
  240. data/spec/public/reloading/directory/app/controllers/application.rb +3 -0
  241. data/spec/public/reloading/directory/app/controllers/reload.rb +6 -0
  242. data/spec/public/reloading/directory/config/init.rb +2 -0
  243. data/spec/public/reloading/directory/log/merb_test.log +138 -0
  244. data/spec/public/reloading/reload_spec.rb +103 -0
  245. data/spec/public/request/multipart_spec.rb +41 -0
  246. data/spec/public/request/request_spec.rb +228 -0
  247. data/spec/public/router/default_spec.rb +21 -0
  248. data/spec/public/router/deferred_spec.rb +22 -0
  249. data/spec/public/router/fixation_spec.rb +27 -0
  250. data/spec/public/router/fixture/log/merb_test.log +1556 -0
  251. data/spec/public/router/namespace_spec.rb +113 -0
  252. data/spec/public/router/nested_matches_spec.rb +97 -0
  253. data/spec/public/router/nested_resources_spec.rb +41 -0
  254. data/spec/public/router/resource_spec.rb +37 -0
  255. data/spec/public/router/resources_spec.rb +82 -0
  256. data/spec/public/router/spec_helper.rb +90 -0
  257. data/spec/public/router/special_spec.rb +61 -0
  258. data/spec/public/router/string_spec.rb +61 -0
  259. data/spec/public/template/template_spec.rb +104 -0
  260. data/spec/public/template/templates/error.html.erb +2 -0
  261. data/spec/public/template/templates/template.html.erb +1 -0
  262. data/spec/public/template/templates/template.html.myt +1 -0
  263. data/spec/public/test/controller_matchers_spec.rb +402 -0
  264. data/spec/public/test/controllers/controller_assertion_mock.rb +7 -0
  265. data/spec/public/test/controllers/dispatch_controller.rb +11 -0
  266. data/spec/public/test/controllers/spec_helper_controller.rb +38 -0
  267. data/spec/public/test/multipart_request_helper_spec.rb +159 -0
  268. data/spec/public/test/multipart_upload_text_file.txt +1 -0
  269. data/spec/public/test/request_helper_spec.rb +221 -0
  270. data/spec/public/test/route_helper_spec.rb +71 -0
  271. data/spec/public/test/route_matchers_spec.rb +162 -0
  272. data/spec/public/test/view_helper_spec.rb +96 -0
  273. data/spec/public/test/view_matchers_spec.rb +183 -0
  274. data/spec/spec_helper.rb +68 -0
  275. metadata +493 -41
  276. data/README.txt +0 -3
  277. data/lib/extlib.rb +0 -32
  278. data/lib/extlib/assertions.rb +0 -8
  279. data/lib/extlib/blank.rb +0 -42
  280. data/lib/extlib/class.rb +0 -175
  281. data/lib/extlib/hash.rb +0 -410
  282. data/lib/extlib/hook.rb +0 -366
  283. data/lib/extlib/inflection.rb +0 -141
  284. data/lib/extlib/lazy_array.rb +0 -106
  285. data/lib/extlib/mash.rb +0 -143
  286. data/lib/extlib/module.rb +0 -37
  287. data/lib/extlib/object.rb +0 -165
  288. data/lib/extlib/object_space.rb +0 -13
  289. data/lib/extlib/pathname.rb +0 -5
  290. data/lib/extlib/pooling.rb +0 -233
  291. data/lib/extlib/rubygems.rb +0 -38
  292. data/lib/extlib/simple_set.rb +0 -39
  293. data/lib/extlib/string.rb +0 -132
  294. data/lib/extlib/struct.rb +0 -8
  295. data/lib/extlib/tasks/release.rb +0 -9
  296. data/lib/extlib/time.rb +0 -12
  297. data/lib/extlib/version.rb +0 -3
  298. data/lib/extlib/virtual_file.rb +0 -10
data/README.txt DELETED
@@ -1,3 +0,0 @@
1
- = extlib
2
-
3
- A support library for DataMapper, DataObjects and Merb.
@@ -1,32 +0,0 @@
1
- require 'pathname'
2
- require 'rubygems'
3
-
4
- __DIR__ = File.expand_path(File.dirname(__FILE__))
5
- $LOAD_PATH.unshift(__DIR__) unless $LOAD_PATH.include?(__DIR__)
6
-
7
- # for Pathname /
8
- require File.expand_path(File.join(__DIR__, 'extlib', 'pathname'))
9
-
10
- dir = Pathname(__FILE__).dirname.expand_path / 'extlib'
11
-
12
- require dir / "class.rb"
13
- require dir / "object"
14
- require dir / "object_space"
15
-
16
- require dir / "string"
17
- require dir / "hash"
18
- require dir / "mash"
19
- require dir / "virtual_file"
20
- require dir / "logger"
21
- require dir / "time"
22
-
23
- require dir / 'assertions'
24
- require dir / 'blank'
25
- require dir / 'inflection'
26
- require dir / 'lazy_array'
27
- require dir / 'module'
28
- require dir / 'blank'
29
- require dir / 'pooling'
30
- require dir / 'simple_set'
31
- require dir / 'struct'
32
- require dir / 'hook'
@@ -1,8 +0,0 @@
1
- module Extlib
2
- module Assertions
3
- def assert_kind_of(name, value, *klasses)
4
- klasses.each { |k| return if value.kind_of?(k) }
5
- raise ArgumentError, "+#{name}+ should be #{klasses.map { |k| k.name } * ' or '}, but was #{value.class.name}", caller(2)
6
- end
7
- end
8
- end
@@ -1,42 +0,0 @@
1
- # blank? methods for several different class types
2
- class Object
3
- # Returns true if the object is nil or empty (if applicable)
4
- def blank?
5
- nil? || (respond_to?(:empty?) && empty?)
6
- end
7
- end # class Object
8
-
9
- class Numeric
10
- # Numerics can't be blank
11
- def blank?
12
- false
13
- end
14
- end # class Numeric
15
-
16
- class NilClass
17
- # Nils are always blank
18
- def blank?
19
- true
20
- end
21
- end # class NilClass
22
-
23
- class TrueClass
24
- # True is not blank.
25
- def blank?
26
- false
27
- end
28
- end # class TrueClass
29
-
30
- class FalseClass
31
- # False is always blank.
32
- def blank?
33
- true
34
- end
35
- end # class FalseClass
36
-
37
- class String
38
- # Strips out whitespace then tests if the string is empty.
39
- def blank?
40
- strip.empty?
41
- end
42
- end # class String
@@ -1,175 +0,0 @@
1
- # Copyright (c) 2004-2008 David Heinemeier Hansson
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining
4
- # a copy of this software and associated documentation files (the
5
- # "Software"), to deal in the Software without restriction, including
6
- # without limitation the rights to use, copy, modify, merge, publish,
7
- # distribute, sublicense, and/or sell copies of the Software, and to
8
- # permit persons to whom the Software is furnished to do so, subject to
9
- # the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be
12
- # included in all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
22
- # Allows attributes to be shared within an inheritance hierarchy, but where
23
- # each descendant gets a copy of their parents' attributes, instead of just a
24
- # pointer to the same. This means that the child can add elements to, for
25
- # example, an array without those additions being shared with either their
26
- # parent, siblings, or children, which is unlike the regular class-level
27
- # attributes that are shared across the entire hierarchy.
28
- class Class
29
- # Defines class-level and instance-level attribute reader.
30
- #
31
- # @param *syms<Array> Array of attributes to define reader for.
32
- # @return <Array[#to_s]> List of attributes that were made into cattr_readers
33
- #
34
- # @api public
35
- #
36
- # @todo Is this inconsistent in that it does not allow you to prevent
37
- # an instance_reader via :instance_reader => false
38
- def cattr_reader(*syms)
39
- syms.flatten.each do |sym|
40
- next if sym.is_a?(Hash)
41
- class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
42
- unless defined? @@#{sym}
43
- @@#{sym} = nil
44
- end
45
-
46
- def self.#{sym}
47
- @@#{sym}
48
- end
49
-
50
- def #{sym}
51
- @@#{sym}
52
- end
53
- RUBY
54
- end
55
- end
56
-
57
- # Defines class-level (and optionally instance-level) attribute writer.
58
- #
59
- # @param <Array[*#to_s, Hash{:instance_writer => Boolean}]> Array of attributes to define writer for.
60
- # @option syms :instance_writer<Boolean> if true, instance-level attribute writer is defined.
61
- # @return <Array[#to_s]> List of attributes that were made into cattr_writers
62
- #
63
- # @api public
64
- def cattr_writer(*syms)
65
- options = syms.last.is_a?(Hash) ? syms.pop : {}
66
- syms.flatten.each do |sym|
67
- class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
68
- unless defined? @@#{sym}
69
- @@#{sym} = nil
70
- end
71
-
72
- def self.#{sym}=(obj)
73
- @@#{sym} = obj
74
- end
75
- RUBY
76
-
77
- unless options[:instance_writer] == false
78
- class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
79
- def #{sym}=(obj)
80
- @@#{sym} = obj
81
- end
82
- RUBY
83
- end
84
- end
85
- end
86
-
87
- # Defines class-level (and optionally instance-level) attribute accessor.
88
- #
89
- # @param *syms<Array[*#to_s, Hash{:instance_writer => Boolean}]> Array of attributes to define accessor for.
90
- # @option syms :instance_writer<Boolean> if true, instance-level attribute writer is defined.
91
- # @return <Array[#to_s]> List of attributes that were made into accessors
92
- #
93
- # @api public
94
- def cattr_accessor(*syms)
95
- cattr_reader(*syms)
96
- cattr_writer(*syms)
97
- end
98
-
99
- # Defines class-level inheritable attribute reader. Attributes are available to subclasses,
100
- # each subclass has a copy of parent's attribute.
101
- #
102
- # @param *syms<Array[#to_s]> Array of attributes to define inheritable reader for.
103
- # @return <Array[#to_s]> Array of attributes converted into inheritable_readers.
104
- #
105
- # @api public
106
- #
107
- # @todo Do we want to block instance_reader via :instance_reader => false
108
- # @todo It would be preferable that we do something with a Hash passed in
109
- # (error out or do the same as other methods above) instead of silently
110
- # moving on). In particular, this makes the return value of this function
111
- # less useful.
112
- def class_inheritable_reader(*ivars)
113
- instance_reader = ivars.pop[:reader] if ivars.last.is_a?(Hash)
114
-
115
- ivars.each do |ivar|
116
- self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
117
- def self.#{ivar}
118
- return @#{ivar} if self == #{self} || defined?(@#{ivar})
119
- ivar = superclass.#{ivar}
120
- return nil if ivar.nil? && !#{self}.instance_variable_defined?("@#{ivar}")
121
- @#{ivar} = ivar && !ivar.is_a?(Module) ? ivar.dup : ivar
122
- end
123
- RUBY
124
- unless instance_reader == false
125
- self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
126
- def #{ivar}
127
- self.class.#{ivar}
128
- end
129
- RUBY
130
- end
131
- end
132
- end
133
-
134
- # Defines class-level inheritable attribute writer. Attributes are available to subclasses,
135
- # each subclass has a copy of parent's attribute.
136
- #
137
- # @param *syms<Array[*#to_s, Hash{:instance_writer => Boolean}]> Array of attributes to
138
- # define inheritable writer for.
139
- # @option syms :instance_writer<Boolean> if true, instance-level inheritable attribute writer is defined.
140
- # @return <Array[#to_s]> An Array of the attributes that were made into inheritable writers.
141
- #
142
- # @api public
143
- #
144
- # @todo We need a style for class_eval <<-HEREDOC. I'd like to make it
145
- # class_eval(<<-RUBY, __FILE__, __LINE__), but we should codify it somewhere.
146
- def class_inheritable_writer(*ivars)
147
- instance_writer = ivars.pop[:instance_writer] if ivars.last.is_a?(Hash)
148
- ivars.each do |ivar|
149
- self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
150
- def self.#{ivar}=(obj)
151
- @#{ivar} = obj
152
- end
153
- RUBY
154
- unless instance_writer == false
155
- self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
156
- def #{ivar}=(obj) self.class.#{ivar} = obj end
157
- RUBY
158
- end
159
- end
160
- end
161
-
162
- # Defines class-level inheritable attribute accessor. Attributes are available to subclasses,
163
- # each subclass has a copy of parent's attribute.
164
- #
165
- # @param *syms<Array[*#to_s, Hash{:instance_writer => Boolean}]> Array of attributes to
166
- # define inheritable accessor for.
167
- # @option syms :instance_writer<Boolean> if true, instance-level inheritable attribute writer is defined.
168
- # @return <Array[#to_s]> An Array of attributes turned into inheritable accessors.
169
- #
170
- # @api public
171
- def class_inheritable_accessor(*syms)
172
- class_inheritable_reader(*syms)
173
- class_inheritable_writer(*syms)
174
- end
175
- end
@@ -1,410 +0,0 @@
1
- require 'base64'
2
-
3
- class Hash
4
- class << self
5
- # Converts valid XML into a Ruby Hash structure.
6
- #
7
- # @param xml<String> A string representation of valid XML.
8
- #
9
- # @note Mixed content is treated as text and any tags in it are left unparsed
10
- # @note Any attributes other than type on a node containing a text node will be
11
- # discarded
12
- #
13
- # @details [Typecasting]
14
- # Typecasting is performed on elements that have a +type+ attribute:
15
- # integer::
16
- # boolean:: Anything other than "true" evaluates to false.
17
- # datetime::
18
- # Returns a Time object. See Time documentation for valid Time strings.
19
- # date::
20
- # Returns a Date object. See Date documentation for valid Date strings.
21
- #
22
- # Keys are automatically converted to +snake_case+
23
- #
24
- # @example [Simple]
25
- # <user gender='m'>
26
- # <age type='integer'>35</age>
27
- # <name>Home Simpson</name>
28
- # <dob type='date'>1988-01-01</dob>
29
- # <joined-at type='datetime'>2000-04-28 23:01</joined-at>
30
- # <is-cool type='boolean'>true</is-cool>
31
- # </user>
32
- #
33
- # evaluates to
34
- #
35
- # { "user" => {
36
- # "gender" => "m",
37
- # "age" => 35,
38
- # "name" => "Home Simpson",
39
- # "dob" => DateObject( 1998-01-01 ),
40
- # "joined_at" => TimeObject( 2000-04-28 23:01),
41
- # "is_cool" => true
42
- # }
43
- # }
44
- #
45
- # @example [Mixed Content]
46
- # <story>
47
- # A Quick <em>brown</em> Fox
48
- # </story>
49
- #
50
- # evaluates to
51
- #
52
- # { "story" => "A Quick <em>brown</em> Fox" }
53
- #
54
- # @details [Attributes other than type on a node containing text]
55
- # <story is-good='false'>
56
- # A Quick <em>brown</em> Fox
57
- # </story>
58
- #
59
- # evaluates to
60
- #
61
- # { "story" => "A Quick <em>brown</em> Fox" }
62
- #
63
- # <bicep unit='inches' type='integer'>60</bicep>
64
- #
65
- # evaluates with a typecast to an integer. But unit attribute is ignored.
66
- #
67
- # { "bicep" => 60 }
68
- def from_xml( xml )
69
- ToHashParser.from_xml(xml)
70
- end
71
- end
72
-
73
- # This class has semantics of ActiveSupport's HashWithIndifferentAccess
74
- # and we only have it so that people can write
75
- # params[:key] instead of params['key'].
76
- #
77
- # @return <Mash> This hash as a Mash for string or symbol key access.
78
- def to_mash
79
- hash = Mash.new(self)
80
- hash.default = default
81
- hash
82
- end
83
-
84
- # @return <String> This hash as a query string
85
- #
86
- # @example
87
- # { :name => "Bob",
88
- # :address => {
89
- # :street => '111 Ruby Ave.',
90
- # :city => 'Ruby Central',
91
- # :phones => ['111-111-1111', '222-222-2222']
92
- # }
93
- # }.to_params
94
- # #=> "name=Bob&address[city]=Ruby Central&address[phones]=111-111-1111222-222-2222&address[street]=111 Ruby Ave."
95
- def to_params
96
- params = ''
97
- stack = []
98
-
99
- each do |k, v|
100
- if v.is_a?(Hash)
101
- stack << [k,v]
102
- else
103
- params << "#{k}=#{v}&"
104
- end
105
- end
106
-
107
- stack.each do |parent, hash|
108
- hash.each do |k, v|
109
- if v.is_a?(Hash)
110
- stack << ["#{parent}[#{k}]", v]
111
- else
112
- params << "#{parent}[#{k}]=#{v}&"
113
- end
114
- end
115
- end
116
-
117
- params.chop! # trailing &
118
- params
119
- end
120
-
121
- # @param *allowed<Array[(String, Symbol)]> The hash keys to include.
122
- #
123
- # @return <Hash> A new hash with only the selected keys.
124
- #
125
- # @example
126
- # { :one => 1, :two => 2, :three => 3 }.only(:one)
127
- # #=> { :one => 1 }
128
- def only(*allowed)
129
- hash = {}
130
- allowed.each {|k| hash[k] = self[k] if self.has_key?(k) }
131
- hash
132
- end
133
-
134
- # @param *rejected<Array[(String, Symbol)] The hash keys to exclude.
135
- #
136
- # @return <Hash> A new hash without the selected keys.
137
- #
138
- # @example
139
- # { :one => 1, :two => 2, :three => 3 }.except(:one)
140
- # #=> { :two => 2, :three => 3 }
141
- def except(*rejected)
142
- hash = self.dup
143
- rejected.each {|k| hash.delete(k) }
144
- hash
145
- end
146
-
147
- # @return <String> The hash as attributes for an XML tag.
148
- #
149
- # @example
150
- # { :one => 1, "two"=>"TWO" }.to_xml_attributes
151
- # #=> 'one="1" two="TWO"'
152
- def to_xml_attributes
153
- map do |k,v|
154
- %{#{k.to_s.camel_case.sub(/^(.{1,1})/) { |m| m.downcase }}="#{v}"}
155
- end.join(' ')
156
- end
157
-
158
- alias_method :to_html_attributes, :to_xml_attributes
159
-
160
- # @param html_class<#to_s>
161
- # The HTML class to add to the :class key. The html_class will be
162
- # concatenated to any existing classes.
163
- #
164
- # @example hash[:class] #=> nil
165
- # @example hash.add_html_class!(:selected)
166
- # @example hash[:class] #=> "selected"
167
- # @example hash.add_html_class!("class1 class2")
168
- # @example hash[:class] #=> "selected class1 class2"
169
- def add_html_class!(html_class)
170
- if self[:class]
171
- self[:class] = "#{self[:class]} #{html_class}"
172
- else
173
- self[:class] = html_class.to_s
174
- end
175
- end
176
-
177
- # Converts all keys into string values. This is used during reloading to
178
- # prevent problems when classes are no longer declared.
179
- #
180
- # @return <Array> An array of they hash's keys
181
- #
182
- # @example
183
- # hash = { One => 1, Two => 2 }.proctect_keys!
184
- # hash # => { "One" => 1, "Two" => 2 }
185
- def protect_keys!
186
- keys.each {|key| self[key.to_s] = delete(key) }
187
- end
188
-
189
- # Attempts to convert all string keys into Class keys. We run this after
190
- # reloading to convert protected hashes back into usable hashes.
191
- #
192
- # @example
193
- # # Provided that classes One and Two are declared in this scope:
194
- # hash = { "One" => 1, "Two" => 2 }.unproctect_keys!
195
- # hash # => { One => 1, Two => 2 }
196
- def unprotect_keys!
197
- keys.each do |key|
198
- (self[Object.full_const_get(key)] = delete(key)) rescue nil
199
- end
200
- end
201
-
202
- # Destructively and non-recursively convert each key to an uppercase string,
203
- # deleting nil values along the way.
204
- #
205
- # @return <Hash> The newly environmentized hash.
206
- #
207
- # @example
208
- # { :name => "Bob", :contact => { :email => "bob@bob.com" } }.environmentize_keys!
209
- # #=> { "NAME" => "Bob", "CONTACT" => { :email => "bob@bob.com" } }
210
- def environmentize_keys!
211
- keys.each do |key|
212
- val = delete(key)
213
- next if val.nil?
214
- self[key.to_s.upcase] = val
215
- end
216
- self
217
- end
218
- end
219
-
220
- require 'rexml/parsers/streamparser'
221
- require 'rexml/parsers/baseparser'
222
- require 'rexml/light/node'
223
-
224
- # This is a slighly modified version of the XMLUtilityNode from
225
- # http://merb.devjavu.com/projects/merb/ticket/95 (has.sox@gmail.com)
226
- # It's mainly just adding vowels, as I ht cd wth n vwls :)
227
- # This represents the hard part of the work, all I did was change the
228
- # underlying parser.
229
- class REXMLUtilityNode
230
- attr_accessor :name, :attributes, :children, :type
231
- cattr_accessor :typecasts, :available_typecasts
232
-
233
- self.typecasts = {}
234
- self.typecasts["integer"] = lambda{|v| v.nil? ? nil : v.to_i}
235
- self.typecasts["boolean"] = lambda{|v| v.nil? ? nil : (v.strip != "false")}
236
- self.typecasts["datetime"] = lambda{|v| v.nil? ? nil : Time.parse(v).utc}
237
- self.typecasts["date"] = lambda{|v| v.nil? ? nil : Date.parse(v)}
238
- self.typecasts["dateTime"] = lambda{|v| v.nil? ? nil : Time.parse(v).utc}
239
- self.typecasts["decimal"] = lambda{|v| BigDecimal(v)}
240
- self.typecasts["double"] = lambda{|v| v.nil? ? nil : v.to_f}
241
- self.typecasts["float"] = lambda{|v| v.nil? ? nil : v.to_f}
242
- self.typecasts["symbol"] = lambda{|v| v.to_sym}
243
- self.typecasts["string"] = lambda{|v| v.to_s}
244
- self.typecasts["yaml"] = lambda{|v| v.nil? ? nil : YAML.load(v)}
245
- self.typecasts["base64Binary"] = lambda{|v| Base64.decode64(v)}
246
-
247
- self.available_typecasts = self.typecasts.keys
248
-
249
- def initialize(name, attributes = {})
250
- @name = name.tr("-", "_")
251
- # leave the type alone if we don't know what it is
252
- @type = self.class.available_typecasts.include?(attributes["type"]) ? attributes.delete("type") : attributes["type"]
253
-
254
- @nil_element = attributes.delete("nil") == "true"
255
- @attributes = undasherize_keys(attributes)
256
- @children = []
257
- @text = false
258
- end
259
-
260
- def add_node(node)
261
- @text = true if node.is_a? String
262
- @children << node
263
- end
264
-
265
- def to_hash
266
- if @type == "file"
267
- f = StringIO.new(::Base64.decode64(@children.first || ""))
268
- class << f
269
- attr_accessor :original_filename, :content_type
270
- end
271
- f.original_filename = attributes['name'] || 'untitled'
272
- f.content_type = attributes['content_type'] || 'application/octet-stream'
273
- return {name => f}
274
- end
275
-
276
- if @text
277
- return { name => typecast_value( translate_xml_entities( inner_html ) ) }
278
- else
279
- #change repeating groups into an array
280
- groups = @children.inject({}) { |s,e| (s[e.name] ||= []) << e; s }
281
-
282
- out = nil
283
- if @type == "array"
284
- out = []
285
- groups.each do |k, v|
286
- if v.size == 1
287
- out << v.first.to_hash.entries.first.last
288
- else
289
- out << v.map{|e| e.to_hash[k]}
290
- end
291
- end
292
- out = out.flatten
293
-
294
- else # If Hash
295
- out = {}
296
- groups.each do |k,v|
297
- if v.size == 1
298
- out.merge!(v.first)
299
- else
300
- out.merge!( k => v.map{|e| e.to_hash[k]})
301
- end
302
- end
303
- out.merge! attributes unless attributes.empty?
304
- out = out.empty? ? nil : out
305
- end
306
-
307
- if @type && out.nil?
308
- { name => typecast_value(out) }
309
- else
310
- { name => out }
311
- end
312
- end
313
- end
314
-
315
- # Typecasts a value based upon its type. For instance, if
316
- # +node+ has #type == "integer",
317
- # {{[node.typecast_value("12") #=> 12]}}
318
- #
319
- # @param value<String> The value that is being typecast.
320
- #
321
- # @details [:type options]
322
- # "integer"::
323
- # converts +value+ to an integer with #to_i
324
- # "boolean"::
325
- # checks whether +value+, after removing spaces, is the literal
326
- # "true"
327
- # "datetime"::
328
- # Parses +value+ using Time.parse, and returns a UTC Time
329
- # "date"::
330
- # Parses +value+ using Date.parse
331
- #
332
- # @return <Integer, TrueClass, FalseClass, Time, Date, Object>
333
- # The result of typecasting +value+.
334
- #
335
- # @note
336
- # If +self+ does not have a "type" key, or if it's not one of the
337
- # options specified above, the raw +value+ will be returned.
338
- def typecast_value(value)
339
- return value unless @type
340
- proc = self.class.typecasts[@type]
341
- proc.nil? ? value : proc.call(value)
342
- end
343
-
344
- # Convert basic XML entities into their literal values.
345
- #
346
- # @param value<#gsub> An XML fragment.
347
- #
348
- # @return <#gsub> The XML fragment after converting entities.
349
- def translate_xml_entities(value)
350
- value.gsub(/&lt;/, "<").
351
- gsub(/&gt;/, ">").
352
- gsub(/&quot;/, '"').
353
- gsub(/&apos;/, "'").
354
- gsub(/&amp;/, "&")
355
- end
356
-
357
- # Take keys of the form foo-bar and convert them to foo_bar
358
- def undasherize_keys(params)
359
- params.keys.each do |key, value|
360
- params[key.tr("-", "_")] = params.delete(key)
361
- end
362
- params
363
- end
364
-
365
- # Get the inner_html of the REXML node.
366
- def inner_html
367
- @children.join
368
- end
369
-
370
- # Converts the node into a readable HTML node.
371
- #
372
- # @return <String> The HTML node in text form.
373
- def to_html
374
- attributes.merge!(:type => @type ) if @type
375
- "<#{name}#{attributes.to_xml_attributes}>#{@nil_element ? '' : inner_html}</#{name}>"
376
- end
377
-
378
- # @alias #to_html #to_s
379
- def to_s
380
- to_html
381
- end
382
- end
383
-
384
- class ToHashParser
385
-
386
- def self.from_xml(xml)
387
- stack = []
388
- parser = REXML::Parsers::BaseParser.new(xml)
389
-
390
- while true
391
- event = parser.pull
392
- case event[0]
393
- when :end_document
394
- break
395
- when :end_doctype, :start_doctype
396
- # do nothing
397
- when :start_element
398
- stack.push REXMLUtilityNode.new(event[1], event[2])
399
- when :end_element
400
- if stack.size > 1
401
- temp = stack.pop
402
- stack.last.add_node(temp)
403
- end
404
- when :text, :cdata
405
- stack.last.add_node(event[1]) unless event[1].strip.length == 0
406
- end
407
- end
408
- stack.pop.to_hash
409
- end
410
- end