wallaby 5.0.1 → 5.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (350) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -3
  3. data/app/assets/images/wallaby/404.png +0 -0
  4. data/app/assets/images/wallaby/422.png +0 -0
  5. data/app/assets/images/wallaby/500.png +0 -0
  6. data/app/assets/javascripts/wallaby/application.js +1 -15
  7. data/app/assets/javascripts/wallaby/auto_select.js +77 -0
  8. data/app/assets/javascripts/wallaby/base.js +17 -0
  9. data/app/assets/javascripts/wallaby/setup.js.erb +60 -0
  10. data/app/assets/stylesheets/wallaby/application.scss +1 -51
  11. data/app/assets/stylesheets/wallaby/base/_layout.scss +257 -9
  12. data/app/assets/stylesheets/wallaby/base/_layout_desktop.scss +53 -0
  13. data/app/assets/stylesheets/wallaby/base/_mixins.scss +119 -0
  14. data/app/assets/stylesheets/wallaby/base/_override.scss +10 -0
  15. data/app/assets/stylesheets/wallaby/base/_vars.scss +72 -2
  16. data/app/assets/stylesheets/wallaby/base.scss +27 -0
  17. data/app/assets/stylesheets/wallaby/components/_auto_select.scss +119 -0
  18. data/app/assets/stylesheets/wallaby/components/_auto_select_desktop.scss +7 -0
  19. data/app/assets/stylesheets/wallaby/components/_color_square.scss +8 -0
  20. data/app/assets/stylesheets/wallaby/components/_filters.scss +14 -0
  21. data/app/assets/stylesheets/wallaby/components/_links.scss +25 -0
  22. data/app/assets/stylesheets/wallaby/components/_pagination.scss +35 -91
  23. data/app/assets/stylesheets/wallaby/components/_query.scss +101 -0
  24. data/app/assets/stylesheets/wallaby/components/_text.scss +6 -6
  25. data/app/assets/stylesheets/wallaby/pages/_error.scss +108 -0
  26. data/app/assets/stylesheets/wallaby/pages/_form.scss +40 -0
  27. data/app/assets/stylesheets/wallaby/pages/_index.scss +193 -0
  28. data/app/assets/stylesheets/wallaby/pages/_index_desktop.scss +22 -0
  29. data/app/assets/stylesheets/wallaby/pages/_show.scss +21 -0
  30. data/app/controllers/wallaby/abstract_resources_controller.rb +334 -0
  31. data/app/controllers/wallaby/application_controller.rb +45 -15
  32. data/app/controllers/wallaby/base_controller.rb +30 -0
  33. data/app/controllers/wallaby/resources_controller.rb +2 -131
  34. data/app/controllers/wallaby/secure_controller.rb +38 -24
  35. data/app/routes/wallaby/resources_router.rb +40 -43
  36. data/app/security/ability.rb +4 -28
  37. data/app/views/layouts/wallaby/application.html.erb +11 -6
  38. data/app/views/layouts/wallaby/error.html.erb +26 -4
  39. data/app/views/wallaby/error.html.erb +11 -0
  40. data/app/views/wallaby/error.json.jbuilder +8 -0
  41. data/app/views/wallaby/{shared → resources}/_flash_messages.html.erb +0 -0
  42. data/app/views/wallaby/resources/_footer.html.erb +1 -0
  43. data/app/views/wallaby/resources/_form.html.erb +2 -2
  44. data/app/views/wallaby/resources/_header.html.erb +38 -0
  45. data/app/views/wallaby/resources/_imodal.html.erb +13 -0
  46. data/app/views/wallaby/resources/_index_actions.html.erb +4 -1
  47. data/app/views/wallaby/resources/_index_filters.html.erb +23 -0
  48. data/app/views/wallaby/resources/_index_pagination.html.erb +63 -0
  49. data/app/views/wallaby/resources/_index_query.html.erb +23 -0
  50. data/app/views/wallaby/resources/_logo.html.erb +1 -0
  51. data/app/views/wallaby/resources/_navs.html.erb +9 -0
  52. data/app/views/wallaby/resources/_resource_actions.html.erb +3 -3
  53. data/app/views/wallaby/resources/{shared/_resource_nav.html.erb → _resource_navs.html.erb} +6 -6
  54. data/app/views/wallaby/resources/_title.html.erb +1 -0
  55. data/app/views/wallaby/resources/_user_menu.html.erb +5 -0
  56. data/app/views/wallaby/resources/bad_request.json.jbuilder +7 -0
  57. data/app/views/wallaby/resources/edit.html.erb +16 -12
  58. data/app/views/wallaby/resources/form/_belongs_to.html.erb +63 -12
  59. data/app/views/wallaby/resources/form/_bigint.html.erb +10 -1
  60. data/app/views/wallaby/resources/form/_bigserial.html.erb +18 -0
  61. data/app/views/wallaby/resources/form/_binary.html.erb +11 -2
  62. data/app/views/wallaby/resources/form/_bit.html.erb +10 -1
  63. data/app/views/wallaby/resources/form/_bit_varying.html.erb +10 -1
  64. data/app/views/wallaby/resources/form/_blob.html.erb +21 -0
  65. data/app/views/wallaby/resources/form/_boolean.html.erb +9 -0
  66. data/app/views/wallaby/resources/form/_box.html.erb +21 -0
  67. data/app/views/wallaby/resources/form/_cidr.html.erb +13 -1
  68. data/app/views/wallaby/resources/form/_circle.html.erb +21 -0
  69. data/app/views/wallaby/resources/form/_citext.html.erb +11 -2
  70. data/app/views/wallaby/resources/form/_color.html.erb +11 -2
  71. data/app/views/wallaby/resources/form/_date.html.erb +12 -3
  72. data/app/views/wallaby/resources/form/_daterange.html.erb +14 -5
  73. data/app/views/wallaby/resources/form/_datetime.html.erb +12 -3
  74. data/app/views/wallaby/resources/form/_decimal.html.erb +10 -1
  75. data/app/views/wallaby/resources/form/_dropdown.html.erb +18 -0
  76. data/app/views/wallaby/resources/form/_email.html.erb +9 -0
  77. data/app/views/wallaby/resources/form/_file.html.erb +21 -0
  78. data/app/views/wallaby/resources/form/_float.html.erb +10 -1
  79. data/app/views/wallaby/resources/form/_has_and_belongs_to_many.html.erb +53 -7
  80. data/app/views/wallaby/resources/form/_has_many.html.erb +52 -7
  81. data/app/views/wallaby/resources/form/_has_one.html.erb +10 -2
  82. data/app/views/wallaby/resources/form/_hstore.html.erb +12 -5
  83. data/app/views/wallaby/resources/form/_inet.html.erb +13 -1
  84. data/app/views/wallaby/resources/form/_int4range.html.erb +11 -2
  85. data/app/views/wallaby/resources/form/_int8range.html.erb +11 -2
  86. data/app/views/wallaby/resources/form/_integer.html.erb +10 -1
  87. data/app/views/wallaby/resources/form/_json.html.erb +13 -6
  88. data/app/views/wallaby/resources/form/_jsonb.html.erb +13 -6
  89. data/app/views/wallaby/resources/form/_line.html.erb +21 -0
  90. data/app/views/wallaby/resources/form/_longblob.html.erb +21 -0
  91. data/app/views/wallaby/resources/form/_longtext.html.erb +30 -0
  92. data/app/views/wallaby/resources/form/_lseg.html.erb +21 -0
  93. data/app/views/wallaby/resources/form/_ltree.html.erb +17 -1
  94. data/app/views/wallaby/resources/form/_macaddr.html.erb +13 -1
  95. data/app/views/wallaby/resources/form/_markdown.html.erb +29 -0
  96. data/app/views/wallaby/resources/form/_mediumblob.html.erb +21 -0
  97. data/app/views/wallaby/resources/form/_mediumtext.html.erb +30 -0
  98. data/app/views/wallaby/resources/form/_money.html.erb +10 -1
  99. data/app/views/wallaby/resources/form/_numrange.html.erb +11 -2
  100. data/app/views/wallaby/resources/form/_password.html.erb +14 -1
  101. data/app/views/wallaby/resources/form/_path.html.erb +17 -0
  102. data/app/views/wallaby/resources/form/_point.html.erb +11 -2
  103. data/app/views/wallaby/resources/form/_polygon.html.erb +17 -0
  104. data/app/views/wallaby/resources/form/_serial.html.erb +18 -0
  105. data/app/views/wallaby/resources/form/_sti.html.erb +18 -0
  106. data/app/views/wallaby/resources/form/_string.html.erb +14 -1
  107. data/app/views/wallaby/resources/form/_text.html.erb +11 -2
  108. data/app/views/wallaby/resources/form/_time.html.erb +12 -3
  109. data/app/views/wallaby/resources/form/_tinyblob.html.erb +21 -0
  110. data/app/views/wallaby/resources/form/_tinytext.html.erb +30 -0
  111. data/app/views/wallaby/resources/form/_tsrange.html.erb +14 -5
  112. data/app/views/wallaby/resources/form/_tstzrange.html.erb +14 -5
  113. data/app/views/wallaby/resources/form/_tsvector.html.erb +9 -0
  114. data/app/views/wallaby/resources/form/_unsigned_bigint.html.erb +18 -0
  115. data/app/views/wallaby/resources/form/_unsigned_decimal.html.erb +18 -0
  116. data/app/views/wallaby/resources/form/_unsigned_float.html.erb +18 -0
  117. data/app/views/wallaby/resources/form/_unsigned_integer.html.erb +18 -0
  118. data/app/views/wallaby/resources/form/_uuid.html.erb +10 -1
  119. data/app/views/wallaby/resources/form/_xml.html.erb +11 -5
  120. data/app/views/wallaby/resources/form.json.jbuilder +5 -0
  121. data/app/views/wallaby/{core → resources}/home.html.erb +1 -1
  122. data/app/views/wallaby/resources/index/_belongs_to.html.erb +5 -1
  123. data/app/views/wallaby/resources/index/_bigint.html.erb +4 -0
  124. data/app/views/wallaby/resources/index/_bigserial.html.erb +5 -0
  125. data/app/views/wallaby/resources/index/_binary.html.erb +5 -1
  126. data/app/views/wallaby/resources/index/_bit.html.erb +4 -0
  127. data/app/views/wallaby/resources/index/_bit_varying.html.erb +4 -0
  128. data/app/views/wallaby/resources/index/_blob.html.erb +5 -0
  129. data/app/views/wallaby/resources/index/_boolean.html.erb +5 -1
  130. data/app/views/wallaby/resources/index/_box.html.erb +16 -0
  131. data/app/views/wallaby/resources/index/_cidr.html.erb +5 -1
  132. data/app/views/wallaby/resources/index/_circle.html.erb +16 -0
  133. data/app/views/wallaby/resources/index/_citext.html.erb +5 -1
  134. data/app/views/wallaby/resources/index/_color.html.erb +6 -1
  135. data/app/views/wallaby/resources/index/_date.html.erb +4 -0
  136. data/app/views/wallaby/resources/index/_daterange.html.erb +5 -1
  137. data/app/views/wallaby/resources/index/_datetime.html.erb +5 -1
  138. data/app/views/wallaby/resources/index/_decimal.html.erb +4 -0
  139. data/app/views/wallaby/resources/index/_email.html.erb +4 -0
  140. data/app/views/wallaby/resources/index/_float.html.erb +4 -0
  141. data/app/views/wallaby/resources/index/_has_and_belongs_to_many.html.erb +6 -2
  142. data/app/views/wallaby/resources/index/_has_many.html.erb +6 -2
  143. data/app/views/wallaby/resources/index/_has_one.html.erb +5 -1
  144. data/app/views/wallaby/resources/index/_hstore.html.erb +6 -2
  145. data/app/views/wallaby/resources/index/_inet.html.erb +5 -1
  146. data/app/views/wallaby/resources/index/_int4range.html.erb +4 -0
  147. data/app/views/wallaby/resources/index/_int8range.html.erb +4 -0
  148. data/app/views/wallaby/resources/index/_integer.html.erb +4 -0
  149. data/app/views/wallaby/resources/index/_json.html.erb +5 -2
  150. data/app/views/wallaby/resources/index/_jsonb.html.erb +5 -2
  151. data/app/views/wallaby/resources/index/_line.html.erb +16 -0
  152. data/app/views/wallaby/resources/index/_longblob.html.erb +5 -0
  153. data/app/views/wallaby/resources/index/_longtext.html.erb +16 -0
  154. data/app/views/wallaby/resources/index/_lseg.html.erb +16 -0
  155. data/app/views/wallaby/resources/index/_ltree.html.erb +5 -1
  156. data/app/views/wallaby/resources/index/_macaddr.html.erb +4 -0
  157. data/app/views/wallaby/resources/index/_mediumblob.html.erb +5 -0
  158. data/app/views/wallaby/resources/index/_mediumtext.html.erb +16 -0
  159. data/app/views/wallaby/resources/index/_money.html.erb +4 -0
  160. data/app/views/wallaby/resources/index/_numrange.html.erb +4 -0
  161. data/app/views/wallaby/resources/index/_password.html.erb +9 -0
  162. data/app/views/wallaby/resources/index/_path.html.erb +16 -0
  163. data/app/views/wallaby/resources/index/_point.html.erb +4 -0
  164. data/app/views/wallaby/resources/index/_polygon.html.erb +16 -0
  165. data/app/views/wallaby/resources/index/_raw.html.erb +9 -0
  166. data/app/views/wallaby/resources/index/_serial.html.erb +5 -0
  167. data/app/views/wallaby/resources/index/_sti.html.erb +16 -0
  168. data/app/views/wallaby/resources/index/_string.html.erb +5 -1
  169. data/app/views/wallaby/resources/index/_text.html.erb +5 -1
  170. data/app/views/wallaby/resources/index/_time.html.erb +4 -0
  171. data/app/views/wallaby/resources/index/_tinyblob.html.erb +5 -0
  172. data/app/views/wallaby/resources/index/_tinytext.html.erb +16 -0
  173. data/app/views/wallaby/resources/index/_tsrange.html.erb +5 -1
  174. data/app/views/wallaby/resources/index/_tstzrange.html.erb +5 -1
  175. data/app/views/wallaby/resources/index/_tsvector.html.erb +5 -1
  176. data/app/views/wallaby/resources/index/_unsigned_bigint.html.erb +5 -0
  177. data/app/views/wallaby/resources/index/_unsigned_decimal.html.erb +5 -0
  178. data/app/views/wallaby/resources/index/_unsigned_float.html.erb +5 -0
  179. data/app/views/wallaby/resources/index/_unsigned_integer.html.erb +5 -0
  180. data/app/views/wallaby/resources/index/_uuid.html.erb +5 -1
  181. data/app/views/wallaby/resources/index/_xml.html.erb +5 -1
  182. data/app/views/wallaby/resources/index.csv.erb +26 -0
  183. data/app/views/wallaby/resources/index.html.erb +47 -59
  184. data/app/views/wallaby/resources/index.json.jbuilder +5 -0
  185. data/app/views/wallaby/resources/new.html.erb +12 -11
  186. data/app/views/wallaby/resources/show/_belongs_to.html.erb +5 -1
  187. data/app/views/wallaby/resources/show/_bigint.html.erb +4 -0
  188. data/app/views/wallaby/resources/show/_bigserial.html.erb +5 -0
  189. data/app/views/wallaby/resources/show/_binary.html.erb +5 -1
  190. data/app/views/wallaby/resources/show/_bit.html.erb +4 -0
  191. data/app/views/wallaby/resources/show/_bit_varying.html.erb +4 -0
  192. data/app/views/wallaby/resources/show/_blob.html.erb +5 -0
  193. data/app/views/wallaby/resources/show/_boolean.html.erb +5 -1
  194. data/app/views/wallaby/resources/show/_box.html.erb +9 -0
  195. data/app/views/wallaby/resources/show/_cidr.html.erb +5 -1
  196. data/app/views/wallaby/resources/show/_circle.html.erb +9 -0
  197. data/app/views/wallaby/resources/show/_citext.html.erb +4 -0
  198. data/app/views/wallaby/resources/show/_color.html.erb +6 -1
  199. data/app/views/wallaby/resources/show/_date.html.erb +4 -0
  200. data/app/views/wallaby/resources/show/_daterange.html.erb +4 -0
  201. data/app/views/wallaby/resources/show/_datetime.html.erb +4 -0
  202. data/app/views/wallaby/resources/show/_decimal.html.erb +4 -0
  203. data/app/views/wallaby/resources/show/_email.html.erb +4 -0
  204. data/app/views/wallaby/resources/show/_float.html.erb +4 -0
  205. data/app/views/wallaby/resources/show/_has_and_belongs_to_many.html.erb +6 -2
  206. data/app/views/wallaby/resources/show/_has_many.html.erb +6 -2
  207. data/app/views/wallaby/resources/show/_has_one.html.erb +5 -1
  208. data/app/views/wallaby/resources/show/_hstore.html.erb +4 -0
  209. data/app/views/wallaby/resources/show/_image.html.erb +9 -0
  210. data/app/views/wallaby/resources/show/_inet.html.erb +5 -1
  211. data/app/views/wallaby/resources/show/_int4range.html.erb +4 -0
  212. data/app/views/wallaby/resources/show/_int8range.html.erb +4 -0
  213. data/app/views/wallaby/resources/show/_integer.html.erb +4 -0
  214. data/app/views/wallaby/resources/show/_json.html.erb +4 -0
  215. data/app/views/wallaby/resources/show/_jsonb.html.erb +4 -0
  216. data/app/views/wallaby/resources/show/_line.html.erb +9 -0
  217. data/app/views/wallaby/resources/show/_longblob.html.erb +5 -0
  218. data/app/views/wallaby/resources/show/_longtext.html.erb +5 -0
  219. data/app/views/wallaby/resources/show/_lseg.html.erb +9 -0
  220. data/app/views/wallaby/resources/show/_ltree.html.erb +4 -0
  221. data/app/views/wallaby/resources/show/_macaddr.html.erb +4 -0
  222. data/app/views/wallaby/resources/show/_mediumblob.html.erb +5 -0
  223. data/app/views/wallaby/resources/show/_mediumtext.html.erb +5 -0
  224. data/app/views/wallaby/resources/show/_money.html.erb +4 -0
  225. data/app/views/wallaby/resources/show/_numrange.html.erb +4 -0
  226. data/app/views/wallaby/resources/show/_password.html.erb +9 -0
  227. data/app/views/wallaby/resources/show/_path.html.erb +9 -0
  228. data/app/views/wallaby/resources/show/_point.html.erb +4 -0
  229. data/app/views/wallaby/resources/show/_polygon.html.erb +9 -0
  230. data/app/views/wallaby/resources/show/_raw.html.erb +9 -0
  231. data/app/views/wallaby/resources/show/_serial.html.erb +5 -0
  232. data/app/views/wallaby/resources/show/_sti.html.erb +5 -0
  233. data/app/views/wallaby/resources/show/_string.html.erb +4 -0
  234. data/app/views/wallaby/resources/show/_text.html.erb +4 -0
  235. data/app/views/wallaby/resources/show/_time.html.erb +4 -0
  236. data/app/views/wallaby/resources/show/_tinyblob.html.erb +5 -0
  237. data/app/views/wallaby/resources/show/_tinytext.html.erb +5 -0
  238. data/app/views/wallaby/resources/show/_tsrange.html.erb +4 -0
  239. data/app/views/wallaby/resources/show/_tstzrange.html.erb +4 -0
  240. data/app/views/wallaby/resources/show/_tsvector.html.erb +4 -0
  241. data/app/views/wallaby/resources/show/_unsigned_bigint.html.erb +5 -0
  242. data/app/views/wallaby/resources/show/_unsigned_decimal.html.erb +5 -0
  243. data/app/views/wallaby/resources/show/_unsigned_float.html.erb +5 -0
  244. data/app/views/wallaby/resources/show/_unsigned_integer.html.erb +5 -0
  245. data/app/views/wallaby/resources/show/_uuid.html.erb +4 -0
  246. data/app/views/wallaby/resources/show/_xml.html.erb +4 -0
  247. data/app/views/wallaby/resources/show.html.erb +14 -24
  248. data/app/views/wallaby/resources/show.json.jbuilder +5 -0
  249. data/config/brakeman.ignore +26 -0
  250. data/config/locales/wallaby.en.yml +91 -0
  251. data/config/massa.yml +45 -0
  252. data/config/rails_best_practices.yml +42 -0
  253. data/config/routes.rb +29 -23
  254. data/lib/adaptors/wallaby/active_record/model_decorator/fields_builder/association_builder.rb +39 -0
  255. data/lib/adaptors/wallaby/active_record/model_decorator/fields_builder/polymorphic_builder.rb +44 -0
  256. data/lib/adaptors/wallaby/active_record/model_decorator/fields_builder/sti_builder.rb +42 -0
  257. data/lib/adaptors/wallaby/active_record/model_decorator/fields_builder.rb +41 -94
  258. data/lib/adaptors/wallaby/active_record/model_decorator/title_field_finder.rb +24 -14
  259. data/lib/adaptors/wallaby/active_record/model_decorator.rb +118 -64
  260. data/lib/adaptors/wallaby/active_record/model_finder.rb +44 -15
  261. data/lib/adaptors/wallaby/active_record/model_pagination_provider.rb +30 -0
  262. data/lib/adaptors/wallaby/active_record/model_service_provider/normalizer.rb +42 -0
  263. data/lib/adaptors/wallaby/active_record/model_service_provider/permitter.rb +64 -0
  264. data/lib/adaptors/wallaby/active_record/model_service_provider/querier/transformer.rb +70 -0
  265. data/lib/adaptors/wallaby/active_record/model_service_provider/querier.rb +102 -0
  266. data/lib/adaptors/wallaby/active_record/model_service_provider/validator.rb +29 -0
  267. data/lib/adaptors/wallaby/active_record/model_service_provider.rb +137 -0
  268. data/lib/adaptors/wallaby/active_record.rb +4 -1
  269. data/lib/decorators/wallaby/abstract_resource_decorator.rb +74 -0
  270. data/lib/decorators/wallaby/resource_decorator.rb +5 -76
  271. data/lib/errors/wallaby/model_not_found.rb +5 -1
  272. data/lib/errors/wallaby/not_found.rb +4 -0
  273. data/lib/errors/wallaby/resource_not_found.rb +5 -1
  274. data/lib/forms/wallaby/form_builder.rb +42 -19
  275. data/lib/helpers/wallaby/application_helper.rb +34 -24
  276. data/lib/helpers/wallaby/base_helper.rb +52 -0
  277. data/lib/helpers/wallaby/form_helper.rb +40 -16
  278. data/lib/helpers/wallaby/index_helper.rb +59 -0
  279. data/lib/helpers/wallaby/links_helper.rb +150 -81
  280. data/lib/helpers/wallaby/resources_helper.rb +41 -46
  281. data/lib/helpers/wallaby/secure_helper.rb +36 -19
  282. data/lib/helpers/wallaby/styling_helper.rb +53 -44
  283. data/lib/interfaces/wallaby/mode.rb +19 -12
  284. data/lib/interfaces/wallaby/model_decorator.rb +176 -50
  285. data/lib/interfaces/wallaby/model_finder.rb +7 -3
  286. data/lib/interfaces/wallaby/model_pagination_provider.rb +104 -0
  287. data/lib/interfaces/wallaby/model_service_provider.rb +71 -0
  288. data/lib/paginators/wallaby/abstract_resource_paginator.rb +23 -0
  289. data/lib/paginators/wallaby/resource_paginator.rb +6 -0
  290. data/lib/parsers/wallaby/parser.rb +32 -0
  291. data/lib/responders/wallaby/abstract_responder.rb +68 -0
  292. data/lib/responders/wallaby/resources_responder.rb +6 -0
  293. data/lib/servicers/wallaby/abstract_model_servicer.rb +48 -0
  294. data/lib/servicers/wallaby/model_servicer.rb +5 -0
  295. data/lib/services/wallaby/link_options_normalizer.rb +16 -0
  296. data/lib/services/wallaby/lookup_context_wrapper.rb +23 -30
  297. data/lib/services/wallaby/map/mode_mapper.rb +19 -0
  298. data/lib/services/wallaby/map/model_class_collector.rb +41 -0
  299. data/lib/services/wallaby/map/model_class_mapper.rb +24 -0
  300. data/lib/services/wallaby/map.rb +76 -39
  301. data/lib/services/wallaby/partial_renderer.rb +60 -0
  302. data/lib/services/wallaby/prefixes_builder.rb +54 -0
  303. data/lib/services/wallaby/sorting/hash_builder.rb +16 -0
  304. data/lib/services/wallaby/sorting/link_builder.rb +45 -0
  305. data/lib/services/wallaby/sorting/next_builder.rb +54 -0
  306. data/lib/services/wallaby/url_for.rb +36 -0
  307. data/lib/tree/wallaby/node.rb +17 -0
  308. data/lib/utils/wallaby/utils.rb +67 -22
  309. data/lib/wallaby/configuration/features.rb +12 -0
  310. data/lib/wallaby/configuration/metadata.rb +12 -0
  311. data/lib/wallaby/configuration/models.rb +27 -12
  312. data/lib/wallaby/configuration/pagination.rb +12 -0
  313. data/lib/wallaby/configuration/security.rb +55 -24
  314. data/lib/wallaby/configuration.rb +38 -19
  315. data/lib/wallaby/engine.rb +84 -39
  316. data/lib/wallaby/version.rb +1 -1
  317. data/lib/wallaby.rb +22 -3
  318. metadata +200 -55
  319. data/app/assets/javascripts/wallaby/form.js +0 -8
  320. data/app/assets/stylesheets/wallaby/base/_functions.scss +0 -0
  321. data/app/assets/stylesheets/wallaby/base/_normalize.scss +0 -0
  322. data/app/assets/stylesheets/wallaby/base/_reset.scss +0 -0
  323. data/app/assets/stylesheets/wallaby/components/_forms.scss +0 -53
  324. data/app/assets/stylesheets/wallaby/components/_nav.scss +0 -19
  325. data/app/assets/stylesheets/wallaby/components/_tables.scss +0 -78
  326. data/app/assets/stylesheets/wallaby/form.scss +0 -11
  327. data/app/controllers/wallaby/core_controller.rb +0 -28
  328. data/app/views/layouts/wallaby/_footer.html.erb +0 -2
  329. data/app/views/layouts/wallaby/_header.html.erb +0 -57
  330. data/app/views/layouts/wallaby/_navs.html.erb +0 -1
  331. data/app/views/wallaby/errors/access_denied.html.erb +0 -1
  332. data/app/views/wallaby/errors/not_authenticated.html.erb +0 -1
  333. data/app/views/wallaby/errors/not_found.html.erb +0 -6
  334. data/app/views/wallaby/errors/unprocessable_entity.erb +0 -1
  335. data/config/locales/en.yml +0 -29
  336. data/lib/adaptors/wallaby/active_record/model_operator/normalizer.rb +0 -44
  337. data/lib/adaptors/wallaby/active_record/model_operator/permitter.rb +0 -50
  338. data/lib/adaptors/wallaby/active_record/model_operator/querier.rb +0 -47
  339. data/lib/adaptors/wallaby/active_record/model_operator/validator.rb +0 -16
  340. data/lib/adaptors/wallaby/active_record/model_operator.rb +0 -82
  341. data/lib/errors/wallaby/deprecated.rb +0 -4
  342. data/lib/errors/wallaby/operation_not_found.rb +0 -4
  343. data/lib/handlers/wallaby/cached_compiled_erb.rb +0 -14
  344. data/lib/helpers/wallaby/core_helper.rb +0 -50
  345. data/lib/helpers/wallaby/paginatable_helper.rb +0 -9
  346. data/lib/helpers/wallaby/sorting_helper.rb +0 -43
  347. data/lib/interfaces/wallaby/model_operator.rb +0 -31
  348. data/lib/services/wallaby/decorator_finder.rb +0 -16
  349. data/lib/services/wallaby/model_servicer.rb +0 -38
  350. data/lib/services/wallaby/servicer_finder.rb +0 -5
