hobo 1.1.0 → 1.3.0.RC

Sign up to get free protection for your applications and to get access to all the features.
Files changed (278) hide show
  1. data/CHANGES.txt +238 -287
  2. data/Rakefile +14 -31
  3. data/VERSION +1 -0
  4. data/{lib/hobo → app/controllers}/dev_controller.rb +6 -6
  5. data/app/controllers/dryml_support_controller.rb +13 -0
  6. data/{rails_generators/hobo_front_controller/templates → app/views/dev}/summary.dryml +7 -10
  7. data/bin/hobo +12 -144
  8. data/config/initializers/inflections.rb +3 -0
  9. data/config/routes.rb +6 -0
  10. data/{doctest → doctests}/hobo/lifecycles.rdoctest +40 -59
  11. data/{doctest → doctests/hobo}/model.rdoctest +33 -40
  12. data/{doctest → doctests/hobo}/multi_model_forms.rdoctest +15 -19
  13. data/{doctest → doctests/hobo}/scopes.rdoctest +27 -41
  14. data/doctests/prepare_testapp.rb +8 -0
  15. data/hobo.gemspec +26 -199
  16. data/lib/generators/hobo/activation_email.rb +11 -0
  17. data/lib/generators/hobo/admin_subsite/admin_subsite_generator.rb +35 -0
  18. data/lib/generators/hobo/admin_subsite/templates/admin.css +20 -0
  19. data/lib/generators/hobo/admin_subsite/templates/admin_tag_injection.erb +10 -0
  20. data/{rails_generators/hobo_admin_site → lib/generators/hobo/admin_subsite}/templates/application.dryml +0 -0
  21. data/{rails_generators/hobo_admin_site/templates/controller.rb → lib/generators/hobo/admin_subsite/templates/controller.rb.erb} +5 -5
  22. data/lib/generators/hobo/admin_subsite/templates/users_index.dryml +7 -0
  23. data/lib/generators/hobo/assets/assets_generator.rb +18 -0
  24. data/{rails_generators/hobo → lib/generators/hobo/assets}/templates/application.css +0 -0
  25. data/lib/generators/hobo/assets/templates/application.dryml.erb +9 -0
  26. data/{rails_generators/hobo → lib/generators/hobo/assets}/templates/dryml-support.js +2 -2
  27. data/lib/generators/hobo/assets/templates/dryml_taglibs_initializer.rb +1 -0
  28. data/lib/generators/hobo/assets/templates/en_injection.yml +19 -0
  29. data/{rails_generators/hobo → lib/generators/hobo/assets}/templates/guest.rb +1 -1
  30. data/lib/generators/hobo/controller.rb +35 -0
  31. data/lib/generators/hobo/controller/controller_generator.rb +6 -0
  32. data/lib/generators/hobo/controller/templates/controller.rb.erb +7 -0
  33. data/{rails_generators/hobo_front_controller → lib/generators/hobo/front_controller}/USAGE +0 -0
  34. data/lib/generators/hobo/front_controller/front_controller_generator.rb +55 -0
  35. data/{rails_generators/hobo_front_controller/templates/controller.rb → lib/generators/hobo/front_controller/templates/controller.rb.erb} +0 -0
  36. data/{rails_generators/hobo_front_controller → lib/generators/hobo/front_controller}/templates/index.dryml +6 -12
  37. data/lib/generators/hobo/i18n/i18n_generator.rb +35 -0
  38. data/lib/generators/hobo/i18n/templates/app.de.yml +30 -0
  39. data/lib/generators/hobo/i18n/templates/app.en.yml +25 -0
  40. data/lib/generators/hobo/i18n/templates/app.es.yml +31 -0
  41. data/lib/generators/hobo/i18n/templates/app.fr.yml +26 -0
  42. data/lib/generators/hobo/i18n/templates/app.it.yml +28 -0
  43. data/lib/generators/hobo/i18n/templates/app.pt-PT.yml +25 -0
  44. data/lib/generators/hobo/i18n/templates/app.ru.yml +24 -0
  45. data/lib/generators/hobo/i18n/templates/hobo.de.yml +204 -0
  46. data/lib/generators/hobo/i18n/templates/hobo.en.yml +195 -0
  47. data/lib/generators/hobo/i18n/templates/hobo.es.yml +202 -0
  48. data/lib/generators/hobo/i18n/templates/hobo.fr.yml +195 -0
  49. data/lib/generators/hobo/i18n/templates/hobo.it.yml +202 -0
  50. data/lib/generators/hobo/i18n/templates/hobo.pt-PT.yml +196 -0
  51. data/lib/generators/hobo/i18n/templates/hobo.ru.yml +200 -0
  52. data/lib/generators/hobo/invite_only.rb +18 -0
  53. data/lib/generators/hobo/model/USAGE +19 -0
  54. data/lib/generators/hobo/model/model_generator.rb +11 -0
  55. data/{rails_generators/hobo_model/templates/model.rb → lib/generators/hobo/model/templates/model_injection.rb.erb} +0 -2
  56. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/USAGE +0 -0
  57. data/lib/generators/hobo/rapid/rapid_generator.rb +24 -0
  58. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/IE7.js +0 -0
  59. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/blank.gif +0 -0
  60. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/hobo-rapid.css +0 -0
  61. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/hobo-rapid.js +65 -65
  62. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/ie7-recalc.js +21 -21
  63. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/lowpro.js +31 -31
  64. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/reset.css +1 -1
  65. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/100-ACD3E6-DBE1E5-H.png +0 -0
  66. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/100-DBE1E5-FCFEF5-H.png +0 -0
  67. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/300-3B5F87-ACD3E6-H.png +0 -0
  68. data/{rails_generators/hobo_rapid/templates/themes/clean → lib/generators/hobo/rapid/templates/themes/clean-sidemenu}/public/images/spinner.gif +0 -0
  69. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/stylesheets/clean-sidemenu.css +81 -0
  70. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/views/clean-sidemenu.dryml +30 -0
  71. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/101-3B5F87-ACD3E6.png +0 -0
  72. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/30-3E547A-242E42.png +0 -0
  73. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/30-DBE1E5-FCFEF5.png +0 -0
  74. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/300-ACD3E6-fff.png +0 -0
  75. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/50-ACD3E6-fff.png +0 -0
  76. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/fieldbg.gif +0 -0
  77. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/pencil.png +0 -0
  78. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/small_close.png +0 -0
  79. data/lib/generators/hobo/rapid/templates/themes/clean/public/images/spinner.gif +0 -0
  80. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/stylesheets/clean.css +16 -16
  81. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/stylesheets/rapid-ui.css +3 -3
  82. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/views/clean.dryml +1 -1
  83. data/lib/generators/hobo/resource/resource_generator.rb +23 -0
  84. data/lib/generators/hobo/routes/USAGE +9 -0
  85. data/lib/generators/hobo/routes/router.rb +115 -0
  86. data/lib/generators/hobo/routes/routes_generator.rb +40 -0
  87. data/lib/generators/hobo/routes/templates/hobo_routes.rb.erb +33 -0
  88. data/lib/generators/hobo/setup_wizard/USAGE +4 -0
  89. data/lib/generators/hobo/setup_wizard/setup_wizard_generator.rb +274 -0
  90. data/lib/generators/hobo/subsite.rb +48 -0
  91. data/lib/generators/hobo/subsite/subsite_generator.rb +16 -0
  92. data/{rails_generators/hobo_subsite → lib/generators/hobo/subsite}/templates/application.dryml +0 -0
  93. data/{rails_generators/hobo_subsite/templates/controller.rb → lib/generators/hobo/subsite/templates/controller.rb.erb} +1 -1
  94. data/lib/generators/hobo/subsite_taglib/subsite_taglib_generator.rb +16 -0
  95. data/{rails_generators/hobo_admin_site/templates/site_taglib.dryml → lib/generators/hobo/subsite_taglib/templates/taglib.dryml.erb} +9 -10
  96. data/lib/generators/hobo/taglib.rb +12 -0
  97. data/lib/generators/hobo/test_framework/test_framework_generator.rb +72 -0
  98. data/lib/generators/hobo/test_options.rb +19 -0
  99. data/{rails_generators/hobo_user_controller → lib/generators/hobo/user_controller}/templates/accept_invitation.dryml +0 -0
  100. data/lib/generators/hobo/user_controller/templates/controller.rb.erb +31 -0
  101. data/lib/generators/hobo/user_controller/user_controller_generator.rb +25 -0
  102. data/lib/generators/hobo/user_mailer/templates/activation.erb +9 -0
  103. data/{rails_generators/hobo_user_model → lib/generators/hobo/user_mailer}/templates/forgot_password.erb +2 -2
  104. data/{rails_generators/hobo_user_model → lib/generators/hobo/user_mailer}/templates/invite.erb +2 -2
  105. data/lib/generators/hobo/user_mailer/templates/mailer.rb.erb +25 -0
  106. data/lib/generators/hobo/user_mailer/user_mailer_generator.rb +33 -0
  107. data/lib/generators/hobo/user_model/USAGE +12 -0
  108. data/{rails_generators/hobo_user_model/templates/model.rb → lib/generators/hobo/user_model/templates/model_injection.rb.erb} +40 -20
  109. data/lib/generators/hobo/user_model/user_model_generator.rb +23 -0
  110. data/lib/generators/hobo/user_resource/user_resource_generator.rb +27 -0
  111. data/lib/hobo.rb +29 -129
  112. data/lib/hobo/controller.rb +37 -47
  113. data/lib/hobo/controller/authentication_support.rb +109 -0
  114. data/lib/hobo/{model_controller.rb → controller/model.rb} +71 -79
  115. data/lib/hobo/{user_controller.rb → controller/user.rb} +59 -49
  116. data/lib/hobo/engine.rb +80 -0
  117. data/lib/hobo/extensions/action_controller/hobo_methods.rb +44 -0
  118. data/lib/hobo/extensions/action_mailer/helper.rb +38 -0
  119. data/lib/{action_view_extensions/helpers → hobo/extensions/action_view}/tag_helper.rb +5 -2
  120. data/lib/hobo/extensions/action_view/translation_helper.rb +25 -0
  121. data/lib/hobo/extensions/active_model/name.rb +16 -0
  122. data/lib/hobo/extensions/active_model/translation.rb +35 -0
  123. data/lib/{active_record/association_collection.rb → hobo/extensions/active_record/associations/collection.rb} +8 -17
  124. data/lib/{active_record/association_proxy.rb → hobo/extensions/active_record/associations/proxy.rb} +6 -7
  125. data/lib/hobo/extensions/active_record/associations/reflection.rb +23 -0
  126. data/lib/hobo/extensions/active_record/associations/scope.rb +35 -0
  127. data/lib/hobo/extensions/active_record/hobo_methods.rb +11 -0
  128. data/lib/hobo/extensions/active_record/permissions.rb +159 -0
  129. data/lib/hobo/extensions/active_record/relation_with_origin.rb +28 -0
  130. data/lib/hobo/extensions/array.rb +27 -0
  131. data/lib/hobo/extensions/enumerable.rb +12 -0
  132. data/lib/hobo/extensions/i18n.rb +17 -0
  133. data/lib/hobo/{hobo_helper.rb → helper.rb} +58 -31
  134. data/lib/hobo/helper/translations.rb +54 -0
  135. data/lib/hobo/helper/translations/normalizer.rb +39 -0
  136. data/lib/hobo/model.rb +61 -95
  137. data/lib/hobo/model/accessible_associations.rb +178 -0
  138. data/lib/hobo/{find_for.rb → model/find_for.rb} +17 -17
  139. data/lib/hobo/model/guest.rb +25 -0
  140. data/lib/hobo/model/include_in_save.rb +55 -0
  141. data/lib/hobo/model/lifecycles.rb +119 -0
  142. data/lib/hobo/model/lifecycles/actions.rb +146 -0
  143. data/lib/hobo/model/lifecycles/creator.rb +74 -0
  144. data/lib/hobo/model/lifecycles/lifecycle.rb +243 -0
  145. data/lib/hobo/model/lifecycles/state.rb +22 -0
  146. data/lib/hobo/model/lifecycles/transition.rb +70 -0
  147. data/lib/hobo/model/permissions.rb +448 -0
  148. data/lib/hobo/model/scopes.rb +38 -0
  149. data/lib/hobo/model/scopes/apply_scopes.rb +21 -0
  150. data/lib/hobo/model/scopes/automatic_scopes.rb +428 -0
  151. data/lib/hobo/model/user_base.rb +184 -0
  152. data/lib/hobo/model/view_hints.rb +123 -0
  153. data/{rapid_generators → lib/hobo/rapid/generators}/rapid/cards.dryml.erb +2 -2
  154. data/{rapid_generators → lib/hobo/rapid/generators}/rapid/forms.dryml.erb +3 -3
  155. data/{rapid_generators → lib/hobo/rapid/generators}/rapid/pages.dryml.erb +38 -51
  156. data/lib/hobo/rapid/helper.rb +166 -0
  157. data/{taglibs → lib/hobo/rapid/taglibs}/rapid.dryml +6 -5
  158. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_core.dryml +286 -118
  159. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_document_tags.dryml +2 -2
  160. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_editing.dryml +45 -45
  161. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_forms.dryml +190 -158
  162. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_generics.dryml +12 -9
  163. data/lib/hobo/rapid/taglibs/rapid_i18n.dryml +107 -0
  164. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_lifecycles.dryml +7 -7
  165. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_navigation.dryml +15 -15
  166. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_pages.dryml +37 -36
  167. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_plus.dryml +107 -43
  168. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_summary.dryml +28 -57
  169. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_support.dryml +9 -9
  170. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_user_pages.dryml +41 -40
  171. data/lib/hobo/routes.rb +31 -0
  172. data/{doctest → test/doctest}/hobo/hobo_helper.rdoctest +11 -11
  173. data/test/irt/generators/admin_subsite.irt +27 -0
  174. data/test/irt/generators/assets.irt +16 -0
  175. data/test/irt/generators/controller.irt +6 -0
  176. data/test/irt/generators/front_controller.irt +30 -0
  177. data/test/irt/generators/helper.rb +31 -0
  178. data/test/irt/generators/model.irt +28 -0
  179. data/test/irt/generators/partials/_account_user_model_tests.rb +21 -0
  180. data/test/irt/generators/partials/_accounts_users_controller_tests.rb +15 -0
  181. data/test/irt/generators/partials/_default_user_model_tests.rb +21 -0
  182. data/test/irt/generators/partials/_default_users_controller_tests.rb +16 -0
  183. data/test/irt/generators/partials/_house_controller_tests.rb +15 -0
  184. data/test/irt/generators/partials/_house_model_tests.rb +18 -0
  185. data/test/irt/generators/partials/_subsite_taglib_admin.rb +4 -0
  186. data/test/irt/generators/partials/_subsite_taglib_admin_invite_only.rb +3 -0
  187. data/test/irt/generators/partials/_subsite_taglib_noopt.rb +4 -0
  188. data/test/irt/generators/partials/_subsite_taglib_variables.rb +27 -0
  189. data/test/irt/generators/partials/_user_mailer_tests.rb +19 -0
  190. data/test/irt/generators/rapid.irt +29 -0
  191. data/test/irt/generators/resource.irt +8 -0
  192. data/test/irt/generators/subsite.irt +52 -0
  193. data/test/irt/generators/subsite_taglib.irt +23 -0
  194. data/test/irt/generators/test_framework.irt +62 -0
  195. data/test/irt/generators/user_controller.irt +10 -0
  196. data/test/irt/generators/user_mailer.irt +20 -0
  197. data/test/irt/generators/user_model.irt +10 -0
  198. data/test/irt/generators/user_resource.irt +14 -0
  199. data/test/irt/readme.txt +7 -0
  200. data/test/permissions/models/models.rb +27 -24
  201. data/test/permissions/test_permissions.rb +104 -104
  202. metadata +239 -217
  203. data/lib/active_record/association_reflection.rb +0 -20
  204. data/lib/active_record/viewhints_validations_interceptor.rb +0 -9
  205. data/lib/hobo/accessible_associations.rb +0 -183
  206. data/lib/hobo/authentication_support.rb +0 -131
  207. data/lib/hobo/generator.rb +0 -26
  208. data/lib/hobo/guest.rb +0 -25
  209. data/lib/hobo/include_in_save.rb +0 -55
  210. data/lib/hobo/lifecycles.rb +0 -137
  211. data/lib/hobo/lifecycles/actions.rb +0 -142
  212. data/lib/hobo/lifecycles/creator.rb +0 -72
  213. data/lib/hobo/lifecycles/lifecycle.rb +0 -249
  214. data/lib/hobo/lifecycles/state.rb +0 -22
  215. data/lib/hobo/lifecycles/transition.rb +0 -70
  216. data/lib/hobo/model_router.rb +0 -290
  217. data/lib/hobo/permissions.rb +0 -451
  218. data/lib/hobo/permissions/associations.rb +0 -175
  219. data/lib/hobo/rapid_helper.rb +0 -157
  220. data/lib/hobo/scopes.rb +0 -43
  221. data/lib/hobo/scopes/apply_scopes.rb +0 -23
  222. data/lib/hobo/scopes/association_proxy_extensions.rb +0 -62
  223. data/lib/hobo/scopes/automatic_scopes.rb +0 -421
  224. data/lib/hobo/scopes/named_scope_extensions.rb +0 -39
  225. data/lib/hobo/tasks/rails.rb +0 -4
  226. data/lib/hobo/translations.rb +0 -93
  227. data/lib/hobo/undefined_access_error.rb +0 -5
  228. data/lib/hobo/user.rb +0 -182
  229. data/lib/hobo/view_hints.rb +0 -115
  230. data/rails/init.rb +0 -10
  231. data/rails_generators/hobo/USAGE +0 -4
  232. data/rails_generators/hobo/hobo_generator.rb +0 -53
  233. data/rails_generators/hobo/templates/application.dryml +0 -1
  234. data/rails_generators/hobo/templates/initializer.rb +0 -2
  235. data/rails_generators/hobo_admin_site/USAGE +0 -16
  236. data/rails_generators/hobo_admin_site/hobo_admin_site_generator.rb +0 -45
  237. data/rails_generators/hobo_admin_site/templates/admin.css +0 -2
  238. data/rails_generators/hobo_admin_site/templates/users_index.dryml +0 -5
  239. data/rails_generators/hobo_front_controller/hobo_front_controller_generator.rb +0 -95
  240. data/rails_generators/hobo_front_controller/templates/functional_test.rb +0 -8
  241. data/rails_generators/hobo_front_controller/templates/helper.rb +0 -2
  242. data/rails_generators/hobo_model/USAGE +0 -25
  243. data/rails_generators/hobo_model/hobo_model_generator.rb +0 -43
  244. data/rails_generators/hobo_model/templates/fixtures.yml +0 -6
  245. data/rails_generators/hobo_model/templates/hints.rb +0 -7
  246. data/rails_generators/hobo_model/templates/unit_test.rb +0 -8
  247. data/rails_generators/hobo_model_controller/USAGE +0 -30
  248. data/rails_generators/hobo_model_controller/hobo_model_controller_generator.rb +0 -46
  249. data/rails_generators/hobo_model_controller/templates/controller.rb +0 -7
  250. data/rails_generators/hobo_model_controller/templates/functional_test.rb +0 -8
  251. data/rails_generators/hobo_model_controller/templates/helper.rb +0 -2
  252. data/rails_generators/hobo_model_resource/USAGE +0 -38
  253. data/rails_generators/hobo_model_resource/hobo_model_resource_generator.rb +0 -73
  254. data/rails_generators/hobo_model_resource/templates/controller.rb +0 -7
  255. data/rails_generators/hobo_model_resource/templates/functional_test.rb +0 -8
  256. data/rails_generators/hobo_model_resource/templates/helper.rb +0 -2
  257. data/rails_generators/hobo_rapid/hobo_rapid_generator.rb +0 -94
  258. data/rails_generators/hobo_subsite/USAGE +0 -16
  259. data/rails_generators/hobo_subsite/hobo_subsite_generator.rb +0 -73
  260. data/rails_generators/hobo_subsite/templates/site_taglib.dryml +0 -13
  261. data/rails_generators/hobo_user_controller/USAGE +0 -34
  262. data/rails_generators/hobo_user_controller/hobo_user_controller_generator.rb +0 -65
  263. data/rails_generators/hobo_user_controller/templates/controller.rb +0 -29
  264. data/rails_generators/hobo_user_controller/templates/functional_test.rb +0 -8
  265. data/rails_generators/hobo_user_controller/templates/helper.rb +0 -2
  266. data/rails_generators/hobo_user_model/USAGE +0 -16
  267. data/rails_generators/hobo_user_model/hobo_user_model_generator.rb +0 -46
  268. data/rails_generators/hobo_user_model/templates/fixtures.yml +0 -19
  269. data/rails_generators/hobo_user_model/templates/mailer.rb +0 -29
  270. data/rails_generators/hobo_user_model/templates/unit_test.rb +0 -8
  271. data/script/destroy +0 -14
  272. data/script/generate +0 -14
  273. data/taglibs/rapid_translations.dryml +0 -36
  274. data/tasks/environments.rake +0 -19
  275. data/tasks/hobo_tasks.rake +0 -58
  276. data/test/generators/test_generator_helper.rb +0 -29
  277. data/test/generators/test_helper.rb +0 -1
  278. data/test/generators/test_hobo_model_controller_generator.rb +0 -56
