rabl 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +3 -1
- data/CHANGELOG.md +8 -0
- data/Gemfile +2 -1
- data/README.md +16 -10
- data/Rakefile +13 -4
- data/fixtures/ashared/NOTES +46 -0
- data/fixtures/ashared/controllers_rails_5/posts_controller.rb +17 -0
- data/fixtures/ashared/controllers_rails_5/users_controller.rb +11 -0
- data/fixtures/ashared/helpers/application_helper.rb +5 -0
- data/fixtures/ashared/views_rails_3/users/phone_number.xml.rabl +1 -0
- data/fixtures/padrino_test/app/views +1 -0
- data/fixtures/padrino_test/db/migrate +1 -0
- data/fixtures/padrino_test/models +1 -0
- data/fixtures/padrino_test/test/app/controllers/posts_controller_test.rb +1 -0
- data/fixtures/padrino_test/test/app/controllers/users_controller_test.rb +1 -0
- data/fixtures/rails2/app/models +1 -0
- data/fixtures/rails2/app/views +1 -0
- data/fixtures/rails2/db/migrate +1 -0
- data/fixtures/rails2/test/functionals/posts_controller_test.rb +1 -0
- data/fixtures/rails2/test/functionals/users_controller_test.rb +1 -0
- data/fixtures/rails3/app/models +1 -0
- data/fixtures/rails3/app/views +1 -0
- data/fixtures/rails3/db/migrate +1 -0
- data/fixtures/rails3/db/schema.rb +42 -0
- data/fixtures/rails3/test/functional/posts_controller_test.rb +1 -0
- data/fixtures/rails3/test/functional/users_controller_test.rb +1 -0
- data/fixtures/rails3_2/app/models +1 -0
- data/fixtures/rails3_2/app/views +1 -0
- data/fixtures/rails3_2/db/migrate +1 -0
- data/fixtures/rails3_2/test/functional/posts_controller_test.rb +1 -0
- data/fixtures/rails3_2/test/functional/users_controller_test.rb +1 -0
- data/fixtures/rails4/Gemfile +5 -1
- data/fixtures/rails4/app/models +1 -0
- data/fixtures/rails4/app/views +1 -0
- data/fixtures/rails4/config/environments/test.rb +3 -0
- data/fixtures/rails4/db/migrate +1 -0
- data/fixtures/rails4/db/schema.rb +42 -0
- data/fixtures/rails4/test/functional/posts_controller_test.rb +1 -0
- data/fixtures/rails4/test/functional/users_controller_test.rb +1 -0
- data/fixtures/rails5/.gitignore +21 -0
- data/fixtures/rails5/Gemfile +53 -0
- data/fixtures/rails5/README.md +24 -0
- data/fixtures/rails5/Rakefile +13 -0
- data/fixtures/rails5/app/assets/config/manifest.js +3 -0
- data/fixtures/rails5/app/assets/images/.keep +0 -0
- data/fixtures/rails5/app/assets/javascripts/application.js +16 -0
- data/fixtures/rails5/app/assets/javascripts/cable.js +13 -0
- data/fixtures/rails5/app/assets/javascripts/channels/.keep +0 -0
- data/fixtures/rails5/app/assets/stylesheets/application.css +15 -0
- data/fixtures/rails5/app/channels/application_cable/channel.rb +4 -0
- data/fixtures/rails5/app/channels/application_cable/connection.rb +4 -0
- data/fixtures/rails5/app/controllers/application_controller.rb +3 -0
- data/fixtures/rails5/app/controllers/concerns/.keep +0 -0
- data/fixtures/rails5/app/controllers/posts_controller.rb +1 -0
- data/fixtures/rails5/app/controllers/users_controller.rb +1 -0
- data/fixtures/rails5/app/helpers +1 -0
- data/fixtures/rails5/app/jobs/application_job.rb +2 -0
- data/fixtures/rails5/app/mailers/application_mailer.rb +4 -0
- data/fixtures/rails5/app/models +1 -0
- data/fixtures/rails5/app/views +1 -0
- data/fixtures/rails5/bin/bundle +3 -0
- data/fixtures/rails5/bin/rails +9 -0
- data/fixtures/rails5/bin/rake +9 -0
- data/fixtures/rails5/bin/setup +34 -0
- data/fixtures/rails5/bin/spring +15 -0
- data/fixtures/rails5/bin/update +29 -0
- data/fixtures/rails5/config/application.rb +15 -0
- data/fixtures/rails5/config/boot.rb +3 -0
- data/fixtures/rails5/config/cable.yml +9 -0
- data/fixtures/rails5/config/database.yml +25 -0
- data/fixtures/rails5/config/environment.rb +5 -0
- data/fixtures/rails5/config/environments/development.rb +54 -0
- data/fixtures/rails5/config/environments/production.rb +86 -0
- data/fixtures/rails5/config/environments/test.rb +42 -0
- data/fixtures/rails5/config/initializers/application_controller_renderer.rb +6 -0
- data/fixtures/rails5/config/initializers/assets.rb +11 -0
- data/fixtures/rails5/config/initializers/backtrace_silencers.rb +7 -0
- data/fixtures/rails5/config/initializers/cookies_serializer.rb +5 -0
- data/fixtures/rails5/config/initializers/filter_parameter_logging.rb +4 -0
- data/fixtures/rails5/config/initializers/inflections.rb +16 -0
- data/fixtures/rails5/config/initializers/mime_types.rb +6 -0
- data/fixtures/rails5/config/initializers/new_framework_defaults.rb +24 -0
- data/fixtures/rails5/config/initializers/session_store.rb +3 -0
- data/fixtures/rails5/config/initializers/wrap_parameters.rb +14 -0
- data/fixtures/rails5/config/locales/en.yml +23 -0
- data/fixtures/rails5/config/puma.rb +47 -0
- data/fixtures/rails5/config/routes.rb +8 -0
- data/fixtures/rails5/config/secrets.yml +22 -0
- data/fixtures/rails5/config/spring.rb +6 -0
- data/fixtures/rails5/config.ru +5 -0
- data/fixtures/rails5/db/migrate +1 -0
- data/fixtures/rails5/db/schema.rb +41 -0
- data/fixtures/rails5/db/seeds.rb +7 -0
- 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 +67 -0
- data/fixtures/rails5/public/422.html +67 -0
- data/fixtures/rails5/public/500.html +66 -0
- 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 +5 -0
- 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/functional/posts_controller_test.rb +1 -0
- data/fixtures/rails5/test/functional/users_controller_test.rb +1 -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 +26 -0
- 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/rails5_api/.gitignore +21 -0
- data/fixtures/rails5_api/Gemfile +46 -0
- data/fixtures/rails5_api/README.md +24 -0
- data/fixtures/rails5_api/Rakefile +13 -0
- data/fixtures/rails5_api/app/channels/application_cable/channel.rb +4 -0
- data/fixtures/rails5_api/app/channels/application_cable/connection.rb +4 -0
- data/fixtures/rails5_api/app/controllers/application_controller.rb +2 -0
- data/fixtures/rails5_api/app/controllers/concerns/.keep +0 -0
- data/fixtures/rails5_api/app/controllers/posts_controller.rb +1 -0
- data/fixtures/rails5_api/app/controllers/users_controller.rb +1 -0
- data/fixtures/rails5_api/app/helpers +1 -0
- data/fixtures/rails5_api/app/jobs/application_job.rb +2 -0
- data/fixtures/rails5_api/app/mailers/application_mailer.rb +4 -0
- data/fixtures/rails5_api/app/models +1 -0
- data/fixtures/rails5_api/app/views +1 -0
- data/fixtures/rails5_api/bin/bundle +3 -0
- data/fixtures/rails5_api/bin/rails +9 -0
- data/fixtures/rails5_api/bin/rake +9 -0
- data/fixtures/rails5_api/bin/setup +34 -0
- data/fixtures/rails5_api/bin/spring +17 -0
- data/fixtures/rails5_api/bin/update +29 -0
- data/fixtures/rails5_api/config/application.rb +30 -0
- data/fixtures/rails5_api/config/boot.rb +3 -0
- data/fixtures/rails5_api/config/cable.yml +9 -0
- data/fixtures/rails5_api/config/database.yml +25 -0
- data/fixtures/rails5_api/config/environment.rb +5 -0
- data/fixtures/rails5_api/config/environments/development.rb +47 -0
- data/fixtures/rails5_api/config/environments/production.rb +78 -0
- data/fixtures/rails5_api/config/environments/test.rb +42 -0
- data/fixtures/rails5_api/config/initializers/application_controller_renderer.rb +6 -0
- data/fixtures/rails5_api/config/initializers/backtrace_silencers.rb +7 -0
- data/fixtures/rails5_api/config/initializers/cors.rb +16 -0
- data/fixtures/rails5_api/config/initializers/filter_parameter_logging.rb +4 -0
- data/fixtures/rails5_api/config/initializers/inflections.rb +16 -0
- data/fixtures/rails5_api/config/initializers/mime_types.rb +5 -0
- data/fixtures/rails5_api/config/initializers/new_framework_defaults.rb +18 -0
- data/fixtures/rails5_api/config/initializers/wrap_parameters.rb +14 -0
- data/fixtures/rails5_api/config/locales/en.yml +23 -0
- data/fixtures/rails5_api/config/puma.rb +47 -0
- data/fixtures/rails5_api/config/routes.rb +8 -0
- data/fixtures/rails5_api/config/secrets.yml +22 -0
- data/fixtures/rails5_api/config/spring.rb +6 -0
- data/fixtures/rails5_api/config.ru +5 -0
- data/fixtures/rails5_api/db/migrate +1 -0
- data/fixtures/rails5_api/db/schema.rb +41 -0
- data/fixtures/rails5_api/db/seeds.rb +7 -0
- data/fixtures/rails5_api/lib/tasks/.keep +0 -0
- data/fixtures/rails5_api/log/.keep +0 -0
- data/fixtures/rails5_api/public/robots.txt +5 -0
- data/fixtures/rails5_api/test/controllers/.keep +0 -0
- data/fixtures/rails5_api/test/fixtures/.keep +0 -0
- data/fixtures/rails5_api/test/fixtures/files/.keep +0 -0
- data/fixtures/rails5_api/test/functional/posts_controller_test.rb +1 -0
- data/fixtures/rails5_api/test/functional/users_controller_test.rb +1 -0
- data/fixtures/rails5_api/test/integration/.keep +0 -0
- data/fixtures/rails5_api/test/mailers/.keep +0 -0
- data/fixtures/rails5_api/test/models/.keep +0 -0
- data/fixtures/rails5_api/test/test_helper.rb +39 -0
- data/fixtures/rails5_api/tmp/.keep +0 -0
- data/fixtures/sinatra_test/db/migrate +1 -0
- data/fixtures/sinatra_test/models +1 -0
- data/fixtures/sinatra_test/test/functional/posts_controller_test.rb +1 -0
- data/fixtures/sinatra_test/test/functional/users_controller_test.rb +1 -0
- data/fixtures/sinatra_test/views +1 -0
- data/lib/rabl/builder.rb +13 -3
- data/lib/rabl/configuration.rb +3 -1
- data/lib/rabl/digestor/rails3.rb +10 -0
- data/lib/rabl/digestor/rails41.rb +10 -0
- data/lib/rabl/digestor/rails5.rb +4 -0
- data/lib/rabl/digestor.rb +3 -37
- data/lib/rabl/engine.rb +3 -1
- data/lib/rabl/railtie.rb +17 -0
- data/lib/rabl/version.rb +1 -1
- data/lib/rabl.rb +2 -2
- data/rabl.gemspec +1 -1
- data/test/builder_test.rb +26 -0
- data/test/engine_test.rb +6 -0
- data/test/integration/rails5/posts_controller_test.rb +251 -0
- data/test/integration/rails5/users_controller_test.rb +87 -0
- data/test/models/user.rb +10 -9
- metadata +169 -5
- data/fixtures/ashared/views_rails_3/users/phone_number.xml.rabl +0 -8
- data/fixtures/padrino_test/test/app/controllers/posts_controller_test.rb +0 -108
- data/fixtures/padrino_test/test/app/controllers/users_controller_test.rb +0 -87
- data/fixtures/rails2/test/functionals/posts_controller_test.rb +0 -108
- data/fixtures/rails2/test/functionals/users_controller_test.rb +0 -87
- data/fixtures/rails3/test/functional/posts_controller_test.rb +0 -108
- data/fixtures/rails3/test/functional/users_controller_test.rb +0 -87
- data/fixtures/rails3_2/test/functional/posts_controller_test.rb +0 -263
- data/fixtures/rails3_2/test/functional/users_controller_test.rb +0 -87
- data/fixtures/rails4/test/functional/posts_controller_test.rb +0 -248
- data/fixtures/rails4/test/functional/users_controller_test.rb +0 -87
- data/fixtures/sinatra_test/test/functional/posts_controller_test.rb +0 -108
- data/fixtures/sinatra_test/test/functional/users_controller_test.rb +0 -87
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0f39e37962add4e967db96ddb7970e8b5567180494024c83ab1cd0f40b215789
|
4
|
+
data.tar.gz: f61f64c38bb2baf81ce33885feb2fb7a9fc3a9e3587a8767f08d29cacb88a455
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fffcd3104d9a52f11ea39205040858112b12199df5062ad7e3bce56d5ef12f02c97718974bb11765cc2afbde585a8190d0aa93630e655b588d76d66a503854f2
|
7
|
+
data.tar.gz: 8a780a5d5dc6ca50da1183a71d2292bee13be1abbaffa8f7c7972854c009265c32543710a8879f8de1cbc1d7186cfd48b5d2528907e184a918832b07675f6d50
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -14,9 +14,10 @@ group :test do
|
|
14
14
|
# RABL TEST
|
15
15
|
gem 'builder'
|
16
16
|
|
17
|
+
rails_version = RUBY_VERSION =~ /\A(1|2.[01])/ ? '~> 4.0' : '>= 4.0'
|
17
18
|
# FIXTURES
|
18
19
|
gem 'rack-test', :require => 'rack/test'
|
19
|
-
gem 'activerecord', :require => 'active_record'
|
20
|
+
gem 'activerecord', rails_version, :require => 'active_record'
|
20
21
|
gem 'sqlite3'
|
21
22
|
gem 'sinatra', '>= 1.2.0'
|
22
23
|
gem 'hashie'
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# RABL #
|
2
2
|
|
3
|
-
[![Continuous Integration status](https://secure.travis-ci.org/nesquena/rabl.
|
4
|
-
[![Dependency Status](https://gemnasium.com/nesquena/rabl.
|
5
|
-
[![Code Climate](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
|
+
[![Dependency Status](https://gemnasium.com/nesquena/rabl.svg)](https://gemnasium.com/nesquena/rabl)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/nesquena/rabl.svg)](https://codeclimate.com/github/nesquena/rabl)
|
6
6
|
|
7
7
|
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
8
|
When using the ActiveRecord 'to_json' method, I find myself wanting a more expressive and powerful solution for generating APIs.
|
@@ -146,6 +146,7 @@ Rabl.configure do |config|
|
|
146
146
|
# config.replace_empty_string_values_with_nil_values = true # Defaults to false
|
147
147
|
# config.exclude_nil_values = true # Defaults to false
|
148
148
|
# config.exclude_empty_values_in_collections = true # Defaults to false
|
149
|
+
# config.camelize_keys = :upper # Defaults to false
|
149
150
|
end
|
150
151
|
```
|
151
152
|
|
@@ -186,6 +187,8 @@ If `exclude_nil_values` is set to `true`, all values that are `nil` and would no
|
|
186
187
|
|
187
188
|
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
189
|
|
190
|
+
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.
|
191
|
+
|
189
192
|
If you wish to use [oj](https://github.com/ohler55/oj) as
|
190
193
|
the primary JSON encoding engine simply add that to your Gemfile:
|
191
194
|
|
@@ -300,6 +303,13 @@ Named and aliased attributes can not be combined on the same line. This currentl
|
|
300
303
|
attributes :foo, :bar => :baz # throws exception
|
301
304
|
```
|
302
305
|
|
306
|
+
in such cases, you need to specify attributes twice.
|
307
|
+
|
308
|
+
```ruby
|
309
|
+
attributes :foo
|
310
|
+
attributes :bar => :baz
|
311
|
+
```
|
312
|
+
|
303
313
|
### Child Nodes ###
|
304
314
|
|
305
315
|
Often a response requires including nested information from data associated with the parent model:
|
@@ -580,11 +590,11 @@ You can also pass in other instance variables to be used in your template as:
|
|
580
590
|
Rabl::Renderer.new('posts/show', @post, :locals => { :custom_title => "Hello world!" })
|
581
591
|
````
|
582
592
|
|
583
|
-
Then, in your template, you can use
|
593
|
+
Then, in your template, you can use `locals[:custom_title]` as:
|
584
594
|
|
585
|
-
```
|
595
|
+
```ruby
|
586
596
|
attribute :content
|
587
|
-
node(:title) {
|
597
|
+
node(:title) { locals[:custom_title] }
|
588
598
|
```
|
589
599
|
|
590
600
|
### Content Type Headers ###
|
@@ -624,13 +634,9 @@ Tutorials can always be helpful when first getting started:
|
|
624
634
|
|
625
635
|
* [Railscasts #322](http://railscasts.com/episodes/322-rabl) - Ryan Bates explains RABL
|
626
636
|
* [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
637
|
* 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
638
|
* http://tech.favoritemedium.com/2011/06/using-rabl-in-rails-json-web-api.html
|
632
639
|
* http://seesparkbox.com/foundry/better_rails_apis_with_rabl
|
633
|
-
* http://blog.dcxn.com/2011/06/22/rails-json-templates-through-rabl
|
634
640
|
* http://teohm.github.com/blog/2011/05/31/using-rabl-in-rails-json-web-api
|
635
641
|
|
636
642
|
Let me know if there's any other useful resources not listed here.
|
data/Rakefile
CHANGED
@@ -9,7 +9,11 @@ Rake::TestTask.new(:test) do |test|
|
|
9
9
|
test.pattern = 'test/*_test.rb'
|
10
10
|
test.warning = true
|
11
11
|
test.verbose = true
|
12
|
-
|
12
|
+
if RUBY_VERSION < "1.9.0"
|
13
|
+
# -rubygems isn't needed as of 1.9, and is gone as of 2.5
|
14
|
+
# https://github.com/ruby/ruby/blob/v2_5_0/NEWS#stdlib-compatibility-issues-excluding-feature-bug-fixes
|
15
|
+
test.ruby_opts = ['-rubygems']
|
16
|
+
end
|
13
17
|
end
|
14
18
|
|
15
19
|
# Running integration tests
|
@@ -17,7 +21,7 @@ end
|
|
17
21
|
# rake test:setup
|
18
22
|
# rake test:full
|
19
23
|
|
20
|
-
fixture_list = "{padrino_test,sinatra_test,rails2,rails3,rails3_2,rails4}"
|
24
|
+
fixture_list = "{padrino_test,sinatra_test,rails2,rails3,rails3_2,rails4,rails5,rails5_api}"
|
21
25
|
|
22
26
|
desc "Clean up the fixtures being tested by cleaning and installing dependencies"
|
23
27
|
task "test:clean" do
|
@@ -33,7 +37,12 @@ task "test:setup" do
|
|
33
37
|
puts "\n*** Setting up for #{File.basename(fixture)} tests ***\n"
|
34
38
|
`export BUNDLE_GEMFILE="#{fixture}/Gemfile"` if ENV["TRAVIS"]
|
35
39
|
Bundler.with_clean_env {
|
36
|
-
Dir.chdir(fixture) {
|
40
|
+
Dir.chdir(fixture) {
|
41
|
+
puts `mkdir -p tmp/cache; bundle install --gemfile="#{fixture}/Gemfile"`
|
42
|
+
if fixture.include? 'rails'
|
43
|
+
puts `bundle exec rake db:reset`
|
44
|
+
end
|
45
|
+
}
|
37
46
|
}
|
38
47
|
end
|
39
48
|
end
|
@@ -51,4 +60,4 @@ end
|
|
51
60
|
task "test:full" => [:test, "test:fixtures"]
|
52
61
|
|
53
62
|
desc "Run tests for rabl"
|
54
|
-
task :default => :test
|
63
|
+
task :default => :test
|
data/fixtures/ashared/NOTES
CHANGED
@@ -42,3 +42,49 @@ ln -s "../../ashared/views_rails_3/" app/views
|
|
42
42
|
ln -s "../../ashared/migrate" db/migrate
|
43
43
|
ln -s ../../../../test/integration/rails3_2/posts_controller_test.rb test/functional/posts_controller_test.rb
|
44
44
|
ln -s ../../../../test/integration/rails3_2/users_controller_test.rb test/functional/users_controller_test.rb
|
45
|
+
|
46
|
+
# Rails 5
|
47
|
+
|
48
|
+
cd fixtures/rails5
|
49
|
+
ln -s "../../ashared/models" app/models
|
50
|
+
ln -s "../../ashared/views_rails_3/" app/views
|
51
|
+
ln -s "../../ashared/migrate" db/migrate
|
52
|
+
ln -s "../../ashared/helpers" app/helpers
|
53
|
+
ln -s "../../../ashared/controllers_rails_5/posts_controller.rb" app/controllers/posts_controller.rb
|
54
|
+
ln -s "../../../ashared/controllers_rails_5/users_controller.rb" app/controllers/users_controller.rb
|
55
|
+
ln -s ../../../../test/integration/rails5/posts_controller_test.rb test/functional/posts_controller_test.rb
|
56
|
+
ln -s ../../../../test/integration/rails5/users_controller_test.rb test/functional/users_controller_test.rb
|
57
|
+
echo "Mime::Type.register 'application/vnd.rabl-test_v1+json', :rabl_test_v1" >> config/initializers/mime_types.rb
|
58
|
+
# Do route file?
|
59
|
+
|
60
|
+
# Rails 5 API mode
|
61
|
+
|
62
|
+
# Basic setup
|
63
|
+
cd fixtures
|
64
|
+
rvm use 2.5.0
|
65
|
+
rails _5.0.2_ new rails5_api --api
|
66
|
+
cd rails5_api
|
67
|
+
|
68
|
+
# Server config
|
69
|
+
echo "Mime::Type.register 'application/vnd.rabl-test_v1+json', :rabl_test_v1" >> config/initializers/mime_types.rb
|
70
|
+
cp ../rails5/config/routes.rb config/routes.rb
|
71
|
+
|
72
|
+
# Application
|
73
|
+
rm -r app/models app/views app/migrate
|
74
|
+
ln -s "../../ashared/models" app/models
|
75
|
+
ln -s "../../ashared/views_rails_3/" app/views
|
76
|
+
ln -s "../../ashared/migrate" db/migrate
|
77
|
+
ln -s "../../ashared/helpers" app/helpers
|
78
|
+
ln -s "../../../ashared/controllers_rails_5/posts_controller.rb" app/controllers/posts_controller.rb
|
79
|
+
ln -s "../../../ashared/controllers_rails_5/users_controller.rb" app/controllers/users_controller.rb
|
80
|
+
|
81
|
+
# Test setup
|
82
|
+
cp ../rails5/Rakefile ./
|
83
|
+
mkdir test/functional
|
84
|
+
ln -s ../../../../test/integration/rails5/posts_controller_test.rb test/functional/posts_controller_test.rb
|
85
|
+
ln -s ../../../../test/integration/rails5/users_controller_test.rb test/functional/users_controller_test.rb
|
86
|
+
cp ../rails5/test/test_helper.rb ./test/test_helper.rb
|
87
|
+
|
88
|
+
# Do a bunch of junk with gemfiles and test helpers and such
|
89
|
+
|
90
|
+
# end Rails 5 API mode
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class PostsController < ApplicationController
|
2
|
+
|
3
|
+
respond_to :json, :xml, :html, :rabl_test_v1
|
4
|
+
|
5
|
+
def index
|
6
|
+
@posts = Post.order('id ASC').load
|
7
|
+
end
|
8
|
+
|
9
|
+
def show
|
10
|
+
@post = Post.find(params[:id])
|
11
|
+
end
|
12
|
+
|
13
|
+
def renderer
|
14
|
+
post = Post.find(params[:id])
|
15
|
+
render json: Rabl.render(post, 'posts/renderer', view_path: 'app/views', format: :json, scope: view_context)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/ashared/views_rails_3/users/phone_number.json.rabl
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/padrino_test/app/../../ashared/views/
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/padrino_test/db/../../ashared/migrate
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/padrino_test/../ashared/models
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/padrino_test/test/app/controllers/../../../../../test/integration/posts_controller_test.rb
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/padrino_test/test/app/controllers/../../../../../test/integration/users_controller_test.rb
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails2/app/../../ashared/models
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails2/app/../../ashared/views/
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails2/db/../../ashared/migrate
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails2/test/functionals/../../../../test/integration/posts_controller_test.rb
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails2/test/functionals/../../../../test/integration/users_controller_test.rb
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails3/app/../../ashared/models
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails3/app/../../ashared/views/
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails3/db/../../ashared/migrate
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended to check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(:version => 20111002092024) do
|
15
|
+
|
16
|
+
create_table "phone_numbers", :force => true do |t|
|
17
|
+
t.integer "user_id"
|
18
|
+
t.boolean "is_primary"
|
19
|
+
t.string "area_code"
|
20
|
+
t.string "prefix"
|
21
|
+
t.string "suffix"
|
22
|
+
t.string "name"
|
23
|
+
end
|
24
|
+
|
25
|
+
create_table "posts", :force => true do |t|
|
26
|
+
t.integer "user_id"
|
27
|
+
t.string "title"
|
28
|
+
t.text "body"
|
29
|
+
t.datetime "created_at"
|
30
|
+
t.datetime "updated_at"
|
31
|
+
end
|
32
|
+
|
33
|
+
create_table "users", :force => true do |t|
|
34
|
+
t.string "username"
|
35
|
+
t.string "email"
|
36
|
+
t.string "location"
|
37
|
+
t.boolean "is_admin"
|
38
|
+
t.datetime "created_at"
|
39
|
+
t.datetime "updated_at"
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails3/test/functional/../../../../test/integration/posts_controller_test.rb
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails3/test/functional/../../../../test/integration/users_controller_test.rb
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails3_2/app/../../ashared/models
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails3_2/app/../../ashared/views_rails_3/
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails3_2/db/../../ashared/migrate
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails3_2/test/functional/../../../../test/integration/rails3_2/posts_controller_test.rb
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails3_2/test/functional/../../../../test/integration/rails3_2/users_controller_test.rb
|
data/fixtures/rails4/Gemfile
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
4
|
-
gem 'rails', '4.
|
4
|
+
gem 'rails', '4.2.8'
|
5
5
|
|
6
6
|
# Use sqlite3 as the database for Active Record
|
7
7
|
gem 'sqlite3'
|
8
8
|
gem 'rabl', :path => File.expand_path(File.dirname(__FILE__) + "/../../")
|
9
9
|
gem 'riot', :group => "test"
|
10
|
+
gem 'pry-rails', :group => "test"
|
10
11
|
|
11
12
|
gem "oj"
|
12
13
|
|
14
|
+
# respond_to is its own gem now
|
15
|
+
gem 'responders', '~> 2.0'
|
16
|
+
|
13
17
|
# Use SCSS for stylesheets
|
14
18
|
gem 'sass-rails', '~> 4.0.0'
|
15
19
|
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails4/app/../../ashared/models
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails4/app/../../ashared/views_rails_3
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails4/db/../../ashared/migrate
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended that you check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(version: 20111002092024) do
|
15
|
+
|
16
|
+
create_table "phone_numbers", force: :cascade do |t|
|
17
|
+
t.integer "user_id"
|
18
|
+
t.boolean "is_primary"
|
19
|
+
t.string "area_code"
|
20
|
+
t.string "prefix"
|
21
|
+
t.string "suffix"
|
22
|
+
t.string "name"
|
23
|
+
end
|
24
|
+
|
25
|
+
create_table "posts", force: :cascade do |t|
|
26
|
+
t.integer "user_id"
|
27
|
+
t.string "title"
|
28
|
+
t.text "body"
|
29
|
+
t.datetime "created_at"
|
30
|
+
t.datetime "updated_at"
|
31
|
+
end
|
32
|
+
|
33
|
+
create_table "users", force: :cascade do |t|
|
34
|
+
t.string "username"
|
35
|
+
t.string "email"
|
36
|
+
t.string "location"
|
37
|
+
t.boolean "is_admin"
|
38
|
+
t.datetime "created_at"
|
39
|
+
t.datetime "updated_at"
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails4/test/functional/../../../../test/integration/rails4/posts_controller_test.rb
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails4/test/functional/../../../../test/integration/rails4/users_controller_test.rb
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore the default SQLite database.
|
11
|
+
/db/*.sqlite3
|
12
|
+
/db/*.sqlite3-journal
|
13
|
+
|
14
|
+
# Ignore all logfiles and tempfiles.
|
15
|
+
/log/*
|
16
|
+
/tmp/*
|
17
|
+
!/log/.keep
|
18
|
+
!/tmp/.keep
|
19
|
+
|
20
|
+
# Ignore Byebug command history file.
|
21
|
+
.byebug_history
|
@@ -0,0 +1,53 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
|
4
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
5
|
+
gem 'rails', '~> 5.0.0'
|
6
|
+
# Use sqlite3 as the database for Active Record
|
7
|
+
gem 'sqlite3'
|
8
|
+
# Use Puma as the app server
|
9
|
+
gem 'puma', '~> 3.0'
|
10
|
+
# Use SCSS for stylesheets
|
11
|
+
gem 'sass-rails', '~> 5.0'
|
12
|
+
# Use Uglifier as compressor for JavaScript assets
|
13
|
+
gem 'uglifier', '>= 1.3.0'
|
14
|
+
# Use CoffeeScript for .coffee assets and views
|
15
|
+
gem 'coffee-rails', '~> 4.2'
|
16
|
+
# See https://github.com/rails/execjs#readme for more supported runtimes
|
17
|
+
# gem 'therubyracer', platforms: :ruby
|
18
|
+
|
19
|
+
# Use jquery as the JavaScript library
|
20
|
+
gem 'jquery-rails'
|
21
|
+
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
|
22
|
+
gem 'turbolinks', '~> 5'
|
23
|
+
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
24
|
+
gem 'jbuilder', '~> 2.5'
|
25
|
+
# Use Redis adapter to run Action Cable in production
|
26
|
+
# gem 'redis', '~> 3.0'
|
27
|
+
# Use ActiveModel has_secure_password
|
28
|
+
# gem 'bcrypt', '~> 3.1.7'
|
29
|
+
|
30
|
+
# Use Capistrano for deployment
|
31
|
+
# gem 'capistrano-rails', group: :development
|
32
|
+
|
33
|
+
group :development, :test do
|
34
|
+
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
35
|
+
gem 'byebug', platform: :mri
|
36
|
+
gem 'pry-rails'
|
37
|
+
end
|
38
|
+
|
39
|
+
group :development do
|
40
|
+
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
|
41
|
+
gem 'web-console'
|
42
|
+
gem 'listen', '~> 3.0.5'
|
43
|
+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
44
|
+
gem 'spring'
|
45
|
+
gem 'spring-watcher-listen', '~> 2.0.0'
|
46
|
+
end
|
47
|
+
|
48
|
+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
49
|
+
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
50
|
+
|
51
|
+
gem 'rabl', :path => File.expand_path(File.dirname(__FILE__) + "/../../")
|
52
|
+
gem 'riot', :group => "test"
|
53
|
+
gem 'responders', '~> 2.0'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require_relative 'config/application'
|
5
|
+
require 'rake/testtask'
|
6
|
+
|
7
|
+
Rails.application.load_tasks
|
8
|
+
|
9
|
+
Rake::TestTask.new("test:rabl") do |test|
|
10
|
+
test.pattern = "test/functional/**/*_test.rb"
|
11
|
+
test.verbose = true
|
12
|
+
test.warning = false
|
13
|
+
end
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require turbolinks
|
16
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
+
// You can generate new channels where WebSocket features live using the rails generate channel command.
|
3
|
+
//
|
4
|
+
//= require action_cable
|
5
|
+
//= require_self
|
6
|
+
//= require_tree ./channels
|
7
|
+
|
8
|
+
(function() {
|
9
|
+
this.App || (this.App = {});
|
10
|
+
|
11
|
+
App.cable = ActionCable.createConsumer();
|
12
|
+
|
13
|
+
}).call(this);
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|