@@ -0,0 +1,12 @@
1
+ module Wallaby
2
+ class Configuration
3
+ # Configuration for metadata
4
+ class Metadata
5
+ attr_writer :max
6
+
7
+ def max
8
+ @max ||= DEFAULT_MAX
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,17 +1,32 @@
1
- class Wallaby::Configuration::Models
2
- def set(models)
3
- @models = Array models
4
- end
1
+ module Wallaby
2
+ class Configuration
3
+ # Configuration for the model classes that Wallaby should handle
4
+ # > NOTE: In `devlopment` environment, Rails recreates module/class
5
+ # > constants on reload event. If we cache constants, they will become
6
+ # > stale and raise conflicts.
7
+ # > Hence, we need to storing name strings instead of constants.
8
+ class Models
9
+ # Specify the model classes that Wallaby should handle
10
+ # @param models [Array<Class>]
11
+ def set(*models)
12
+ @models = Array(models).flatten.map(&:to_s)
13
+ end
5
14
 
6
- def presence
7
- @models.presence
8
- end
15
+ # @return [Array<Class>, nil] the list of models that user has configured
16
+ def presence
17
+ (@models ||= []).map(&:constantize)
18
+ end
9
19
 
10
- def excludes
11
- @excludes ||= []
12
- end
20
+ # Specify the model classes that user wants to exclude
21
+ # @param models [Array<Class>]
22
+ def exclude(*models)
23
+ @excludes = Array(models).flatten.map(&:to_s)
24
+ end
13
25
 
