hobo 0.7.5 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (212) hide show
  1. data/{hobo_files/plugin/CHANGES.txt → CHANGES.txt} +391 -0
  2. data/Manifest +146 -0
  3. data/{hobo_files/plugin/README → README} +0 -0
  4. data/bin/hobo +13 -26
  5. data/dryml_generators/rapid/cards.dryml.erb +55 -0
  6. data/dryml_generators/rapid/forms.dryml.erb +43 -0
  7. data/dryml_generators/rapid/pages.dryml.erb +284 -0
  8. data/hobo.gemspec +168 -0
  9. data/init.rb +9 -0
  10. data/lib/action_view_extensions/helpers/tag_helper.rb +7 -0
  11. data/lib/active_record/association_collection.rb +54 -0
  12. data/{hobo_files/plugin/lib → lib}/active_record/association_proxy.rb +12 -4
  13. data/{hobo_files/plugin/lib → lib}/active_record/association_reflection.rb +7 -1
  14. data/{hobo_files/plugin/lib → lib}/extensions/test_case.rb +17 -17
  15. data/{hobo_files/plugin/lib → lib}/hobo.rb +193 -100
  16. data/{hobo_files/plugin/lib → lib}/hobo/authentication_support.rb +8 -8
  17. data/{hobo_files/plugin/lib → lib}/hobo/bundle.rb +90 -89
  18. data/{hobo_files/plugin/lib → lib}/hobo/composite_model.rb +21 -21
  19. data/{hobo_files/plugin/lib → lib}/hobo/controller.rb +38 -25
  20. data/{hobo_files/plugin/lib → lib}/hobo/dev_controller.rb +10 -6
  21. data/lib/hobo/dryml.rb +167 -0
  22. data/{hobo_files/plugin/lib → lib}/hobo/dryml/dryml_builder.rb +28 -25
  23. data/lib/hobo/dryml/dryml_generator.rb +210 -0
  24. data/{hobo_files/plugin/lib → lib}/hobo/dryml/dryml_support_controller.rb +1 -1
  25. data/lib/hobo/dryml/parser.rb +3 -0
  26. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/attribute.rb +6 -6
  27. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/base_parser.rb +16 -16
  28. data/lib/hobo/dryml/parser/document.rb +57 -0
  29. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/element.rb +7 -7
  30. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/elements.rb +9 -9
  31. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/source.rb +3 -3
  32. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/text.rb +3 -3
  33. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/tree_parser.rb +3 -3
  34. data/{hobo_files/plugin/lib → lib}/hobo/dryml/part_context.rb +26 -26
  35. data/{hobo_files/plugin/lib → lib}/hobo/dryml/scoped_variables.rb +15 -15
  36. data/{hobo_files/plugin/lib → lib}/hobo/dryml/tag_parameters.rb +10 -10
  37. data/{hobo_files/plugin/lib → lib}/hobo/dryml/taglib.rb +43 -37
  38. data/{hobo_files/plugin/lib → lib}/hobo/dryml/template.rb +290 -208
  39. data/{hobo_files/plugin/lib → lib}/hobo/dryml/template_environment.rb +173 -115
  40. data/{hobo_files/plugin/lib → lib}/hobo/dryml/template_handler.rb +19 -24
  41. data/lib/hobo/find_for.rb +95 -0
  42. data/{hobo_files/plugin/lib → lib}/hobo/generator.rb +2 -1
  43. data/{hobo_files/plugin/lib → lib}/hobo/guest.rb +12 -4
  44. data/{hobo_files/plugin/lib → lib}/hobo/hobo_helper.rb +146 -117
  45. data/lib/hobo/include_in_save.rb +43 -0
  46. data/lib/hobo/lifecycles.rb +94 -0
  47. data/lib/hobo/lifecycles/actions.rb +73 -0
  48. data/lib/hobo/lifecycles/creator.rb +76 -0
  49. data/lib/hobo/lifecycles/lifecycle.rb +205 -0
  50. data/lib/hobo/lifecycles/state.rb +23 -0
  51. data/lib/hobo/lifecycles/transition.rb +66 -0
  52. data/{hobo_files/plugin/lib → lib}/hobo/model.rb +306 -217
  53. data/{hobo_files/plugin/lib → lib}/hobo/model_controller.rb +342 -213
  54. data/{hobo_files/plugin/lib → lib}/hobo/model_router.rb +151 -120
  55. data/{hobo_files/plugin/lib → lib}/hobo/model_support.rb +9 -9
  56. data/{hobo_files/plugin/lib → lib}/hobo/rapid_helper.rb +30 -23
  57. data/{hobo_files/plugin/lib → lib}/hobo/scopes.rb +22 -68
  58. data/{hobo_files/plugin/lib → lib}/hobo/scopes/apply_scopes.rb +5 -5
  59. data/lib/hobo/scopes/association_proxy_extensions.rb +47 -0
  60. data/{hobo_files/plugin/lib → lib}/hobo/scopes/automatic_scopes.rb +104 -79
  61. data/lib/hobo/scopes/named_scope_extensions.rb +27 -0
  62. data/{hobo_files/plugin/lib → lib}/hobo/static_tags +1 -11
  63. data/{hobo_files/plugin/lib → lib}/hobo/undefined.rb +1 -1
  64. data/{hobo_files/plugin/lib → lib}/hobo/undefined_access_error.rb +0 -0
  65. data/{hobo_files/plugin/lib → lib}/hobo/user.rb +27 -25
  66. data/{hobo_files/plugin/lib → lib}/hobo/user_controller.rb +80 -34
  67. data/{hobo_files/plugin/generators → rails_generators}/hobo/hobo_generator.rb +7 -7
  68. data/rails_generators/hobo/templates/application.css +0 -0
  69. data/{hobo_files/plugin/generators → rails_generators}/hobo/templates/application.dryml +0 -2
  70. data/{hobo_files/plugin/generators → rails_generators}/hobo/templates/dryml-support.js +0 -0
  71. data/{hobo_files/plugin/generators → rails_generators}/hobo/templates/guest.rb +0 -0
  72. data/rails_generators/hobo/templates/initializer.rb +9 -0
  73. data/{hobo_files/plugin/generators → rails_generators}/hobo_front_controller/USAGE +0 -0
  74. data/{hobo_files/plugin/generators → rails_generators}/hobo_front_controller/hobo_front_controller_generator.rb +1 -3
  75. data/{hobo_files/plugin/generators → rails_generators}/hobo_front_controller/templates/controller.rb +1 -1
  76. data/{hobo_files/plugin/generators → rails_generators}/hobo_front_controller/templates/functional_test.rb +0 -0
  77. data/{hobo_files/plugin/generators → rails_generators}/hobo_front_controller/templates/helper.rb +0 -0
  78. data/rails_generators/hobo_front_controller/templates/index.dryml +25 -0
  79. data/{hobo_files/plugin/generators → rails_generators}/hobo_model/USAGE +0 -0
  80. data/{hobo_files/plugin/generators → rails_generators}/hobo_model/hobo_model_generator.rb +0 -0
  81. data/{hobo_files/plugin/generators → rails_generators}/hobo_model/templates/fixtures.yml +0 -0
  82. data/{hobo_files/plugin/generators → rails_generators}/hobo_model/templates/model.rb +0 -0
  83. data/{hobo_files/plugin/generators → rails_generators}/hobo_model/templates/unit_test.rb +0 -0
  84. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_controller/USAGE +0 -0
  85. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_controller/hobo_model_controller_generator.rb +0 -7
  86. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_controller/templates/controller.rb +0 -0
  87. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_controller/templates/functional_test.rb +0 -0
  88. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_controller/templates/helper.rb +0 -0
  89. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_resource/hobo_model_resource_generator.rb +0 -0
  90. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_resource/templates/controller.rb +0 -0
  91. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_resource/templates/functional_test.rb +0 -0
  92. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_resource/templates/helper.rb +0 -0
  93. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/hobo_rapid_generator.rb +21 -11
  94. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/IE7.js +1 -1
  95. data/rails_generators/hobo_rapid/templates/blank.gif +0 -0
  96. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/hobo-rapid.css +0 -0
  97. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/hobo-rapid.js +175 -104
  98. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/lowpro.js +0 -0
  99. data/rails_generators/hobo_rapid/templates/nicEditorIcons.gif +0 -0
  100. data/rails_generators/hobo_rapid/templates/nicedit.js +91 -0
  101. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/reset.css +0 -0
  102. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/images/fieldbg.gif +0 -0
  103. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/images/pencil.png +0 -0
  104. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/images/small_close.png +0 -0
  105. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/images/spinner.gif +0 -0
  106. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/stylesheets/clean.css +80 -71
  107. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/stylesheets/rapid-ui.css +6 -1
  108. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/views/clean.dryml +4 -4
  109. data/rails_generators/hobo_subsite/hobo_subsite_generator.rb +73 -0
  110. data/rails_generators/hobo_subsite/templates/application.dryml +1 -0
  111. data/rails_generators/hobo_subsite/templates/controller.rb +5 -0
  112. data/rails_generators/hobo_subsite/templates/site_taglib.dryml +13 -0
  113. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_controller/USAGE +0 -0
  114. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_controller/hobo_user_controller_generator.rb +0 -0
  115. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_controller/templates/controller.rb +0 -0
  116. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_controller/templates/functional_test.rb +0 -0
  117. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_controller/templates/helper.rb +0 -0
  118. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_model/USAGE +0 -0
  119. data/rails_generators/hobo_user_model/hobo_user_model_generator.rb +30 -0
  120. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_model/templates/fixtures.yml +0 -0
  121. data/rails_generators/hobo_user_model/templates/forgot_password.erb +10 -0
  122. data/rails_generators/hobo_user_model/templates/mailer.rb +14 -0
  123. data/rails_generators/hobo_user_model/templates/model.rb +55 -0
  124. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_model/templates/unit_test.rb +0 -0
  125. data/script/destroy +14 -0
  126. data/script/generate +14 -0
  127. data/{hobo_files/plugin/taglibs → taglibs}/core.dryml +6 -7
  128. data/{hobo_files/plugin/taglibs → taglibs}/rapid.dryml +36 -67
  129. data/{hobo_files/plugin/taglibs → taglibs}/rapid_document_tags.dryml +7 -24
  130. data/{hobo_files/plugin/taglibs → taglibs}/rapid_editing.dryml +51 -50
  131. data/{hobo_files/plugin/taglibs → taglibs}/rapid_forms.dryml +62 -56
  132. data/taglibs/rapid_generics.dryml +33 -0
  133. data/taglibs/rapid_lifecycles.dryml +43 -0
  134. data/{hobo_files/plugin/taglibs → taglibs}/rapid_navigation.dryml +23 -23
  135. data/taglibs/rapid_pages.dryml +183 -0
  136. data/{hobo_files/plugin/taglibs → taglibs}/rapid_plus.dryml +30 -5
  137. data/{hobo_files/plugin/taglibs → taglibs}/rapid_support.dryml +3 -4
  138. data/taglibs/rapid_user_pages.dryml +179 -0
  139. data/{hobo_files/plugin/tasks → tasks}/environments.rake +0 -0
  140. data/{hobo_files/plugin/tasks → tasks}/fix_dryml.rake +0 -0
  141. data/{hobo_files/plugin/tasks → tasks}/generate_tag_reference.rb +21 -22
  142. data/tasks/hobo_tasks.rake +32 -0
  143. data/test/test_generator_helper.rb +29 -0
  144. data/test/test_helper.rb +1 -0
  145. data/test/test_hobo_model_controller_generator.rb +56 -0
  146. data/{hobo_files/plugin/uninstall.rb → uninstall.rb} +0 -0
  147. metadata +240 -225
  148. data/README.txt +0 -18
  149. data/hobo_files/plugin/LICENSE.txt +0 -22
  150. data/hobo_files/plugin/Rakefile +0 -96
  151. data/hobo_files/plugin/generators/hobo_front_controller/templates/index.dryml +0 -24
  152. data/hobo_files/plugin/generators/hobo_front_controller/templates/search.dryml +0 -19
  153. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/banner.gif +0 -0
  154. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-bodytop.gif +0 -0
  155. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-corner-01.gif +0 -0
  156. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-corner-02.gif +0 -0
  157. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-corner-03.gif +0 -0
  158. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-corner-04.gif +0 -0
  159. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-shadow-bottom.gif +0 -0
  160. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-shadow-left.gif +0 -0
  161. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-shadow-right.gif +0 -0
  162. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-shadow-top.gif +0 -0
  163. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header-blue.gif +0 -0
  164. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header-dblue.gif +0 -0
  165. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header-green.gif +0 -0
  166. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header-purple.gif +0 -0
  167. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header-red.gif +0 -0
  168. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/logo.gif +0 -0
  169. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/plus.png +0 -0
  170. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/spinner.gif +0 -0
  171. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt-list-img-dblue.gif +0 -0
  172. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt-list-img-green.gif +0 -0
  173. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt-list-img-purple.gif +0 -0
  174. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt-list-img-red.gif +0 -0
  175. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-corner-01.gif +0 -0
  176. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-corner-02.gif +0 -0
  177. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-corner-03.gif +0 -0
  178. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-corner-04.gif +0 -0
  179. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-shadow-bottom.gif +0 -0
  180. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-shadow-left.gif +0 -0
  181. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-shadow-right.gif +0 -0
  182. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-shadow-top.gif +0 -0
  183. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/stylesheets/application.css +0 -400
  184. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/views/application.dryml +0 -96
  185. data/hobo_files/plugin/generators/hobo_user_model/hobo_user_model_generator.rb +0 -25
  186. data/hobo_files/plugin/generators/hobo_user_model/templates/model.rb +0 -56
  187. data/hobo_files/plugin/init.rb +0 -101
  188. data/hobo_files/plugin/lib/action_view_extensions/base.rb +0 -15
  189. data/hobo_files/plugin/lib/active_record/has_many_association.rb +0 -55
  190. data/hobo_files/plugin/lib/active_record/has_many_through_association.rb +0 -20
  191. data/hobo_files/plugin/lib/hobo/dryml.rb +0 -165
  192. data/hobo_files/plugin/lib/hobo/dryml/parser/document.rb +0 -53
  193. data/hobo_files/plugin/lib/hobo/scopes/association_proxy_extensions.rb +0 -33
  194. data/hobo_files/plugin/lib/hobo/scopes/defined_scope_proxy_extender.rb +0 -90
  195. data/hobo_files/plugin/lib/hobo/scopes/scope_reflection.rb +0 -18
  196. data/hobo_files/plugin/lib/hobo/scopes/scoped_proxy.rb +0 -55
  197. data/hobo_files/plugin/taglib-docs/core.markdown +0 -165
  198. data/hobo_files/plugin/taglib-docs/rapid.markdown +0 -677
  199. data/hobo_files/plugin/taglib-docs/rapid_document_tags.markdown +0 -240
  200. data/hobo_files/plugin/taglib-docs/rapid_editing.markdown +0 -418
  201. data/hobo_files/plugin/taglib-docs/rapid_forms.markdown +0 -562
  202. data/hobo_files/plugin/taglib-docs/rapid_generics.markdown +0 -187
  203. data/hobo_files/plugin/taglib-docs/rapid_navigation.markdown +0 -214
  204. data/hobo_files/plugin/taglib-docs/rapid_pages.markdown +0 -530
  205. data/hobo_files/plugin/taglib-docs/rapid_plus.markdown +0 -65
  206. data/hobo_files/plugin/taglib-docs/rapid_support.markdown +0 -50
  207. data/hobo_files/plugin/taglib-docs/rapid_user_pages.markdown +0 -129
  208. data/hobo_files/plugin/taglibs/rapid_generics.dryml +0 -117
  209. data/hobo_files/plugin/taglibs/rapid_pages.dryml +0 -359
  210. data/hobo_files/plugin/taglibs/rapid_user_pages.dryml +0 -104
  211. data/hobo_files/plugin/tasks/dump_fixtures.rake +0 -70
  212. data/hobo_files/plugin/tasks/hobo_tasks.rake +0 -17