data/Rakefile CHANGED
@@ -1,20 +1,25 @@
1
1
  require 'rake'
2
2
  require 'rake/rdoctask'
3
3
  require 'rake/testtask'
4
+ require 'tmpdir'
4
5
 
5
6
  require 'active_record'
6
7
  ActiveRecord::ActiveRecordError # hack for https://rails.lighthouseapp.com/projects/8994/tickets/2577-when-using-activerecordassociations-outside-of-rails-a-nameerror-is-thrown
7
- $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '/lib')
8
- $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '/../hobofields/lib')
9
- $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '/../hobosupport/lib')
8
+ $:.unshift File.expand_path('../lib', __FILE__)
9
+ $:.unshift File.expand_path('../../hobo_support/lib', __FILE__)
10
+ $:.unshift File.expand_path('../../hobo_fields/lib', __FILE__)
11
+ $:.unshift File.expand_path('../../dryml/lib', __FILE__)
10
12
  require 'hobo'
11
13
 
12
14
  RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']).sub(/.*\s.*/m, '"\&"')
13
- if defined?(Bundler)
14
- RUBYDOCTEST = 'bundle exec rubydoctest'
15
- else
16
- RUBYDOCTEST = ENV['RUBYDOCTEST'] || "#{RUBY} -S rubydoctest"
17
- end
15
+ RUBYDOCTEST = ENV['RUBYDOCTEST'] || "#{RUBY} -S rubydoctest"
16
+
17
+ GEM_ROOT = File.expand_path('../', __FILE__)
18
+ TESTAPP_PATH = File.join Dir.tmpdir, 'hobo_testapp'
19
+ BIN = File.expand_path('../bin/hobo', __FILE__)
20
+ require 'hobo_support/common_tasks'
21
+ include HoboSupport::CommonTasks
22
+
18
23
 