14
- def exclude(*models)
15
- @excludes = models
26
+ # @return [Array<Class>] the list of models that user has configured
27
+ def excludes
28
+ (@excludes ||= []).map(&:constantize)
29
+ end
30
+ end
16
31
  end
17
32
  end
@@ -0,0 +1,12 @@
1
+ module Wallaby
2
+ class Configuration
3
+ # Configuration for metadata
4
+ class Pagination
5
+ attr_writer :page_size
6
+
7
+ def page_size
8
+ @page_size ||= DEFAULT_PAGE_SIZE
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,30 +1,61 @@
1
- class Wallaby::Configuration::Security
2
- # by default, current_user returns nil
3
- DEFAULT_CURRENT_USER = -> {}
4
- # by default, authenticate returns true not to stop the before_action chain
5
- DEFAULT_AUTHENTICATE = -> { true }
1
+ module Wallaby
2
+ class Configuration
3
+ # Security configuration
4
+ class Security
5
+ # by default, current_user returns nil
6
+ DEFAULT_CURRENT_USER = -> { nil }
7
+ # by default, not to stop the before_action chain
8
+ DEFAULT_AUTHENTICATE = -> { true }
6
9
 
7
- def current_user(&block)
8
- if block_given?
9
- @current_user = block
10
- else
11
- @current_user ||= DEFAULT_CURRENT_USER
12
- end
13
- end
10
+ # Configure how to get the current user. All application controller
11
+ # methods will be available.
12
+ # @example
13
+ # ```
14
+ # Wallaby.config do |c|
15
+ # c.security.current_user do
16
+ # User.find_by_email session[:user_email]
17
+ # end
18
+ # end
19
+ # ```
20
+ def current_user(&block)
21
+ if block_given?
22
+ @current_user = block
23
+ else
24
+ @current_user ||= DEFAULT_CURRENT_USER
25
+ end
26
+ end
14
27
 
