rabl 0.13.1 → 0.14.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (392) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +21 -0
  3. data/CONTRIBUTING.md +2 -2
  4. data/README.md +15 -10
  5. data/lib/rabl.rb +4 -4
  6. data/lib/rabl/builder.rb +29 -17
  7. data/lib/rabl/cache_engine.rb +30 -1
  8. data/lib/rabl/configuration.rb +2 -0
  9. data/lib/rabl/engine.rb +21 -10
  10. data/lib/rabl/helpers.rb +7 -3
  11. data/lib/rabl/railtie.rb +18 -1
  12. data/lib/rabl/template.rb +21 -1
  13. data/lib/rabl/version.rb +1 -1
  14. metadata +5 -384
  15. data/.gitignore +0 -8
  16. data/.travis.yml +0 -15
  17. data/Gemfile +0 -28
  18. data/Rakefile +0 -54
  19. data/examples/base.json.rabl +0 -8
  20. data/examples/demo.json.rabl +0 -42
  21. data/examples/inherited.json.rabl +0 -11
  22. data/fixtures/ashared/NOTES +0 -44
  23. data/fixtures/ashared/README +0 -39
  24. data/fixtures/ashared/migrate/20111002092016_create_users.rb +0 -15
  25. data/fixtures/ashared/migrate/20111002092019_create_posts.rb +0 -14
  26. data/fixtures/ashared/migrate/20111002092024_create_phone_numbers.rb +0 -16
  27. data/fixtures/ashared/models/phone_number.rb +0 -7
  28. data/fixtures/ashared/models/post.rb +0 -3
  29. data/fixtures/ashared/models/user.rb +0 -3
  30. data/fixtures/ashared/views/layouts/application.html.erb +0 -9
  31. data/fixtures/ashared/views/posts/_show_footer_script.js.erb +0 -1
  32. data/fixtures/ashared/views/posts/date.rabl +0 -3
  33. data/fixtures/ashared/views/posts/index.rabl +0 -12
  34. data/fixtures/ashared/views/posts/show.rabl +0 -17
  35. data/fixtures/ashared/views/users/index.json.rabl +0 -3
  36. data/fixtures/ashared/views/users/phone_number.json.rabl +0 -6
  37. data/fixtures/ashared/views/users/show.json.rabl +0 -16
  38. data/fixtures/ashared/views_rails_3/layouts/application.html.erb +0 -13
  39. data/fixtures/ashared/views_rails_3/posts/_show_footer_script.js.erb +0 -1
  40. data/fixtures/ashared/views_rails_3/posts/date.rabl +0 -3
  41. data/fixtures/ashared/views_rails_3/posts/index.html.erb +0 -3
  42. data/fixtures/ashared/views_rails_3/posts/index.rabl +0 -12
  43. data/fixtures/ashared/views_rails_3/posts/renderer.rabl +0 -8
  44. data/fixtures/ashared/views_rails_3/posts/renderer_partial.rabl +0 -4
  45. data/fixtures/ashared/views_rails_3/posts/show.html.erb +0 -3
  46. data/fixtures/ashared/views_rails_3/posts/show.rabl +0 -25
  47. data/fixtures/ashared/views_rails_3/posts/show.rabl_test_v1.rabl +0 -7
  48. data/fixtures/ashared/views_rails_3/users/index.json.rabl +0 -3
  49. data/fixtures/ashared/views_rails_3/users/phone_number.json.rabl +0 -8
  50. data/fixtures/ashared/views_rails_3/users/phone_number.xml.rabl +0 -1
  51. data/fixtures/ashared/views_rails_3/users/show.json.rabl +0 -16
  52. data/fixtures/ashared/views_rails_3/users/show.rabl_test_v1.rabl +0 -3
  53. data/fixtures/padrino_test/.components +0 -7
  54. data/fixtures/padrino_test/.gitignore +0 -7
  55. data/fixtures/padrino_test/Gemfile +0 -17
  56. data/fixtures/padrino_test/Rakefile +0 -3
  57. data/fixtures/padrino_test/app/app.rb +0 -31
  58. data/fixtures/padrino_test/app/controllers/posts.rb +0 -11
  59. data/fixtures/padrino_test/app/controllers/users.rb +0 -11
  60. data/fixtures/padrino_test/app/helpers/posts_helper.rb +0 -7
  61. data/fixtures/padrino_test/app/helpers/users_helper.rb +0 -7
  62. data/fixtures/padrino_test/app/views +0 -1
  63. data/fixtures/padrino_test/config.ru +0 -9
  64. data/fixtures/padrino_test/config/apps.rb +0 -34
  65. data/fixtures/padrino_test/config/boot.rb +0 -29
  66. data/fixtures/padrino_test/config/database.rb +0 -43
  67. data/fixtures/padrino_test/db/migrate +0 -1
  68. data/fixtures/padrino_test/db/schema.rb +0 -42
  69. data/fixtures/padrino_test/models +0 -1
  70. data/fixtures/padrino_test/public/favicon.ico +0 -0
  71. data/fixtures/padrino_test/test/app/controllers/posts_controller_test.rb +0 -1
  72. data/fixtures/padrino_test/test/app/controllers/users_controller_test.rb +0 -1
  73. data/fixtures/padrino_test/test/test.rake +0 -18
  74. data/fixtures/padrino_test/test/test_config.rb +0 -18
  75. data/fixtures/rails2/.gitignore +0 -1
  76. data/fixtures/rails2/Gemfile +0 -10
  77. data/fixtures/rails2/Rakefile +0 -14
  78. data/fixtures/rails2/app/controllers/application_controller.rb +0 -10
  79. data/fixtures/rails2/app/controllers/posts_controller.rb +0 -15
  80. data/fixtures/rails2/app/controllers/users_controller.rb +0 -15
  81. data/fixtures/rails2/app/helpers/application_helper.rb +0 -2
  82. data/fixtures/rails2/app/helpers/posts_helper.rb +0 -2
  83. data/fixtures/rails2/app/helpers/users_helper.rb +0 -2
  84. data/fixtures/rails2/app/models +0 -1
  85. data/fixtures/rails2/app/views +0 -1
  86. data/fixtures/rails2/config/boot.rb +0 -129
  87. data/fixtures/rails2/config/database.yml +0 -16
  88. data/fixtures/rails2/config/environment.rb +0 -64
  89. data/fixtures/rails2/config/environments/development.rb +0 -17
  90. data/fixtures/rails2/config/environments/production.rb +0 -28
  91. data/fixtures/rails2/config/environments/test.rb +0 -28
  92. data/fixtures/rails2/config/initializers/backtrace_silencers.rb +0 -7
  93. data/fixtures/rails2/config/initializers/cookie_verification_secret.rb +0 -7
  94. data/fixtures/rails2/config/initializers/inflections.rb +0 -10
  95. data/fixtures/rails2/config/initializers/mime_types.rb +0 -5
  96. data/fixtures/rails2/config/initializers/new_rails_defaults.rb +0 -21
  97. data/fixtures/rails2/config/initializers/session_store.rb +0 -15
  98. data/fixtures/rails2/config/locales/en.yml +0 -5
  99. data/fixtures/rails2/config/preinitializer.rb +0 -20
  100. data/fixtures/rails2/config/routes.rb +0 -45
  101. data/fixtures/rails2/db/migrate +0 -1
  102. data/fixtures/rails2/db/schema.rb +0 -40
  103. data/fixtures/rails2/db/seeds.rb +0 -7
  104. data/fixtures/rails2/public/404.html +0 -30
  105. data/fixtures/rails2/public/422.html +0 -30
  106. data/fixtures/rails2/public/500.html +0 -30
  107. data/fixtures/rails2/public/favicon.ico +0 -0
  108. data/fixtures/rails2/public/images/rails.png +0 -0
  109. data/fixtures/rails2/public/index.html +0 -275
  110. data/fixtures/rails2/public/robots.txt +0 -5
  111. data/fixtures/rails2/script/about +0 -4
  112. data/fixtures/rails2/script/console +0 -3
  113. data/fixtures/rails2/script/dbconsole +0 -3
  114. data/fixtures/rails2/script/destroy +0 -3
  115. data/fixtures/rails2/script/generate +0 -3
  116. data/fixtures/rails2/script/performance/benchmarker +0 -3
  117. data/fixtures/rails2/script/performance/profiler +0 -3
  118. data/fixtures/rails2/script/plugin +0 -3
  119. data/fixtures/rails2/script/runner +0 -3
  120. data/fixtures/rails2/script/server +0 -3
  121. data/fixtures/rails2/test/functionals/posts_controller_test.rb +0 -1
  122. data/fixtures/rails2/test/functionals/users_controller_test.rb +0 -1
  123. data/fixtures/rails2/test/test_helper.rb +0 -33
  124. data/fixtures/rails3/.gitignore +0 -4
  125. data/fixtures/rails3/Gemfile +0 -37
  126. data/fixtures/rails3/Rakefile +0 -12
  127. data/fixtures/rails3/app/controllers/application_controller.rb +0 -14
  128. data/fixtures/rails3/app/controllers/posts_controller.rb +0 -11
  129. data/fixtures/rails3/app/controllers/users_controller.rb +0 -11
  130. data/fixtures/rails3/app/models +0 -1
  131. data/fixtures/rails3/app/views +0 -1
  132. data/fixtures/rails3/config.ru +0 -4
  133. data/fixtures/rails3/config/application.rb +0 -42
  134. data/fixtures/rails3/config/boot.rb +0 -6
  135. data/fixtures/rails3/config/database.yml +0 -22
  136. data/fixtures/rails3/config/environment.rb +0 -5
  137. data/fixtures/rails3/config/environments/development.rb +0 -26
  138. data/fixtures/rails3/config/environments/production.rb +0 -49
  139. data/fixtures/rails3/config/environments/test.rb +0 -35
  140. data/fixtures/rails3/config/initializers/backtrace_silencers.rb +0 -7
  141. data/fixtures/rails3/config/initializers/inflections.rb +0 -10
  142. data/fixtures/rails3/config/initializers/mime_types.rb +0 -5
  143. data/fixtures/rails3/config/initializers/secret_token.rb +0 -7
  144. data/fixtures/rails3/config/initializers/session_store.rb +0 -8
  145. data/fixtures/rails3/config/locales/en.yml +0 -5
  146. data/fixtures/rails3/config/routes.rb +0 -61
  147. data/fixtures/rails3/db/migrate +0 -1
  148. data/fixtures/rails3/db/seeds.rb +0 -7
  149. data/fixtures/rails3/lib/tasks/.gitkeep +0 -0
  150. data/fixtures/rails3/public/404.html +0 -26
  151. data/fixtures/rails3/public/422.html +0 -26
  152. data/fixtures/rails3/public/500.html +0 -26
  153. data/fixtures/rails3/public/favicon.ico +0 -0
  154. data/fixtures/rails3/public/images/rails.png +0 -0
  155. data/fixtures/rails3/public/index.html +0 -239
  156. data/fixtures/rails3/public/robots.txt +0 -5
  157. data/fixtures/rails3/public/stylesheets/.gitkeep +0 -0
  158. data/fixtures/rails3/script/rails +0 -6
  159. data/fixtures/rails3/test/functional/posts_controller_test.rb +0 -1
  160. data/fixtures/rails3/test/functional/users_controller_test.rb +0 -1
  161. data/fixtures/rails3/test/test_helper.rb +0 -26
  162. data/fixtures/rails3_2/.gitignore +0 -15
  163. data/fixtures/rails3_2/Gemfile +0 -40
  164. data/fixtures/rails3_2/README.rdoc +0 -261
  165. data/fixtures/rails3_2/Rakefile +0 -12
  166. data/fixtures/rails3_2/app/assets/images/rails.png +0 -0
  167. data/fixtures/rails3_2/app/assets/javascripts/application.js +0 -15
  168. data/fixtures/rails3_2/app/assets/javascripts/posts.js.coffee +0 -3
  169. data/fixtures/rails3_2/app/assets/javascripts/users.js.coffee +0 -3
  170. data/fixtures/rails3_2/app/assets/stylesheets/application.css +0 -13
  171. data/fixtures/rails3_2/app/assets/stylesheets/posts.css.scss +0 -3
  172. data/fixtures/rails3_2/app/assets/stylesheets/users.css.scss +0 -3
  173. data/fixtures/rails3_2/app/controllers/application_controller.rb +0 -14
  174. data/fixtures/rails3_2/app/controllers/posts_controller.rb +0 -16
  175. data/fixtures/rails3_2/app/controllers/users_controller.rb +0 -11
  176. data/fixtures/rails3_2/app/helpers/application_helper.rb +0 -5
  177. data/fixtures/rails3_2/app/helpers/posts_helper.rb +0 -2
  178. data/fixtures/rails3_2/app/helpers/users_helper.rb +0 -2
  179. data/fixtures/rails3_2/app/mailers/.gitkeep +0 -0
  180. data/fixtures/rails3_2/app/models +0 -1
  181. data/fixtures/rails3_2/app/views +0 -1
  182. data/fixtures/rails3_2/config.ru +0 -4
  183. data/fixtures/rails3_2/config/application.rb +0 -59
  184. data/fixtures/rails3_2/config/boot.rb +0 -6
  185. data/fixtures/rails3_2/config/database.yml +0 -25
  186. data/fixtures/rails3_2/config/environment.rb +0 -5
  187. data/fixtures/rails3_2/config/environments/development.rb +0 -37
  188. data/fixtures/rails3_2/config/environments/production.rb +0 -67
  189. data/fixtures/rails3_2/config/environments/test.rb +0 -37
  190. data/fixtures/rails3_2/config/initializers/backtrace_silencers.rb +0 -7
  191. data/fixtures/rails3_2/config/initializers/inflections.rb +0 -15
  192. data/fixtures/rails3_2/config/initializers/mime_types.rb +0 -7
  193. data/fixtures/rails3_2/config/initializers/secret_token.rb +0 -7
  194. data/fixtures/rails3_2/config/initializers/session_store.rb +0 -8
  195. data/fixtures/rails3_2/config/initializers/wrap_parameters.rb +0 -14
  196. data/fixtures/rails3_2/config/locales/en.yml +0 -5
  197. data/fixtures/rails3_2/config/routes.rb +0 -64
  198. data/fixtures/rails3_2/db/migrate +0 -1
  199. data/fixtures/rails3_2/db/schema.rb +0 -42
  200. data/fixtures/rails3_2/db/seeds.rb +0 -7
  201. data/fixtures/rails3_2/doc/README_FOR_APP +0 -2
  202. data/fixtures/rails3_2/lib/assets/.gitkeep +0 -0
  203. data/fixtures/rails3_2/lib/tasks/.gitkeep +0 -0
  204. data/fixtures/rails3_2/log/.gitkeep +0 -0
  205. data/fixtures/rails3_2/public/404.html +0 -26
  206. data/fixtures/rails3_2/public/422.html +0 -26
  207. data/fixtures/rails3_2/public/500.html +0 -25
  208. data/fixtures/rails3_2/public/favicon.ico +0 -0
  209. data/fixtures/rails3_2/public/index.html +0 -241
  210. data/fixtures/rails3_2/public/robots.txt +0 -5
  211. data/fixtures/rails3_2/script/rails +0 -6
  212. data/fixtures/rails3_2/test/fixtures/phone_numbers.yml +0 -11
  213. data/fixtures/rails3_2/test/fixtures/posts.yml +0 -11
  214. data/fixtures/rails3_2/test/fixtures/users.yml +0 -11
  215. data/fixtures/rails3_2/test/functional/posts_controller_test.rb +0 -1
  216. data/fixtures/rails3_2/test/functional/users_controller_test.rb +0 -1
  217. data/fixtures/rails3_2/test/integration/.gitkeep +0 -0
  218. data/fixtures/rails3_2/test/performance/browsing_test.rb +0 -12
  219. data/fixtures/rails3_2/test/test_helper.rb +0 -26
  220. data/fixtures/rails3_2/test/unit/helpers/posts_helper_test.rb +0 -4
  221. data/fixtures/rails3_2/test/unit/helpers/users_helper_test.rb +0 -4
  222. data/fixtures/rails3_2/test/unit/phone_number_test.rb +0 -7
  223. data/fixtures/rails3_2/test/unit/post_test.rb +0 -7
  224. data/fixtures/rails3_2/test/unit/user_test.rb +0 -7
  225. data/fixtures/rails3_2/vendor/assets/javascripts/.gitkeep +0 -0
  226. data/fixtures/rails3_2/vendor/assets/stylesheets/.gitkeep +0 -0
  227. data/fixtures/rails3_2/vendor/plugins/.gitkeep +0 -0
  228. data/fixtures/rails4/.gitignore +0 -16
  229. data/fixtures/rails4/Gemfile +0 -49
  230. data/fixtures/rails4/README.rdoc +0 -28
  231. data/fixtures/rails4/Rakefile +0 -11
  232. data/fixtures/rails4/app/assets/javascripts/application.js +0 -16
  233. data/fixtures/rails4/app/assets/stylesheets/application.css +0 -13
  234. data/fixtures/rails4/app/controllers/application_controller.rb +0 -5
  235. data/fixtures/rails4/app/controllers/concerns/.keep +0 -0
  236. data/fixtures/rails4/app/controllers/posts_controller.rb +0 -16
  237. data/fixtures/rails4/app/controllers/users_controller.rb +0 -11
  238. data/fixtures/rails4/app/helpers/application_helper.rb +0 -5
  239. data/fixtures/rails4/app/mailers/.keep +0 -0
  240. data/fixtures/rails4/app/models +0 -1
  241. data/fixtures/rails4/app/views +0 -1
  242. data/fixtures/rails4/bin/bundle +0 -3
  243. data/fixtures/rails4/bin/rails +0 -4
  244. data/fixtures/rails4/bin/rake +0 -4
  245. data/fixtures/rails4/config.ru +0 -4
  246. data/fixtures/rails4/config/application.rb +0 -23
  247. data/fixtures/rails4/config/boot.rb +0 -4
  248. data/fixtures/rails4/config/database.yml +0 -25
  249. data/fixtures/rails4/config/environment.rb +0 -5
  250. data/fixtures/rails4/config/environments/development.rb +0 -29
  251. data/fixtures/rails4/config/environments/production.rb +0 -80
  252. data/fixtures/rails4/config/environments/test.rb +0 -36
  253. data/fixtures/rails4/config/initializers/backtrace_silencers.rb +0 -7
  254. data/fixtures/rails4/config/initializers/filter_parameter_logging.rb +0 -4
  255. data/fixtures/rails4/config/initializers/inflections.rb +0 -16
  256. data/fixtures/rails4/config/initializers/mime_types.rb +0 -7
  257. data/fixtures/rails4/config/initializers/secret_token.rb +0 -12
  258. data/fixtures/rails4/config/initializers/session_store.rb +0 -3
  259. data/fixtures/rails4/config/initializers/wrap_parameters.rb +0 -14
  260. data/fixtures/rails4/config/locales/en.yml +0 -23
  261. data/fixtures/rails4/config/routes.rb +0 -55
  262. data/fixtures/rails4/db/migrate +0 -1
  263. data/fixtures/rails4/db/seeds.rb +0 -7
  264. data/fixtures/rails4/lib/assets/.keep +0 -0
  265. data/fixtures/rails4/lib/tasks/.keep +0 -0
  266. data/fixtures/rails4/log/.keep +0 -0
  267. data/fixtures/rails4/public/404.html +0 -58
  268. data/fixtures/rails4/public/422.html +0 -58
  269. data/fixtures/rails4/public/500.html +0 -57
  270. data/fixtures/rails4/public/favicon.ico +0 -0
  271. data/fixtures/rails4/public/robots.txt +0 -5
  272. data/fixtures/rails4/test/controllers/.keep +0 -0
  273. data/fixtures/rails4/test/fixtures/.keep +0 -0
  274. data/fixtures/rails4/test/functional/posts_controller_test.rb +0 -1
  275. data/fixtures/rails4/test/functional/users_controller_test.rb +0 -1
  276. data/fixtures/rails4/test/helpers/.keep +0 -0
  277. data/fixtures/rails4/test/integration/.keep +0 -0
  278. data/fixtures/rails4/test/mailers/.keep +0 -0
  279. data/fixtures/rails4/test/models/.keep +0 -0
  280. data/fixtures/rails4/test/test_helper.rb +0 -26
  281. data/fixtures/rails4/vendor/assets/javascripts/.keep +0 -0
  282. data/fixtures/rails4/vendor/assets/stylesheets/.keep +0 -0
  283. data/fixtures/rails5/.gitignore +0 -21
  284. data/fixtures/rails5/Gemfile +0 -52
  285. data/fixtures/rails5/README.md +0 -24
  286. data/fixtures/rails5/Rakefile +0 -13
  287. data/fixtures/rails5/app/assets/config/manifest.js +0 -3
  288. data/fixtures/rails5/app/assets/images/.keep +0 -0
  289. data/fixtures/rails5/app/assets/javascripts/application.js +0 -16
  290. data/fixtures/rails5/app/assets/javascripts/cable.js +0 -13
  291. data/fixtures/rails5/app/assets/javascripts/channels/.keep +0 -0
  292. data/fixtures/rails5/app/assets/stylesheets/application.css +0 -15
  293. data/fixtures/rails5/app/channels/application_cable/channel.rb +0 -4
  294. data/fixtures/rails5/app/channels/application_cable/connection.rb +0 -4
  295. data/fixtures/rails5/app/controllers/application_controller.rb +0 -3
  296. data/fixtures/rails5/app/controllers/concerns/.keep +0 -0
  297. data/fixtures/rails5/app/controllers/posts_controller.rb +0 -17
  298. data/fixtures/rails5/app/controllers/users_controller.rb +0 -11
  299. data/fixtures/rails5/app/helpers/application_helper.rb +0 -5
  300. data/fixtures/rails5/app/jobs/application_job.rb +0 -2
  301. data/fixtures/rails5/app/mailers/application_mailer.rb +0 -4
  302. data/fixtures/rails5/app/models +0 -1
  303. data/fixtures/rails5/app/views +0 -1
  304. data/fixtures/rails5/bin/bundle +0 -3
  305. data/fixtures/rails5/bin/rails +0 -9
  306. data/fixtures/rails5/bin/rake +0 -9
  307. data/fixtures/rails5/bin/setup +0 -34
  308. data/fixtures/rails5/bin/spring +0 -15
  309. data/fixtures/rails5/bin/update +0 -29
  310. data/fixtures/rails5/config.ru +0 -5
  311. data/fixtures/rails5/config/application.rb +0 -15
  312. data/fixtures/rails5/config/boot.rb +0 -3
  313. data/fixtures/rails5/config/cable.yml +0 -9
  314. data/fixtures/rails5/config/database.yml +0 -25
  315. data/fixtures/rails5/config/environment.rb +0 -5
  316. data/fixtures/rails5/config/environments/development.rb +0 -54
  317. data/fixtures/rails5/config/environments/production.rb +0 -86
  318. data/fixtures/rails5/config/environments/test.rb +0 -42
  319. data/fixtures/rails5/config/initializers/application_controller_renderer.rb +0 -6
  320. data/fixtures/rails5/config/initializers/assets.rb +0 -11
  321. data/fixtures/rails5/config/initializers/backtrace_silencers.rb +0 -7
  322. data/fixtures/rails5/config/initializers/cookies_serializer.rb +0 -5
  323. data/fixtures/rails5/config/initializers/filter_parameter_logging.rb +0 -4
  324. data/fixtures/rails5/config/initializers/inflections.rb +0 -16
  325. data/fixtures/rails5/config/initializers/mime_types.rb +0 -4
  326. data/fixtures/rails5/config/initializers/new_framework_defaults.rb +0 -24
  327. data/fixtures/rails5/config/initializers/session_store.rb +0 -3
  328. data/fixtures/rails5/config/initializers/wrap_parameters.rb +0 -14
  329. data/fixtures/rails5/config/locales/en.yml +0 -23
  330. data/fixtures/rails5/config/puma.rb +0 -47
  331. data/fixtures/rails5/config/routes.rb +0 -8
  332. data/fixtures/rails5/config/secrets.yml +0 -22
  333. data/fixtures/rails5/config/spring.rb +0 -6
  334. data/fixtures/rails5/db/migrate +0 -1
  335. data/fixtures/rails5/db/schema.rb +0 -41
  336. data/fixtures/rails5/db/seeds.rb +0 -7
  337. data/fixtures/rails5/lib/assets/.keep +0 -0
  338. data/fixtures/rails5/lib/tasks/.keep +0 -0
  339. data/fixtures/rails5/log/.keep +0 -0
  340. data/fixtures/rails5/public/404.html +0 -67
  341. data/fixtures/rails5/public/422.html +0 -67
  342. data/fixtures/rails5/public/500.html +0 -66
  343. data/fixtures/rails5/public/apple-touch-icon-precomposed.png +0 -0
  344. data/fixtures/rails5/public/apple-touch-icon.png +0 -0
  345. data/fixtures/rails5/public/favicon.ico +0 -0
  346. data/fixtures/rails5/public/robots.txt +0 -5
  347. data/fixtures/rails5/test/controllers/.keep +0 -0
  348. data/fixtures/rails5/test/fixtures/.keep +0 -0
  349. data/fixtures/rails5/test/fixtures/files/.keep +0 -0
  350. data/fixtures/rails5/test/helpers/.keep +0 -0
  351. data/fixtures/rails5/test/integration/.keep +0 -0
  352. data/fixtures/rails5/test/mailers/.keep +0 -0
  353. data/fixtures/rails5/test/models/.keep +0 -0
  354. data/fixtures/rails5/test/test_helper.rb +0 -26
  355. data/fixtures/rails5/tmp/.keep +0 -0
  356. data/fixtures/rails5/vendor/assets/javascripts/.keep +0 -0
  357. data/fixtures/rails5/vendor/assets/stylesheets/.keep +0 -0
  358. data/fixtures/sinatra_test/Gemfile +0 -13
  359. data/fixtures/sinatra_test/Rakefile +0 -6
  360. data/fixtures/sinatra_test/app.rb +0 -55
  361. data/fixtures/sinatra_test/config.ru +0 -7
  362. data/fixtures/sinatra_test/db/migrate +0 -1
  363. data/fixtures/sinatra_test/models +0 -1
  364. data/fixtures/sinatra_test/test/functional/posts_controller_test.rb +0 -1
  365. data/fixtures/sinatra_test/test/functional/users_controller_test.rb +0 -1
  366. data/fixtures/sinatra_test/test/test_helper.rb +0 -19
  367. data/fixtures/sinatra_test/views +0 -1
  368. data/rabl.gemspec +0 -36
  369. data/test.watchr +0 -47
  370. data/test/bson_engine_test.rb +0 -310
  371. data/test/builder_test.rb +0 -362
  372. data/test/configuration_test.rb +0 -91
  373. data/test/engine_test.rb +0 -835
  374. data/test/helpers_test.rb +0 -136
  375. data/test/integration/posts_controller_test.rb +0 -108
  376. data/test/integration/rails3_2/posts_controller_test.rb +0 -263
  377. data/test/integration/rails3_2/users_controller_test.rb +0 -87
  378. data/test/integration/rails4/posts_controller_test.rb +0 -248
  379. data/test/integration/rails4/users_controller_test.rb +0 -87
  380. data/test/integration/test_init.rb +0 -36
  381. data/test/integration/users_controller_test.rb +0 -87
  382. data/test/models/ormless.rb +0 -3
  383. data/test/models/user.rb +0 -34
  384. data/test/msgpack_engine_test.rb +0 -312
  385. data/test/multi_builder_test.rb +0 -69
  386. data/test/partials_test.rb +0 -205
  387. data/test/plist_engine_test.rb +0 -308
  388. data/test/renderer_test.rb +0 -390
  389. data/test/silence.rb +0 -21
  390. data/test/template_test.rb +0 -63
  391. data/test/teststrap.rb +0 -37
  392. data/test/xml_test.rb +0 -297
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 69b64e79c938fa56b79fa08d95a97f92c4f1fff8
4
- data.tar.gz: 92afd63714dd8aae58385ed097682baab04c81ab
2
+ SHA256:
3
+ metadata.gz: 319983ae5fd329b2650da09ab880866b0f07f4d81bc722a27c9d0305fd1a77af
4
+ data.tar.gz: 7b6b13b88d7da8b770e1f4cc8aaa0d3193f50f01b0f57980a4ce8071538e4849
5
5
  SHA512:
6
- metadata.gz: 7721e7744da0a52bd67aea61d060a1db815cb926b9f4b7e019519ad581ba35ab1a0af5eefe4dfe9fc9cc22fff3e24c3479f2e54a66810180047ca6d93c993363
7
- data.tar.gz: 95df50736a71777c09a731eb9cc3e9752a7282e3a22bf93ebd1da7c1a024fd1d6771351e2d84b8097bef872580c43d6556a37d4c0a75c891f730bed46e45cc3d
6
+ metadata.gz: b1362d83db64761f01d4080168836f8eba428679b71d81b099aed9280b9b8a4514ad3ba02a318371eb1749a4321610e6da111f7a73450898894a702f075611be
7
+ data.tar.gz: 0f321dcb3312a35df5f5381aa66af94a527c526c529922994346d8833c72ec986f8879de6050c7bc35dfbe333bc4257846ddb3d70d74406e94b0cab0c65aaaf3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.14.4 (April 1st, 2021)
4
+
5
+ * Test against latest Ruby versions
6
+ * Exclude yarn lock
7
+ * Remove non-required files from the .gem
8
+
9
+ ## 0.14.3 (April 22nd, 2020)
10
+
11
+ * Fix regression on Rails 4.2 (@tagliala)
12
+
13
+ ## 0.14.2 (September 10th, 2019)
14
+
15
+ * Made Rails 6 compatible (@jpawlyn)
16
+ * Drop EOL'd property from gemspec (@olleolleolle)
17
+
18
+ ## 0.14.1 (April 28th, 2019)
19
+
20
+ * Many adjustments and various non-breaking fixes
21
+ * Improvements to caching (@zenspider)
22
+ * Fix tests for Rails 5 (@robertoz)
23
+
3
24
  ## 0.13.1 (October 21st, 2016)
