rabl 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +3 -1
  3. data/CHANGELOG.md +8 -0
  4. data/Gemfile +2 -1
  5. data/README.md +16 -10
  6. data/Rakefile +13 -4
  7. data/fixtures/ashared/NOTES +46 -0
  8. data/fixtures/ashared/controllers_rails_5/posts_controller.rb +17 -0
  9. data/fixtures/ashared/controllers_rails_5/users_controller.rb +11 -0
  10. data/fixtures/ashared/helpers/application_helper.rb +5 -0
  11. data/fixtures/ashared/views_rails_3/users/phone_number.xml.rabl +1 -0
  12. data/fixtures/padrino_test/app/views +1 -0
  13. data/fixtures/padrino_test/db/migrate +1 -0
  14. data/fixtures/padrino_test/models +1 -0
  15. data/fixtures/padrino_test/test/app/controllers/posts_controller_test.rb +1 -0
  16. data/fixtures/padrino_test/test/app/controllers/users_controller_test.rb +1 -0
  17. data/fixtures/rails2/app/models +1 -0
  18. data/fixtures/rails2/app/views +1 -0
  19. data/fixtures/rails2/db/migrate +1 -0
  20. data/fixtures/rails2/test/functionals/posts_controller_test.rb +1 -0
  21. data/fixtures/rails2/test/functionals/users_controller_test.rb +1 -0
  22. data/fixtures/rails3/app/models +1 -0
  23. data/fixtures/rails3/app/views +1 -0
  24. data/fixtures/rails3/db/migrate +1 -0
  25. data/fixtures/rails3/db/schema.rb +42 -0
  26. data/fixtures/rails3/test/functional/posts_controller_test.rb +1 -0
  27. data/fixtures/rails3/test/functional/users_controller_test.rb +1 -0
  28. data/fixtures/rails3_2/app/models +1 -0
  29. data/fixtures/rails3_2/app/views +1 -0
  30. data/fixtures/rails3_2/db/migrate +1 -0
  31. data/fixtures/rails3_2/test/functional/posts_controller_test.rb +1 -0
  32. data/fixtures/rails3_2/test/functional/users_controller_test.rb +1 -0
  33. data/fixtures/rails4/Gemfile +5 -1
  34. data/fixtures/rails4/app/models +1 -0
  35. data/fixtures/rails4/app/views +1 -0
  36. data/fixtures/rails4/config/environments/test.rb +3 -0
  37. data/fixtures/rails4/db/migrate +1 -0
  38. data/fixtures/rails4/db/schema.rb +42 -0
  39. data/fixtures/rails4/test/functional/posts_controller_test.rb +1 -0
  40. data/fixtures/rails4/test/functional/users_controller_test.rb +1 -0
  41. data/fixtures/rails5/.gitignore +21 -0
  42. data/fixtures/rails5/Gemfile +53 -0
  43. data/fixtures/rails5/README.md +24 -0
  44. data/fixtures/rails5/Rakefile +13 -0
  45. data/fixtures/rails5/app/assets/config/manifest.js +3 -0
  46. data/fixtures/rails5/app/assets/images/.keep +0 -0
  47. data/fixtures/rails5/app/assets/javascripts/application.js +16 -0
  48. data/fixtures/rails5/app/assets/javascripts/cable.js +13 -0
  49. data/fixtures/rails5/app/assets/javascripts/channels/.keep +0 -0
  50. data/fixtures/rails5/app/assets/stylesheets/application.css +15 -0
  51. data/fixtures/rails5/app/channels/application_cable/channel.rb +4 -0
  52. data/fixtures/rails5/app/channels/application_cable/connection.rb +4 -0
  53. data/fixtures/rails5/app/controllers/application_controller.rb +3 -0
  54. data/fixtures/rails5/app/controllers/concerns/.keep +0 -0
  55. data/fixtures/rails5/app/controllers/posts_controller.rb +1 -0
  56. data/fixtures/rails5/app/controllers/users_controller.rb +1 -0
  57. data/fixtures/rails5/app/helpers +1 -0
  58. data/fixtures/rails5/app/jobs/application_job.rb +2 -0
  59. data/fixtures/rails5/app/mailers/application_mailer.rb +4 -0
  60. data/fixtures/rails5/app/models +1 -0
  61. data/fixtures/rails5/app/views +1 -0
  62. data/fixtures/rails5/bin/bundle +3 -0
  63. data/fixtures/rails5/bin/rails +9 -0
  64. data/fixtures/rails5/bin/rake +9 -0
  65. data/fixtures/rails5/bin/setup +34 -0
  66. data/fixtures/rails5/bin/spring +15 -0
  67. data/fixtures/rails5/bin/update +29 -0
  68. data/fixtures/rails5/config/application.rb +15 -0
  69. data/fixtures/rails5/config/boot.rb +3 -0
  70. data/fixtures/rails5/config/cable.yml +9 -0
  71. data/fixtures/rails5/config/database.yml +25 -0
  72. data/fixtures/rails5/config/environment.rb +5 -0
  73. data/fixtures/rails5/config/environments/development.rb +54 -0
  74. data/fixtures/rails5/config/environments/production.rb +86 -0
  75. data/fixtures/rails5/config/environments/test.rb +42 -0
  76. data/fixtures/rails5/config/initializers/application_controller_renderer.rb +6 -0
  77. data/fixtures/rails5/config/initializers/assets.rb +11 -0
  78. data/fixtures/rails5/config/initializers/backtrace_silencers.rb +7 -0
  79. data/fixtures/rails5/config/initializers/cookies_serializer.rb +5 -0
  80. data/fixtures/rails5/config/initializers/filter_parameter_logging.rb +4 -0
  81. data/fixtures/rails5/config/initializers/inflections.rb +16 -0
  82. data/fixtures/rails5/config/initializers/mime_types.rb +6 -0
  83. data/fixtures/rails5/config/initializers/new_framework_defaults.rb +24 -0
  84. data/fixtures/rails5/config/initializers/session_store.rb +3 -0
  85. data/fixtures/rails5/config/initializers/wrap_parameters.rb +14 -0
  86. data/fixtures/rails5/config/locales/en.yml +23 -0
  87. data/fixtures/rails5/config/puma.rb +47 -0
  88. data/fixtures/rails5/config/routes.rb +8 -0
  89. data/fixtures/rails5/config/secrets.yml +22 -0
  90. data/fixtures/rails5/config/spring.rb +6 -0
  91. data/fixtures/rails5/config.ru +5 -0
  92. data/fixtures/rails5/db/migrate +1 -0
  93. data/fixtures/rails5/db/schema.rb +41 -0
  94. data/fixtures/rails5/db/seeds.rb +7 -0
  95. data/fixtures/rails5/lib/assets/.keep +0 -0
  96. data/fixtures/rails5/lib/tasks/.keep +0 -0
  97. data/fixtures/rails5/log/.keep +0 -0
  98. data/fixtures/rails5/public/404.html +67 -0
  99. data/fixtures/rails5/public/422.html +67 -0
  100. data/fixtures/rails5/public/500.html +66 -0
  101. data/fixtures/rails5/public/apple-touch-icon-precomposed.png +0 -0
  102. data/fixtures/rails5/public/apple-touch-icon.png +0 -0
  103. data/fixtures/rails5/public/favicon.ico +0 -0
  104. data/fixtures/rails5/public/robots.txt +5 -0
  105. data/fixtures/rails5/test/controllers/.keep +0 -0
  106. data/fixtures/rails5/test/fixtures/.keep +0 -0
  107. data/fixtures/rails5/test/fixtures/files/.keep +0 -0
  108. data/fixtures/rails5/test/functional/posts_controller_test.rb +1 -0
  109. data/fixtures/rails5/test/functional/users_controller_test.rb +1 -0
  110. data/fixtures/rails5/test/helpers/.keep +0 -0
  111. data/fixtures/rails5/test/integration/.keep +0 -0
  112. data/fixtures/rails5/test/mailers/.keep +0 -0
  113. data/fixtures/rails5/test/models/.keep +0 -0
  114. data/fixtures/rails5/test/test_helper.rb +26 -0
  115. data/fixtures/rails5/tmp/.keep +0 -0
  116. data/fixtures/rails5/vendor/assets/javascripts/.keep +0 -0
  117. data/fixtures/rails5/vendor/assets/stylesheets/.keep +0 -0
  118. data/fixtures/rails5_api/.gitignore +21 -0
  119. data/fixtures/rails5_api/Gemfile +46 -0
  120. data/fixtures/rails5_api/README.md +24 -0
  121. data/fixtures/rails5_api/Rakefile +13 -0
  122. data/fixtures/rails5_api/app/channels/application_cable/channel.rb +4 -0
  123. data/fixtures/rails5_api/app/channels/application_cable/connection.rb +4 -0
  124. data/fixtures/rails5_api/app/controllers/application_controller.rb +2 -0
  125. data/fixtures/rails5_api/app/controllers/concerns/.keep +0 -0
  126. data/fixtures/rails5_api/app/controllers/posts_controller.rb +1 -0
  127. data/fixtures/rails5_api/app/controllers/users_controller.rb +1 -0
  128. data/fixtures/rails5_api/app/helpers +1 -0
  129. data/fixtures/rails5_api/app/jobs/application_job.rb +2 -0
  130. data/fixtures/rails5_api/app/mailers/application_mailer.rb +4 -0
  131. data/fixtures/rails5_api/app/models +1 -0
  132. data/fixtures/rails5_api/app/views +1 -0
  133. data/fixtures/rails5_api/bin/bundle +3 -0
  134. data/fixtures/rails5_api/bin/rails +9 -0
  135. data/fixtures/rails5_api/bin/rake +9 -0
  136. data/fixtures/rails5_api/bin/setup +34 -0
  137. data/fixtures/rails5_api/bin/spring +17 -0
  138. data/fixtures/rails5_api/bin/update +29 -0
  139. data/fixtures/rails5_api/config/application.rb +30 -0
  140. data/fixtures/rails5_api/config/boot.rb +3 -0
  141. data/fixtures/rails5_api/config/cable.yml +9 -0
  142. data/fixtures/rails5_api/config/database.yml +25 -0
  143. data/fixtures/rails5_api/config/environment.rb +5 -0
  144. data/fixtures/rails5_api/config/environments/development.rb +47 -0
  145. data/fixtures/rails5_api/config/environments/production.rb +78 -0
  146. data/fixtures/rails5_api/config/environments/test.rb +42 -0
  147. data/fixtures/rails5_api/config/initializers/application_controller_renderer.rb +6 -0
  148. data/fixtures/rails5_api/config/initializers/backtrace_silencers.rb +7 -0
  149. data/fixtures/rails5_api/config/initializers/cors.rb +16 -0
  150. data/fixtures/rails5_api/config/initializers/filter_parameter_logging.rb +4 -0
  151. data/fixtures/rails5_api/config/initializers/inflections.rb +16 -0
  152. data/fixtures/rails5_api/config/initializers/mime_types.rb +5 -0
  153. data/fixtures/rails5_api/config/initializers/new_framework_defaults.rb +18 -0
  154. data/fixtures/rails5_api/config/initializers/wrap_parameters.rb +14 -0
  155. data/fixtures/rails5_api/config/locales/en.yml +23 -0
  156. data/fixtures/rails5_api/config/puma.rb +47 -0
  157. data/fixtures/rails5_api/config/routes.rb +8 -0
  158. data/fixtures/rails5_api/config/secrets.yml +22 -0
  159. data/fixtures/rails5_api/config/spring.rb +6 -0
  160. data/fixtures/rails5_api/config.ru +5 -0
  161. data/fixtures/rails5_api/db/migrate +1 -0
  162. data/fixtures/rails5_api/db/schema.rb +41 -0
  163. data/fixtures/rails5_api/db/seeds.rb +7 -0
  164. data/fixtures/rails5_api/lib/tasks/.keep +0 -0
  165. data/fixtures/rails5_api/log/.keep +0 -0
  166. data/fixtures/rails5_api/public/robots.txt +5 -0
  167. data/fixtures/rails5_api/test/controllers/.keep +0 -0
  168. data/fixtures/rails5_api/test/fixtures/.keep +0 -0
  169. data/fixtures/rails5_api/test/fixtures/files/.keep +0 -0
  170. data/fixtures/rails5_api/test/functional/posts_controller_test.rb +1 -0
  171. data/fixtures/rails5_api/test/functional/users_controller_test.rb +1 -0
  172. data/fixtures/rails5_api/test/integration/.keep +0 -0
  173. data/fixtures/rails5_api/test/mailers/.keep +0 -0
  174. data/fixtures/rails5_api/test/models/.keep +0 -0
  175. data/fixtures/rails5_api/test/test_helper.rb +39 -0
  176. data/fixtures/rails5_api/tmp/.keep +0 -0
  177. data/fixtures/sinatra_test/db/migrate +1 -0
  178. data/fixtures/sinatra_test/models +1 -0
  179. data/fixtures/sinatra_test/test/functional/posts_controller_test.rb +1 -0
  180. data/fixtures/sinatra_test/test/functional/users_controller_test.rb +1 -0
  181. data/fixtures/sinatra_test/views +1 -0
  182. data/lib/rabl/builder.rb +13 -3
  183. data/lib/rabl/configuration.rb +3 -1
  184. data/lib/rabl/digestor/rails3.rb +10 -0
  185. data/lib/rabl/digestor/rails41.rb +10 -0
  186. data/lib/rabl/digestor/rails5.rb +4 -0
  187. data/lib/rabl/digestor.rb +3 -37
  188. data/lib/rabl/engine.rb +3 -1
  189. data/lib/rabl/railtie.rb +17 -0
  190. data/lib/rabl/version.rb +1 -1
  191. data/lib/rabl.rb +2 -2
  192. data/rabl.gemspec +1 -1
  193. data/test/builder_test.rb +26 -0
  194. data/test/engine_test.rb +6 -0
  195. data/test/integration/rails5/posts_controller_test.rb +251 -0
  196. data/test/integration/rails5/users_controller_test.rb +87 -0
  197. data/test/models/user.rb +10 -9
  198. metadata +169 -5
  199. data/fixtures/ashared/views_rails_3/users/phone_number.xml.rabl +0 -8
  200. data/fixtures/padrino_test/test/app/controllers/posts_controller_test.rb +0 -108
  201. data/fixtures/padrino_test/test/app/controllers/users_controller_test.rb +0 -87
  202. data/fixtures/rails2/test/functionals/posts_controller_test.rb +0 -108
  203. data/fixtures/rails2/test/functionals/users_controller_test.rb +0 -87
  204. data/fixtures/rails3/test/functional/posts_controller_test.rb +0 -108
  205. data/fixtures/rails3/test/functional/users_controller_test.rb +0 -87
  206. data/fixtures/rails3_2/test/functional/posts_controller_test.rb +0 -263
  207. data/fixtures/rails3_2/test/functional/users_controller_test.rb +0 -87
  208. data/fixtures/rails4/test/functional/posts_controller_test.rb +0 -248
  209. data/fixtures/rails4/test/functional/users_controller_test.rb +0 -87
  210. data/fixtures/sinatra_test/test/functional/posts_controller_test.rb +0 -108
  211. data/fixtures/sinatra_test/test/functional/users_controller_test.rb +0 -87
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9181c1a232aab327e58bd686eb3cf14403e6aac9
4
- data.tar.gz: 3e2f0d536f6752cb575e5843709be0b40f8bd09a
2
+ SHA256:
3
+ metadata.gz: 0f39e37962add4e967db96ddb7970e8b5567180494024c83ab1cd0f40b215789
4
+ data.tar.gz: f61f64c38bb2baf81ce33885feb2fb7a9fc3a9e3587a8767f08d29cacb88a455
5
5
  SHA512:
6
- metadata.gz: 8ea05c8211d750c882c4b0fa6e29a20b56e4ebfcff23e12a2af18e0f50302b191be374a76eace11ed46a787ae702cb7ff5eb7ef659a6d7096db2823451c5b6d1
7
- data.tar.gz: c8634ea3cfbbc11e131b484e598326888c81f15f2a304caf06ec786f8a3ab5d72cfb77f88fc47b4fd34d1dc595c3468ef5c460d44effc949c352dd6ca23d7398
6
+ metadata.gz: fffcd3104d9a52f11ea39205040858112b12199df5062ad7e3bce56d5ef12f02c97718974bb11765cc2afbde585a8190d0aa93630e655b588d76d66a503854f2
7
+ data.tar.gz: 8a780a5d5dc6ca50da1183a71d2292bee13be1abbaffa8f7c7972854c009265c32543710a8879f8de1cbc1d7186cfd48b5d2528907e184a918832b07675f6d50
data/.travis.yml CHANGED
@@ -6,7 +6,9 @@ rvm:
6
6
  - 2.0.0
7
7
  - 2.1
8
8
  - 2.2
9
- - 2.3.1
9
+ - 2.3
10
+ - 2.4
11
+ - 2.5
10
12
  notifications:
11
13
  recipients:
12
14
  - nesquena@gmail.com
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.14.0 (October 31st, 2018)
4
+
5
+ * Compatibility with Rails 5 API mode
6
+
7
+ ## 0.13.1 (October 21st, 2016)
8
+
9
+ * Further compatibility with Rails 5
10
+
3
11
  ## 0.13.0 (July 15th, 2016)
4
12
 
5
13
  * Compatibility with Rails 5
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.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
+ [![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 `@custom_title` as:
593
+ Then, in your template, you can use `locals[:custom_title]` as:
584
594
 
585
- ```
595
+ ```ruby
586
596
  attribute :content
587
- node(:title) { @custom_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
- test.ruby_opts = ['-rubygems']
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) { puts `mkdir -p tmp/cache; bundle install --gemfile="#{fixture}/Gemfile"`; }
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
@@ -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,11 @@
1
+ class UsersController < ApplicationController
2
+ respond_to :json
3
+
4
+ def index
5
+ @users = User.order('username ASC').load
6
+ end
7
+
8
+ def show
9
+ @user = User.find(params[:id])
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ module ApplicationHelper
2
+ def helper_foo
3
+ "BAR!"
4
+ end
5
+ 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
@@ -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.0.0'
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
@@ -33,4 +33,7 @@ Rails4::Application.configure do
33
33
 
34
34
  # Print deprecation notices to the stderr.
35
35
  config.active_support.deprecation = :stderr
36
+
37
+ # Run tests in sorted order (squash test error)
38
+ config.active_support.test_order = :sorted
36
39
  end
@@ -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
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
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);
@@ -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
+ */
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end