15
- def current_user?
16
- current_user != DEFAULT_CURRENT_USER
17
- end
28
+ # See if current_user configuration is set
29
+ # @return [Boolean]
30
+ def current_user?
31
+ current_user != DEFAULT_CURRENT_USER
32
+ end
18
33
 
19
- def authenticate(&block)
20
- if block_given?
21
- @authenticate = block
22
- else
23
- @authenticate ||= DEFAULT_AUTHENTICATE
24
- end
25
- end
34
+ # Configure how to authenicate a user. All application controller
35
+ # methods will be available.
36
+ # @example
37
+ # ```
38
+ # Wallaby.config do |c|
39
+ # c.security.authenticate do
40
+ # authenticate_or_request_with_http_basic do |username, password|
41
+ # username == 'too_simple' && password == 'too_naive'
42
+ # end
43
+ # end
44
+ # end
45
+ # ```
46
+ def authenticate(&block)
47
+ if block_given?
48
+ @authenticate = block
49
+ else
50
+ @authenticate ||= DEFAULT_AUTHENTICATE
51
+ end
52
+ end
26
53
 
27
- def authenticate?
28
- authenticate != DEFAULT_AUTHENTICATE
54
+ # See if authenticate configuration is set
55
+ # @return [Boolean]
56
+ def authenticate?
57
+ authenticate != DEFAULT_AUTHENTICATE
58
+ end
59
+ end
29
60
  end