4
25
 
5
26
  * Further compatibility with Rails 5
data/CONTRIBUTING.md CHANGED
@@ -3,7 +3,7 @@ We love pull requests. Here's a quick guide:
3
3
  1. Fork the repo.
4
4
 
5
5
  2. Run the tests. We only take pull requests with passing tests, and it's great
6
- to know that you have a clean slate: `bundle && rake test`
6
+ to know that you have a clean slate: `bundle && bundle exec rake test`
7
7
 
8
8
  3. Add a test for your change. Only refactoring and documentation changes
9
9
  require no new tests. If you are adding functionality or fixing a bug, we need
@@ -34,4 +34,4 @@ Syntax:
34
34
 
35
35
  And in case we didn't emphasize it enough: we love tests!
36
36
 
37
- NOTE: Adapted from https://raw.github.com/thoughtbot/factory_girl_rails/master/CONTRIBUTING.md
37
+ NOTE: Adapted from https://raw.github.com/thoughtbot/factory_girl_rails/master/CONTRIBUTING.md
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # RABL #
2
2
 
3
- [![Continuous Integration status](https://secure.travis-ci.org/nesquena/rabl.png)](http://travis-ci.org/nesquena/rabl)
4
- [![Dependency Status](https://gemnasium.com/nesquena/rabl.png)](https://gemnasium.com/nesquena/rabl)
5
- [![Code Climate](https://codeclimate.com/github/nesquena/rabl.png)](https://codeclimate.com/github/nesquena/rabl)
3
+ [![Continuous Integration status](https://secure.travis-ci.org/nesquena/rabl.svg)](http://travis-ci.org/nesquena/rabl)
4
+ [![Code Climate](https://codeclimate.com/github/nesquena/rabl.svg)](https://codeclimate.com/github/nesquena/rabl)
6
5
 
7
6
  RABL (Ruby API Builder Language) is a Rails and [Padrino](http://padrinorb.com) ruby templating system for generating JSON, XML, MessagePack, PList and BSON.
8
7
  When using the ActiveRecord 'to_json' method, I find myself wanting a more expressive and powerful solution for generating APIs.
@@ -146,6 +145,7 @@ Rabl.configure do |config|
146
145
  # config.replace_empty_string_values_with_nil_values = true # Defaults to false
147
146
  # config.exclude_nil_values = true # Defaults to false
148
147
  # config.exclude_empty_values_in_collections = true # Defaults to false
148
+ # config.camelize_keys = :upper # Defaults to false
149
149
  end
150
150
  ```
151
151
 
@@ -186,6 +186,8 @@ If `exclude_nil_values` is set to `true`, all values that are `nil` and would no
186
186
 
187
187
  if `exclude_empty_values_in_collections` is set to `true`, all vaules in a collection that are `{}` and would normally be displayed as `{}` in the response are not included in the response.
188
188
 
189
+ If `camelize_keys` is set to `true`, all object keys will be converted to camel case. By default the first character will be lower case. The value can be set to `:upper` to set the first chracter to upper case.
190
+
189
191
  If you wish to use [oj](https://github.com/ohler55/oj) as
190
192
  the primary JSON encoding engine simply add that to your Gemfile:
191
193
 
@@ -300,6 +302,13 @@ Named and aliased attributes can not be combined on the same line. This currentl
300
302
  attributes :foo, :bar => :baz # throws exception
301
303
  ```
302
304
 
305
+ in such cases, you need to specify attributes twice.
306
+
307
+ ```ruby
308
+ attributes :foo
309
+ attributes :bar => :baz
310
+ ```
311
+
303
312
  ### Child Nodes ###
304
313
 
305
314
  Often a response requires including nested information from data associated with the parent model:
@@ -580,11 +589,11 @@ You can also pass in other instance variables to be used in your template as:
580
589
  Rabl::Renderer.new('posts/show', @post, :locals => { :custom_title => "Hello world!" })
581
590
  ````
582
591
 
583
- Then, in your template, you can use `@custom_title` as:
592
+ Then, in your template, you can use `locals[:custom_title]` as:
584
593
 
585
- ```
594
+ ```ruby
586
595
  attribute :content
587
- node(:title) { @custom_title }
596
+ node(:title) { locals[:custom_title] }
588
597
  ```
589
598
 
590
599
  ### Content Type Headers ###
@@ -624,13 +633,9 @@ Tutorials can always be helpful when first getting started:
624
633
 
625
634
  * [Railscasts #322](http://railscasts.com/episodes/322-rabl) - Ryan Bates explains RABL
626
635
  * [BackboneRails](http://www.backbonerails.com/) - Great screencasts by Brian Mann
627
- * [Creating an API with RABL and Padrino](http://blog.crowdint.com/2012/10/22/rabl-with-padrino.html)
628
636
  * http://blog.joshsoftware.com/2011/12/23/designing-rails-api-using-rabl-and-devise/
629
- * http://engineering.gomiso.com/2011/06/27/building-a-platform-api-on-rails/
630
- * http://blog.lawrencenorton.com/better-json-requests-with-rabl
631
637
  * http://tech.favoritemedium.com/2011/06/using-rabl-in-rails-json-web-api.html
632
638
  * http://seesparkbox.com/foundry/better_rails_apis_with_rabl
633
- * http://blog.dcxn.com/2011/06/22/rails-json-templates-through-rabl
634
639
  * http://teohm.github.com/blog/2011/05/31/using-rabl-in-rails-json-web-api
635
640
 
636
641
  Let me know if there's any other useful resources not listed here.
data/lib/rabl.rb CHANGED
@@ -17,9 +17,9 @@ require 'rabl/renderer'
17
17
  require 'rabl/cache_engine'
18
18
 
19
19
  if defined?(Rails) && Rails.respond_to?(:version)
20
- require 'rabl/tracker' if Rails.version =~ /^[45]/
21
- require 'rabl/digestor' if Rails.version =~ /^[45]/
22
- require 'rabl/railtie' if Rails.version =~ /^[345]/
20
+ require 'rabl/tracker' if Rails.version =~ /^[456]/
21
+ require 'rabl/digestor' if Rails.version =~ /^[456]/
22
+ require 'rabl/railtie' if Rails.version =~ /^[3456]/
23
23
  end
24
24
 
25
25
  # Rabl.register!
@@ -83,6 +83,6 @@ end
83
83
  if defined?(Padrino)
84
84
  require 'padrino-core'
85
85
  Padrino.after_load { Rabl.register! }
86
- elsif defined?(Rails) && Rails.version =~ /^2/
86
+ elsif defined?(Rails.version) && Rails.version =~ /^2/
87
87
  Rabl.register!
88
88
  end
data/lib/rabl/builder.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'active_support/inflector' # for the sake of camelcasing keys
2
+
1
3
  module Rabl
2
4
  class Builder
3
5
  include Helpers
@@ -135,10 +137,13 @@ module Rabl
135
137
  # attribute :foo, :as => "bar"
136
138
  # attribute :foo, :as => "bar", :if => lambda { |m| m.foo }
137
139
  def attribute(name, options = {})
138
- return unless @_object && attribute_present?(name) && resolve_condition(options)
140
+ return unless
141
+ @_object &&
142
+ attribute_present?(name) &&
143
+ resolve_condition(options)
139
144
 
140
145
  attribute = data_object_attribute(name)
141
- name = (options[:as] || name).to_sym
146
+ name = create_key(options[:as] || name)
142
147
  @_result[name] = attribute
143
148
  end
144
149
  alias_method :attributes, :attribute
@@ -151,7 +156,7 @@ module Rabl
151
156
 
152
157
  result = block.call(@_object)
153
158
  if name.present?
154
- @_result[name.to_sym] = result
159
+ @_result[create_key(name)] = result
155
160
  elsif result.is_a?(Hash) # merge hash into root hash
156
161
  @_result.merge!(result)
157
162
  end
@@ -174,7 +179,7 @@ module Rabl
174
179
 
175
180
  object = { object => name } if data.is_a?(Hash) && object # child :users => :people
176
181
 
177
- engines << { name.to_sym => object_to_engine(object, engine_options, &block) }
182
+ engines << { create_key(name) => object_to_engine(object, engine_options, &block) }
178
183
  end
179
184
 
180
185
  # Glues data from a child node to the json_output
@@ -198,10 +203,11 @@ module Rabl
198
203
 
199
204
  # Evaluate conditions given a symbol/proc/lambda/variable to evaluate
200
205
  def call_condition_proc(condition, object)
201
- # This will evaluate lambda, proc & symbol and call it with 1 argument
202
- return condition.to_proc.call(object) if condition.is_a?(Proc) || condition.is_a?(Symbol)
203
- # Else we send directly the object
204
- condition
206
+ case condition
207
+ when Proc then condition.call(object)
208
+ when Symbol then condition.to_proc.call(object)
209
+ else condition
210
+ end
205
211
  end
206
212
 
207
213
  # resolve_condition(:if => true) => true
@@ -211,8 +217,10 @@ module Rabl
211
217
  # resolve_condition(:unless => lambda { |m| false }, :if => proc { true}) => true
212
218
  def resolve_condition(options)
213
219
  result = true
214
- result &&= call_condition_proc(options[:if], @_object) if options.key?(:if)
215
- result &&= !call_condition_proc(options[:unless], @_object) if options.key?(:unless)
220
+ result &&= call_condition_proc(options[:if], @_object) if
221
+ options.key?(:if)
222
+ result &&= !call_condition_proc(options[:unless], @_object) if
223
+ options.key?(:unless)
216
224
  result
217
225
  end
218
226
 
@@ -220,13 +228,9 @@ module Rabl
220
228
  # Checks if an attribute is present. If not, check if the configuration specifies that this is an error
221
229
  # attribute_present?(created_at) => true
222
230
  def attribute_present?(name)
223
- if @_object.respond_to?(name)
224
- true
225
- elsif Rabl.configuration.raise_on_missing_attribute
226
- raise "Failed to render missing attribute #{name}"
227
- else
228
- false
229
- end
231
+ @_object.respond_to?(name) ||
232
+ (Rabl.configuration.raise_on_missing_attribute &&
233
+ raise("Failed to render missing attribute #{name}"))
230
234
  end
231
235
 
232
236
  # Returns a guess at the format in this context_scope
@@ -248,5 +252,13 @@ module Rabl
248
252
  yield
249
253
  end
250
254
  end
255
+
256
+ def create_key(name)
257
+ if Rabl.configuration.camelize_keys
258
+ name.to_s.camelize(Rabl.configuration.camelize_keys == :upper ? :upper : :lower).to_sym
259
+ else
260
+ name.to_sym
261
+ end
262
+ end
251
263
  end
252
264
  end
@@ -5,8 +5,35 @@
5
5
  # config.cache_engine = AdvancedCacheEngine.new
6
6
  #
7
7
 
8
+ class LRU < Hash
9
+ attr_accessor :max_size
10
+
11
+ def initialize
12
+ super
13
+ self.max_size = 100_000
14
+ end
15
+
16
+ def []= k,v
17
+ r = super
18
+ limit_size
19
+ r
20
+ end
21
+
22
+ def limit_size
23
+ if size > max_size then
24
+ delete keys.shift while size > max_size
25
+ end
26
+ end
27
+ end
28
+
8
29
  module Rabl
9
30
  class CacheEngine
31
+ def initialize
32
+ unless defined?(Rails)
33
+ @cache = LRU.new
34
+ end
35
+ end
36
+
10
37
 
11
38
  # Fetch given a key and options and a fallback block attempts to find the key in the cache
12
39
  # and stores the block result in there if no key is found.
@@ -17,13 +44,15 @@ module Rabl
17
44
  if defined?(Rails)
18
45
  Rails.cache.fetch(key, cache_options, &block)
19
46
  else
20
- yield
47
+ @cache[key] ||= yield
21
48
  end
22
49
  end
23
50
 
24
51
  def write(key, value, options = {})
25
52
  if defined?(Rails)
26
53
  Rails.cache.write(key, value, options)
54
+ else
55
+ @cache[key] = yield
27
56
  end
28
57
  end
29
58
 
@@ -52,6 +52,7 @@ module Rabl
52
52
  attr_accessor :replace_empty_string_values_with_nil_values
53
53
  attr_accessor :exclude_nil_values
54
54
  attr_accessor :exclude_empty_values_in_collections
55
+ attr_accessor :camelize_keys
55
56
 
56
57
  DEFAULT_XML_OPTIONS = { :dasherize => true, :skip_types => false }
57
58
 
@@ -81,6 +82,7 @@ module Rabl
81
82
  @replace_empty_string_values_with_nil_values = false
82
83
  @exclude_nil_values = false
83
84
  @exclude_empty_values_in_collections = false
85
+ @camelize_keys = false
84
86
  end
85
87
 
86
88
  # @return The JSON engine used to encode Rabl templates into JSON
data/lib/rabl/engine.rb CHANGED
@@ -27,6 +27,8 @@ module Rabl
27
27
  # Renders the representation based on source, object, context_scope and locals
28
28
  # Rabl::Engine.new("...source...", { :format => "xml" }).apply(context_scope, { :foo => "bar", :object => @user })
29
29
  def apply(context_scope, locals, &block)
30
+ locals = locals.dup unless locals.nil?
31
+
30
32
  set_instance_variables!(context_scope, locals)
31
33
 
32
34
  reset_settings!
@@ -58,8 +60,10 @@ module Rabl
58
60
  if digestor_available? && respond_to?(:lookup_context) && lookup_context
59
61
  template = @_options[:template] || @virtual_path
60
62
 
61
- digest = \
62
- if Gem::Version.new(Rails.version) >= Gem::Version.new('4.1')
63
+ digest =
64
+ if Rails.version.to_s =~ /^[6]/
65
+ Digestor.digest(name: template, finder: lookup_context, format: :rabl)
66
+ elsif Gem::Version.new(Rails.version) >= Gem::Version.new('4.1')
63
67
  Digestor.digest(:name => template, :finder => lookup_context)
64
68
  else
65
69
  Digestor.digest(template, :rabl, lookup_context)
@@ -81,7 +85,7 @@ module Rabl
81
85
 
82
86
  options[:root_name] = determine_object_root(data, root_name, options[:root])
83
87
 
84
- result = \
88
+ result =
85
89
  if is_object?(data) || !data # object @user
86
90
  Builder.new(data, @_settings, options).to_hash
87
91
  elsif is_collection?(data) # collection @users
@@ -165,6 +169,7 @@ module Rabl
165
169
  @_root_name_data = @_root_name_data.values.first if @_root_name_data.is_a?(Hash)
166
170
 
167
171
  # If we turn this around, `@_root_name_date ==` may trigger data to be loaded unnecessarily.
172
+ # TODO: is nil a different semantic? otherwise don't use `false ==`, use !
168
173
  if false == @_root_name_data
169
174
  @_object_root_name = false
170
175
  @_collection_name = false
@@ -387,7 +392,7 @@ module Rabl
387
392
  end
388
393
 
389
394
  def digestor_available?
390
- defined?(Rails) && Rails.version =~ /^[45]/
395
+ defined?(Rails) && Rails.version =~ /^[456]/
391
396
  end
392
397
 
393
398
  def set_instance_variables!(context_scope, locals)
@@ -407,15 +412,21 @@ module Rabl
407
412
  end
408
413
 
409
414
  def eval_source(locals, &block)
410
- # Note: locals and block may be used by the eval'ed source
411
-
412
415
  return unless @_source.present?
413
416
 
414
- if @_options[:source_location]
415
- instance_eval(@_source, @_options[:source_location])
416
- else
417
- instance_eval(@_source)
417
+ msg = "cached_source_#{@_source.hash.abs}"
418
+
419
+ unless self.respond_to? msg then
420
+ src = "def #{msg} locals, &block\n#{@_source}\nend"
421
+
422
+ if @_options[:source_location]
423
+ self.class.class_eval(src, @_options[:source_location])
424
+ else
425
+ self.class.class_eval(src)
426
+ end
418
427
  end
428
+
429
+ send msg, locals, &block
419
430
  end
420
431
  end
421
432
  end
data/lib/rabl/helpers.rb CHANGED
@@ -14,7 +14,9 @@ module Rabl
14
14
  # data_object_attribute(data) => @_object.send(data)
15
15
  def data_object_attribute(data)
16
16
  attribute = @_object.__send__(data)
17
- attribute = attribute.as_json if is_collection?(attribute, false) && attribute.respond_to?(:as_json)
17
+ attribute = attribute.as_json if
18
+ is_collection?(attribute, false) &&
19
+ attribute.respond_to?(:as_json)
18
20
  attribute
19
21
  end
20
22
 
@@ -81,8 +83,10 @@ module Rabl
81
83
  # is_collection?([]) => true
82
84
  def is_collection?(obj, follow_symbols = true)
83
85
  data_obj = follow_symbols ? data_object(obj) : obj
84
- data_obj && data_obj.respond_to?(:map) && data_obj.respond_to?(:each) &&
85
- !(data_obj.is_a?(Struct) || defined?(Hashie::Mash) && data_obj.is_a?(Hashie::Mash))
86
+ data_obj &&
87
+ data_obj.respond_to?(:map) && data_obj.respond_to?(:each) &&
88
+ !(data_obj.is_a?(Struct) ||
89
+ defined?(Hashie::Mash) && data_obj.is_a?(Hashie::Mash))
86
90
  end
87
91
 
88
92
  # Returns the context_scope wrapping this engine, used for retrieving data, invoking methods, etc
data/lib/rabl/railtie.rb CHANGED
@@ -1,11 +1,28 @@
1
1
  module Rabl
2
2
  class Railtie < Rails::Railtie
3
3
  initializer "rabl.initialize" do |app|
4
+ # Force Rails to load view templates even in API mode
5
+ # Stolen shamelessly from jbuilder: https://github.com/rails/jbuilder/blob/master/lib/jbuilder/railtie.rb
6
+ if Rails::VERSION::MAJOR >= 5
7
+ module ::ActionController
8
+ module ApiRendering
9
+ include ActionView::Rendering
10
+ end
11
+ end
12
+
13
+ ActiveSupport.on_load :action_controller do
14
+ if self == ActionController::API
15
+ include ActionController::Helpers
16
+ include ActionController::ImplicitRender
17
+ end
18
+ end
19
+ end
20
+
4
21
  ActiveSupport.on_load(:action_view) do
5
22
  Rabl.register!
6
23
 
7
24
  # Inject dependency tracker for :rabl
8
- if Rails.version =~ /^[45]/
25
+ if Rails.version =~ /^[456]/
9
26
  require 'action_view/dependency_tracker'
10
27
  ActionView::DependencyTracker.register_tracker :rabl, Rabl::Tracker
11
28
  end
data/lib/rabl/template.rb CHANGED
@@ -40,7 +40,7 @@ if defined?(ActionView) && defined?(Rails) && Rails.respond_to?(:version) && Rai
40
40
  ActionView::Template.register_template_handler :rabl, ActionView::TemplateHandlers::RablHandler
41
41
  end
42
42
 
43
- # Rails 3.X / 4.X Template
43
+ # Rails 3.X / 4.X / 5.X Template
44
44
  if defined?(ActionView) && defined?(Rails) && Rails.respond_to?(:version) && Rails.version.to_s =~ /^[345]/
45
45
  module ActionView
46
46
  module Template::Handlers
@@ -61,3 +61,23 @@ if defined?(ActionView) && defined?(Rails) && Rails.respond_to?(:version) && Rai
61
61
 
62
62
  ActionView::Template.register_template_handler :rabl, ActionView::Template::Handlers::Rabl
63
63
  end
64
+
65
+ # Rails 6.X Template
66
+ if defined?(ActionView) && defined?(Rails) && Rails.respond_to?(:version) && Rails.version.to_s =~ /^[6]/
67
+ module ActionView
68
+ module Template::Handlers
69
+ class Rabl
70
+ class_attribute :default_format
71
+ self.default_format = :json
72
+
73
+ def self.call(template, source)
74
+ %{ ::Rabl::Engine.new(#{source.inspect}).
75
+ apply(self, assigns.merge(local_assigns)).
76
+ render }
77
+ end # call
78
+ end # rabl class
79
+ end # handlers
80
+ end
81
+
82
+ ActionView::Template.register_template_handler :rabl, ActionView::Template::Handlers::Rabl
83
+ end