rango 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (616) hide show
  1. data/CHANGELOG +8 -0
  2. data/LICENSE +20 -0
  3. data/README.textile +18 -0
  4. data/bin/rango +30 -0
  5. data/doc/head/Array.html +114 -0
  6. data/doc/head/AttributeMixin.html +613 -0
  7. data/doc/head/Class.html +102 -0
  8. data/doc/head/ColoredString.html +476 -0
  9. data/doc/head/Hash.html +643 -0
  10. data/doc/head/Kernel.html +641 -0
  11. data/doc/head/Object.html +140 -0
  12. data/doc/head/ObjectSpace.html +103 -0
  13. data/doc/head/Path.html +2499 -0
  14. data/doc/head/Range.html +109 -0
  15. data/doc/head/Rango.html +397 -0
  16. data/doc/head/Rango/ApplicationMixin.html +396 -0
  17. data/doc/head/Rango/Bundling.html +23 -0
  18. data/doc/head/Rango/Bundling/RequireStrategy.html +283 -0
  19. data/doc/head/Rango/Bundling/Strategy.html +703 -0
  20. data/doc/head/Rango/CallableStrategy.html +300 -0
  21. data/doc/head/Rango/Chainable.html +181 -0
  22. data/doc/head/Rango/Configurable.html +199 -0
  23. data/doc/head/Rango/Controller.html +962 -0
  24. data/doc/head/Rango/ControllerMixin.html +860 -0
  25. data/doc/head/Rango/ControllerStrategy.html +264 -0
  26. data/doc/head/Rango/DependencyStrategy.html +116 -0
  27. data/doc/head/Rango/Dispatcher.html +305 -0
  28. data/doc/head/Rango/Form.html +162 -0
  29. data/doc/head/Rango/GemDependencyStrategy.html +210 -0
  30. data/doc/head/Rango/Generator.html +93 -0
  31. data/doc/head/Rango/GenericViews.html +128 -0
  32. data/doc/head/Rango/GitDependencyStrategy.html +224 -0
  33. data/doc/head/Rango/GithubDependencyStrategy.html +118 -0
  34. data/doc/head/Rango/Handler.html +474 -0
  35. data/doc/head/Rango/Helpers.html +1271 -0
  36. data/doc/head/Rango/Hookable.html +202 -0
  37. data/doc/head/Rango/ImportMixin.html +755 -0
  38. data/doc/head/Rango/Logger.html +920 -0
  39. data/doc/head/Rango/ModelForm.html +42 -0
  40. data/doc/head/Rango/Project.html +516 -0
  41. data/doc/head/Rango/RenderMixin.html +23 -0
  42. data/doc/head/Rango/Request.html +1177 -0
  43. data/doc/head/Rango/Route.html +751 -0
  44. data/doc/head/Rango/Router.html +42 -0
  45. data/doc/head/Rango/Router/Dispatcher.html +311 -0
  46. data/doc/head/Rango/RouterStrategy.html +258 -0
  47. data/doc/head/Rango/Session.html +23 -0
  48. data/doc/head/Rango/Settings.html +23 -0
  49. data/doc/head/Rango/Settings/Erubis.html +23 -0
  50. data/doc/head/Rango/Settings/Framework.html +198 -0
  51. data/doc/head/Rango/Settings/Haml.html +23 -0
  52. data/doc/head/Rango/SimpleTemplate.html +187 -0
  53. data/doc/head/Rango/StrategyMixin.html +261 -0
  54. data/doc/head/Rango/Tasks.html +251 -0
  55. data/doc/head/Rango/Template.html +95 -0
  56. data/doc/head/Rango/Template/Adapter.html +90 -0
  57. data/doc/head/Rango/Templates.html +116 -0
  58. data/doc/head/Rango/Templates/Adapter.html +128 -0
  59. data/doc/head/Rango/Templates/Template.html +636 -0
  60. data/doc/head/Rango/Templates/TemplateHelpers.html +328 -0
  61. data/doc/head/RangoThor.html +205 -0
  62. data/doc/head/String.html +163 -0
  63. data/doc/head/TimeDSL.html +612 -0
  64. data/doc/head/all-methods.html +2012 -0
  65. data/doc/head/all-namespaces.html +114 -0
  66. data/doc/head/app.js +18 -0
  67. data/doc/head/index.html +18 -0
  68. data/doc/head/jquery.js +11 -0
  69. data/doc/head/readme.html +34 -0
  70. data/doc/head/style.css +68 -0
  71. data/doc/head/syntax_highlight.css +21 -0
  72. data/doc/versions/0.0.1/Rango.html +1025 -0
  73. data/doc/versions/0.0.1/Rango/CallableStrategy.html +166 -0
  74. data/doc/versions/0.0.1/Rango/ControllerStrategy.html +180 -0
  75. data/doc/versions/0.0.1/Rango/Route.html +340 -0
  76. data/doc/versions/0.0.1/Rango/Router.html +502 -0
  77. data/doc/versions/0.0.1/Rango/RouterStrategy.html +94 -0
  78. data/doc/versions/0.0.1/Rango/Template.html +28 -0
  79. data/doc/versions/0.0.1/Rango/Template/Adapter.html +90 -0
  80. data/doc/versions/0.0.1/all-methods.html +228 -0
  81. data/doc/versions/0.0.1/all-namespaces.html +36 -0
  82. data/doc/versions/0.0.1/app.js +18 -0
  83. data/doc/versions/0.0.1/index.html +18 -0
  84. data/doc/versions/0.0.1/jquery.js +11 -0
  85. data/doc/versions/0.0.1/readme.html +137 -0
  86. data/doc/versions/0.0.1/style.css +68 -0
  87. data/doc/versions/0.0.1/syntax_highlight.css +21 -0
  88. data/lib/rango.rb +25 -0
  89. data/lib/rango/boot.rb +54 -0
  90. data/lib/rango/bundling/dependency.rb +65 -0
  91. data/lib/rango/bundling/strategies/copy.rb +36 -0
  92. data/lib/rango/bundling/strategies/gem.rb +55 -0
  93. data/lib/rango/bundling/strategies/git.rb +71 -0
  94. data/lib/rango/bundling/strategies/hg.rb +9 -0
  95. data/lib/rango/bundling/strategy.rb +85 -0
  96. data/lib/rango/cli/generator.rb +15 -0
  97. data/lib/rango/cli/project.rb +87 -0
  98. data/lib/rango/cli/simple_template.rb +47 -0
  99. data/lib/rango/contrib/pagination.rb +15 -0
  100. data/lib/rango/contrib/pagination/README.textile +21 -0
  101. data/lib/rango/contrib/pagination/TODO +3 -0
  102. data/lib/rango/contrib/pagination/_pagination.html.haml +39 -0
  103. data/lib/rango/contrib/pagination/adapters/datamapper.rb +22 -0
  104. data/lib/rango/contrib/pagination/helpers.rb +12 -0
  105. data/lib/rango/contrib/pagination/page.rb +107 -0
  106. data/lib/rango/contrib/pagination/strategies.rb +49 -0
  107. data/lib/rango/contrib/syndication.rb +1 -0
  108. data/lib/rango/exceptions.rb +269 -0
  109. data/lib/rango/ext.rb +14 -0
  110. data/lib/rango/ext/attribute.rb +140 -0
  111. data/lib/rango/ext/class.rb +99 -0
  112. data/lib/rango/ext/colored_string.rb +105 -0
  113. data/lib/rango/ext/core_ext.rb +52 -0
  114. data/lib/rango/ext/hash.rb +21 -0
  115. data/lib/rango/ext/kernel.rb +74 -0
  116. data/lib/rango/ext/object_space.rb +11 -0
  117. data/lib/rango/ext/path.rb +222 -0
  118. data/lib/rango/ext/random.rb +22 -0
  119. data/lib/rango/ext/string.rb +16 -0
  120. data/lib/rango/ext/thor.rb +32 -0
  121. data/lib/rango/ext/time_dsl.rb +63 -0
  122. data/lib/rango/ext/try.rb +30 -0
  123. data/lib/rango/forms/form.rb +29 -0
  124. data/lib/rango/generic_views/static.rb +7 -0
  125. data/lib/rango/helpers.rb +24 -0
  126. data/lib/rango/helpers/README +179 -0
  127. data/lib/rango/helpers/assets.rb +29 -0
  128. data/lib/rango/helpers/general.rb +41 -0
  129. data/lib/rango/helpers/merb-helpers.rb +40 -0
  130. data/lib/rango/helpers/merb-helpers/core_ext.rb +58 -0
  131. data/lib/rango/helpers/merb-helpers/core_ext/numeric.rb +388 -0
  132. data/lib/rango/helpers/merb-helpers/date_time_formatting.rb +158 -0
  133. data/lib/rango/helpers/merb-helpers/date_time_helpers.rb +191 -0
  134. data/lib/rango/helpers/merb-helpers/form/builder.rb +447 -0
  135. data/lib/rango/helpers/merb-helpers/form/helpers.rb +451 -0
  136. data/lib/rango/helpers/merb-helpers/form_helpers.rb +19 -0
  137. data/lib/rango/helpers/merb-helpers/tag_helpers.rb +63 -0
  138. data/lib/rango/helpers/merb-helpers/text_helpers.rb +63 -0
  139. data/lib/rango/helpers/merb-helpers/time_dsl.rb +61 -0
  140. data/lib/rango/helpers/spec/core_ext_spec.rb +21 -0
  141. data/lib/rango/helpers/spec/fixture/app/controllers/application.rb +4 -0
  142. data/lib/rango/helpers/spec/fixture/app/controllers/bound_check_box.rb +2 -0
  143. data/lib/rango/helpers/spec/fixture/app/controllers/bound_file_field.rb +2 -0
  144. data/lib/rango/helpers/spec/fixture/app/controllers/bound_hidden_field.rb +2 -0
  145. data/lib/rango/helpers/spec/fixture/app/controllers/bound_option_tag.rb +2 -0
  146. data/lib/rango/helpers/spec/fixture/app/controllers/bound_password_field.rb +2 -0
  147. data/lib/rango/helpers/spec/fixture/app/controllers/bound_radio_button.rb +2 -0
  148. data/lib/rango/helpers/spec/fixture/app/controllers/bound_radio_group.rb +2 -0
  149. data/lib/rango/helpers/spec/fixture/app/controllers/bound_select.rb +2 -0
  150. data/lib/rango/helpers/spec/fixture/app/controllers/bound_text_area.rb +2 -0
  151. data/lib/rango/helpers/spec/fixture/app/controllers/bound_text_field.rb +2 -0
  152. data/lib/rango/helpers/spec/fixture/app/controllers/button.rb +2 -0
  153. data/lib/rango/helpers/spec/fixture/app/controllers/check_box.rb +2 -0
  154. data/lib/rango/helpers/spec/fixture/app/controllers/custom_builder.rb +2 -0
  155. data/lib/rango/helpers/spec/fixture/app/controllers/delete_button.rb +2 -0
  156. data/lib/rango/helpers/spec/fixture/app/controllers/exceptions.rb +25 -0
  157. data/lib/rango/helpers/spec/fixture/app/controllers/field_set.rb +2 -0
  158. data/lib/rango/helpers/spec/fixture/app/controllers/fields_for.rb +3 -0
  159. data/lib/rango/helpers/spec/fixture/app/controllers/file_field.rb +2 -0
  160. data/lib/rango/helpers/spec/fixture/app/controllers/foo.rb +23 -0
  161. data/lib/rango/helpers/spec/fixture/app/controllers/form.rb +2 -0
  162. data/lib/rango/helpers/spec/fixture/app/controllers/form_for.rb +2 -0
  163. data/lib/rango/helpers/spec/fixture/app/controllers/hacker.rb +2 -0
  164. data/lib/rango/helpers/spec/fixture/app/controllers/hidden_field.rb +2 -0
  165. data/lib/rango/helpers/spec/fixture/app/controllers/label.rb +3 -0
  166. data/lib/rango/helpers/spec/fixture/app/controllers/numeric_ext.rb +3 -0
  167. data/lib/rango/helpers/spec/fixture/app/controllers/option_tag.rb +2 -0
  168. data/lib/rango/helpers/spec/fixture/app/controllers/password_field.rb +2 -0
  169. data/lib/rango/helpers/spec/fixture/app/controllers/radio_button.rb +2 -0
  170. data/lib/rango/helpers/spec/fixture/app/controllers/radio_group.rb +2 -0
  171. data/lib/rango/helpers/spec/fixture/app/controllers/relative_date.rb +2 -0
  172. data/lib/rango/helpers/spec/fixture/app/controllers/relative_date_span.rb +2 -0
  173. data/lib/rango/helpers/spec/fixture/app/controllers/select.rb +2 -0
  174. data/lib/rango/helpers/spec/fixture/app/controllers/specs_controller.rb +11 -0
  175. data/lib/rango/helpers/spec/fixture/app/controllers/submit.rb +2 -0
  176. data/lib/rango/helpers/spec/fixture/app/controllers/tag_helper.rb +21 -0
  177. data/lib/rango/helpers/spec/fixture/app/controllers/text_area.rb +2 -0
  178. data/lib/rango/helpers/spec/fixture/app/controllers/text_field.rb +3 -0
  179. data/lib/rango/helpers/spec/fixture/app/helpers/global_helpers.rb +8 -0
  180. data/lib/rango/helpers/spec/fixture/app/models/fake_dm_model.rb +25 -0
  181. data/lib/rango/helpers/spec/fixture/app/models/first_generic_fake_model.rb +57 -0
  182. data/lib/rango/helpers/spec/fixture/app/models/hacker_generic_model.rb +5 -0
  183. data/lib/rango/helpers/spec/fixture/app/models/second_generic_fake_model.rb +18 -0
  184. data/lib/rango/helpers/spec/fixture/app/models/third_generic_fake_model.rb +3 -0
  185. data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/basic.html.erb +4 -0
  186. data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/basic_unchecked.html.erb +3 -0
  187. data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/checked.html.erb +4 -0
  188. data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/errors.html.erb +4 -0
  189. data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/label.html.erb +3 -0
  190. data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/on_and_off.html.erb +3 -0
  191. data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/raise_value_error.html.erb +3 -0
  192. data/lib/rango/helpers/spec/fixture/app/views/bound_file_field_specs/additional_attributes.html.erb +3 -0
  193. data/lib/rango/helpers/spec/fixture/app/views/bound_file_field_specs/takes_string.html.erb +3 -0
  194. data/lib/rango/helpers/spec/fixture/app/views/bound_file_field_specs/with_label.html.erb +3 -0
  195. data/lib/rango/helpers/spec/fixture/app/views/bound_hidden_field_specs/basic.html.erb +3 -0
  196. data/lib/rango/helpers/spec/fixture/app/views/bound_hidden_field_specs/errors.html.erb +3 -0
  197. data/lib/rango/helpers/spec/fixture/app/views/bound_hidden_field_specs/hidden_error.html.erb +3 -0
  198. data/lib/rango/helpers/spec/fixture/app/views/bound_hidden_field_specs/label.html.erb +3 -0
  199. data/lib/rango/helpers/spec/fixture/app/views/bound_option_tag_specs/grouped.html.erb +3 -0
  200. data/lib/rango/helpers/spec/fixture/app/views/bound_option_tag_specs/nested.html.erb +3 -0
  201. data/lib/rango/helpers/spec/fixture/app/views/bound_option_tag_specs/text_and_value.html.erb +4 -0
  202. data/lib/rango/helpers/spec/fixture/app/views/bound_password_field_specs/attributes.html.erb +3 -0
  203. data/lib/rango/helpers/spec/fixture/app/views/bound_password_field_specs/basic.html.erb +3 -0
  204. data/lib/rango/helpers/spec/fixture/app/views/bound_password_field_specs/label.html.erb +3 -0
  205. data/lib/rango/helpers/spec/fixture/app/views/bound_radio_button_specs/basic.html.erb +3 -0
  206. data/lib/rango/helpers/spec/fixture/app/views/bound_radio_group_specs/basic.html.erb +3 -0
  207. data/lib/rango/helpers/spec/fixture/app/views/bound_radio_group_specs/hashes.html.erb +3 -0
  208. data/lib/rango/helpers/spec/fixture/app/views/bound_radio_group_specs/mixed.html.erb +4 -0
  209. data/lib/rango/helpers/spec/fixture/app/views/bound_radio_group_specs/override_id.html.erb +3 -0
  210. data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/basic.html.erb +3 -0
  211. data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/blank.html.erb +3 -0
  212. data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/label.html.erb +3 -0
  213. data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/multiple.html.erb +3 -0
  214. data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/prompt.html.erb +3 -0
  215. data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/with_options.html.erb +3 -0
  216. data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/with_options_with_blank.html.erb +3 -0
  217. data/lib/rango/helpers/spec/fixture/app/views/bound_text_area_specs/basic.html.erb +3 -0
  218. data/lib/rango/helpers/spec/fixture/app/views/bound_text_area_specs/label.html.erb +3 -0
  219. data/lib/rango/helpers/spec/fixture/app/views/bound_text_field_specs/basic.html.erb +3 -0
  220. data/lib/rango/helpers/spec/fixture/app/views/button_specs/button_with_label.html.erb +1 -0
  221. data/lib/rango/helpers/spec/fixture/app/views/button_specs/button_with_values.html.erb +1 -0
  222. data/lib/rango/helpers/spec/fixture/app/views/button_specs/disabled_button.html.erb +1 -0
  223. data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/basic.html.erb +1 -0
  224. data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/boolean.html.erb +1 -0
  225. data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/disabled.html.erb +1 -0
  226. data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/label.html.erb +1 -0
  227. data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/on_off_is_boolean.html.erb +1 -0
  228. data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/raise_unless_both_on_and_off.html.erb +2 -0
  229. data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/raises_error_if_not_boolean.html.erb +1 -0
  230. data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/raises_error_if_on_off_and_boolean_false.html.erb +1 -0
  231. data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/simple.html.erb +1 -0
  232. data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/to_string.html.erb +8 -0
  233. data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/unchecked.html.erb +2 -0
  234. data/lib/rango/helpers/spec/fixture/app/views/custom_builder_specs/everything.html.erb +10 -0
  235. data/lib/rango/helpers/spec/fixture/app/views/delete_button_specs/delete_with_explicit_url.html.erb +1 -0
  236. data/lib/rango/helpers/spec/fixture/app/views/delete_button_specs/delete_with_extra_params.html.erb +1 -0
  237. data/lib/rango/helpers/spec/fixture/app/views/delete_button_specs/delete_with_label.html.erb +1 -0
  238. data/lib/rango/helpers/spec/fixture/app/views/delete_button_specs/simple_delete.html.erb +1 -0
  239. data/lib/rango/helpers/spec/fixture/app/views/exeptions/client_error.html.erb +37 -0
  240. data/lib/rango/helpers/spec/fixture/app/views/exeptions/internal_server_error.html.erb +216 -0
  241. data/lib/rango/helpers/spec/fixture/app/views/exeptions/not_acceptable.html.erb +38 -0
  242. data/lib/rango/helpers/spec/fixture/app/views/exeptions/not_found.html.erb +40 -0
  243. data/lib/rango/helpers/spec/fixture/app/views/fields_for_specs/basic.html.erb +3 -0
  244. data/lib/rango/helpers/spec/fixture/app/views/fields_for_specs/midstream.html.erb +7 -0
  245. data/lib/rango/helpers/spec/fixture/app/views/fields_for_specs/nil.html.erb +3 -0
  246. data/lib/rango/helpers/spec/fixture/app/views/fieldset_specs/legend.html.erb +3 -0
  247. data/lib/rango/helpers/spec/fixture/app/views/file_field_specs/disabled.html.erb +1 -0
  248. data/lib/rango/helpers/spec/fixture/app/views/file_field_specs/makes_multipart.html.erb +3 -0
  249. data/lib/rango/helpers/spec/fixture/app/views/file_field_specs/with_label.html.erb +1 -0
  250. data/lib/rango/helpers/spec/fixture/app/views/file_field_specs/with_values.html.erb +1 -0
  251. data/lib/rango/helpers/spec/fixture/app/views/foo/bar.html.erb +0 -0
  252. data/lib/rango/helpers/spec/fixture/app/views/form_for_specs/basic.html.erb +3 -0
  253. data/lib/rango/helpers/spec/fixture/app/views/form_specs/create_a_form.html.erb +3 -0
  254. data/lib/rango/helpers/spec/fixture/app/views/form_specs/create_a_multipart_form.html.erb +3 -0
  255. data/lib/rango/helpers/spec/fixture/app/views/form_specs/fake_delete_if_set.html.erb +3 -0
  256. data/lib/rango/helpers/spec/fixture/app/views/form_specs/fake_put_if_set.html.erb +3 -0
  257. data/lib/rango/helpers/spec/fixture/app/views/form_specs/get_if_set.html.erb +3 -0
  258. data/lib/rango/helpers/spec/fixture/app/views/form_specs/post_by_default.html.erb +3 -0
  259. data/lib/rango/helpers/spec/fixture/app/views/form_specs/resourceful_form.html.erb +3 -0
  260. data/lib/rango/helpers/spec/fixture/app/views/hacker/file_field.html.erb +3 -0
  261. data/lib/rango/helpers/spec/fixture/app/views/hacker/hidden_field.html.erb +3 -0
  262. data/lib/rango/helpers/spec/fixture/app/views/hacker/option_tag.html.erb +4 -0
  263. data/lib/rango/helpers/spec/fixture/app/views/hacker/password_field.html.erb +3 -0
  264. data/lib/rango/helpers/spec/fixture/app/views/hacker/radio_button.html.erb +3 -0
  265. data/lib/rango/helpers/spec/fixture/app/views/hacker/radio_group.html.erb +3 -0
  266. data/lib/rango/helpers/spec/fixture/app/views/hacker/text_area.html.erb +3 -0
  267. data/lib/rango/helpers/spec/fixture/app/views/hacker/text_field.html.erb +3 -0
  268. data/lib/rango/helpers/spec/fixture/app/views/hidden_field_specs/basic.html.erb +1 -0
  269. data/lib/rango/helpers/spec/fixture/app/views/hidden_field_specs/disabled.html.erb +1 -0
  270. data/lib/rango/helpers/spec/fixture/app/views/hidden_field_specs/label.html.erb +1 -0
  271. data/lib/rango/helpers/spec/fixture/app/views/label_specs/basic.html.erb +1 -0
  272. data/lib/rango/helpers/spec/fixture/app/views/label_specs/basic_with_attributes.html.erb +1 -0
  273. data/lib/rango/helpers/spec/fixture/app/views/label_specs/basic_with_class.html.erb +1 -0
  274. data/lib/rango/helpers/spec/fixture/app/views/layout/application.html.erb +11 -0
  275. data/lib/rango/helpers/spec/fixture/app/views/numeric_ext_specs/minutes_to_hours.html.erb +1 -0
  276. data/lib/rango/helpers/spec/fixture/app/views/numeric_ext_specs/to_concurrency_default.html.erb +1 -0
  277. data/lib/rango/helpers/spec/fixture/app/views/numeric_ext_specs/two_digits.html.erb +1 -0
  278. data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/array.html.erb +1 -0
  279. data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/clean.html.erb +1 -0
  280. data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/collection.html.erb +1 -0
  281. data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/multiple_selects.html.erb +1 -0
  282. data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/no_extra_attributes.html.erb +1 -0
  283. data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/optgroups.html.erb +1 -0
  284. data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/selected.html.erb +1 -0
  285. data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/with_blank.html.erb +1 -0
  286. data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/with_prompt.html.erb +1 -0
  287. data/lib/rango/helpers/spec/fixture/app/views/password_field_specs/basic.html.erb +1 -0
  288. data/lib/rango/helpers/spec/fixture/app/views/password_field_specs/disabled.html.erb +1 -0
  289. data/lib/rango/helpers/spec/fixture/app/views/radio_button_specs/basic.html.erb +1 -0
  290. data/lib/rango/helpers/spec/fixture/app/views/radio_button_specs/checked.html.erb +1 -0
  291. data/lib/rango/helpers/spec/fixture/app/views/radio_button_specs/disabled.html.erb +1 -0
  292. data/lib/rango/helpers/spec/fixture/app/views/radio_button_specs/label.html.erb +1 -0
  293. data/lib/rango/helpers/spec/fixture/app/views/radio_button_specs/unchecked.html.erb +1 -0
  294. data/lib/rango/helpers/spec/fixture/app/views/radio_group_specs/attributes.html.erb +1 -0
  295. data/lib/rango/helpers/spec/fixture/app/views/radio_group_specs/basic.html.erb +1 -0
  296. data/lib/rango/helpers/spec/fixture/app/views/radio_group_specs/checked.html.erb +1 -0
  297. data/lib/rango/helpers/spec/fixture/app/views/radio_group_specs/hash.html.erb +1 -0
  298. data/lib/rango/helpers/spec/fixture/app/views/radio_group_specs/specific_attributes.html.erb +1 -0
  299. data/lib/rango/helpers/spec/fixture/app/views/relative_date_span_specs/date_span_on_same_day.html.erb +1 -0
  300. data/lib/rango/helpers/spec/fixture/app/views/relative_date_span_specs/date_span_on_same_day_on_different_year.html.erb +1 -0
  301. data/lib/rango/helpers/spec/fixture/app/views/relative_date_specs/relative_date_with_year.html.erb +1 -0
  302. data/lib/rango/helpers/spec/fixture/app/views/relative_date_specs/relative_date_without_year.html.erb +1 -0
  303. data/lib/rango/helpers/spec/fixture/app/views/relative_date_specs/relative_today.html.erb +1 -0
  304. data/lib/rango/helpers/spec/fixture/app/views/relative_date_specs/relative_tomorrow.html.erb +1 -0
  305. data/lib/rango/helpers/spec/fixture/app/views/relative_date_specs/relative_yesterday.html.erb +1 -0
  306. data/lib/rango/helpers/spec/fixture/app/views/select_specs/basic.html.erb +1 -0
  307. data/lib/rango/helpers/spec/fixture/app/views/select_specs/blank.html.erb +1 -0
  308. data/lib/rango/helpers/spec/fixture/app/views/select_specs/multiple.html.erb +1 -0
  309. data/lib/rango/helpers/spec/fixture/app/views/select_specs/selected.html.erb +1 -0
  310. data/lib/rango/helpers/spec/fixture/app/views/submit_specs/disabled_submit.html.erb +1 -0
  311. data/lib/rango/helpers/spec/fixture/app/views/submit_specs/submit_with_label.html.erb +1 -0
  312. data/lib/rango/helpers/spec/fixture/app/views/submit_specs/submit_with_values.html.erb +1 -0
  313. data/lib/rango/helpers/spec/fixture/app/views/tag_helper/nested_tags.html.erb +5 -0
  314. data/lib/rango/helpers/spec/fixture/app/views/tag_helper/tag_with_attributes.html.erb +1 -0
  315. data/lib/rango/helpers/spec/fixture/app/views/tag_helper/tag_with_content.html.erb +1 -0
  316. data/lib/rango/helpers/spec/fixture/app/views/tag_helper/tag_with_content_in_the_block.html.erb +3 -0
  317. data/lib/rango/helpers/spec/fixture/app/views/text_area_specs/basic.html.erb +1 -0
  318. data/lib/rango/helpers/spec/fixture/app/views/text_area_specs/disabled.html.erb +1 -0
  319. data/lib/rango/helpers/spec/fixture/app/views/text_area_specs/label.html.erb +1 -0
  320. data/lib/rango/helpers/spec/fixture/app/views/text_area_specs/nil.html.erb +1 -0
  321. data/lib/rango/helpers/spec/fixture/app/views/text_field_specs/basic.html.erb +1 -0
  322. data/lib/rango/helpers/spec/fixture/app/views/text_field_specs/class.html.erb +1 -0
  323. data/lib/rango/helpers/spec/fixture/app/views/text_field_specs/disabled.html.erb +1 -0
  324. data/lib/rango/helpers/spec/fixture/app/views/text_field_specs/label.html.erb +1 -0
  325. data/lib/rango/helpers/spec/fixture/app/views/text_field_specs/symbolized_name.html.erb +1 -0
  326. data/lib/rango/helpers/spec/fixture/config/environments/development.rb +6 -0
  327. data/lib/rango/helpers/spec/fixture/config/environments/production.rb +5 -0
  328. data/lib/rango/helpers/spec/fixture/config/environments/test.rb +6 -0
  329. data/lib/rango/helpers/spec/fixture/config/init.rb +46 -0
  330. data/lib/rango/helpers/spec/fixture/config/rack.rb +11 -0
  331. data/lib/rango/helpers/spec/fixture/config/router.rb +38 -0
  332. data/lib/rango/helpers/spec/fixture/public/images/merb.jpg +0 -0
  333. data/lib/rango/helpers/spec/fixture/public/merb.fcgi +4 -0
  334. data/lib/rango/helpers/spec/fixture/public/stylesheets/master.css +119 -0
  335. data/lib/rango/helpers/spec/merb_helpers_config_spec.rb +84 -0
  336. data/lib/rango/helpers/spec/merb_helpers_date_time_spec.rb +270 -0
  337. data/lib/rango/helpers/spec/merb_helpers_form_spec.rb +1371 -0
  338. data/lib/rango/helpers/spec/merb_helpers_tag_helper_spec.rb +42 -0
  339. data/lib/rango/helpers/spec/merb_helpers_text_spec.rb +69 -0
  340. data/lib/rango/helpers/spec/numeric_extlib_spec.rb +137 -0
  341. data/lib/rango/helpers/spec/ordinalize_spec.rb +53 -0
  342. data/lib/rango/helpers/spec/spec_helper.rb +160 -0
  343. data/lib/rango/helpers/spec/time_dsl_spec.rb +45 -0
  344. data/lib/rango/helpers/syntax.rb +28 -0
  345. data/lib/rango/loggers/fireruby.rb +1 -0
  346. data/lib/rango/loggers/logger.rb +100 -0
  347. data/lib/rango/mixins/application.rb +25 -0
  348. data/lib/rango/mixins/configurable.rb +20 -0
  349. data/lib/rango/mixins/controller.rb +113 -0
  350. data/lib/rango/mixins/import.rb +89 -0
  351. data/lib/rango/mixins/strategy.rb +28 -0
  352. data/lib/rango/mvc/controller.rb +139 -0
  353. data/lib/rango/mvc/strategies.rb +6 -0
  354. data/lib/rango/orm/adapters/datamapper/fields.rb +3 -0
  355. data/lib/rango/orm/adapters/datamapper/setup.rb +16 -0
  356. data/lib/rango/orm/adapters/datamapper/support.rb +15 -0
  357. data/lib/rango/orm/adapters/datamapper/tasks.thor +41 -0
  358. data/lib/rango/orm/adapters/datamapper/types/unicode_string.rb +15 -0
  359. data/lib/rango/project.rb +28 -0
  360. data/lib/rango/rack/dispatcher.rb +61 -0
  361. data/lib/rango/rack/middlewares/emails.rb +7 -0
  362. data/lib/rango/rack/middlewares/encoding.rb +25 -0
  363. data/lib/rango/rack/middlewares/static.rb +49 -0
  364. data/lib/rango/rack/request.rb +166 -0
  365. data/lib/rango/rango.rb +75 -0
  366. data/lib/rango/router/adapters/basic.rb +21 -0
  367. data/lib/rango/router/adapters/rack-router.rb +18 -0
  368. data/lib/rango/router/dispatcher.rb +29 -0
  369. data/lib/rango/router/specification.txt +16 -0
  370. data/lib/rango/settings.rb +87 -0
  371. data/lib/rango/settings/erubis.rb +13 -0
  372. data/lib/rango/settings/framework.rb +85 -0
  373. data/lib/rango/settings/haml.rb +35 -0
  374. data/lib/rango/support/cucumber/steps/given_steps.rb +5 -0
  375. data/lib/rango/support/cucumber/steps/then_steps.rb +41 -0
  376. data/lib/rango/support/cucumber/steps/when_steps.rb +54 -0
  377. data/lib/rango/tasks/bundle.thor +28 -0
  378. data/lib/rango/tasks/stats.thor +0 -0
  379. data/lib/rango/templates/adapter.rb +19 -0
  380. data/lib/rango/templates/adapters/erb.rb +45 -0
  381. data/lib/rango/templates/adapters/erubis.rb +60 -0
  382. data/lib/rango/templates/adapters/haml.rb +17 -0
  383. data/lib/rango/templates/template.rb +123 -0
  384. data/rango.gemspec +35 -0
  385. data/spec/factories.rb +21 -0
  386. data/spec/rango/auth/core/authenticated_helper_spec.rb +0 -0
  387. data/spec/rango/auth/core/authentication_spec.rb +0 -0
  388. data/spec/rango/auth/core/callbacks_spec.rb +0 -0
  389. data/spec/rango/auth/core/errors_spec.rb +0 -0
  390. data/spec/rango/auth/core/responses_spec.rb +0 -0
  391. data/spec/rango/auth/core/session_mixin_spec.rb +0 -0
  392. data/spec/rango/auth/core/spec/helpers/authentication_helper_spec_spec.rb +0 -0
  393. data/spec/rango/auth/core/spec/merb-auth-core/activation_fixture_spec.rb +0 -0
  394. data/spec/rango/auth/core/spec/merb-auth-core/authentication_spec_spec.rb +0 -0
  395. data/spec/rango/auth/core/spec/merb-auth-core/callbacks_spec_spec.rb +0 -0
  396. data/spec/rango/auth/core/spec/merb-auth-core/customizations_spec_spec.rb +0 -0
  397. data/spec/rango/auth/core/spec/merb-auth-core/errors_spec_spec.rb +0 -0
  398. data/spec/rango/auth/core/spec/merb-auth-core/failed_login_spec_spec.rb +0 -0
  399. data/spec/rango/auth/core/spec/merb-auth-core/merb-auth-core_spec_spec.rb +0 -0
  400. data/spec/rango/auth/core/spec/merb-auth-core/router_helper_spec_spec.rb +0 -0
  401. data/spec/rango/auth/core/spec/merb-auth-core/strategy_spec_spec.rb +0 -0
  402. data/spec/rango/auth/core/spec/spec_helper_spec.rb +0 -0
  403. data/spec/rango/auth/core/strategy_spec.rb +0 -0
  404. data/spec/rango/auth/core_spec.rb +0 -0
  405. data/spec/rango/auth/more/mixins/redirect_back_spec.rb +0 -0
  406. data/spec/rango/auth/more/mixins/salted_user/ar_salted_user_spec.rb +0 -0
  407. data/spec/rango/auth/more/mixins/salted_user/dm_salted_user_spec.rb +0 -0
  408. data/spec/rango/auth/more/mixins/salted_user/relaxdb_salted_user_spec.rb +0 -0
  409. data/spec/rango/auth/more/mixins/salted_user/sq_salted_user_spec.rb +0 -0
  410. data/spec/rango/auth/more/mixins/salted_user_spec.rb +0 -0
  411. data/spec/rango/auth/more/spec/merb-auth-more_spec_spec.rb +0 -0
  412. data/spec/rango/auth/more/spec/mixins/redirect_back_spec_spec.rb +0 -0
  413. data/spec/rango/auth/more/spec/mixins/salted_user_spec_spec.rb +0 -0
  414. data/spec/rango/auth/more/spec/spec_helper_spec.rb +0 -0
  415. data/spec/rango/auth/more/strategies/abstract_password_spec.rb +0 -0
  416. data/spec/rango/auth/more/strategies/basic/basic_auth_spec.rb +0 -0
  417. data/spec/rango/auth/more/strategies/basic/openid_spec.rb +0 -0
  418. data/spec/rango/auth/more/strategies/basic/password_form_spec.rb +0 -0
  419. data/spec/rango/auth/more_spec.rb +0 -0
  420. data/spec/rango/auth/slice/exceptions_spec.rb +0 -0
  421. data/spec/rango/auth/slice/merb-auth-slice-password_spec.rb +0 -0
  422. data/spec/rango/auth/slice/sessions_spec.rb +0 -0
  423. data/spec/rango/auth/slice/spec_helper_spec.rb +0 -0
  424. data/spec/rango/auth/slice/xsessions_spec.rb +0 -0
  425. data/spec/rango/boot_spec.rb +19 -0
  426. data/spec/rango/bundling/dependency_spec.rb +0 -0
  427. data/spec/rango/bundling/strategies_spec.rb +0 -0
  428. data/spec/rango/cli/project_spec.rb +0 -0
  429. data/spec/rango/contrib/pagination/adapters/dm_spec.rb +0 -0
  430. data/spec/rango/contrib/pagination/helpers_spec.rb +0 -0
  431. data/spec/rango/contrib/pagination/page_spec.rb +94 -0
  432. data/spec/rango/contrib/pagination/strategies_spec.rb +0 -0
  433. data/spec/rango/contrib/pagination_spec.rb +0 -0
  434. data/spec/rango/contrib/syndication_spec.rb +0 -0
  435. data/spec/rango/exceptions_spec.rb +0 -0
  436. data/spec/rango/ext/attribute_spec.rb +0 -0
  437. data/spec/rango/ext/colored_string_spec.rb +0 -0
  438. data/spec/rango/ext/core_ext_spec.rb +0 -0
  439. data/spec/rango/ext/kernel_spec.rb +0 -0
  440. data/spec/rango/ext/path_spec.rb +0 -0
  441. data/spec/rango/ext/string_spec.rb +0 -0
  442. data/spec/rango/ext/thor_spec.rb +0 -0
  443. data/spec/rango/ext/time_dsl_spec.rb +0 -0
  444. data/spec/rango/ext_spec.rb +0 -0
  445. data/spec/rango/forms/form_spec.rb +0 -0
  446. data/spec/rango/generators_spec.rb +0 -0
  447. data/spec/rango/generic_views/static_spec.rb +0 -0
  448. data/spec/rango/helpers/assets_spec.rb +0 -0
  449. data/spec/rango/helpers/general_spec.rb +0 -0
  450. data/spec/rango/helpers/merb-helpers/core_ext/numeric_spec.rb +0 -0
  451. data/spec/rango/helpers/merb-helpers/core_ext_spec.rb +0 -0
  452. data/spec/rango/helpers/merb-helpers/date_time_formatting_spec.rb +0 -0
  453. data/spec/rango/helpers/merb-helpers/date_time_helpers_spec.rb +0 -0
  454. data/spec/rango/helpers/merb-helpers/form/builder_spec.rb +0 -0
  455. data/spec/rango/helpers/merb-helpers/form/helpers_spec.rb +0 -0
  456. data/spec/rango/helpers/merb-helpers/form_helpers_spec.rb +0 -0
  457. data/spec/rango/helpers/merb-helpers/tag_helpers_spec.rb +0 -0
  458. data/spec/rango/helpers/merb-helpers/text_helpers_spec.rb +0 -0
  459. data/spec/rango/helpers/merb-helpers/time_dsl_spec.rb +0 -0
  460. data/spec/rango/helpers/merb-helpers_spec.rb +0 -0
  461. data/spec/rango/helpers/spec/core_ext_spec_spec.rb +0 -0
  462. data/spec/rango/helpers/spec/fixture/app/controllers/application_spec.rb +0 -0
  463. data/spec/rango/helpers/spec/fixture/app/controllers/bound_check_box_spec.rb +0 -0
  464. data/spec/rango/helpers/spec/fixture/app/controllers/bound_file_field_spec.rb +0 -0
  465. data/spec/rango/helpers/spec/fixture/app/controllers/bound_hidden_field_spec.rb +0 -0
  466. data/spec/rango/helpers/spec/fixture/app/controllers/bound_option_tag_spec.rb +0 -0
  467. data/spec/rango/helpers/spec/fixture/app/controllers/bound_password_field_spec.rb +0 -0
  468. data/spec/rango/helpers/spec/fixture/app/controllers/bound_radio_button_spec.rb +0 -0
  469. data/spec/rango/helpers/spec/fixture/app/controllers/bound_radio_group_spec.rb +0 -0
  470. data/spec/rango/helpers/spec/fixture/app/controllers/bound_select_spec.rb +0 -0
  471. data/spec/rango/helpers/spec/fixture/app/controllers/bound_text_area_spec.rb +0 -0
  472. data/spec/rango/helpers/spec/fixture/app/controllers/bound_text_field_spec.rb +0 -0
  473. data/spec/rango/helpers/spec/fixture/app/controllers/button_spec.rb +0 -0
  474. data/spec/rango/helpers/spec/fixture/app/controllers/check_box_spec.rb +0 -0
  475. data/spec/rango/helpers/spec/fixture/app/controllers/custom_builder_spec.rb +0 -0
  476. data/spec/rango/helpers/spec/fixture/app/controllers/delete_button_spec.rb +0 -0
  477. data/spec/rango/helpers/spec/fixture/app/controllers/exceptions_spec.rb +0 -0
  478. data/spec/rango/helpers/spec/fixture/app/controllers/field_set_spec.rb +0 -0
  479. data/spec/rango/helpers/spec/fixture/app/controllers/fields_for_spec.rb +0 -0
  480. data/spec/rango/helpers/spec/fixture/app/controllers/file_field_spec.rb +0 -0
  481. data/spec/rango/helpers/spec/fixture/app/controllers/foo_spec.rb +0 -0
  482. data/spec/rango/helpers/spec/fixture/app/controllers/form_for_spec.rb +0 -0
  483. data/spec/rango/helpers/spec/fixture/app/controllers/form_spec.rb +0 -0
  484. data/spec/rango/helpers/spec/fixture/app/controllers/hacker_spec.rb +0 -0
  485. data/spec/rango/helpers/spec/fixture/app/controllers/hidden_field_spec.rb +0 -0
  486. data/spec/rango/helpers/spec/fixture/app/controllers/label_spec.rb +0 -0
  487. data/spec/rango/helpers/spec/fixture/app/controllers/numeric_ext_spec.rb +0 -0
  488. data/spec/rango/helpers/spec/fixture/app/controllers/option_tag_spec.rb +0 -0
  489. data/spec/rango/helpers/spec/fixture/app/controllers/password_field_spec.rb +0 -0
  490. data/spec/rango/helpers/spec/fixture/app/controllers/radio_button_spec.rb +0 -0
  491. data/spec/rango/helpers/spec/fixture/app/controllers/radio_group_spec.rb +0 -0
  492. data/spec/rango/helpers/spec/fixture/app/controllers/relative_date_span_spec.rb +0 -0
  493. data/spec/rango/helpers/spec/fixture/app/controllers/relative_date_spec.rb +0 -0
  494. data/spec/rango/helpers/spec/fixture/app/controllers/select_spec.rb +0 -0
  495. data/spec/rango/helpers/spec/fixture/app/controllers/specs_controller_spec.rb +0 -0
  496. data/spec/rango/helpers/spec/fixture/app/controllers/submit_spec.rb +0 -0
  497. data/spec/rango/helpers/spec/fixture/app/controllers/tag_helper_spec.rb +0 -0
  498. data/spec/rango/helpers/spec/fixture/app/controllers/text_area_spec.rb +0 -0
  499. data/spec/rango/helpers/spec/fixture/app/controllers/text_field_spec.rb +0 -0
  500. data/spec/rango/helpers/spec/fixture/app/helpers/global_helpers_spec.rb +0 -0
  501. data/spec/rango/helpers/spec/fixture/app/models/fake_dm_model_spec.rb +0 -0
  502. data/spec/rango/helpers/spec/fixture/app/models/first_generic_fake_model_spec.rb +0 -0
  503. data/spec/rango/helpers/spec/fixture/app/models/hacker_generic_model_spec.rb +0 -0
  504. data/spec/rango/helpers/spec/fixture/app/models/second_generic_fake_model_spec.rb +0 -0
  505. data/spec/rango/helpers/spec/fixture/app/models/third_generic_fake_model_spec.rb +0 -0
  506. data/spec/rango/helpers/spec/fixture/config/environments/development_spec.rb +0 -0
  507. data/spec/rango/helpers/spec/fixture/config/environments/production_spec.rb +0 -0
  508. data/spec/rango/helpers/spec/fixture/config/environments/test_spec.rb +0 -0
  509. data/spec/rango/helpers/spec/fixture/config/init_spec.rb +0 -0
  510. data/spec/rango/helpers/spec/fixture/config/rack_spec.rb +0 -0
  511. data/spec/rango/helpers/spec/fixture/config/router_spec.rb +0 -0
  512. data/spec/rango/helpers/spec/merb_helpers_config_spec_spec.rb +0 -0
  513. data/spec/rango/helpers/spec/merb_helpers_date_time_spec_spec.rb +0 -0
  514. data/spec/rango/helpers/spec/merb_helpers_form_spec_spec.rb +0 -0
  515. data/spec/rango/helpers/spec/merb_helpers_tag_helper_spec_spec.rb +0 -0
  516. data/spec/rango/helpers/spec/merb_helpers_text_spec_spec.rb +0 -0
  517. data/spec/rango/helpers/spec/numeric_extlib_spec_spec.rb +0 -0
  518. data/spec/rango/helpers/spec/ordinalize_spec_spec.rb +0 -0
  519. data/spec/rango/helpers/spec/spec_helper_spec.rb +0 -0
  520. data/spec/rango/helpers/spec/time_dsl_spec_spec.rb +0 -0
  521. data/spec/rango/helpers/syntax_spec.rb +0 -0
  522. data/spec/rango/helpers_spec.rb +0 -0
  523. data/spec/rango/loggers/fireruby_spec.rb +0 -0
  524. data/spec/rango/loggers/logger_spec.rb +0 -0
  525. data/spec/rango/mixins/application_spec.rb +0 -0
  526. data/spec/rango/mixins/controller_spec.rb +0 -0
  527. data/spec/rango/mixins/import_spec.rb +0 -0
  528. data/spec/rango/mvc/controller_spec.rb +24 -0
  529. data/spec/rango/mvc/strategies_spec.rb +0 -0
  530. data/spec/rango/orm/adapters/dm/fields_spec.rb +0 -0
  531. data/spec/rango/orm/adapters/dm/setup_spec.rb +0 -0
  532. data/spec/rango/project_spec.rb +46 -0
  533. data/spec/rango/rack/dispatcher_spec.rb +0 -0
  534. data/spec/rango/rack/middlewares/emails_spec.rb +0 -0
  535. data/spec/rango/rack/middlewares/static_spec.rb +0 -0
  536. data/spec/rango/rack/request_spec.rb +18 -0
  537. data/spec/rango/rango_spec.rb +0 -0
  538. data/spec/rango/router/route_spec.rb +0 -0
  539. data/spec/rango/router/router_spec.rb +0 -0
  540. data/spec/rango/router/strategies_spec.rb +0 -0
  541. data/spec/rango/settings_spec.rb +26 -0
  542. data/spec/rango/spec/cucumber_spec.rb +0 -0
  543. data/spec/rango/spec/rspec_spec.rb +0 -0
  544. data/spec/rango/templates/adapter_spec.rb +0 -0
  545. data/spec/rango/templates/adapters/erb_spec.rb +0 -0
  546. data/spec/rango/templates/adapters/erubis_spec.rb +0 -0
  547. data/spec/rango/templates/adapters/haml_spec.rb +0 -0
  548. data/spec/rango/templates/template_spec.rb +0 -0
  549. data/spec/rango_spec.rb +37 -0
  550. data/spec/spec.opts +5 -0
  551. data/spec/spec_helper.rb +7 -0
  552. data/spec/stubs/flat.rb +0 -0
  553. data/stubs/app/content/init.rb.rbt +6 -0
  554. data/stubs/app/content/models.rb.rbt +9 -0
  555. data/stubs/app/content/views.rb.rbt +10 -0
  556. data/stubs/app/preprocess.rb +13 -0
  557. data/stubs/bigapp/content/init.rb +0 -0
  558. data/stubs/bigapp/content/views/application.rb +0 -0
  559. data/stubs/bigapp/preprocess.rb +5 -0
  560. data/stubs/features/content/env.rb +36 -0
  561. data/stubs/flat/content/flat.ru.rbt +19 -0
  562. data/stubs/flat/preprocess.rb +5 -0
  563. data/stubs/project/content/TODO +0 -0
  564. data/stubs/project/content/Thorfile +12 -0
  565. data/stubs/project/content/config.ru +34 -0
  566. data/stubs/project/content/init.rb +14 -0
  567. data/stubs/project/content/settings.rb.rbt +10 -0
  568. data/stubs/project/content/settings_local.rb.rbt +6 -0
  569. data/stubs/project/content/templates/base.html.haml.rbt +29 -0
  570. data/stubs/project/preprocess.rb +5 -0
  571. data/stubs/pupu/preprocess.rb +5 -0
  572. data/stubs/stub/content/metadata.yml +2 -0
  573. data/stubs/stub/content/postprocess.rb +7 -0
  574. data/stubs/stub/content/preprocess.rb +5 -0
  575. data/stubs/stub/preprocess.rb +5 -0
  576. data/support/Rango.tmbundle/Commands/Documentation for current word.tmCommand +22 -0
  577. data/support/Rango.tmbundle/Commands/Got to import.tmCommand +23 -0
  578. data/support/Rango.tmbundle/Commands/Rango console.tmCommand +22 -0
  579. data/support/Rango.tmbundle/Commands/Rango server.tmCommand +22 -0
  580. data/support/Rango.tmbundle/Commands/Read documentation.tmCommand +22 -0
  581. data/support/Rango.tmbundle/Snippets/Method with yardoc.tmSnippet +20 -0
  582. data/support/Rango.tmbundle/Snippets/Project_configure.tmSnippet +18 -0
  583. data/support/Rango.tmbundle/Snippets/Project_import.tmSnippet +16 -0
  584. data/support/Rango.tmbundle/Snippets/Project_logger_debug.tmSnippet +16 -0
  585. data/support/Rango.tmbundle/Snippets/Project_logger_error.tmSnippet +16 -0
  586. data/support/Rango.tmbundle/Snippets/Project_logger_fatal.tmSnippet +16 -0
  587. data/support/Rango.tmbundle/Snippets/Project_logger_inspect.tmSnippet +16 -0
  588. data/support/Rango.tmbundle/Snippets/Project_logger_warn.tmSnippet +16 -0
  589. data/support/Rango.tmbundle/Snippets/Rango_dependency.tmSnippet +16 -0
  590. data/support/Rango.tmbundle/Snippets/Rango_import.tmSnippet +16 -0
  591. data/support/Rango.tmbundle/Snippets/Rango_logger_debug.tmSnippet +16 -0
  592. data/support/Rango.tmbundle/Snippets/Rango_logger_error.tmSnippet +16 -0
  593. data/support/Rango.tmbundle/Snippets/Rango_logger_fatal.tmSnippet +16 -0
  594. data/support/Rango.tmbundle/Snippets/Rango_logger_inspect.tmSnippet +16 -0
  595. data/support/Rango.tmbundle/Snippets/Rango_logger_warn.tmSnippet +16 -0
  596. data/support/Rango.tmbundle/Snippets/controller.tmSnippet +28 -0
  597. data/support/Rango.tmbundle/Snippets/doc.tmSnippet +20 -0
  598. data/support/Rango.tmbundle/Snippets/match.tmSnippet +16 -0
  599. data/support/Rango.tmbundle/Snippets/thor task.tmSnippet +19 -0
  600. data/support/Rango.tmbundle/info.plist +37 -0
  601. data/support/hooks/commit-msg +13 -0
  602. data/support/hooks/post-commit +4 -0
  603. data/support/hooks/pre-commit +4 -0
  604. data/support/hooks/pre-rebase +169 -0
  605. data/support/hooks/prepare-commit-msg +36 -0
  606. data/tasks/hooks.thor +26 -0
  607. data/tasks/package.thor +49 -0
  608. data/tasks/release.thor +72 -0
  609. data/tasks/repair.thor +75 -0
  610. data/tasks/spec.thor +39 -0
  611. data/tasks/stats.thor +66 -0
  612. data/tasks/yardoc.thor +16 -0
  613. data/templates/errors/404.html.erb +52 -0
  614. data/templates/errors/406.html.erb +1 -0
  615. data/templates/errors/500.html.erb +48 -0
  616. metadata +866 -0