19
24
  desc "Default Task"
20
25
  task :default => [ :test ]
@@ -32,8 +37,7 @@ Rake::TestTask.new(:test) { |t|
32
37
  namespace "test" do
33
38
  desc "Run the doctests"
34
39
  task :doctest do |t|
35
- files=Dir['doctest/*.rdoctest'].map {|f| File.expand_path(f)}.join(' ')
36
- # note, tests in doctest/hobo/ are out of date
40
+ files=Dir['doctests/**/*.rdoctest'].map {|f| File.expand_path(f)}.join(' ')
37
41
  exit(1) if !system("#{RUBYDOCTEST} #{files}")
38
42
  end
39
43
  end
@@ -50,24 +54,3 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
50
54
  end
51
55
 
52
56
 
53
- # --- Packaging and Rubyforge & gemcutter & github--- #
54
-
55
- require 'jeweler'
56
- Jeweler::Tasks.new do |gemspec|
57
- gemspec.version = Hobo::VERSION
58
- gemspec.name = "hobo"
59
- gemspec.email = "tom@tomlocke.com"
60
- gemspec.summary = "The web app builder for Rails"
61
- gemspec.homepage = "http://hobocentral.net/"
62
- gemspec.authors = ["Tom Locke"]
63
- gemspec.executables = ['hobo']
64
- gemspec.default_executable = 'hobo'
65
- gemspec.rubyforge_project = "hobo"
66
- gemspec.add_dependency("rails", [">= 2.2.2", "< 3.0.0"])
67
- gemspec.add_dependency("will_paginate", [">= 2.3.11", "~> 2"])
68
- gemspec.add_dependency("hobosupport", ["= #{Hobo::VERSION}"])
69
- gemspec.add_dependency("hobofields", ["= #{Hobo::VERSION}"])
70
- gemspec.add_dependency("dryml", ["= #{Hobo::VERSION}"])
71
- gemspec.files.include %w(tasks/environments.rake tasks/hobo_tasks.rake)
72
- end
73
- Jeweler::GemcutterTasks.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.3.0.RC
@@ -1,13 +1,13 @@
1
- class Hobo::DevController < ActionController::Base
1
+ class DevController < ActionController::Base
2
2
 
3
3
  hobo_controller
4
4
 
5
5
  before_filter :developer_modes_only
6
-
6
+
7
7
  def set_current_user
8
- model = params[:model] || Hobo::User.default_user_model
8
+ model = params[:model] || Hobo::Model::UserBase.default_user_model
9
9
  self.current_user = if params[:login]
10
- model.find(:first, :conditions => {model.login_attribute => params[:login]})
10
+ model.where(model.login_attribute => params[:login]).first
11
11
  else
12
12
  model.find(params[:id])
13
13
  end
@@ -18,8 +18,8 @@ class Hobo::DevController < ActionController::Base
18
18
 
19
19
  def developer_modes_only
20
20
  # Belt and braces. In addition to this check, the routes only get
21
- # defined when developer_features? is true
22
- render :text => "Permission Denied", :status => 403 unless Hobo.developer_features?
21
+ # defined when developer_features is true
22
+ render :text => "Permission Denied", :status => 403 unless Rails.application.config.hobo.developer_features
23
23
  end
24
24
 
25
25
  end
@@ -0,0 +1,13 @@
1
+ class DrymlSupportController < ActionController::Base
2
+
3
+ def edit_source
4
+ dryml_editor = ENV['DRYML_EDITOR']
5
+ if dryml_editor
6
+ file = File.join(Rails.root, params[:file])
7
+ command = dryml_editor.sub(":file", file).sub(":line", params[:line])
8
+ system(command)
9
+ end
10
+ render :nothing => true
11
+ end
12
+
13
+ end
@@ -8,12 +8,11 @@
8
8
  <tr> <td>Application Name</td> <td><app-name/></td> </tr>
9
9
  <tr> <td>Application Location</td> <td><rails-root/></td> </tr>
10
10
  <tr> <td>Rails Version</td> <td><rails-version/></td> </tr>
11
- <tr> <td>Rails Location</td> <td><rails-location/></td> </tr>
12
11
  <tr> <td>Mode</td> <td><rails-env/></td> </tr>
13
12
  </table>
14
13
 
15
14
  <h3>Change Control</h3>
16
- <table class="app-summary">
15
+ <table class="app-summary">
17
16
  <tr> <th></th><th></th></tr>
18
17
  <tr> <td>Method</td> <td><cms-method/></td> </tr>
19
18
  <if test="&cms_method.strip=='git'">
@@ -25,15 +24,13 @@
25
24
  </table>
26
25
 
27
26
 
28
- <h3>Gems</h3>
27
+ <h3>Bundled Gems</h3>
29
28
  <table class="app-summary">
30
29
  <with-gems>
31
- <tr if="&first_item?"><th></th><th>Required</th><th>Installed</th><th>Status</th><th>Dependencies</th></tr>
30
+ <tr if="&first_item?"><th></th><th>Version</th><th>Dependencies</th></tr>
32
31
  <tr>
33
32
  <td><gem-name/></td>
34
- <td><gem-version-required/></td>
35
- <td><gem-version/></td>
36
- <td><gem-frozen/></td>
33
+ <td><gem-version/></td>
37
34
  <td><gem-dependencies/></td>
38
35
  </tr>
39
36
  </with-gems>
@@ -75,8 +72,8 @@
75
72
  <td><model-table-comment/></td>
76
73
  </tr>
77
74
  </with-models>
78
- </table>
79
-
75
+ </table>
76
+
80
77
  <with-models>
81
78
  <h3 if="&this.try.table_name"><model-name /></h3>
82
79
  <table class="app-summary">
@@ -102,4 +99,4 @@
102
99
  </with-models>
103
100
  </div>
104
101
  </content:>
105
- </page>
102
+ </page>
data/bin/hobo CHANGED
@@ -1,151 +1,19 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  require 'fileutils'
4
- require 'pathname'
5
-
6
- require 'rbconfig'
7
3
 
8
- RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']).sub(/.*\s.*/m, '"\&"')
9
-
10
- if RUBY.empty?
11
- puts "ruby not found"
12
- exit 2
4
+ if ENV["HOBODEV"]
5
+ dev_root = File.expand_path ENV["HOBODEV"], FileUtils.pwd
6
+ $:.unshift "#{dev_root}/hobo_support/lib"
7
+ else
8
+ require 'rubygems'
13
9
  end
14
10
 
15
- Signal.trap("INT") { puts; exit }
16
-
17
- hobo_src = File.join(File.dirname(__FILE__), "../hobo_files/plugin")
18
-
19
- USAGE = "USAGE: hobo <options> <app-path>
20
-
21
- Options:
22
- --user-model <model-name-or-false>
23
- --db-create # Run rake db:create:all
24
- --hobo-src <path to hobo src>
25
- -d | --database <database> # e.g. mysql, sqlite
26
- -r | --rails <version> # rails version to use
27
- -n | --no-rails # don't run 'rails'. Assumes app-path=='.'
28
- --invite-only # add features for an invite-only website (admin site, no signup)
29
- "
30
-
31
-
32
- ### Nasty stuff needed for Windows :-( ###
33
- if Config::CONFIG["arch"] =~ /win32/
34
- require "win32/registry"
35
- def system(command)
36
- win = Win32API.new("crtdll", "system", ['P'], 'L').Call(command)
37
- end
11
+ begin
12
+ require 'hobo_support/command'
13
+ rescue LoadError
14
+ puts "The 'hobo_support' gem is not installed.
15
+ You probably need to set the HOBODEV environment variable to your local hobo git-repository path."
16
+ exit
38
17
  end
39
- ### end nasty stuff ###
40
18
 
41
-
42
- def command(*s)
43
- com = s.join(' ')
44
- puts "--> #{com}"
45
- ok = system(com)
46
- exit(1) unless ok
47
- end
48
-
49
- user_model = "user"
50
- create_db = false
51
- run_rails = true
52
- invite_only = ""
53
-
54
- while true
55
- case arg_name = ARGV.shift
56
- when "--user-model"
57
- arg = ARGV.shift
58
- user_model = arg == "false" ? nil : arg
59
- when "--db-create"
60
- create_db = true
61
- when "--hobo-src"
62
- hobo_src = ARGV.shift
63
- hobo_src = "../" + hobo_src unless Pathname.new(hobo_src).absolute?
64
- when "-d", "--database"
65
- database_type = ARGV.shift
66
- when "-r", "--rails"
67
- rails_version = ARGV.shift
68
- when "-n", "--no-rails"
69
- run_rails = false
70
- when "--invite-only"
71
- invite_only = "--invite-only"
72
- when "--help"
73
- puts USAGE
74
- exit
75
- else
76
- app_path = arg_name
77
- break
78
- end
79
- end
80
-
81
- if run_rails==false && app_path.nil?
82
- app_path = '.'
83
- end
84
-
85
- if !ARGV.empty? || app_path.nil?
86
- puts USAGE
87
- exit 1
88
- end
89
-
90
- if run_rails
91
- puts "\nGenerating Rails app...\n"
92
- opts = []
93
- if rails_version
94
- opts << "_#{rails_version}_"
95
- else
96
- v=`#{RUBY} -S rails -v`.split[1].split(".")
97
- unless v.length>=3
98
- puts "rails not found!"
99
- exit 2
100
- end
101
- unless v[0]=='2' && ['2', '3'].include?(v[1])
102
- puts "Rails 2.2 or 2.3 required!"
103
- puts "Rails 3 requires Hobo 1.1 or later."
104
- exit 2
105
- end
106
- end
107
- opts << "-d #{database_type}" if database_type
108
- system("#{RUBY} -S rails #{opts * ' '} #{app_path}")
109
- end
110
-
111
- Dir.chdir(app_path) do
112
- gen = "#{RUBY} #{File.join('script', 'generate')}"
113
- plugin = "#{RUBY} #{File.join('script', 'plugin')}"
114
-
115
- FileUtils.touch("public/stylesheets/application.css")
116
-
117
- puts "\nInitialising Hobo...\n"
118
- command(gen, "hobo --add-gem --add-routes")
119
-
120
- puts "\nInstalling Hobo Rapid and default theme...\n"
121
- command("#{gen} hobo_rapid --import-tags #{invite_only}")
122
-
123
- if user_model
124
- puts "\nCreating #{user_model} model and controller...\n"
125
- command("#{gen} hobo_user_model #{user_model} #{invite_only}")
126
- command("#{gen} hobo_user_controller #{user_model} #{invite_only}")
127
- end
128
-
129
- puts "\nCreating standard pages...\n"
130
- command("#{gen} hobo_front_controller front --delete-index --add-routes #{invite_only}")
131
-
132
- if create_db
133
- puts "\nCreating databases"
134
- command("#{RUBY} -S rake db:create:all")
135
- end
136
- end
137
-
138
- if !invite_only.empty?
139
- puts %(
140
- Invite-only website
141
- If you wish to prevent all access to the site to non-members, add 'before_filter :login_required'
142
- to the relevant controllers, e.g. to prevent all access to the site, add
143
-
144
- include Hobo::AuthenticationSupport
145
- before_filter :login_required
146
-
147
- to application_controller.rb (note that the include statement is not required for hobo_controllers)
148
-
149
- NOTE: You might want to sign up as the administrator before adding this!
150
- )
151
- end
19
+ HoboSupport::Command.run(:hobo)
@@ -0,0 +1,3 @@
1
+ ActiveSupport::Inflector.inflections do |inflect|
2
+ inflect.singular(/ess$/i, 'ess')
3
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,6 @@
1
+ Rails.application.routes.draw do
2
+
3
+ match 'dryml/:action', :controller => 'dryml_support', :as => 'dryml_support'
4
+ match 'dev/:action', :controller => 'dev', :as => 'dev_support' if Rails.application.config.hobo.developer_features
5
+
6
+ end
@@ -15,17 +15,8 @@ Hobo lifecycles is a mechanism for declaring the life-cycle of a model in a natu
15
15
 
16
16
  First the junk to get us started:
17
17
 
18
- doctest_require: 'rubygems'
19
- doctest_require: 'active_record'
20
- >> $:.unshift '/home/blarsen/dev/agility-master/vendor/plugins/hobo/hobo/lib'
21
- >> $:.unshift '/home/blarsen/dev/agility-master/vendor/plugins/hobo/hobo/lib'
22
- >> $:.unshift '/home/blarsen/dev/agility-master/vendor/plugins/hobo/hobofields/lib'
23
- >> $:.unshift '/home/blarsen/dev/agility-master/vendor/plugins/hobo/hobosupport/lib'
24
- >> require 'hobo'
25
- >> require 'hobo/model'
26
- >> ActiveRecord::Base.establish_connection(:adapter => "sqlite3",
27
- :database => "lifecycle_doctest")
28
-
18
+ doctest: prepare testapp environment
19
+ doctest_require: '../prepare_testapp'
29
20
 
30
21
  A user model for our example:
31
22
 
@@ -42,6 +33,7 @@ Now the friendship. For now we'll just declare the *invite* part of the lifecycl
42
33
  >>
43
34
  class Friendship < ActiveRecord::Base
44
35
  hobo_model
36
+ fields {} # just to trigger hobo:migration
45
37
  belongs_to :requester, :class_name => "User"
46
38
  belongs_to :requestee, :class_name => "User"
47
39
 
@@ -53,9 +45,7 @@ Now the friendship. For now we'll just declare the *invite* part of the lifecycl
53
45
 
54
46
  Now let's get the DB ready:
55
47
 
56
- doctest_require: '../../../hobofields/lib/hobo_fields/migration_generator'
57
- >> up, down = HoboFields::MigrationGenerator.run
58
- >> ActiveRecord::Migration.class_eval up
48
+ >> Rails::Generators.invoke 'hobo:migration', %w(-n -m)
59
49
  >> User.delete_all
60
50
  >> Friendship.delete_all
61
51
 
@@ -85,8 +75,8 @@ To continue modeling the friendship lifecycle, we add some *transitions*:
85
75
  class Friendship
86
76
  lifecycle do
87
77
  state :active
88
- transition :accept, { :requested => :active}, :available_to => :requestee
89
- transition :reject, { :requested => :destroy}, :available_to => :requestee
78
+ transition :accept, { :requested => :active}, :available_to => :requestee
79
+ transition :reject, { :requested => :destroy}, :available_to => :requestee
90
80
  end
91
81
  end
92
82
 
@@ -101,7 +91,7 @@ We can test which transitions are available:
101
91
  >> f.lifecycle.available_transitions_for(tom).*.name
102
92
  => []
103
93
  >> f.lifecycle.available_transitions_for(bob).*.name
104
- => ["accept", "reject"]
94
+ => [:accept, :reject]
105
95
  >> f.lifecycle.can_accept?(tom)
106
96
  => false
107
97
  >> f.lifecycle.can_reject?(tom)
@@ -113,7 +103,7 @@ We can test which transitions are available:
113
103
 
114
104
  Accept the friendship
115
105
 
116
- >> f.lifecycle.accept(bob)
106
+ >> f.lifecycle.accept!(bob)
117
107
  >> f.state
118
108
  => "active"
119
109
 
@@ -137,7 +127,7 @@ Let's try a rejected friendship:
137
127
  => true
138
128
  >> Friendship.count
139
129
  => 1
140
- >> f.lifecycle.reject(bob)
130
+ >> f.lifecycle.reject!(bob)
141
131
  >> Friendship.count
142
132
  => 0
143
133
 
@@ -166,55 +156,53 @@ We'll extend the lifecycle to allow:
166
156
  Here is the entire lifecycle
167
157
 
168
158
  >>
169
- class Friendship < ActiveRecord::Base
170
- hobo_model
171
- belongs_to :requester, :class_name => "User"
172
- belongs_to :requestee, :class_name => "User"
159
+ class Friendship < ActiveRecord::Base
160
+ fields {}
173
161
 
174
- lifecycle do
175
- state :requested, :active, :ignored
162
+ lifecycle do
163
+ state :requested, :active, :ignored
176
164
 
177
- create :requester, :request, :params => [ :requestee ], :become => :requested do
178
- $emails << "Dear #{requestee.name}, #{requester.name} wants to be friends with you"
179
- end
165
+ create :request, :params => [ :requestee ], :become => :requested, :available_to => "User", :user_becomes => :requester do
166
+ $emails << "Dear #{requestee.name}, #{requester.name} wants to be friends with you"
167
+ end
180
168
 
181
169
 
182
- transition :requestee, :accept, { :requested => :active } do
183
- $emails << "Dear #{requester.name}, #{requestee.name} is now your friend :-)"
184
- end
170
+ transition :accept, { :requested => :active }, :available_to => :requestee do
171
+ $emails << "Dear #{requester.name}, #{requestee.name} is now your friend :-)"
172
+ end
185
173
 
186
- transition :requestee, :reject, { :requested => :destroy } do
187
- $emails << "Dear #{requester.name}, #{requestee.name} blew you out :-("
188
- end
174
+ transition :reject, { :requested => :destroy }, :available_to => :requestee do
175
+ $emails << "Dear #{requester.name}, #{requestee.name} blew you out :-("
176
+ end
189
177
 
190
- transition :requestee, :ignore, { :requested => :ignored }
178
+ transition :ignore, { :requested => :ignored }, :available_to => :requestee
191
179
 
192
- transition :requester, :retract, { :requested => :destroy } do
193
- $emails << "Dear #{requestee.name}, #{requester.name} reconsidered"
194
- end
180
+ transition :retract, { :requested => :destroy }, :available_to => :requester do
181
+ $emails << "Dear #{requestee.name}, #{requester.name} reconsidered"
182
+ end
195
183
 
196
- transition [ :requester, :requestee ], :cancel, { :active => :destroy }
197
- # TODO: send the email - for this we need the acting user to be passed to the block
184
+ transition :cancel, { :active => :destroy }, :available_to => [ :requester, :requestee ]
185
+ # TODO: send the email - for this we need the acting user to be passed to the block
198
186
 
199
- end
187
+ end
200
188
 
201
- end
189
+ end
202
190
 
203
191
  Check the simple accept still works, and sends emails
204
192
 
205
193
  >> f = Friendship::Lifecycle.request(tom, :requestee => bob)
206
194
  >> $emails.last
207
195
  => "Dear Bob, Tom wants to be friends with you"
208
- >> f.lifecycle.accept(bob)
196
+ >> f.lifecycle.accept!(bob)
209
197
  >> $emails.last
210
198
  => "Dear Tom, Bob is now your friend :-)"
211
- >> f.lifecycle.active?
212
- => true
199
+ >> f.state
200
+ => "active"
213
201
 
214
202
  Rejection:
215
203
 
216
204
  >> f = Friendship::Lifecycle.request(tom, :requestee => bob)
217
- >> f.lifecycle.reject(bob)
205
+ >> f.lifecycle.reject!(bob)
218
206
  >> $emails.last
219
207
  => "Dear Tom, Bob blew you out :-("
220
208
  >> f.state
@@ -225,16 +213,17 @@ Retraction:
225
213
  >> f = Friendship::Lifecycle.request(tom, :requestee => bob)
226
214
  >> f.lifecycle.can_retract?(bob)
227
215
  => false
228
- >> f.lifecycle.retract(tom)
216
+ >> f.lifecycle.retract!(tom)
229
217
  >> $emails.last
230
218
  => "Dear Bob, Tom reconsidered"
231
- >> f.lifecycle.active?
219
+ >> f.state
220
+ => "destroy"
232
221
 
233
222
  Ignoring
234
223
 
235
224
  >> f = Friendship::Lifecycle.request(tom, :requestee => bob)
236
225
  >> $emails = []
237
- >> f.lifecycle.ignore(bob)
226
+ >> f.lifecycle.ignore!(bob)
238
227
  >> $emails # Ignoring shouldn't send any email
239
228
  => []
240
229
  >> f.state
@@ -245,17 +234,9 @@ Requester cancels
245
234
  >> f = Friendship::Lifecycle.request(tom, :requestee => bob)
246
235
  >> f.lifecycle.can_cancel?(tom)
247
236
  => false
248
- >> f.lifecycle.accept(bob)
249
- >> f.lifecycle.cancel(tom)
237
+ >> f.lifecycle.accept!(bob)
238
+ >> f.lifecycle.cancel!(tom)
250
239
  >> f.state
251
240
  => "destroy"
252
241
 
253
242
 
254
-
255
-
256
-
257
-
258
-
259
-
260
-
261
-