30
61
  end
@@ -1,49 +1,68 @@
1
+ # Wallaby
1
2
  module Wallaby
3
+ # Global configuration
2
4
  class Configuration
3
- def adaptor
4
- @adaptor ||= Wallaby::ActiveRecord
5
- end
5
+ attr_writer :base_controller, :page_size
6
6
 
7
- def adaptor=(adaptor)
8
- if @adaptor
9
- fail 'Adaptor has been initialized. Please place adaptor assignment at the top of configuration.'
10
- end
11
- @adaptor = adaptor
7
+ # @return [Class]
8
+ # the controller that Wallaby should inherit from
9
+ def base_controller
10
+ @base_controller ||= ::ApplicationController
12
11
  end
13
12
 
13
+ # @see Wallaby::Configuration#models= for configuration
14
+ # @return [Wallaby::Configuration::Models]
15
+ # a list of models that Wallaby should handle
14
16
  def models
15
17
  @models ||= Models.new
16
18
  end
17
19
 
20
+ # To configure the models that Wallaby should handle
21
+ # @models [Array] a list of models
18
22
  def models=(models)
19
23
  self.models.set models
20
24
  end
21
25
 
26
+ # @return [Wallaby::Configuration::Security]
27
+ # security configuration, mostly for authentication
22
28
  def security
