rabl 0.13.1 → 0.14.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +21 -0
- data/CONTRIBUTING.md +2 -2
- data/README.md +15 -10
- data/lib/rabl.rb +4 -4
- data/lib/rabl/builder.rb +29 -17
- data/lib/rabl/cache_engine.rb +30 -1
- data/lib/rabl/configuration.rb +2 -0
- data/lib/rabl/engine.rb +21 -10
- data/lib/rabl/helpers.rb +7 -3
- data/lib/rabl/railtie.rb +18 -1
- data/lib/rabl/template.rb +21 -1
- data/lib/rabl/version.rb +1 -1
- metadata +5 -384
- data/.gitignore +0 -8
- data/.travis.yml +0 -15
- data/Gemfile +0 -28
- data/Rakefile +0 -54
- data/examples/base.json.rabl +0 -8
- data/examples/demo.json.rabl +0 -42
- data/examples/inherited.json.rabl +0 -11
- data/fixtures/ashared/NOTES +0 -44
- data/fixtures/ashared/README +0 -39
- data/fixtures/ashared/migrate/20111002092016_create_users.rb +0 -15
- data/fixtures/ashared/migrate/20111002092019_create_posts.rb +0 -14
- data/fixtures/ashared/migrate/20111002092024_create_phone_numbers.rb +0 -16
- data/fixtures/ashared/models/phone_number.rb +0 -7
- data/fixtures/ashared/models/post.rb +0 -3
- data/fixtures/ashared/models/user.rb +0 -3
- data/fixtures/ashared/views/layouts/application.html.erb +0 -9
- data/fixtures/ashared/views/posts/_show_footer_script.js.erb +0 -1
- data/fixtures/ashared/views/posts/date.rabl +0 -3
- data/fixtures/ashared/views/posts/index.rabl +0 -12
- data/fixtures/ashared/views/posts/show.rabl +0 -17
- data/fixtures/ashared/views/users/index.json.rabl +0 -3
- data/fixtures/ashared/views/users/phone_number.json.rabl +0 -6
- data/fixtures/ashared/views/users/show.json.rabl +0 -16
- data/fixtures/ashared/views_rails_3/layouts/application.html.erb +0 -13
- data/fixtures/ashared/views_rails_3/posts/_show_footer_script.js.erb +0 -1
- data/fixtures/ashared/views_rails_3/posts/date.rabl +0 -3
- data/fixtures/ashared/views_rails_3/posts/index.html.erb +0 -3
- data/fixtures/ashared/views_rails_3/posts/index.rabl +0 -12
- data/fixtures/ashared/views_rails_3/posts/renderer.rabl +0 -8
- data/fixtures/ashared/views_rails_3/posts/renderer_partial.rabl +0 -4
- data/fixtures/ashared/views_rails_3/posts/show.html.erb +0 -3
- data/fixtures/ashared/views_rails_3/posts/show.rabl +0 -25
- data/fixtures/ashared/views_rails_3/posts/show.rabl_test_v1.rabl +0 -7
- data/fixtures/ashared/views_rails_3/users/index.json.rabl +0 -3
- data/fixtures/ashared/views_rails_3/users/phone_number.json.rabl +0 -8
- data/fixtures/ashared/views_rails_3/users/phone_number.xml.rabl +0 -1
- data/fixtures/ashared/views_rails_3/users/show.json.rabl +0 -16
- data/fixtures/ashared/views_rails_3/users/show.rabl_test_v1.rabl +0 -3
- data/fixtures/padrino_test/.components +0 -7
- data/fixtures/padrino_test/.gitignore +0 -7
- data/fixtures/padrino_test/Gemfile +0 -17
- data/fixtures/padrino_test/Rakefile +0 -3
- data/fixtures/padrino_test/app/app.rb +0 -31
- data/fixtures/padrino_test/app/controllers/posts.rb +0 -11
- data/fixtures/padrino_test/app/controllers/users.rb +0 -11
- data/fixtures/padrino_test/app/helpers/posts_helper.rb +0 -7
- data/fixtures/padrino_test/app/helpers/users_helper.rb +0 -7
- data/fixtures/padrino_test/app/views +0 -1
- data/fixtures/padrino_test/config.ru +0 -9
- data/fixtures/padrino_test/config/apps.rb +0 -34
- data/fixtures/padrino_test/config/boot.rb +0 -29
- data/fixtures/padrino_test/config/database.rb +0 -43
- data/fixtures/padrino_test/db/migrate +0 -1
- data/fixtures/padrino_test/db/schema.rb +0 -42
- data/fixtures/padrino_test/models +0 -1
- data/fixtures/padrino_test/public/favicon.ico +0 -0
- data/fixtures/padrino_test/test/app/controllers/posts_controller_test.rb +0 -1
- data/fixtures/padrino_test/test/app/controllers/users_controller_test.rb +0 -1
- data/fixtures/padrino_test/test/test.rake +0 -18
- data/fixtures/padrino_test/test/test_config.rb +0 -18
- data/fixtures/rails2/.gitignore +0 -1
- data/fixtures/rails2/Gemfile +0 -10
- data/fixtures/rails2/Rakefile +0 -14
- data/fixtures/rails2/app/controllers/application_controller.rb +0 -10
- data/fixtures/rails2/app/controllers/posts_controller.rb +0 -15
- data/fixtures/rails2/app/controllers/users_controller.rb +0 -15
- data/fixtures/rails2/app/helpers/application_helper.rb +0 -2
- data/fixtures/rails2/app/helpers/posts_helper.rb +0 -2
- data/fixtures/rails2/app/helpers/users_helper.rb +0 -2
- data/fixtures/rails2/app/models +0 -1
- data/fixtures/rails2/app/views +0 -1
- data/fixtures/rails2/config/boot.rb +0 -129
- data/fixtures/rails2/config/database.yml +0 -16
- data/fixtures/rails2/config/environment.rb +0 -64
- data/fixtures/rails2/config/environments/development.rb +0 -17
- data/fixtures/rails2/config/environments/production.rb +0 -28
- data/fixtures/rails2/config/environments/test.rb +0 -28
- data/fixtures/rails2/config/initializers/backtrace_silencers.rb +0 -7
- data/fixtures/rails2/config/initializers/cookie_verification_secret.rb +0 -7
- data/fixtures/rails2/config/initializers/inflections.rb +0 -10
- data/fixtures/rails2/config/initializers/mime_types.rb +0 -5
- data/fixtures/rails2/config/initializers/new_rails_defaults.rb +0 -21
- data/fixtures/rails2/config/initializers/session_store.rb +0 -15
- data/fixtures/rails2/config/locales/en.yml +0 -5
- data/fixtures/rails2/config/preinitializer.rb +0 -20
- data/fixtures/rails2/config/routes.rb +0 -45
- data/fixtures/rails2/db/migrate +0 -1
- data/fixtures/rails2/db/schema.rb +0 -40
- data/fixtures/rails2/db/seeds.rb +0 -7
- data/fixtures/rails2/public/404.html +0 -30
- data/fixtures/rails2/public/422.html +0 -30
- data/fixtures/rails2/public/500.html +0 -30
- data/fixtures/rails2/public/favicon.ico +0 -0
- data/fixtures/rails2/public/images/rails.png +0 -0
- data/fixtures/rails2/public/index.html +0 -275
- data/fixtures/rails2/public/robots.txt +0 -5
- data/fixtures/rails2/script/about +0 -4
- data/fixtures/rails2/script/console +0 -3
- data/fixtures/rails2/script/dbconsole +0 -3
- data/fixtures/rails2/script/destroy +0 -3
- data/fixtures/rails2/script/generate +0 -3
- data/fixtures/rails2/script/performance/benchmarker +0 -3
- data/fixtures/rails2/script/performance/profiler +0 -3
- data/fixtures/rails2/script/plugin +0 -3
- data/fixtures/rails2/script/runner +0 -3
- data/fixtures/rails2/script/server +0 -3
- data/fixtures/rails2/test/functionals/posts_controller_test.rb +0 -1
- data/fixtures/rails2/test/functionals/users_controller_test.rb +0 -1
- data/fixtures/rails2/test/test_helper.rb +0 -33
- data/fixtures/rails3/.gitignore +0 -4
- data/fixtures/rails3/Gemfile +0 -37
- data/fixtures/rails3/Rakefile +0 -12
- data/fixtures/rails3/app/controllers/application_controller.rb +0 -14
- data/fixtures/rails3/app/controllers/posts_controller.rb +0 -11
- data/fixtures/rails3/app/controllers/users_controller.rb +0 -11
- data/fixtures/rails3/app/models +0 -1
- data/fixtures/rails3/app/views +0 -1
- data/fixtures/rails3/config.ru +0 -4
- data/fixtures/rails3/config/application.rb +0 -42
- data/fixtures/rails3/config/boot.rb +0 -6
- data/fixtures/rails3/config/database.yml +0 -22
- data/fixtures/rails3/config/environment.rb +0 -5
- data/fixtures/rails3/config/environments/development.rb +0 -26
- data/fixtures/rails3/config/environments/production.rb +0 -49
- data/fixtures/rails3/config/environments/test.rb +0 -35
- data/fixtures/rails3/config/initializers/backtrace_silencers.rb +0 -7
- data/fixtures/rails3/config/initializers/inflections.rb +0 -10
- data/fixtures/rails3/config/initializers/mime_types.rb +0 -5
- data/fixtures/rails3/config/initializers/secret_token.rb +0 -7
- data/fixtures/rails3/config/initializers/session_store.rb +0 -8
- data/fixtures/rails3/config/locales/en.yml +0 -5
- data/fixtures/rails3/config/routes.rb +0 -61
- data/fixtures/rails3/db/migrate +0 -1
- data/fixtures/rails3/db/seeds.rb +0 -7
- data/fixtures/rails3/lib/tasks/.gitkeep +0 -0
- data/fixtures/rails3/public/404.html +0 -26
- data/fixtures/rails3/public/422.html +0 -26
- data/fixtures/rails3/public/500.html +0 -26
- data/fixtures/rails3/public/favicon.ico +0 -0
- data/fixtures/rails3/public/images/rails.png +0 -0
- data/fixtures/rails3/public/index.html +0 -239
- data/fixtures/rails3/public/robots.txt +0 -5
- data/fixtures/rails3/public/stylesheets/.gitkeep +0 -0
- data/fixtures/rails3/script/rails +0 -6
- data/fixtures/rails3/test/functional/posts_controller_test.rb +0 -1
- data/fixtures/rails3/test/functional/users_controller_test.rb +0 -1
- data/fixtures/rails3/test/test_helper.rb +0 -26
- data/fixtures/rails3_2/.gitignore +0 -15
- data/fixtures/rails3_2/Gemfile +0 -40
- data/fixtures/rails3_2/README.rdoc +0 -261
- data/fixtures/rails3_2/Rakefile +0 -12
- data/fixtures/rails3_2/app/assets/images/rails.png +0 -0
- data/fixtures/rails3_2/app/assets/javascripts/application.js +0 -15
- data/fixtures/rails3_2/app/assets/javascripts/posts.js.coffee +0 -3
- data/fixtures/rails3_2/app/assets/javascripts/users.js.coffee +0 -3
- data/fixtures/rails3_2/app/assets/stylesheets/application.css +0 -13
- data/fixtures/rails3_2/app/assets/stylesheets/posts.css.scss +0 -3
- data/fixtures/rails3_2/app/assets/stylesheets/users.css.scss +0 -3
- data/fixtures/rails3_2/app/controllers/application_controller.rb +0 -14
- data/fixtures/rails3_2/app/controllers/posts_controller.rb +0 -16
- data/fixtures/rails3_2/app/controllers/users_controller.rb +0 -11
- data/fixtures/rails3_2/app/helpers/application_helper.rb +0 -5
- data/fixtures/rails3_2/app/helpers/posts_helper.rb +0 -2
- data/fixtures/rails3_2/app/helpers/users_helper.rb +0 -2
- data/fixtures/rails3_2/app/mailers/.gitkeep +0 -0
- data/fixtures/rails3_2/app/models +0 -1
- data/fixtures/rails3_2/app/views +0 -1
- data/fixtures/rails3_2/config.ru +0 -4
- data/fixtures/rails3_2/config/application.rb +0 -59
- data/fixtures/rails3_2/config/boot.rb +0 -6
- data/fixtures/rails3_2/config/database.yml +0 -25
- data/fixtures/rails3_2/config/environment.rb +0 -5
- data/fixtures/rails3_2/config/environments/development.rb +0 -37
- data/fixtures/rails3_2/config/environments/production.rb +0 -67
- data/fixtures/rails3_2/config/environments/test.rb +0 -37
- data/fixtures/rails3_2/config/initializers/backtrace_silencers.rb +0 -7
- data/fixtures/rails3_2/config/initializers/inflections.rb +0 -15
- data/fixtures/rails3_2/config/initializers/mime_types.rb +0 -7
- data/fixtures/rails3_2/config/initializers/secret_token.rb +0 -7
- data/fixtures/rails3_2/config/initializers/session_store.rb +0 -8
- data/fixtures/rails3_2/config/initializers/wrap_parameters.rb +0 -14
- data/fixtures/rails3_2/config/locales/en.yml +0 -5
- data/fixtures/rails3_2/config/routes.rb +0 -64
- data/fixtures/rails3_2/db/migrate +0 -1
- data/fixtures/rails3_2/db/schema.rb +0 -42
- data/fixtures/rails3_2/db/seeds.rb +0 -7
- data/fixtures/rails3_2/doc/README_FOR_APP +0 -2
- data/fixtures/rails3_2/lib/assets/.gitkeep +0 -0
- data/fixtures/rails3_2/lib/tasks/.gitkeep +0 -0
- data/fixtures/rails3_2/log/.gitkeep +0 -0
- data/fixtures/rails3_2/public/404.html +0 -26
- data/fixtures/rails3_2/public/422.html +0 -26
- data/fixtures/rails3_2/public/500.html +0 -25
- data/fixtures/rails3_2/public/favicon.ico +0 -0
- data/fixtures/rails3_2/public/index.html +0 -241
- data/fixtures/rails3_2/public/robots.txt +0 -5
- data/fixtures/rails3_2/script/rails +0 -6
- data/fixtures/rails3_2/test/fixtures/phone_numbers.yml +0 -11
- data/fixtures/rails3_2/test/fixtures/posts.yml +0 -11
- data/fixtures/rails3_2/test/fixtures/users.yml +0 -11
- data/fixtures/rails3_2/test/functional/posts_controller_test.rb +0 -1
- data/fixtures/rails3_2/test/functional/users_controller_test.rb +0 -1
- data/fixtures/rails3_2/test/integration/.gitkeep +0 -0
- data/fixtures/rails3_2/test/performance/browsing_test.rb +0 -12
- data/fixtures/rails3_2/test/test_helper.rb +0 -26
- data/fixtures/rails3_2/test/unit/helpers/posts_helper_test.rb +0 -4
- data/fixtures/rails3_2/test/unit/helpers/users_helper_test.rb +0 -4
- data/fixtures/rails3_2/test/unit/phone_number_test.rb +0 -7
- data/fixtures/rails3_2/test/unit/post_test.rb +0 -7
- data/fixtures/rails3_2/test/unit/user_test.rb +0 -7
- data/fixtures/rails3_2/vendor/assets/javascripts/.gitkeep +0 -0
- data/fixtures/rails3_2/vendor/assets/stylesheets/.gitkeep +0 -0
- data/fixtures/rails3_2/vendor/plugins/.gitkeep +0 -0
- data/fixtures/rails4/.gitignore +0 -16
- data/fixtures/rails4/Gemfile +0 -49
- data/fixtures/rails4/README.rdoc +0 -28
- data/fixtures/rails4/Rakefile +0 -11
- data/fixtures/rails4/app/assets/javascripts/application.js +0 -16
- data/fixtures/rails4/app/assets/stylesheets/application.css +0 -13
- data/fixtures/rails4/app/controllers/application_controller.rb +0 -5
- data/fixtures/rails4/app/controllers/concerns/.keep +0 -0
- data/fixtures/rails4/app/controllers/posts_controller.rb +0 -16
- data/fixtures/rails4/app/controllers/users_controller.rb +0 -11
- data/fixtures/rails4/app/helpers/application_helper.rb +0 -5
- data/fixtures/rails4/app/mailers/.keep +0 -0
- data/fixtures/rails4/app/models +0 -1
- data/fixtures/rails4/app/views +0 -1
- data/fixtures/rails4/bin/bundle +0 -3
- data/fixtures/rails4/bin/rails +0 -4
- data/fixtures/rails4/bin/rake +0 -4
- data/fixtures/rails4/config.ru +0 -4
- data/fixtures/rails4/config/application.rb +0 -23
- data/fixtures/rails4/config/boot.rb +0 -4
- data/fixtures/rails4/config/database.yml +0 -25
- data/fixtures/rails4/config/environment.rb +0 -5
- data/fixtures/rails4/config/environments/development.rb +0 -29
- data/fixtures/rails4/config/environments/production.rb +0 -80
- data/fixtures/rails4/config/environments/test.rb +0 -36
- data/fixtures/rails4/config/initializers/backtrace_silencers.rb +0 -7
- data/fixtures/rails4/config/initializers/filter_parameter_logging.rb +0 -4
- data/fixtures/rails4/config/initializers/inflections.rb +0 -16
- data/fixtures/rails4/config/initializers/mime_types.rb +0 -7
- data/fixtures/rails4/config/initializers/secret_token.rb +0 -12
- data/fixtures/rails4/config/initializers/session_store.rb +0 -3
- data/fixtures/rails4/config/initializers/wrap_parameters.rb +0 -14
- data/fixtures/rails4/config/locales/en.yml +0 -23
- data/fixtures/rails4/config/routes.rb +0 -55
- data/fixtures/rails4/db/migrate +0 -1
- data/fixtures/rails4/db/seeds.rb +0 -7
- data/fixtures/rails4/lib/assets/.keep +0 -0
- data/fixtures/rails4/lib/tasks/.keep +0 -0
- data/fixtures/rails4/log/.keep +0 -0
- data/fixtures/rails4/public/404.html +0 -58
- data/fixtures/rails4/public/422.html +0 -58
- data/fixtures/rails4/public/500.html +0 -57
- data/fixtures/rails4/public/favicon.ico +0 -0
- data/fixtures/rails4/public/robots.txt +0 -5
- data/fixtures/rails4/test/controllers/.keep +0 -0
- data/fixtures/rails4/test/fixtures/.keep +0 -0
- data/fixtures/rails4/test/functional/posts_controller_test.rb +0 -1
- data/fixtures/rails4/test/functional/users_controller_test.rb +0 -1
- data/fixtures/rails4/test/helpers/.keep +0 -0
- data/fixtures/rails4/test/integration/.keep +0 -0
- data/fixtures/rails4/test/mailers/.keep +0 -0
- data/fixtures/rails4/test/models/.keep +0 -0
- data/fixtures/rails4/test/test_helper.rb +0 -26
- data/fixtures/rails4/vendor/assets/javascripts/.keep +0 -0
- data/fixtures/rails4/vendor/assets/stylesheets/.keep +0 -0
- data/fixtures/rails5/.gitignore +0 -21
- data/fixtures/rails5/Gemfile +0 -52
- data/fixtures/rails5/README.md +0 -24
- data/fixtures/rails5/Rakefile +0 -13
- data/fixtures/rails5/app/assets/config/manifest.js +0 -3
- data/fixtures/rails5/app/assets/images/.keep +0 -0
- data/fixtures/rails5/app/assets/javascripts/application.js +0 -16
- data/fixtures/rails5/app/assets/javascripts/cable.js +0 -13
- data/fixtures/rails5/app/assets/javascripts/channels/.keep +0 -0
- data/fixtures/rails5/app/assets/stylesheets/application.css +0 -15
- data/fixtures/rails5/app/channels/application_cable/channel.rb +0 -4
- data/fixtures/rails5/app/channels/application_cable/connection.rb +0 -4
- data/fixtures/rails5/app/controllers/application_controller.rb +0 -3
- data/fixtures/rails5/app/controllers/concerns/.keep +0 -0
- data/fixtures/rails5/app/controllers/posts_controller.rb +0 -17
- data/fixtures/rails5/app/controllers/users_controller.rb +0 -11
- data/fixtures/rails5/app/helpers/application_helper.rb +0 -5
- data/fixtures/rails5/app/jobs/application_job.rb +0 -2
- data/fixtures/rails5/app/mailers/application_mailer.rb +0 -4
- data/fixtures/rails5/app/models +0 -1
- data/fixtures/rails5/app/views +0 -1
- data/fixtures/rails5/bin/bundle +0 -3
- data/fixtures/rails5/bin/rails +0 -9
- data/fixtures/rails5/bin/rake +0 -9
- data/fixtures/rails5/bin/setup +0 -34
- data/fixtures/rails5/bin/spring +0 -15
- data/fixtures/rails5/bin/update +0 -29
- data/fixtures/rails5/config.ru +0 -5
- data/fixtures/rails5/config/application.rb +0 -15
- data/fixtures/rails5/config/boot.rb +0 -3
- data/fixtures/rails5/config/cable.yml +0 -9
- data/fixtures/rails5/config/database.yml +0 -25
- data/fixtures/rails5/config/environment.rb +0 -5
- data/fixtures/rails5/config/environments/development.rb +0 -54
- data/fixtures/rails5/config/environments/production.rb +0 -86
- data/fixtures/rails5/config/environments/test.rb +0 -42
- data/fixtures/rails5/config/initializers/application_controller_renderer.rb +0 -6
- data/fixtures/rails5/config/initializers/assets.rb +0 -11
- data/fixtures/rails5/config/initializers/backtrace_silencers.rb +0 -7
- data/fixtures/rails5/config/initializers/cookies_serializer.rb +0 -5
- data/fixtures/rails5/config/initializers/filter_parameter_logging.rb +0 -4
- data/fixtures/rails5/config/initializers/inflections.rb +0 -16
- data/fixtures/rails5/config/initializers/mime_types.rb +0 -4
- data/fixtures/rails5/config/initializers/new_framework_defaults.rb +0 -24
- data/fixtures/rails5/config/initializers/session_store.rb +0 -3
- data/fixtures/rails5/config/initializers/wrap_parameters.rb +0 -14
- data/fixtures/rails5/config/locales/en.yml +0 -23
- data/fixtures/rails5/config/puma.rb +0 -47
- data/fixtures/rails5/config/routes.rb +0 -8
- data/fixtures/rails5/config/secrets.yml +0 -22
- data/fixtures/rails5/config/spring.rb +0 -6
- data/fixtures/rails5/db/migrate +0 -1
- data/fixtures/rails5/db/schema.rb +0 -41
- data/fixtures/rails5/db/seeds.rb +0 -7
- data/fixtures/rails5/lib/assets/.keep +0 -0
- data/fixtures/rails5/lib/tasks/.keep +0 -0
- data/fixtures/rails5/log/.keep +0 -0
- data/fixtures/rails5/public/404.html +0 -67
- data/fixtures/rails5/public/422.html +0 -67
- data/fixtures/rails5/public/500.html +0 -66
- data/fixtures/rails5/public/apple-touch-icon-precomposed.png +0 -0
- data/fixtures/rails5/public/apple-touch-icon.png +0 -0
- data/fixtures/rails5/public/favicon.ico +0 -0
- data/fixtures/rails5/public/robots.txt +0 -5
- data/fixtures/rails5/test/controllers/.keep +0 -0
- data/fixtures/rails5/test/fixtures/.keep +0 -0
- data/fixtures/rails5/test/fixtures/files/.keep +0 -0
- data/fixtures/rails5/test/helpers/.keep +0 -0
- data/fixtures/rails5/test/integration/.keep +0 -0
- data/fixtures/rails5/test/mailers/.keep +0 -0
- data/fixtures/rails5/test/models/.keep +0 -0
- data/fixtures/rails5/test/test_helper.rb +0 -26
- data/fixtures/rails5/tmp/.keep +0 -0
- data/fixtures/rails5/vendor/assets/javascripts/.keep +0 -0
- data/fixtures/rails5/vendor/assets/stylesheets/.keep +0 -0
- data/fixtures/sinatra_test/Gemfile +0 -13
- data/fixtures/sinatra_test/Rakefile +0 -6
- data/fixtures/sinatra_test/app.rb +0 -55
- data/fixtures/sinatra_test/config.ru +0 -7
- data/fixtures/sinatra_test/db/migrate +0 -1
- data/fixtures/sinatra_test/models +0 -1
- data/fixtures/sinatra_test/test/functional/posts_controller_test.rb +0 -1
- data/fixtures/sinatra_test/test/functional/users_controller_test.rb +0 -1
- data/fixtures/sinatra_test/test/test_helper.rb +0 -19
- data/fixtures/sinatra_test/views +0 -1
- data/rabl.gemspec +0 -36
- data/test.watchr +0 -47
- data/test/bson_engine_test.rb +0 -310
- data/test/builder_test.rb +0 -362
- data/test/configuration_test.rb +0 -91
- data/test/engine_test.rb +0 -835
- data/test/helpers_test.rb +0 -136
- data/test/integration/posts_controller_test.rb +0 -108
- data/test/integration/rails3_2/posts_controller_test.rb +0 -263
- data/test/integration/rails3_2/users_controller_test.rb +0 -87
- data/test/integration/rails4/posts_controller_test.rb +0 -248
- data/test/integration/rails4/users_controller_test.rb +0 -87
- data/test/integration/test_init.rb +0 -36
- data/test/integration/users_controller_test.rb +0 -87
- data/test/models/ormless.rb +0 -3
- data/test/models/user.rb +0 -34
- data/test/msgpack_engine_test.rb +0 -312
- data/test/multi_builder_test.rb +0 -69
- data/test/partials_test.rb +0 -205
- data/test/plist_engine_test.rb +0 -308
- data/test/renderer_test.rb +0 -390
- data/test/silence.rb +0 -21
- data/test/template_test.rb +0 -63
- data/test/teststrap.rb +0 -37
- data/test/xml_test.rb +0 -297
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 319983ae5fd329b2650da09ab880866b0f07f4d81bc722a27c9d0305fd1a77af
|
4
|
+
data.tar.gz: 7b6b13b88d7da8b770e1f4cc8aaa0d3193f50f01b0f57980a4ce8071538e4849
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
4
|
-
[![
|
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
|
592
|
+
Then, in your template, you can use `locals[:custom_title]` as:
|
584
593
|
|
585
|
-
```
|
594
|
+
```ruby
|
586
595
|
attribute :content
|
587
|
-
node(: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 =~ /^[
|
21
|
-
require 'rabl/digestor' if Rails.version =~ /^[
|
22
|
-
require 'rabl/railtie' if Rails.version =~ /^[
|
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
|
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)
|
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
|
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
|
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
|
-
|
202
|
-
|
203
|
-
|
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 &&=
|
215
|
-
|
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
|
-
|
224
|
-
|
225
|
-
|
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
|
data/lib/rabl/cache_engine.rb
CHANGED
@@ -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
|
|
data/lib/rabl/configuration.rb
CHANGED
@@ -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
|
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 =~ /^[
|
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
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
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
|
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 &&
|
85
|
-
|
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 =~ /^[
|
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
|