@@ -0,0 +1,168 @@
1
+
2
+ # Gem::Specification for Hobo-0.8
3
+ # Originally generated by Echoe
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = %q{hobo}
7
+ s.version = "0.8"
8
+
9
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.authors = ["Tom Locke"]
11
+ s.date = %q{2008-09-03}
12
+ s.default_executable = %q{hobo}
13
+ s.description = %q{The web app builder for Rails}
14
+ s.email = %q{tom@tomlocke.com}
15
+ s.executables = ["hobo"]
16
+ s.extra_rdoc_files = ["bin/hobo", "lib/action_view_extensions/helpers/tag_helper.rb", "lib/active_record/association_collection.rb", "lib/active_record/association_proxy.rb", "lib/active_record/association_reflection.rb", "lib/extensions/test_case.rb", "lib/hobo/authentication_support.rb", "lib/hobo/bundle.rb", "lib/hobo/composite_model.rb", "lib/hobo/controller.rb", "lib/hobo/dev_controller.rb", "lib/hobo/dryml/dryml_builder.rb", "lib/hobo/dryml/dryml_generator.rb", "lib/hobo/dryml/dryml_support_controller.rb", "lib/hobo/dryml/parser/attribute.rb", "lib/hobo/dryml/parser/base_parser.rb", "lib/hobo/dryml/parser/document.rb", "lib/hobo/dryml/parser/element.rb", "lib/hobo/dryml/parser/elements.rb", "lib/hobo/dryml/parser/source.rb", "lib/hobo/dryml/parser/text.rb", "lib/hobo/dryml/parser/tree_parser.rb", "lib/hobo/dryml/parser.rb", "lib/hobo/dryml/part_context.rb", "lib/hobo/dryml/scoped_variables.rb", "lib/hobo/dryml/tag_parameters.rb", "lib/hobo/dryml/taglib.rb", "lib/hobo/dryml/template.rb", "lib/hobo/dryml/template_environment.rb", "lib/hobo/dryml/template_handler.rb", "lib/hobo/dryml.rb", "lib/hobo/find_for.rb", "lib/hobo/generator.rb", "lib/hobo/guest.rb", "lib/hobo/hobo_helper.rb", "lib/hobo/include_in_save.rb", "lib/hobo/lifecycles/actions.rb", "lib/hobo/lifecycles/creator.rb", "lib/hobo/lifecycles/lifecycle.rb", "lib/hobo/lifecycles/state.rb", "lib/hobo/lifecycles/transition.rb", "lib/hobo/lifecycles.rb", "lib/hobo/model.rb", "lib/hobo/model_controller.rb", "lib/hobo/model_router.rb", "lib/hobo/model_support.rb", "lib/hobo/rapid_helper.rb", "lib/hobo/scopes/apply_scopes.rb", "lib/hobo/scopes/association_proxy_extensions.rb", "lib/hobo/scopes/automatic_scopes.rb", "lib/hobo/scopes/named_scope_extensions.rb", "lib/hobo/scopes.rb", "lib/hobo/static_tags", "lib/hobo/undefined.rb", "lib/hobo/undefined_access_error.rb", "lib/hobo/user.rb", "lib/hobo/user_controller.rb", "lib/hobo.rb", "LICENSE.txt", "README", "tasks/environments.rake", "tasks/fix_dryml.rake", "tasks/generate_tag_reference.rb", "tasks/hobo_tasks.rake"]
17
+ s.files = ["bin/hobo", "CHANGES.txt", "dryml_generators/rapid/cards.dryml.erb", "dryml_generators/rapid/forms.dryml.erb", "dryml_generators/rapid/pages.dryml.erb", "init.rb", "lib/action_view_extensions/helpers/tag_helper.rb", "lib/active_record/association_collection.rb", "lib/active_record/association_proxy.rb", "lib/active_record/association_reflection.rb", "lib/extensions/test_case.rb", "lib/hobo/authentication_support.rb", "lib/hobo/bundle.rb", "lib/hobo/composite_model.rb", "lib/hobo/controller.rb", "lib/hobo/dev_controller.rb", "lib/hobo/dryml/dryml_builder.rb", "lib/hobo/dryml/dryml_generator.rb", "lib/hobo/dryml/dryml_support_controller.rb", "lib/hobo/dryml/parser/attribute.rb", "lib/hobo/dryml/parser/base_parser.rb", "lib/hobo/dryml/parser/document.rb", "lib/hobo/dryml/parser/element.rb", "lib/hobo/dryml/parser/elements.rb", "lib/hobo/dryml/parser/source.rb", "lib/hobo/dryml/parser/text.rb", "lib/hobo/dryml/parser/tree_parser.rb", "lib/hobo/dryml/parser.rb", "lib/hobo/dryml/part_context.rb", "lib/hobo/dryml/scoped_variables.rb", "lib/hobo/dryml/tag_parameters.rb", "lib/hobo/dryml/taglib.rb", "lib/hobo/dryml/template.rb", "lib/hobo/dryml/template_environment.rb", "lib/hobo/dryml/template_handler.rb", "lib/hobo/dryml.rb", "lib/hobo/find_for.rb", "lib/hobo/generator.rb", "lib/hobo/guest.rb", "lib/hobo/hobo_helper.rb", "lib/hobo/include_in_save.rb", "lib/hobo/lifecycles/actions.rb", "lib/hobo/lifecycles/creator.rb", "lib/hobo/lifecycles/lifecycle.rb", "lib/hobo/lifecycles/state.rb", "lib/hobo/lifecycles/transition.rb", "lib/hobo/lifecycles.rb", "lib/hobo/model.rb", "lib/hobo/model_controller.rb", "lib/hobo/model_router.rb", "lib/hobo/model_support.rb", "lib/hobo/rapid_helper.rb", "lib/hobo/scopes/apply_scopes.rb", "lib/hobo/scopes/association_proxy_extensions.rb", "lib/hobo/scopes/automatic_scopes.rb", "lib/hobo/scopes/named_scope_extensions.rb", "lib/hobo/scopes.rb", "lib/hobo/static_tags", "lib/hobo/undefined.rb", "lib/hobo/undefined_access_error.rb", "lib/hobo/user.rb", "lib/hobo/user_controller.rb", "lib/hobo.rb", "LICENSE.txt", "Manifest", "rails_generators/hobo/hobo_generator.rb", "rails_generators/hobo/templates/application.css", "rails_generators/hobo/templates/application.dryml", "rails_generators/hobo/templates/dryml-support.js", "rails_generators/hobo/templates/guest.rb", "rails_generators/hobo/templates/initializer.rb", "rails_generators/hobo_front_controller/hobo_front_controller_generator.rb", "rails_generators/hobo_front_controller/templates/controller.rb", "rails_generators/hobo_front_controller/templates/functional_test.rb", "rails_generators/hobo_front_controller/templates/helper.rb", "rails_generators/hobo_front_controller/templates/index.dryml", "rails_generators/hobo_front_controller/USAGE", "rails_generators/hobo_model/hobo_model_generator.rb", "rails_generators/hobo_model/templates/fixtures.yml", "rails_generators/hobo_model/templates/model.rb", "rails_generators/hobo_model/templates/unit_test.rb", "rails_generators/hobo_model/USAGE", "rails_generators/hobo_model_controller/hobo_model_controller_generator.rb", "rails_generators/hobo_model_controller/templates/controller.rb", "rails_generators/hobo_model_controller/templates/functional_test.rb", "rails_generators/hobo_model_controller/templates/helper.rb", "rails_generators/hobo_model_controller/USAGE", "rails_generators/hobo_model_resource/hobo_model_resource_generator.rb", "rails_generators/hobo_model_resource/templates/controller.rb", "rails_generators/hobo_model_resource/templates/functional_test.rb", "rails_generators/hobo_model_resource/templates/helper.rb", "rails_generators/hobo_rapid/hobo_rapid_generator.rb", "rails_generators/hobo_rapid/templates/blank.gif", "rails_generators/hobo_rapid/templates/hobo-rapid.css", "rails_generators/hobo_rapid/templates/hobo-rapid.js", "rails_generators/hobo_rapid/templates/IE7.js", "rails_generators/hobo_rapid/templates/lowpro.js", "rails_generators/hobo_rapid/templates/nicedit.js", "rails_generators/hobo_rapid/templates/nicEditorIcons.gif", "rails_generators/hobo_rapid/templates/reset.css", "rails_generators/hobo_rapid/templates/themes/clean/public/images/fieldbg.gif", "rails_generators/hobo_rapid/templates/themes/clean/public/images/pencil.png", "rails_generators/hobo_rapid/templates/themes/clean/public/images/small_close.png", "rails_generators/hobo_rapid/templates/themes/clean/public/images/spinner.gif", "rails_generators/hobo_rapid/templates/themes/clean/public/stylesheets/clean.css", "rails_generators/hobo_rapid/templates/themes/clean/public/stylesheets/rapid-ui.css", "rails_generators/hobo_rapid/templates/themes/clean/views/clean.dryml", "rails_generators/hobo_subsite/hobo_subsite_generator.rb", "rails_generators/hobo_subsite/templates/application.dryml", "rails_generators/hobo_subsite/templates/controller.rb", "rails_generators/hobo_subsite/templates/site_taglib.dryml", "rails_generators/hobo_user_controller/hobo_user_controller_generator.rb", "rails_generators/hobo_user_controller/templates/controller.rb", "rails_generators/hobo_user_controller/templates/functional_test.rb", "rails_generators/hobo_user_controller/templates/helper.rb", "rails_generators/hobo_user_controller/USAGE", "rails_generators/hobo_user_model/hobo_user_model_generator.rb", "rails_generators/hobo_user_model/templates/fixtures.yml", "rails_generators/hobo_user_model/templates/forgot_password.erb", "rails_generators/hobo_user_model/templates/mailer.rb", "rails_generators/hobo_user_model/templates/model.rb", "rails_generators/hobo_user_model/templates/unit_test.rb", "rails_generators/hobo_user_model/USAGE", "README", "script/destroy", "script/generate", "taglibs/core.dryml", "taglibs/rapid.dryml", "taglibs/rapid_document_tags.dryml", "taglibs/rapid_editing.dryml", "taglibs/rapid_forms.dryml", "taglibs/rapid_generics.dryml", "taglibs/rapid_lifecycles.dryml", "taglibs/rapid_navigation.dryml", "taglibs/rapid_pages.dryml", "taglibs/rapid_plus.dryml", "taglibs/rapid_support.dryml", "taglibs/rapid_user_pages.dryml", "tasks/environments.rake", "tasks/fix_dryml.rake", "tasks/generate_tag_reference.rb", "tasks/hobo_tasks.rake", "test/test_generator_helper.rb", "test/test_helper.rb", "test/test_hobo_model_controller_generator.rb", "uninstall.rb", "hobo.gemspec"]
18
+ s.has_rdoc = true
19
+ s.homepage = %q{http://hobocentral.net/}
20
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Hobo", "--main", "README"]
21
+ s.require_paths = ["lib"]
22
+ s.rubyforge_project = %q{hobo}
23
+ s.rubygems_version = %q{1.2.0}
24
+ s.summary = %q{The web app builder for Rails}
25
+ s.test_files = ["test/test_generator_helper.rb", "test/test_helper.rb", "test/test_hobo_model_controller_generator.rb"]
26
+
27
+ if s.respond_to? :specification_version then
28
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
29
+ s.specification_version = 2
30
+
31
+ if current_version >= 3 then
32
+ s.add_runtime_dependency(%q<hobosupport>, [">= 0.8"])
33
+ s.add_runtime_dependency(%q<hobofields>, [">= 0.8"])
34
+ s.add_runtime_dependency(%q<rails>, ["= 2.1"])
35
+ s.add_runtime_dependency(%q<mislav-will_paginate>, [">= 2.2.1"])
36
+ else
37
+ s.add_dependency(%q<hobosupport>, [">= 0.8"])
38
+ s.add_dependency(%q<hobofields>, [">= 0.8"])
39
+ s.add_dependency(%q<rails>, ["= 2.1"])
40
+ s.add_dependency(%q<mislav-will_paginate>, [">= 2.2.1"])
41
+ end
42
+ else
43
+ s.add_dependency(%q<hobosupport>, [">= 0.8"])
44
+ s.add_dependency(%q<hobofields>, [">= 0.8"])
45
+ s.add_dependency(%q<rails>, ["= 2.1"])
46
+ s.add_dependency(%q<mislav-will_paginate>, [">= 2.2.1"])
47
+ end
48
+ end
49
+
50
+
51
+ # # Original Rakefile source (requires the Echoe gem):
52
+ #
53
+ # require 'rake'
54
+ # require 'rake/rdoctask'
55
+ # require 'rake/testtask'
56
+ #
57
+ # load "tasks/generate_tag_reference.rb"
58
+ #
59
+ # desc 'Default: run specs.'
60
+ # task :default => :spec
61
+ #
62
+ # desc 'Generate documentation for the Hobo plugin.'
63
+ # Rake::RDocTask.new(:rdoc) do |rdoc|
64
+ # rdoc.rdoc_dir = 'rdoc'
65
+ # rdoc.title = 'Hobo'
66
+ # rdoc.options << '--line-numbers' << '--inline-source'
67
+ # rdoc.rdoc_files.include('README')
68
+ # rdoc.rdoc_files.include('lib/**/*.rb')
69
+ # end
70
+ #
71
+ # require 'echoe'
72
+ #
73
+ # Echoe.new('hobo') do |p|
74
+ # p.author = "Tom Locke"
75
+ # p.email = "tom@tomlocke.com"
76
+ # p.summary = "The web app builder for Rails"
77
+ # p.url = "http://hobocentral.net/"
78
+ # p.project = "hobo"
79
+ #
80
+ # p.changelog = "CHANGES.txt"
81
+ # p.version = "0.8"
82
+ #
83
+ # p.dependencies = [
84
+ # 'hobosupport >=0.8',
85
+ # 'hobofields >=0.8',
86
+ # 'rails =2.1',
87
+ # 'mislav-will_paginate >=2.2.1']
88
+ # end
89
+ #
90
+ #
91
+ #
92
+ #
93
+ # # --- RSpec --- #
94
+ #
95
+ # # In rails 1.2, plugins aren't available in the path until they're loaded.
96
+ # # Check to see if the rspec plugin is installed first and require
97
+ # # it if it is. If not, use the gem version.
98
+ # PLUGIN_DIR = File.dirname(__FILE__)
99
+ #
100
+ # rspec_base = File.expand_path(PLUGIN_DIR + '/spec/rails_root/vendor/plugins/rspec/lib')
101
+ # $LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
102
+ # require '../hobo_spec/rails_root/vendor/plugins/rspec/lib/spec/rake/spectask'
103
+ # require '../hobo_spec/rails_root/vendor/plugins/rspec/lib/spec/translator'
104
+ #
105
+ # spec_prereq = :noop # File.exist?(File.join(PLUGIN_DIR, 'config', 'database.yml')) ? "db:test:prepare" : :noop
106
+ # task :noop do
107
+ # end
108
+ #
109
+ # task :stats => "spec:statsetup"
110
+ #
111
+ # SPEC_HOME = "#{PLUGIN_DIR}/../hobo_spec"
112
+ #
113
+ # desc "Run all specs in spec directory (excluding plugin specs)"
114
+ # Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t|
115
+ # t.spec_opts = ['--options', "\"#{SPEC_HOME}/spec.opts\""]
116
+ # t.spec_files = FileList["#{SPEC_HOME}/unit/**/*_spec.rb"]
117
+ # end
118
+ #
119
+ # namespace :spec do
120
+ # desc "Run all specs in spec directory with RCov (excluding plugin specs)"
121
+ # Spec::Rake::SpecTask.new(:rcov) do |t|
122
+ # t.spec_opts = ['--options', "\"#{SPEC_HOME}/spec.opts\""]
123
+ # t.spec_files = FileList["#{SPEC_HOME}/unit/**/*_spec.rb"]
124
+ # t.rcov = true
125
+ # t.rcov_opts = ['--exclude', 'spec', '--rails']
126
+ # end
127
+ #
128
+ # desc "Print Specdoc for all specs (excluding plugin specs)"
129
+ # Spec::Rake::SpecTask.new(:doc) do |t|
130
+ # t.spec_opts = ["--format", "specdoc", "--dry-run"]
131
+ # t.spec_files = FileList["#{SPEC_HOME}/unit/**/*_spec.rb"]
132
+ # end
133
+ #
134
+ # [:models, :controllers, :views, :helpers].each do |sub|
135
+ # desc "Run the specs under spec/#{sub}"
136
+ # Spec::Rake::SpecTask.new(sub => spec_prereq) do |t|
137
+ # t.spec_opts = ['--options', "\"#{SPEC_HOME}/spec.opts\""]
138
+ # t.spec_files = FileList["#{SPEC_HOME}/#{sub}/**/*_spec.rb"]
139
+ # end
140
+ # end
141
+ #
142
+ # # Setup specs for stats
143
+ # task :statsetup do
144
+ # require 'code_statistics'
145
+ # ::STATS_DIRECTORIES << %w(Model\ specs spec/models)
146
+ # ::STATS_DIRECTORIES << %w(View\ specs spec/views)
147
+ # ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
148
+ # ::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
149
+ # ::CodeStatistics::TEST_TYPES << "Model specs"
150
+ # ::CodeStatistics::TEST_TYPES << "View specs"
151
+ # ::CodeStatistics::TEST_TYPES << "Controller specs"
152
+ # ::CodeStatistics::TEST_TYPES << "Helper specs"
153
+ # ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
154
+ # end
155
+ #
156
+ # namespace :db do
157
+ # namespace :fixtures do
158
+ # desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
159
+ # task :load => :environment do
160
+ # require 'active_record/fixtures'
161
+ # ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
162
+ # (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(SPEC_HOME, 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
163
+ # Fixtures.create_fixtures("#{SPEC_HOME}/fixtures", File.basename(fixture_file, '.*'))
164
+ # end
165
+ # end
166
+ # end
167
+ # end
168
+ # end
data/init.rb ADDED
@@ -0,0 +1,9 @@
1
+ require File.dirname(__FILE__) + "/lib/hobo"
2
+ require 'rails_generator'
3
+
4
+ # 'orrible but 'reative 'ack to allow generators to be in symlinked plugins
5
+ Rails::Generator::PathSource.class_eval do
6
+ def path
7
+ @path.gsub('**', '*/**')
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ module ActionView::Helpers::TagHelper
2
+ alias_method :tag_without_doctype, :tag
3
+ def tag(name, options = nil, open = false, escape = true)
4
+ open = !scope.xmldoctype if defined?(scope)
5
+ tag_without_doctype(name, options, open, escape)
6
+ end
7
+ end
@@ -0,0 +1,54 @@
1
+ module ActiveRecord
2
+ module Associations
3
+ class AssociationCollection
4
+
5
+ include Hobo::Scopes::ApplyScopes
6
+
7
+
8
+ def hobo_association_collection?
9
+ Hobo::Model.in?(@owner.class.included_modules)
10
+ end
11
+
12
+
13
+ def build_with_reverse_reflection(*args)
14
+ res = build_without_reverse_reflection(*args)
15
+ set_reverse_association(res) if hobo_association_collection?
16
+ res
17
+ end
18
+ alias_method_chain :build, :reverse_reflection
19
+
20
+
21
+ def new(attributes = {})
22
+ record = @reflection.klass.new(attributes)
23
+ if hobo_association_collection?
24
+ set_belongs_to_association_for(record)
25
+ set_reverse_association(record) unless proxy_reflection.options[:as]
26
+ end
27
+ record
28
+ end
29
+
30
+
31
+ def member_class
32
+ proxy_reflection.klass
33
+ end
34
+
35
+
36
+ def proxy_respond_to_with_automatic_scopes?(method, include_priv = false)
37
+ proxy_respond_to_without_automatic_scopes?(method, include_priv) || create_automatic_scope(method)
38
+ end
39
+ alias_method_chain :proxy_respond_to?, :automatic_scopes
40
+
41
+
42
+ private
43
+
44
+ def set_reverse_association(object)
45
+ if @owner.new_record? && (refl = @owner.class.reverse_reflection(@reflection.name))
46
+ bta = ActiveRecord::Associations::BelongsToAssociation.new(object, refl)
47
+ bta.replace(@owner)
48
+ object.instance_variable_set("@#{refl.name}", bta)
49
+ end
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -1,10 +1,18 @@
1
1
  module ActiveRecord
2
2
  module Associations
3
3
  class AssociationProxy #:nodoc:
4
-
4
+
5
+ def origin
6
+ proxy_owner
7
+ end
8
+
9
+ def origin_attribute
10
+ proxy_reflection.name
11
+ end
12
+
5
13
  private
6
-
7
-
14
+
15
+
8
16
  def raise_on_type_mismatch(record)
9
17
  # Don't complain if the interface type of a polymorphic association doesn't exist
10
18
  klass = @reflection.klass rescue nil
@@ -12,7 +20,7 @@ module ActiveRecord
12
20
  raise ActiveRecord::AssociationTypeMismatch, "#{@reflection.klass} expected, got #{record.class}"
13
21
  end
14
22
  end
15
-
23
+
16
24
  end
17
25
  end
18
26
  end
@@ -1,5 +1,11 @@
1
1
  class ActiveRecord::Reflection::AssociationReflection
2
-
2
+
3
3
  alias_method :association_name, :name
4
+
5
+ def safe_class
6
+ klass
7
+ rescue NameError
8
+ nil
9
+ end
4
10
 
5
11
  end
@@ -7,18 +7,18 @@ class Test::Unit::TestCase
7
7
  class_eval "def #{name}; #{model}(:#{name}); end"
8
8
  end
9
9
  end
10
-
10
+
11
11
  protected
12
12
 
13
13
  module HoboTesting
14
14
 
15
15
  class HoboHelpers
16
-
16
+
17
17
  def urlb
18
18
  "http://example.com"
19
19
  end
20
20
  end
21
-
21
+
22
22
  attr_reader :current_user
23
23
 
24
24
  def is_redirected_to(x)
@@ -41,12 +41,12 @@ class Test::Unit::TestCase
41
41
  get object_url(obj, action, params)
42
42
  assert_response :success
43
43
  end
44
-
44
+
45
45
  def cant_visit(obj, action=nil)
46
46
  get object_url(obj, action)
47
47
  assert_response :forbidden
48
48
  end
49
-
49
+
50
50
  def creates(klass, params)
51
51
  replace_objects_in_params!(params)
52
52
  post object_url(klass), klass.name.underscore => params
@@ -55,50 +55,50 @@ class Test::Unit::TestCase
55
55
  assert_response :redirect
56
56
  new_obj
57
57
  end
58
-
58
+
59
59
  def deletes(object)
60
60
  post object_url(object, "destroy")
61
61
  assert_raise(ActiveRecord::RecordNotFound) { object.class.find(object.id) }
62
62
  assert_response :redirect
63
63
  end
64
-
64
+
65
65
  def cant_create(klass, params)
66
66
  replace_objects_in_params!(params)
67
67
  post object_url(klass), klass.name.underscore => params
68
68
  assert_response :forbidden
69
69
  end
70
-
70
+
71
71
  def can_see(s)
72
72
  assert_select("body", Regexp.new(s.split.map { |w| Regexp.escape(w) }.join("\s*")),
73
73
  current_should("be able to see: #{s}"))
74
74
  end
75
-
75
+
76
76
  alias_method :sees, :can_see
77
-
77
+
78
78
  def cant_see(s)
79
79
  assert_select("body", { :text => Regexp.new(s.split.map { |w| Regexp.escape(w) }.join("\s*")), :count => 0 },
80
80
  current_should("not be able to see: #{s}"))
81
81
  end
82
-
82
+
83
83
  def creates_and_visits(klass, params)
84
84
  new_obj = creates(klass, params)
85
85
  visits(new_obj)
86
86
  new_obj
87
87
  end
88
-
88
+
89
89
  def calls_method(object, method, params={})
90
90
  post object_url(object, method), params
91
91
  assert_response :success
92
92
  end
93
-
93
+
94
94
  def current_should(s)
95
95
  "#{current_user.login} should #{s}"
96
96
  end
97
-
97
+
98
98
  def object_url(obj, action=nil, *param_hashes)
99
99
  HoboHelpers.new.send(:object_url, obj, action, *param_hashes)
100
100
  end
101
-
101
+
102
102
  def replace_objects_in_params!(hash)
103
103
  hash.each do |k,v|
104
104
  if v.is_a? ActiveRecord::Base
@@ -108,7 +108,7 @@ class Test::Unit::TestCase
108
108
  end
109
109
  end
110
110
  end
111
-
111
+
112
112
  end
113
113
 
114
114
  def new_session
@@ -125,5 +125,5 @@ class Test::Unit::TestCase
125
125
  yield sess if block_given?
126
126
  end
127
127
  end
128
-
128
+
129
129
  end
@@ -1,18 +1,43 @@
1
+ # gem dependencies
2
+ require 'hobosupport'
3
+ require 'hobofields'
4
+ begin
5
+ require 'will_paginate'
6
+ rescue MissingSourceFile
7
+ # OK, Hobo won't do pagination then
8
+ end
9
+
10
+ Dependencies.load_paths |= [ File.dirname(__FILE__) ]
11
+
12
+ # Hobo can be installed in /vendor/hobo, /vendor/plugins/hobo, vendor/plugins/hobo/hobo, etc.
13
+ ::HOBO_ROOT = File.expand_path(File.dirname(__FILE__) + "/..")
14
+
15
+
16
+ # Modules that must *not* be auto-reloaded by activesupport
17
+ # (explicitly requiring them means they're never unloaded)
18
+ require 'hobo/model_router'
19
+ require 'hobo/undefined'
20
+ require 'hobo/user'
21
+ require 'hobo/dryml'
22
+ require 'hobo/dryml/template'
23
+ require 'hobo/dryml/dryml_generator'
24
+
1
25
  class HoboError < RuntimeError; end
2
26
 
3
27
  module Hobo
4
-
5
- VERSION = "0.7.5"
28
+
29
+ VERSION = "0.8"
6
30
 
7
31
  class RawJs < String; end
8
32
 
9
33
  @models = []
10
-
34
+
11
35
  class << self
12
36
 
37
+
13
38
  attr_accessor :current_theme
14
39
  attr_writer :developer_features
15
-
40
+
16
41
 
17
42
  def developer_features?
18
43
  @developer_features
@@ -22,38 +47,17 @@ module Hobo
22
47
  def raw_js(s)
23
48
  RawJs.new(s)
24
49
  end
25
-
26
-
50
+
51
+
27
52
  def user_model=(model)
28
53
  @user_model = model && model.name
29
54
  end
30
55
 
31
-
56
+
32
57
  def user_model
33
58
  @user_model && @user_model.constantize
34
59
  end
35
60
 
36
-
37
- def models=(models)
38
- @models = models.*.name
39
- end
40
-
41
-
42
- def models
43
- unless @models_loaded
44
- Dir.entries("#{RAILS_ROOT}/app/models/").each do |f|
45
- f =~ /^[a-zA-Z_][a-zA-Z0-9_]*\.rb$/ and f.sub(/.rb$/, '').camelize.constantize
46
- end
47
- @models_loaded = true
48
- end
49
- @models.*.constantize
50
- end
51
-
52
-
53
- def register_model(model)
54
- @models << model.name unless @models.include? model.name
55
- end
56
-
57
61
 
58
62
  def object_from_dom_id(dom_id)
59
63
  return nil if dom_id == 'nil'
@@ -63,7 +67,7 @@ module Hobo
63
67
  if name
64
68
  model_class = name.camelize.constantize rescue (raise ArgumentError.new("no such class in dom-id"))
65
69
  return nil unless model_class
66
-
70
+
67
71
  if id
68
72
  obj = if false and attr and model_class.reflections[attr.to_sym].klass.superclass == ActiveRecord::Base
69
73
  # DISABLED - Eager loading is broken - doesn't support ordering
@@ -85,24 +89,29 @@ module Hobo
85
89
  end
86
90
 
87
91
  def find_by_search(query, search_targets=nil)
88
- search_targets ||=
92
+ search_targets ||=
89
93
  begin
90
94
  # FIXME: This should interrogate the model-router directly, there's no need to enumerate models
91
95
  # By default, search all models, but filter out...
92
- Hobo.models.select do |m|
93
- ModelRouter.linkable?(m, :show) && # ...non-linkables
94
- m.search_columns.any? # and models with no search-columns
96
+ Hobo::Model.all_models.select do |m|
97
+ ModelRouter.linkable?(m, :show) && # ...non-linkables
98
+ m.search_columns.any? # and models with no search-columns
95
99
  end
96
100
  end
97
-
101
+
98
102
  query_words = ActiveRecord::Base.connection.quote_string(query).split
99
-
103
+
100
104
  search_targets.build_hash do |search_target|
101
- conditions = query_words.map do |word|
102
- "(" + search_target.search_columns.map { |column| %(#{column} like "%#{word}%") }.join(" or ") + ")"
103
- end.join(" and ")
104
-
105
- results = search_target.find(:all, :conditions => conditions)
105
+ conditions = []
106
+ parameters = []
107
+ query_words.each do |word|
108
+ column_queries = search_target.search_columns.map { |column| "#{column} like ?" }
109
+ conditions << "(" + column_queries.join(" or ") + ")"
110
+ parameters.concat(["%#{word}%"] * column_queries.length)
111
+ end
112
+ conditions = conditions.join(" and ")
113
+
114
+ results = search_target.find(:all, :conditions => [conditions, *parameters])
106
115
  [search_target.name, results] unless results.empty?
107
116
  end
108
117
  end
@@ -111,12 +120,6 @@ module Hobo
111
120
  Hobo::ModelRouter.add_routes(m)
112
121
  end
113
122
 
114
-
115
- # FIXME: This method won't be needed
116
- def all_models
117
- Hobo.models.map { |m| m.name.underscore }
118
- end
119
-
120
123
 
121
124
  def simple_has_many_association?(array_or_reflection)
122
125
  refl = array_or_reflection.respond_to?(:proxy_reflection) ? array_or_reflection.proxy_reflection : array_or_reflection
@@ -125,37 +128,36 @@ module Hobo
125
128
  (not refl.through_reflection) and
126
129
  (not refl.options[:conditions])
127
130
  end
128
-
129
-
131
+
132
+
130
133
  def can_create_in_association?(array_or_reflection)
131
- refl =
134
+ refl =
132
135
  (array_or_reflection.is_a?(ActiveRecord::Reflection::AssociationReflection) and array_or_reflection) or
133
136
  array_or_reflection.try.proxy_reflection or
134
137
  (origin = array_or_reflection.try.origin and origin.send(array_or_reflection.origin_attribute).try.proxy_reflection)
135
138
 
136
- refl && refl.macro == :has_many && (!refl.through_reflection) && (!refl.options[:conditions])
139
+ refl && refl.macro == :has_many && (!refl.through_reflection) && (!refl.options[:conditions])
137
140
  end
138
-
139
-
141
+
142
+
140
143
  def get_field(object, field)
141
144
  return nil if object.nil?
142
- if field.to_s =~ /^\d+$/
145
+ field_str = field.to_s
146
+ if field_str =~ /^\d+$/
143
147
  object[field.to_i]
144
148
  else
145
149
  object.send(field)
146
150
  end
147
151
  end
148
-
149
-
152
+
153
+
150
154
  def get_field_path(object, path)
151
- path = if path.is_a? Array
152
- path
153
- elsif path.is_a? String
155
+ path = if path.is_a? String
154
156
  path.split('.')
155
157
  else
156
- [path]
158
+ Array(path)
157
159
  end
158
-
160
+
159
161
  field, parent = nil
160
162
  path.each do |field|
161
163
  return nil if object.nil?
@@ -164,8 +166,8 @@ module Hobo
164
166
  end
165
167
  [parent, field, object]
166
168
  end
167
-
168
-
169
+
170
+
169
171
  # --- Permissions --- #
170
172
 
171
173
 
@@ -191,27 +193,28 @@ module Hobo
191
193
 
192
194
 
193
195
  def can_edit?(person, object, field)
196
+ return true if object.try.exempt_from_edit_checks?
194
197
  # Can't view implies can't edit
195
198
  return false if !can_view?(person, object, field)
196
-
199
+
197
200
  if field.nil?
198
201
  if object.has_hobo_method?(:editable_by?)
199
- object.editable_by?(person)
202
+ object.editable_by?(person)
200
203
  elsif object.has_hobo_method?(:updatable_by?)
201
204
  object.updatable_by?(person, nil)
202
205
  else
203
206
  false
204
207
  end
205
-
208
+
206
209
  else
207
- setter = "#{field.to_s.sub /\?$/, ''}="
208
- return false if !object.respond_to?(setter)
209
-
210
+ attribute_name = field.to_s.sub /\?$/, ''
211
+ return false if !object.respond_to?("#{attribute_name}=")
212
+
210
213
  refl = object.class.reflections[field.to_sym] if object.is_a?(ActiveRecord::Base)
211
-
214
+
212
215
  # has_one and polymorphic associations are not editable (for now)
213
216
  return false if refl and (refl.options[:polymorphic] or refl.macro == :has_one)
214
-
217
+
215
218
  if object.has_hobo_method?("#{field}_editable_by?")
216
219
  object.send("#{field}_editable_by?", person)
217
220
  elsif object.has_hobo_method?(:editable_by?)
@@ -222,28 +225,22 @@ module Hobo
222
225
  false
223
226
  else
224
227
  # Fake an edit test by setting the field in question to
225
- # Hobo::Undefined and then testing for update permission
228
+ # Hobo::Undefined and then testing for update/create permission
226
229
  current = object.send(field)
227
230
  new = object.duplicate
228
231
 
229
- begin
230
- # Setting the undefined value can sometimes result in an
231
- # UndefinedAccessError. In that case we have no choice but
232
- # return false.
233
- new.send(setter, if current == true
234
- false
235
- elsif current == false
236
- true
237
- elsif refl and refl.macro == :belongs_to
238
- Hobo::Undefined.new(refl.klass)
239
- else
240
- Hobo::Undefined.new
241
- end)
242
- rescue Hobo::UndefinedAccessError
243
- raise HoboError, ("#{object.class.name}##{field} does not support undefined assignements, " +
244
- "define #{field}_editable_by?(user)")
245
- end
246
-
232
+ edit_test_value = if current == true
233
+ false
234
+ elsif current == false || (current.nil? && object.class.try.attr_type(field) == Hobo::Boolean)
235
+ true
236
+ elsif refl and refl.macro == :belongs_to
237
+ Hobo::Undefined.new(refl.klass)
238
+ else
239
+ Hobo::Undefined.new
240
+ end
241
+
242
+ new.metaclass.send(:define_method, attribute_name) { edit_test_value }
243
+
247
244
  begin
248
245
  if object.new_record?
249
246
  check_permission(:create, person, new)
@@ -251,6 +248,8 @@ module Hobo
251
248
  check_permission(:update, person, object, new)
252
249
  end
253
250
  rescue Hobo::UndefinedAccessError
251
+ # The permission method performed some test on the undefined value
252
+ # so this field is not editable
254
253
  false
255
254
  end
256
255
  end
@@ -277,7 +276,7 @@ module Hobo
277
276
  _, _, object = get_field_path(object, path[0..-2])
278
277
  field = path.last
279
278
  end
280
-
279
+
281
280
  if field
282
281
  field = field.to_sym if field.is_a? String
283
282
  return false if object.class.respond_to?(:never_show?) && object.class.never_show?(field)
@@ -298,18 +297,18 @@ module Hobo
298
297
  viewable
299
298
  end
300
299
  end
301
-
302
-
300
+
301
+
303
302
  def can_call?(person, object, method)
304
303
  return true if person.has_hobo_method?(:super_user?) && person.super_user?
305
304
 
306
305
  m = "#{method}_callable_by?"
307
306
  object.has_hobo_method?(m) && object.send(m, person)
308
- end
309
-
307
+ end
308
+
310
309
  # --- end permissions -- #
311
-
312
-
310
+
311
+
313
312
  def static_tags
314
313
  @static_tags ||= begin
315
314
  path = if FileTest.exists?("#{RAILS_ROOT}/config/dryml_static_tags.txt")
@@ -320,16 +319,22 @@ module Hobo
320
319
  File.readlines(path).*.chop
321
320
  end
322
321
  end
323
-
324
- attr_writer :static_tags
325
322
 
323
+ attr_writer :static_tags
326
324
 
325
+
326
+ def subsites
327
+ # Any directory inside app/controllers defines a subsite
328
+ @subsites ||= Dir["#{RAILS_ROOT}/app/controllers/*"].map { |f| File.basename(f) if File.directory?(f) }.compact
329
+ end
330
+
331
+
327
332
  private
328
333
 
329
334
 
330
335
  def check_permission(permission, person, object, *args)
331
336
  return true if person.has_hobo_method?(:super_user?) and person.super_user?
332
-
337
+
333
338
  return true if permission == :view && !(object.is_a?(ActiveRecord::Base) || object.is_a?(Hobo::CompositeModel))
334
339
 
335
340
  obj_method = case permission
@@ -358,7 +363,95 @@ module Hobo
358
363
  end
359
364
  end
360
365
 
366
+ public
367
+
368
+ def enable
369
+ # Rails monkey patches
370
+ require 'active_record/association_collection'
371
+ require 'active_record/association_proxy'
372
+ require 'active_record/association_reflection'
373
+ require 'action_view_extensions/helpers/tag_helper'
374
+
375
+ Hobo::Dryml.enable
376
+
377
+ Hobo.developer_features = RAILS_ENV.in?(["development", "test"]) if Hobo.developer_features?.nil?
378
+
379
+ require 'hobo/dev_controller' if RAILS_ENV == Hobo.developer_features?
380
+
381
+ ActionController::Base.send(:include, Hobo::ControllerExtensions)
382
+ ActiveRecord::Base.send(:include, Hobo::ModelExtensions)
383
+ end
384
+
361
385
  end
362
-
363
386
 
387
+ ControllerExtensions = classy_module do
388
+ def self.hobo_user_controller(model=nil)
389
+ @model = model
390
+ include Hobo::ModelController
391
+ include Hobo::UserController
392
+ end
393
+
394
+ def self.hobo_model_controller(model=nil)
395
+ @model = model
396
+ include Hobo::ModelController
397
+ end
398
+
399
+ def self.hobo_controller
400
+ include Hobo::Controller
401
+ end
402
+
403
+ end
404
+
405
+
406
+ ModelExtensions = classy_module do
407
+ def self.hobo_model
408
+ include Hobo::Model
409
+ end
410
+ def self.hobo_user_model
411
+ include Hobo::Model
412
+ include Hobo::User
413
+ end
414
+ end
415
+
416
+
417
+ # Empty class to represent the boolean type.
418
+ class Boolean; end
419
+
420
+
421
+ end
422
+
423
+
424
+ if defined? HoboFields
425
+ HoboFields.never_wrap(Hobo::Undefined)
364
426
  end
427
+
428
+
429
+ # Add support for type metadata to arrays
430
+ class ::Array
431
+
432
+ attr_accessor :member_class, :origin, :origin_attribute
433
+
434
+ def to_url_path
435
+ base_path = origin_object.try.to_url_path
436
+ "#{base_path}/#{origin_attribute}" unless base_path.blank?
437
+ end
438
+
439
+ def typed_id
440
+ origin and origin_id = origin.try.typed_id and "#{origin_id}_#{origin_attribute}"
441
+ end
442
+
443
+ end
444
+
445
+
446
+ module ::Enumerable
447
+ def group_by_with_metadata(&block)
448
+ group_by_without_metadata(&block).each do |k,v|
449
+ v.origin = origin
450
+ v.origin_attribute = origin_attribute
451
+ v.member_class = member_class
452
+ end
453
+ end
454
+ alias_method_chain :group_by, :metadata
455
+ end
456
+
457
+ Hobo.enable if defined?(Rails)