23
29
  @security ||= Security.new
24
30
  end
25
31
 
26
- def base_controller
27
- @base_controller ||= ::ApplicationController
32
+ # @return [Wallaby::Configuration::Metadata] configuration of metadata
33
+ def metadata
34
+ @metadata ||= Metadata.new
35
+ end
36
+
37
+ # @return [Wallaby::Configuration::Pagination] pagination configuration
38
+ def pagination
39
+ @pagination ||= Pagination.new
40
+ end
41
+
42
+ # @return [Wallaby::Configuration::Features] configuration for features
43
+ def features
44
+ @features ||= Features.new
28
45
  end
29
46
 
30
- def base_controller=(base_controller)
31
- @base_controller = base_controller
47
+ # Clear all configurations
48
+ # @return nil
49
+ def clear
50
+ @base_controller, @models, @security, @pagination, @metadata,
51
+ @features = []
32
52
  end
33
53
  end
34
54
 
55
+ # @return [Wallaby::Configuration]
35
56
  def self.configuration
36
57
  @configuration ||= Configuration.new
37
58
  end
38
59
 
60
+ # To config settings in below style
61
+ # @example
62
+ # Wallaby.config do |c|
63
+ # c.pagination.page_size = 20
64
+ # end
39
65
  def self.config
40
66
  yield configuration