@@ -0,0 +1,179 @@
1
+ merb-helpers
2
+ =================
3
+
4
+ A plugin for the Rango Web framework that provides different view helpers.
5
+
6
+ To use this plugin in merb in your app
7
+
8
+ config/dependencies.rb
9
+
10
+ #...
11
+
12
+ dependency "merb-helpers"
13
+
14
+ #...
15
+
16
+ # TODO: describe date_time_helpers, form_helpers, tag_helpers
17
+
18
+
19
+ form_helpers
20
+ ------------
21
+
22
+ * +delete_button+. If you want to delete an object, you should call the delete method on the object's controller.
23
+ You should not use a simple link to your action, instead you should make a DELETE request.
24
+ To help you doing that, you can use the delete_button method as follows:
25
+
26
+ <%= delete_button(@comment) %>
27
+
28
+ The delete_button helper has many options, first thing, you can pass an object or an url:
29
+
30
+ <%= delete_button(url(:comment, @comment)) %>
31
+
32
+ This helper creates a form with a submit button.
33
+ You can pass many arguments to the delete_button helper. The first thing you might want to do is to change the
34
+ default button text.
35
+
36
+ <%= delete_button(@comment), "Remove this comment by #{@comment.author.name}" %>
37
+
38
+ You can also pass the usual helper params to specify a class to use for instance:
39
+
40
+ <%= delete_button(@comment, nil, :class => 'custom-class') %>
41
+
42
+ See usage in specs: spec/fixture/app/views/delete_button_specs
43
+
44
+ numeric helpers
45
+ ---------------
46
+
47
+ Numeric helpers extend numeric instances, in lay terms: numbers.
48
+
49
+ * +minutes_to_hours+ converts a +numeric+ value representing minutes into a string representing an hour value
50
+
51
+ 315.minutes_to_hours # => "05:15"
52
+
53
+ * +two_digits+ formats a +number+ into a two digit string. Basically it prepends an integer to a 2 digits string.
54
+
55
+ 3.two_digits # => "03"
56
+
57
+ * +with_delimiter+, this method formats a number with grouped thousands
58
+
59
+ 12345678.with_delimiter # => "12,345,678"
60
+
61
+
62
+ * +with_precison+, this method formats a number with a level of precision
63
+
64
+ 111.2345.with_precision # => "111.235"
65
+
66
+ * +to_currency, this method formats a number into a currency value using a delimited and a set precision
67
+
68
+ 1234567890.506.to_currency # => "$1,234,567,890.51"
69
+
70
+ (For usage example look at spec/numeric_exlib.rb)
71
+
72
+
73
+ Overwriting the default formating options:
74
+
75
+ One can overwrite the default settings by passing the name or of the format used and a hash representing the settings to overwrite.
76
+
77
+ Each method mentioned above has some format settings you can overwrite:
78
+
79
+ * +with_delimiter+
80
+ * :delimiter - Overwrites the thousands delimiter.
81
+ * :separator - Overwrites the separator between the units.
82
+
83
+ * +with_precision+
84
+ * :precision - Overwrites the level of precision
85
+ * :separator - Overwrites the separator between the units
86
+ * :delimiter - Overwrites the thousands delimiter
87
+
88
+ * +with_currency+
89
+ * :precision - Sets the level of precision
90
+ * :unit - Sets the denomination of the currency
91
+ * :format - Sets the format of the output string (defaults to "%u%n"). The field types are:
92
+ * %u The currency unit
93
+ * %n The number
94
+
95
+ Usage example:
96
+
97
+ 1234567890.506.to_currency(:default, :unit => '£') # => "£1,234,567,890.51"
98
+
99
+ merb_helpers comes with a very limited set of formats you can use, here is an example:
100
+
101
+ 1234567890.50.to_currency(:uk) # => "&pound;1,234,567,890.50"
102
+
103
+ Formats are just a hash of settings used by the plugin, here is the default format:
104
+
105
+ :us => {
106
+ :number => {
107
+ :precision => 3,
108
+ :delimiter => ',',
109
+ :separator => '.'
110
+ },
111
+ :currency => {
112
+ :unit => '$',
113
+ :format => '%u%n',
114
+ :precision => 2
115
+ }
116
+ }
117
+
118
+ If you wish to add a new format you can easily do that as follows:
119
+
120
+ custom_format_to_add = { :custom_name => {
121
+ :number => {
122
+ :precision => 3,
123
+ :delimiter => ',',
124
+ :separator => '.'
125
+ },
126
+ :currency => {
127
+ :unit => 'Rangoollars',
128
+ :format => '%n %u',
129
+ :precision => 2
130
+ }
131
+ }
132
+ }
133
+
134
+ Numeric::Transformer.add_format(custom_format_to_add)
135
+
136
+ You can then call the format like that:
137
+
138
+ 1234567890.to_currency(:custom_name) # => "1,234,567,890.00 Rangoollars"
139
+
140
+ After adding a custom format, you can set it as the default format:
141
+
142
+ Numeric::Transformer.change_default_format(:custom_name)
143
+
144
+ You can set this things up in your before/after app load block in the config/init.rb file.
145
+
146
+
147
+ Formating a Date or Time instance
148
+ ---------------
149
+
150
+ Usage examples: spec/merb_helpers_date_time_spec.rb
151
+
152
+ Time.now.formatted(:db) # => "2008-09-21 02:07:31"
153
+ Time.now.formatted(:long) # => "September 21, 2008 02:08"
154
+
155
+ You can also add your own format:
156
+
157
+ Date.add_format(:matt, "%H:%M:%S %Y-%m-%d")
158
+
159
+ And use is as a default format:
160
+
161
+ Time.now.formatted(:matt) # => "02:09:18 2008-09-21"
162
+
163
+
164
+
165
+ Representation of time difference
166
+ -------------------
167
+
168
+ Usage examples: spec/merb_helpers_date_time_spec.rb
169
+
170
+ * Relative time:
171
+
172
+ Let's imagine that we are the June 1st 2007 at 11am UTC
173
+
174
+
175
+ relative_date(Time.now.utc) # => "today"
176
+ relative_date(1.day.ago.utc) # => 'yesterday'
177
+ relative_date(1.day.from_now.utc) # => 'tomorrow'
178
+ relative_date(Time.utc(2005, 11, 15)) # => 'Nov 15th, 2005' (date with the year since it's not this year)
179
+ relative_date(Time.utc(2007, 11, 15)) # => 'Nov 15th' (date without the year this the passed date is this year)
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+
3
+ class Rango
4
+ module Helpers
5
+ # stolen from pupu (but it's OK, it's my code)
6
+ # @since 0.0.2
7
+ def javascript(basename)
8
+ path = Path.new(File.join(Project.settings.media_root, "javascripts", "#{basename}.js"))
9
+ tag :script, src: path.url, type: "text/javascript"
10
+ end
11
+
12
+ # @since 0.0.2
13
+ def stylesheet(basename, attrs = Hash.new)
14
+ path = Path.new(File.join(Project.settings.media_root, basename))
15
+ default = {href: path.url, media: 'screen', rel: 'stylesheet', type: 'text/css'}
16
+ single_tag :link, default.merge(attrs)
17
+ end
18
+
19
+ # @since 0.0.2
20
+ def javascripts(*names)
21
+ names.map { |name| self.javascript(name) }.join("\n")
22
+ end
23
+
24
+ # @since 0.0.2
25
+ def stylesheets(*names)
26
+ names.map { |name| self.stylesheet(name) }.join("\n")
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,41 @@
1
+ # coding: utf-8
2
+ require "uri"
3
+
4
+ class Rango
5
+ module Helpers
6
+ # @since 0.0.1
7
+ def copyright(from)
8
+ now = Time.now.year
9
+ now.eql?(from) ? now : "#{from} - #{now}"
10
+ end
11
+
12
+ # @since 0.0.2
13
+ def link_to(name, url, options = Hash.new)
14
+ default = {href: URI.escape(url), title: name.to_s.gsub(/'/, '&apos;')}
15
+ tag :a, name, default.merge(options)
16
+ end
17
+
18
+ # @since 0.0.2
19
+ def link_item(name, url)
20
+ tag :li, link_to(name, url)
21
+ end
22
+
23
+ # @since 0.0.2
24
+ # mail_to "joe@example.com"
25
+ # => "<a href='mailto:joe@example.com'>joe@example.com</a>"
26
+ # mail_to "joe@example.com", "Title"
27
+ # => "<a href='mailto:joe@example.com'>Title</a>"
28
+ def mail_to(mail, text = mail)
29
+ mail.gsub!("@" "&#x40;")
30
+ tag :a, text, href: "mailto:#{mail}"
31
+ end
32
+
33
+ # @since 0.0.2
34
+ def error_messages_for(model_instance)
35
+ tag :ul do
36
+ messages = model_instance.errors.full_messages
37
+ messages.map { |message| tag :li, message }
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,40 @@
1
+ # coding: utf-8
2
+
3
+ class Rango
4
+
5
+ module Helpers
6
+
7
+ @@helpers_dir = File.dirname(__FILE__) / 'merb-helpers'
8
+ @@helpers_files = Dir["#{@@helpers_dir}/*_helpers.rb"].collect {|h| h.match(/\/(\w+)\.rb/)[1]}
9
+
10
+ def self.load
11
+ require @@helpers_dir + '/time_dsl'
12
+ require @@helpers_dir + '/core_ext'
13
+ require @@helpers_dir + '/core_ext/numeric'
14
+
15
+ # if Rango::Plugins.config[:merb_helpers]
16
+ # config = Rango::Plugins.config[:merb_helpers]
17
+ #
18
+ # if config[:include] && !config[:include].empty?
19
+ # load_helpers(config[:include])
20
+ # else
21
+ # # This is in case someone defines an entry in the config,
22
+ # # but doesn't put in a with or without option
23
+ # load_helpers
24
+ # end
25
+ #
26
+ # else
27
+ load_helpers
28
+ # end
29
+ end
30
+
31
+ # Load only specific helpers instead of loading all the helpers
32
+ def self.load_helpers(helpers = @@helpers_files)
33
+ helpers.each {|helper| Kernel.load(File.join(@@helpers_dir, "#{helper}.rb") )} # using load here allows specs to work
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+
40
+ Rango::Helpers.load
@@ -0,0 +1,58 @@
1
+ # coding: utf-8
2
+
3
+ require "date"
4
+ require File.dirname(__FILE__) + '/date_time_formatting'
5
+ class Date
6
+ include DateAndTimeFormatting
7
+
8
+ # Converts a Date instance to a Time, where the time is set to the beginning of the day.
9
+ # The timezone can be either :local or :utc (default :utc).
10
+ #
11
+ # ==== Examples:
12
+ # date = Date.new(2007, 11, 10)
13
+ # date.to_s # => 2007-11-10
14
+ #
15
+ # date.to_time # => Sat Nov 10 00:00:00 UTC 2007
16
+ # date.to_time(:utc) # => Sat Nov 10 00:00:00 UTC 2007
17
+ # date.to_time(:local) # => Sat Nov 10 00:00:00 -0800 2007
18
+ #
19
+ def to_time(form = :utc)
20
+ ::Time.send("#{form}", year, month, day)
21
+ end
22
+
23
+ def to_date; self; end
24
+
25
+ def formatted(format=:default)
26
+ format = Date.formats[format]
27
+ if format.nil?
28
+ self.to_s
29
+ else
30
+ self.strftime(format)
31
+ end
32
+ end
33
+
34
+ end
35
+
36
+ class Time
37
+ include DateAndTimeFormatting
38
+
39
+ # Ruby 1.8-cvs and 1.9 define private Time#to_date
40
+ %w(to_date to_datetime).each do |method|
41
+ public method if private_instance_methods.include?(method)
42
+ end
43
+
44
+ def to_time; self; end
45
+ end
46
+
47
+ # Truncates a string to the given length and appends the given suffix if the string is, in fact, truncated.
48
+ #
49
+ # ==== Examples:
50
+ # "This is a long string right here".truncate(10, "...") #=> "This is..."
51
+
52
+ class String
53
+ def truncate(length = 30, truncate_string = "...")
54
+ return self unless self.length > length
55
+ length = length - truncate_string.split(//).length
56
+ self[0...length] + truncate_string
57
+ end
58
+ end
@@ -0,0 +1,388 @@
1
+ # coding: utf-8
2
+
3
+ class Numeric
4
+ module Transformer
5
+
6
+ # known formats to use with the app
7
+ # users can add their own formats by using Numeric::Transformer.add_format(:format_name => {})
8
+
9
+ @formats ={
10
+ :us => {
11
+ :number => {
12
+ :precision => 3,
13
+ :delimiter => ',',
14
+ :separator => '.'
15
+ },
16
+ :currency => {
17
+ :unit => '$',
18
+ :format => '%u%n',
19
+ :precision => 2
20
+ }
21
+ },
22
+ :uk => {
23
+ :number => {
24
+ :precision => 3,
25
+ :delimiter => ',',
26
+ :separator => '.'
27
+ },
28
+ :currency => {
29
+ :unit => '&pound;',
30
+ :format => '%u%n',
31
+ :precision => 2
32
+ }
33
+ },
34
+ :au => {
35
+ :number => {
36
+ :precision => 3,
37
+ :delimiter => ',',
38
+ :separator => '.'
39
+ },
40
+ :currency => {
41
+ :unit => '$;',
42
+ :format => '%u%n',
43
+ :precision => 2
44
+ }
45
+ },
46
+ :fr => {
47
+ :number => {
48
+ :precision => 3,
49
+ :delimiter => ' ',
50
+ :separator => ','
51
+ },
52
+ :currency => {
53
+ :unit => '€',
54
+ :format => '%n%u',
55
+ :precision => 2
56
+ }
57
+ },
58
+ :ru => {
59
+ :number => {
60
+ :precision => 2,
61
+ :delimiter => ' ',
62
+ :separator => ','
63
+ },
64
+ :currency => {
65
+ :unit => 'р.',
66
+ :format => '%n %u',
67
+ :precision => 2
68
+ }
69
+ }
70
+ }
71
+
72
+ # accessor for @formats
73
+ #---
74
+ # @private
75
+ def self.formats
76
+ @formats
77
+ end
78
+
79
+ @default_format = @formats[:us]
80
+
81
+
82
+ # Accessor for the default format in use
83
+ #
84
+ #---
85
+ # @public
86
+ def self.default_format
87
+ @default_format
88
+ end
89
+
90
+
91
+ # Changes the default format to use when transforming a +Numeric+ instance
92
+ #
93
+ # ==== Parameters
94
+ # format_code <Symbol>:: format name to use as the new default format
95
+ #
96
+ # ==== Returns
97
+ # Hash:: a hash representing the default format
98
+ #
99
+ #---
100
+ # @public
101
+ def self.change_default_format(format_code)
102
+ @default_format = (formats[format_code] || default_format)
103
+ end
104
+
105
+
106
+ # Adds a new format to the existing transforming formats
107
+ #
108
+ # ==== Parameters
109
+ # format <Hash>:: format defining how to transform numeric values
110
+ #
111
+ # ==== Examples
112
+ #
113
+ #
114
+ #---
115
+ # @public
116
+ def self.add_format(format)
117
+ formats.merge!(format)
118
+ formats[format]
119
+ end
120
+
121
+
122
+ # Formats a +number+ with grouped thousands using +delimiter+ (e.g., 12,324). You can
123
+ # pass another format to format the number differently.
124
+ #
125
+ #
126
+ # ==== Parameters
127
+ # format_name<Symbol>:: name of the format to use
128
+ # options<Hash>:: options which will overwrite the used format
129
+ #
130
+ # ==== Returns
131
+ # String:: a string representing the delimited number
132
+ #
133
+ # ==== Options
134
+ # :delimiter - Overwrites the thousands delimiter.
135
+ # :separator - Overwrites the separator between the units.
136
+ #
137
+ # ==== Examples
138
+ # with_delimiter(12345678) # => 12,345,678
139
+ # with_delimiter(12345678.05) # => 12,345,678.05
140
+ # with_delimiter(12345678, :FR) # => 12.345.678
141
+ # with_delimiter(12345678, :US) # => 12,345,678
142
+ #
143
+ #---
144
+ # @private
145
+ def self.with_delimiter(number, format_name = nil, options = {})
146
+
147
+ format = (formats[format_name] || default_format)[:number].merge(options)
148
+
149
+ begin
150
+ parts = number.to_s.split('.')
151
+ parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{format[:delimiter]}")
152
+ parts.join(format[:separator])
153
+ rescue
154
+ number
155
+ end
156
+ end
157
+
158
+ # Formats a +number+ with a level of <tt>:precision</tt> (e.g., 112.32 has a precision of 2).
159
+ # You can pass another format to use and even overwrite the format's options.
160
+ #
161
+ #
162
+ # ==== Parameters
163
+ # format_name<Symbol>:: name of the format to use
164
+ # options<Hash>:: options which will overwrite the used format
165
+ #
166
+ # ==== Returns
167
+ # String:: a string representing the delimited number
168
+ #
169
+ # ==== Options
170
+ # :precision - Overwrites the level of precision
171
+ # :separator - Overwrites the separator between the units
172
+ # :delimiter - Overwrites the thousands delimiter
173
+ #
174
+ # ==== Examples
175
+ # with_precision(111.2345) # => 111.235
176
+ # with_precision(111.2345, :UK, :precision => 1) # => "111.2"
177
+ # with_precision(1234.567, :US, :precision => 1, :separator => ',', :delimiter => '-') # => "1-234,6"
178
+ #
179
+ #---
180
+ # @private
181
+ def self.with_precision(number, format_name = nil, options={})
182
+
183
+ format = (formats[format_name] || default_format)[:number].merge(options)
184
+
185
+ begin
186
+ rounded_number = (Float(number) * (10 ** format[:precision])).round.to_f / 10 ** format[:precision]
187
+ with_delimiter("%01.#{format[:precision]}f" % rounded_number, format_name, :delimiter => format[:delimiter], :separator => format[:separator])
188
+ rescue
189
+ number
190
+ end
191
+ end
192
+
193
+
194
+ # Formats a +number+ into a currency string (e.g., $13.65). You can specify a format to use
195
+ # and even overwrite some of the format options.
196
+ #
197
+ # ==== Parameters
198
+ # number<Numeric>:: Numeric value to convert
199
+ # format_name<Symbol>:: name of the format to use
200
+ # options<Hash>:: options which will overwrite the used format
201
+ #
202
+ # ==== Returns
203
+ # String:: a string representing the number converted in currency
204
+ #
205
+ # ==== Options
206
+ # :precision - Sets the level of precision
207
+ # :unit - Sets the denomination of the currency
208
+ # :format - Sets the format of the output string (defaults to "%u%n"). The field types are:
209
+ #
210
+ # %u The currency unit
211
+ # %n The number
212
+ #
213
+ # ==== Examples
214
+ # to_currency(1234567890.506, :US, :precision => 1) # => "$1,234,567,890.5"
215
+ # to_currency(1234567890.516, :FR) # =>"1 234 567 890,52€"
216
+ # to_currency(1234567890.516, :US, :unit => "€") # =>"€1,234,567,890.52"
217
+ # to_currency(1234567890.506, :US, :precision => 3, :unit => "€") # => "€1,234,567,890.506"
218
+ # to_currency(1234567890.506, :AU, :unit => "$AUD", :format => '%n %u') # => "1,234,567,890.51 $AUD"
219
+ #
220
+ #---
221
+ # @private
222
+ def self.to_currency(number, format_name = nil, options = {})
223
+
224
+ format = (formats[format_name] || default_format)[:currency].merge(options)
225
+
226
+ begin
227
+ format[:format].gsub(/%n/, with_precision(number,
228
+ format_name, :precision => format[:precision]) ).gsub(/%u/, format[:unit])
229
+ rescue
230
+ number
231
+ end
232
+ end
233
+
234
+
235
+ # Formats a +number+ into a two digit string. Basically it prepends an integer to a 2 digits string.
236
+ #
237
+ # ==== Parameters
238
+ # number<Numeric>:: Numeric value to convert
239
+ #
240
+ # ==== Returns
241
+ # String:: a string representing the number converted into a 2 digits string.
242
+ #
243
+ # ==== Examples
244
+ # two_digits(5-3) # => "02"
245
+ #
246
+ #---
247
+ # @private
248
+ def self.two_digits(number)
249
+ (0..9).include?(number) ? "0#{number}" : number.to_s
250
+ end
251
+
252
+ # Converts a +numeric+ value representing minutes into a string representing an hour value
253
+ #
254
+ # ==== Parameters
255
+ # number<Numeric>:: Numeric value representing minutes to convert in hours
256
+ #
257
+ # ==== Returns
258
+ # String:: a string representing the numeric value converted in hours
259
+ #
260
+ # ==== Examples
261
+ # minutes_to_hours(315) => "05:15"
262
+ #
263
+ #---
264
+ # @private
265
+ def self.minutes_to_hours(minutes)
266
+ hours = (minutes/60).ceil
267
+ minutes = (minutes - (hours * 60)).to_i
268
+ "#{two_digits(hours)}:#{two_digits(minutes)}"
269
+ end
270
+
271
+ end #of Numeric::Transformer
272
+
273
+ # Formats with with grouped thousands using +delimiter+ (e.g., 12,324). You can
274
+ # pass another format to format the number differently.
275
+ #
276
+ #
277
+ # ==== Parameters
278
+ # format_name<Symbol>:: name of the format to use
279
+ # options<Hash>:: options which will overwrite the used format
280
+ #
281
+ # ==== Returns
282
+ # String:: a string representing the delimited number
283
+ #
284
+ # ==== Options
285
+ # :delimiter - Overwrites the thousands delimiter.
286
+ # :separator - Overwrites the separator between the units.
287
+ #
288
+ # ==== Examples
289
+ # 12345678.with_delimiter # => 12,345,678
290
+ # 12345678.05.with_delimiter # => 12,345,678.05
291
+ # 12345678.with_delimiter(:FR) # => 12.345.678
292
+ # 12345678.with_delimiter(:US) # => 12,345,678
293
+ #
294
+ #---
295
+ # @public
296
+ def with_delimiter(format_name = nil, options = {})
297
+ Transformer.with_delimiter(self, format_name, options)
298
+ end
299
+
300
+ # Formats with a level of <tt>:precision</tt> (e.g., 112.32 has a precision of 2).
301
+ # You can pass another format to use and even overwrite the format's options.
302
+ #
303
+ #
304
+ # ==== Parameters
305
+ # format_name<Symbol>:: name of the format to use
306
+ # options<Hash>:: options which will overwrite the used format
307
+ #
308
+ # ==== Returns
309
+ # String:: a string representing the delimited number
310
+ #
311
+ # ==== Options
312
+ # :precision - Overwrites the level of precision
313
+ # :separator - Overwrites the separator between the units
314
+ # :delimiter - Overwrites the thousands delimiter
315
+ #
316
+ # ==== Examples
317
+ # 111.2345.with_precision # => 111.235
318
+ # 111.2345.with_precision(:UK, :precision => 1) # => "111.2"
319
+ # 1234.567.with_precision(:US, :precision => 1, :separator => ',', :delimiter => '-') # => "1-234,6"
320
+ #
321
+ #---
322
+ # @public
323
+ def with_precision(format_name = nil, options = {})
324
+ Transformer.with_precision(self, format_name, options)
325
+ end
326
+
327
+ # Formats into a currency string (e.g., $13.65). You can specify a format to use
328
+ # and even overwrite some of the format options.
329
+ #
330
+ # ==== Parameters
331
+ # format_name<Symbol>:: name of the format to use
332
+ # options<Hash>:: options which will overwrite the used format
333
+ #
334
+ # ==== Returns
335
+ # String:: a string representing the number converted in currency
336
+ #
337
+ # ==== Options
338
+ # :precision - Sets the level of precision
339
+ # :unit - Sets the denomination of the currency
340
+ # :format - Sets the format of the output string (defaults to "%u%n"). The field types are:
341
+ #
342
+ # %u The currency unit
343
+ # %n The number
344
+ #
345
+ # ==== Examples
346
+ # 1234567890.506.to_currency(:US) # => "$1,234,567,890.51"
347
+ # 1234567890.506.to_currency(:US, :precision => 1) # => "$1,234,567,890.5"
348
+ # 1234567890.516.to_currency(:FR) # =>"1 234 567 890,52€"
349
+ # 1234567890.516.to_currency(:US, :unit => "€") # =>"€1,234,567,890.52"
350
+ # 1234567890.506.to_currency(:US, :precision => 3, :unit => "€") # => "€1,234,567,890.506"
351
+ # 1234567890.506.to_currency(:AU, :unit => "$AUD", :format => '%n %u') # => "1,234,567,890.51 $AUD"
352
+ #---
353
+ # @public
354
+ def to_currency(format_name = nil, options = {})
355
+ Transformer.to_currency(self, format_name, options)
356
+ end
357
+
358
+ # Formats a +number+ into a two digit string. Basically it prepends an integer to a 2 digits string.
359
+ #
360
+ # ==== Returns
361
+ # String:: a string representing the number converted into a 2 digits string.
362
+ #
363
+ # ==== Examples
364
+ # (5-3).two_digits # => "02"
365
+ #
366
+ #---
367
+ # @public
368
+ def two_digits
369
+ Transformer.two_digits(self)
370
+ end
371
+
372
+ # Converts a +numeric+ value representing minutes into a string representing an hour value
373
+ #
374
+ # ==== Parameters
375
+ # number<Numeric>:: Numeric value representing minutes to convert in hours
376
+ #
377
+ # ==== Returns
378
+ # String:: a string representing the numeric value converted in hours
379
+ #
380
+ # ==== Examples
381
+ # 315.minutes_to_hours => "05:15"
382
+ #
383
+ #---
384
+ # @public
385
+ def minutes_to_hours
386
+ Transformer.minutes_to_hours(self)
387
+ end
388
+ end