41
67
  end
42
-
43
- def self.adaptor
44
- configuration.adaptor
45
- end
46
68
  end
47
-
48
- require 'wallaby/configuration/models'
49
- require 'wallaby/configuration/security'
@@ -1,89 +1,134 @@
1
1
  # NOTE: We need to require the following rails engines
2
- # so that the main app could pick up the assets from these engines even they don't appear in the `Gemfile`
3
- require 'devise'
2
+ # so that the main app could pick up the assets from these engines
3
+ # even if they don't appear in the `Gemfile`
4
4
  require 'cancancan'
5
5
  require 'kaminari'
6
+ require 'parslet'
7
+ require 'responders'
8
+ require 'jbuilder'
6
9
 
7
10
  require 'sass-rails'
11
+
8
12
  require 'bootstrap-sass'
13
+ require 'font-awesome-sass'
9
14
  require 'bootstrap3-datetimepicker-rails'
10
15
  require 'codemirror-rails'
11
16
  require 'jquery-minicolors-rails'
12
17
  require 'jquery-rails'
13
18
  require 'momentjs-rails'
14
- require 'rails-bootstrap-markdown'
15
19
  require 'summernote-rails'
20
+ require 'twitter-typeahead-rails'
21
+
22
+ require 'csv'
23
+ require 'securerandom'
16
24
 
17
25
  module Wallaby
26
+ # Rails engine
18
27
  class Engine < ::Rails::Engine
19
28
  # isolate_namespace Wallaby
29
+
20
30
  initializer 'wallaby.deflate' do |app|
31
+ # default to Gzip HTML
21
32
  app.config.middleware.use Rack::Deflater
22
33
  end
23
34
 
24
- initializer 'wallaby.initialize_cache' do |app|
25
- Rails.cache.delete_matched 'wallaby/*'
35
+ initializer 'wallaby.assets.precompile' do |app|
36
+ app.config.assets.precompile +=
37
+ %w(
38
+ codemirror* codemirror/**/*
39
+ wallaby/404.png wallaby/422.png wallaby/500.png
40
+ turbolinks
41
+ )
42
+ end
26
43
 
27
- ActionView::Template.class_eval do
28
- register_template_handler :erb, Wallaby::CachedCompiledErb.new
29
- end
44
+ config.before_eager_load do
45
+ # We need to ensure that the core models are loaded before anything else
46
+ ::Wallaby::Utils.preload 'app/models/**/*.rb'
30
47
  end
31
48
 
32
- initializer 'wallaby.assets.precompile' do |app|
33
- app.config.assets.precompile += %w( wallaby/form.js wallaby/form.css )
34
- app.config.assets.precompile += %w( codemirror* codemirror/**/* )
49
+ config.after_initialize do
50
+ unless Rails.env.development? || Rails.configuration.eager_load
51
+ ::Wallaby::Utils.preload_all
52
+ end
35
53
  end
36
54
  end
37
55
  end
38
56
 
39
57
  require 'wallaby/configuration'
58
+ require 'wallaby/configuration/models'
59
+ require 'wallaby/configuration/security'
60
+ require 'wallaby/configuration/metadata'
61
+ require 'wallaby/configuration/pagination'
62
+ require 'wallaby/configuration/features'
63
+
64
+ require 'utils/wallaby/utils'
65
+ require 'tree/wallaby/node'
40
66
 
41
67
  require 'interfaces/wallaby/mode'
42
68
  require 'interfaces/wallaby/model_decorator'
43
69
  require 'interfaces/wallaby/model_finder'
44
- require 'interfaces/wallaby/model_operator'
70
+ require 'interfaces/wallaby/model_service_provider'
71
+ require 'interfaces/wallaby/model_pagination_provider'
45
72
 
46
73
  require 'errors/wallaby/general_error'
47
- require 'errors/wallaby/deprecated'
48
74
  require 'errors/wallaby/invalid_error'
75
+ require 'errors/wallaby/not_found'
49
76
  require 'errors/wallaby/model_not_found'
50
77
  require 'errors/wallaby/not_authenticated'
51
78
  require 'errors/wallaby/not_implemented'
52
- require 'errors/wallaby/operation_not_found'
53
79
  require 'errors/wallaby/resource_not_found'
54
80
 
81
+ require 'parsers/wallaby/parser'
82
+
55
83
  require 'adaptors/wallaby/active_record'
56
84
  require 'adaptors/wallaby/active_record/model_decorator'
57
- require 'adaptors/wallaby/active_record/model_decorator/fields_builder'
85
+ fields_builder = 'adaptors/wallaby/active_record/model_decorator/fields_builder'
86
+ require fields_builder
87
+ require "#{fields_builder}/sti_builder"
88
+ require "#{fields_builder}/association_builder"
89
+ require "#{fields_builder}/polymorphic_builder"
58
90
  require 'adaptors/wallaby/active_record/model_decorator/title_field_finder'
59
91
  require 'adaptors/wallaby/active_record/model_finder'
60
- require 'adaptors/wallaby/active_record/model_operator'
61
- require 'adaptors/wallaby/active_record/model_operator/normalizer'
62
- require 'adaptors/wallaby/active_record/model_operator/permitter'
63
- require 'adaptors/wallaby/active_record/model_operator/querier'
64
- require 'adaptors/wallaby/active_record/model_operator/validator'
65
-
92
+ require 'adaptors/wallaby/active_record/model_pagination_provider'
93
+ service_provider = 'adaptors/wallaby/active_record/model_service_provider'
94
+ require service_provider
95
+ require "#{service_provider}/normalizer"
96
+ require "#{service_provider}/permitter"
97
+ require "#{service_provider}/querier"
98
+ require "#{service_provider}/querier/transformer"
99
+ require "#{service_provider}/validator"
100
+
101
+ require 'paginators/wallaby/abstract_resource_paginator'
102
+ require 'paginators/wallaby/resource_paginator'
103
+ require 'decorators/wallaby/abstract_resource_decorator'
66
104
  require 'decorators/wallaby/resource_decorator'
105
+ require 'servicers/wallaby/abstract_model_servicer'
106
+ require 'servicers/wallaby/model_servicer'
67
107
 
68
108
  require 'forms/wallaby/form_builder'
69
109
 
70
- require 'handlers/wallaby/cached_compiled_erb'
71
-
72
110
  require 'services/wallaby/map'
73
- require 'services/wallaby/decorator_finder'
111
+ require 'services/wallaby/map/mode_mapper'
112
+ require 'services/wallaby/map/model_class_collector'
113
+ require 'services/wallaby/map/model_class_mapper'
74
114
  require 'services/wallaby/lookup_context_wrapper'
75
- require 'services/wallaby/model_servicer'
76
- require 'services/wallaby/servicer_finder'
77
-
78
- require 'utils/wallaby/utils'
79
-
80
- require 'helpers//wallaby/form_helper'
81
- require 'helpers//wallaby/links_helper'
82
- require 'helpers//wallaby/paginatable_helper'
83
- require 'helpers//wallaby/sorting_helper'
84
- require 'helpers//wallaby/styling_helper'
85
-
86
- require 'helpers//wallaby/resources_helper'
87
- require 'helpers//wallaby/core_helper'
88
- require 'helpers//wallaby/secure_helper'
89
- require 'helpers//wallaby/application_helper'
115
+ require 'services/wallaby/prefixes_builder'
116
+ require 'services/wallaby/url_for'
117
+ require 'services/wallaby/partial_renderer'
118
+ require 'services/wallaby/link_options_normalizer'
119
+ require 'services/wallaby/sorting/hash_builder'
120
+ require 'services/wallaby/sorting/next_builder'
121
+ require 'services/wallaby/sorting/link_builder'
122
+
123
+ require 'helpers/wallaby/form_helper'
124
+ require 'helpers/wallaby/links_helper'
125
+ require 'helpers/wallaby/styling_helper'
126
+ require 'helpers/wallaby/index_helper'
127
+
128
+ require 'helpers/wallaby/resources_helper'
129
+ require 'helpers/wallaby/base_helper'
130
+ require 'helpers/wallaby/secure_helper'
131
+ require 'helpers/wallaby/application_helper'
132
+
133
+ require 'responders/wallaby/abstract_responder'
134
+ require 'responders/wallaby/resources_responder'
@@ -1,3 +1,3 @@
1
1
  module Wallaby
2
- VERSION = '5.0.1'
2
+ VERSION = '5.1.3'.freeze
3
3
  end
data/lib/wallaby.rb CHANGED
@@ -1,5 +1,24 @@
1
- require "wallaby/engine"
2
-
3
1
  module Wallaby
4
- NAMESPACE = 'wallaby'
2
+ EMPTY_STRING = ''.freeze
3
+ EMPTY_HASH = {}.freeze
4
+ SPACE = ' '.freeze
5
+ SLASH = '/'.freeze
6
+ COLONS = '::'.freeze
7
+ COMMA = ','.freeze
8
+ CSV = 'csv'.freeze
9
+ PERS = [10, 20, 50, 100].freeze
10
+ DEFAULT_PAGE_SIZE = 20
11
+ DEFAULT_MAX = 20
12
+ ERRORS = %i(
13
+ bad_request
14
+ forbidden
15
+ internal_server_error
16
+ not_found
17
+ unauthorized
18
+ unprocessable_entity
19
+ ).freeze
20
+ WILDCARD = 'QUERY'.freeze
21
+ FORM_ACTIONS = %w(new create edit update).freeze
5
22
  end
23
+
24
+ require 'wallaby/engine'