roar-rails 1.0.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6817e161c3f12ef7ed0c8658a5bdd24aacbb5a7c
4
- data.tar.gz: 20abccfffd64b3f03e6d57fb27bb76ad9cc27812
2
+ SHA256:
3
+ metadata.gz: 72a50deaa37777184a20ec63694f99acd0b6abe45a59b26518c03ed9e47c6657
4
+ data.tar.gz: 152119dacff3fa7a2fd1c175627b5a559c4e035c017b174b00c616296faaadf9
5
5
  SHA512:
6
- metadata.gz: 3bb52c91e664b93082dffb57afab0572329f1312c0a5d9cd0f23b85a9457366fcc47e9072dc40d91294db51a9fcdbd27178c5b4af73d91a1eb9cd873ff5a5f71
7
- data.tar.gz: bfcb2294190c92540ebdf091ce3c7371ba060e24258e69d578ea6c94870cd955f68edd0f2a6a3d6043845176fdc76df2b8a05e44d6d260c0b9d2d246365cbe46
6
+ metadata.gz: fb2d68fc5b0b7dd9086d8826c094eb35b1bff02c083aec98a109bdf77cc206202cdec3f6272823cd5e3b7592577204967da9edbb09303541efe7bb6e083b221e
7
+ data.tar.gz: a202eeddb9816a87f00d56f0333375f10783c403742fb05d545014c586c901b8f1a41c63a5c35dc547880cbe035bd09a89a206d86e36f6ad4892fb410fb01251
data/Appraisals CHANGED
@@ -47,3 +47,12 @@ appraise 'rails-5.0' do
47
47
  gem 'activerecord', '~> 5.0.0'
48
48
  gem 'minitest-rails', '~> 3.0'
49
49
  end
50
+
51
+ appraise 'rails-5.1' do
52
+ gem 'railties', '~> 5.1.0'
53
+ gem 'actionpack', '~> 5.1.0'
54
+
55
+ gem 'activemodel', '~> 5.1.0'
56
+ gem 'activerecord', '~> 5.1.0'
57
+ gem 'minitest-rails', '~> 3.0'
58
+ end
data/CHANGES.markdown CHANGED
@@ -1,7 +1,21 @@
1
+ ## Next
2
+
3
+ ## 1.2.0
4
+
5
+ * Relax version requirement for Roar
6
+
7
+ ## 1.1.0
8
+
9
+ **Roar 1.1 (and Representable 3.0) support** (see [Roar CHANGES](https://github.com/trailblazer/roar/blob/master/CHANGES.markdown#110))
10
+
11
+ * Require Roar >= 1.1.0.
12
+ * Improved support for JSON API (now requires separate [roar-jsonapi](https://github.com/trailblazer/roar-jsonapi) gem).
13
+ * Fix Uber version requirement.
14
+
1
15
  ## 1.0.2
2
16
 
3
17
  * Make Roar version requirement stricter: restrict to 1.0.x series.
4
- * Initial support for Rails 5 support.
18
+ * Initial support for Rails 5.
5
19
 
6
20
  ## 1.0.1
7
21
 
@@ -12,7 +26,7 @@
12
26
  ## 1.0.0
13
27
 
14
28
  * Requires Roar >= 1.0.0.
15
- * In `#consume!` roar-rails now finds the correct representer for the `Content-type:` header. In former version the representer name was infered using the `Accept:` header, which was totally wrong. Thanks to @pgaertig for fixing that.
29
+ * In `#consume!` roar-rails now finds the correct representer for the `Content-type:` header. In former version the representer name was inferred using the `Accept:` header, which was totally wrong. Thanks to @pgaertig for fixing that.
16
30
 
17
31
  ## 0.1.6
18
32
 
@@ -47,7 +61,7 @@
47
61
  ## 0.1.0
48
62
 
49
63
  * `ActiveRecord::Relation` is now detected as a collection and the appropriate representer should be found.
50
- * Entity (singular) representers are now correctly infered even if you only specified `collection:` in `::represents`. That works by querying the model.
64
+ * Entity (singular) representers are now correctly inferred even if you only specified `collection:` in `::represents`. That works by querying the model.
51
65
  * Entity representers are now *namespaced* when guessed (i.e., when you didn't specify them explicitly in `::represents`) as it works with collection representers already. If you have a namespaced controller and it suddenly doesn't find its entity representer anymore, either namespace the representer or specify its name in `::represents`.
52
66
 
53
67
  ## 0.0.14
data/README.markdown CHANGED
@@ -5,9 +5,7 @@ _Makes using Roar's representers in your Rails app fun._
5
5
  [![Build Status](https://travis-ci.org/apotonick/roar-rails.svg?branch=master)](https://travis-ci.org/apotonick/roar-rails)
6
6
  [![Gem Version](https://badge.fury.io/rb/roar-rails.svg)](http://badge.fury.io/rb/roar-rails)
7
7
 
8
- **IMPORTANT NOTE: roar-rails 1.0.2 does not support Roar 1.1**. Support is still under development and will be released as part of roar-rails 1.1. See [#130](https://github.com/apotonick/roar-rails/issues/130).
9
-
10
- _roar-rails development will be discontinued in the future and we will encourage users to begin migrating to [Trailblazer](trailblazer.to) (and [trailblazer-rails](https://github.com/trailblazer/trailblazer-rails))._
8
+ _roar-rails development will be discontinued in the future and we will encourage users to begin migrating to [Trailblazer](http://trailblazer.to) (and [trailblazer-rails](https://github.com/trailblazer/trailblazer-rails))._
11
9
 
12
10
  ---
13
11
 
@@ -1,12 +1,7 @@
1
1
  require 'roar/json/json_api'
2
2
 
3
- Roar::JSON::JSONAPI.class_eval do
3
+ # FIXME: Hack. Add another module to Roar JSON API to hook into.
4
+ Roar::JSON::JSONAPI::Document.class_eval do
4
5
  def to_json_api(*args); to_json(*args); end
5
6
  def from_json_api(*args); from_json(*args); end
6
7
  end
7
-
8
- # allow the same for collections.
9
- Roar::JSON::JSONAPI::Document::Collection.class_eval do
10
- def to_json_api(*args); to_json(*args); end
11
- def from_json_api(*args); from_json(*args); end
12
- end
@@ -1,5 +1,5 @@
1
1
  module Roar
2
2
  module Rails
3
- VERSION = "1.0.2"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
data/lib/roar-rails.rb CHANGED
@@ -35,6 +35,10 @@ module Roar
35
35
  require 'roar/rails/rails4_2_strategy'
36
36
  when Gem::Version.new(5.0)
37
37
  require 'roar/rails/rails5_0_strategy'
38
+ when Gem::Version.new("5.1")
39
+ require 'roar/rails/rails5_0_strategy'
40
+ when Gem::Version.new("5.2")
41
+ require 'roar/rails/rails5_0_strategy'
38
42
  else
39
43
  # fallback to 4.0 strategy
40
44
  require 'roar/rails/rails4_0_strategy'
data/roar-rails.gemspec CHANGED
@@ -18,16 +18,17 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_runtime_dependency "roar", '~> 1.0.4'
21
+ s.add_runtime_dependency "roar", "~> 1.2"
22
22
  s.add_runtime_dependency "test_xml", ">= 0.1.6" # TODO: remove dependency as most people don't use XML.
23
23
  s.add_runtime_dependency "actionpack"
24
24
  s.add_runtime_dependency "railties", ">= 3.0.0"
25
- s.add_runtime_dependency "uber", "~> 0.0.7"
25
+ s.add_runtime_dependency "uber", "< 0.2.0"
26
26
  s.add_runtime_dependency "responders"
27
27
 
28
28
  s.add_development_dependency 'minitest-rails'
29
29
  s.add_development_dependency 'minitest'
30
30
 
31
+ s.add_development_dependency "roar-jsonapi", '>= 0.0.3'
31
32
  s.add_development_dependency "activemodel"
32
33
  s.add_development_dependency "activerecord"
33
34
  s.add_development_dependency "sqlite3"
data/test/consume_test.rb CHANGED
@@ -130,12 +130,17 @@ end
130
130
  class ConsumeJsonApiTest < ActionController::TestCase
131
131
  include Roar::Rails::TestCase
132
132
 
133
- module MusicianRepresenter
134
- include Roar::JSON::JSONAPI
135
- type :singer
136
- property :name
137
- end
133
+ Band = Struct.new(:name, :id)
134
+ Singer = Struct.new(:name, :id)
135
+ Musician = Struct.new(:name, :id)
138
136
 
137
+ class MusicianRepresenter < Roar::Decorator
138
+ include Roar::JSON::JSONAPI.resource :singer
139
+
140
+ attributes do
141
+ property :name
142
+ end
143
+ end
139
144
 
140
145
  class SingersController < ActionController::Base
141
146
  include Roar::Rails::ControllerAdditions
@@ -151,9 +156,9 @@ class ConsumeJsonApiTest < ActionController::TestCase
151
156
 
152
157
  test "#consume parses JSON-API document and updates the model" do
153
158
  @request.env['CONTENT_TYPE'] = 'application/vnd.api+json'
154
- post :consume_json_api, "{\"singer\": {\"name\": \"Bumi\"}}"
159
+ post :consume_json_api, %({"data":{"attributes":{"name":"Bumi"},"type":"song"}})
155
160
 
156
- assert_equal %{#<struct Singer name="Bumi">}, @response.body
161
+ assert_equal %{#<struct ConsumeJsonApiTest::Singer name="Bumi", id=nil>}, @response.body
157
162
  end
158
163
  end
159
164
 
@@ -3,11 +3,17 @@ require 'test_helper'
3
3
  class JsonApiRendererTest < ActionController::TestCase
4
4
  include Roar::Rails::TestCase
5
5
 
6
+ Band = Struct.new(:name, :id)
7
+ Singer = Struct.new(:name, :id)
8
+ Musician = Struct.new(:name, :id)
9
+
6
10
  class SingersController < ActionController::Base
7
- module SingerRepresenter
8
- include Roar::JSON::JSONAPI
9
- type :song
10
- property :name
11
+ class SingerRepresenter < Roar::Decorator
12
+ include Roar::JSON::JSONAPI.resource :song
13
+
14
+ attributes do
15
+ property :name
16
+ end
11
17
 
12
18
  link(:self) { "//self"}
13
19
  end
@@ -33,14 +39,14 @@ class JsonApiRendererTest < ActionController::TestCase
33
39
  test "should render single model correctly in response to a application/vnd.api+json" do
34
40
  get :show, :id => "1", :format => :json_api
35
41
 
36
- response.body.must_equal "{\"song\":{\"name\":\"Bumi\"},\"links\":{\"self\":{\"href\":\"//self\"}}}"
42
+ response.body.must_equal %({"data":{"attributes":{"name":"Bumi"},"type":"song","links":{"self":"//self"}}})
37
43
  end
38
44
 
39
45
  test "should render collection of models correctly in response to a application/vnd.api+json" do
40
46
  get :index, :format => :json_api
41
47
  # assert_body '{"people":[{"first_name":"Chad"},{"first_name":"Fremont"}]}'
42
48
 
43
- response.body.must_equal "{\"song\":[{\"name\":\"Bumi\"},{\"name\":\"Chad\"}],\"links\":{\"self\":{\"href\":\"//self\"}}}"
49
+ response.body.must_equal %({"data":[{"attributes":{"name":"Bumi"},"type":"song","links":{"self":"//self"}},{"attributes":{"name":"Chad"},"type":"song","links":{"self":"//self"}}]})
44
50
  end
45
51
 
46
52
  test "should have a content_type of application/vnd.api+json for a single model" do
@@ -298,8 +298,8 @@ class ResponderTest < ActionController::TestCase
298
298
  # FIXME: should be in generic roar-rails test.
299
299
  module DynamicSingerRepresenter
300
300
  include Roar::JSON
301
- property :name, :setter => lambda { |val, opts| self.name = "#{opts[:title]} #{val}" },
302
- :getter => lambda { |opts| "#{opts[:title]} #{name}" }
301
+ property :name, :setter => lambda { |opts| self.name = "#{opts[:user_options][:title]} #{opts[:fragment]}" },
302
+ :getter => lambda { |opts| "#{opts[:user_options][:title]} #{name}" }
303
303
  end
304
304
  class MusicianController < BaseController
305
305
  represents :json, :entity => DynamicSingerRepresenter, :collection => SingersRepresenter
@@ -310,7 +310,7 @@ class ResponderTest < ActionController::TestCase
310
310
  test "passes options to entity representer" do
311
311
  get do
312
312
  singer = Singer.new("Bumi")
313
- respond_with singer, :title => "Mr."
313
+ respond_with singer, user_options: { title: "Mr." }
314
314
  end
315
315
 
316
316
  @response.body.must_equal("{\"name\":\"Mr. Bumi\"}")
@@ -318,7 +318,7 @@ class ResponderTest < ActionController::TestCase
318
318
 
319
319
  test "passes options to explicit collection representer" do
320
320
  get do
321
- respond_with [Singer.new("Bumi"), Singer.new("Iggy")], :title => "Mr.", :represent_items_with => DynamicSingerRepresenter
321
+ respond_with [Singer.new("Bumi"), Singer.new("Iggy")], user_options: { title: "Mr." }, :represent_items_with => DynamicSingerRepresenter
322
322
  end
323
323
 
324
324
  @response.body.must_equal("[{\"name\":\"Mr. Bumi\"},{\"name\":\"Mr. Iggy\"}]")
@@ -330,7 +330,7 @@ class ResponderTest < ActionController::TestCase
330
330
  @request.env['CONTENT_TYPE'] = 'application/json'
331
331
 
332
332
  put singer.to_json do
333
- created_singer = consume!(Singer.new, :title => "Mr.")
333
+ created_singer = consume!(Singer.new, user_options: { title: "Mr." })
334
334
  respond_with created_singer
335
335
  end
336
336
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roar-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-16 00:00:00.000000000 Z
11
+ date: 2023-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: roar
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.4
19
+ version: '1.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.4
26
+ version: '1.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: test_xml
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -70,16 +70,16 @@ dependencies:
70
70
  name: uber
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - "<"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.0.7
75
+ version: 0.2.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - "<"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.0.7
82
+ version: 0.2.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: responders
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: roar-jsonapi
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 0.0.3
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: 0.0.3
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: activemodel
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -266,7 +280,7 @@ files:
266
280
  homepage: https://github.com/apotonick/roar-rails
267
281
  licenses: []
268
282
  metadata: {}
269
- post_install_message:
283
+ post_install_message:
270
284
  rdoc_options: []
271
285
  require_paths:
272
286
  - lib
@@ -281,9 +295,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
295
  - !ruby/object:Gem::Version
282
296
  version: '0'
283
297
  requirements: []
284
- rubyforge_project: roar-rails
285
- rubygems_version: 2.5.1
286
- signing_key:
298
+ rubygems_version: 3.3.18
299
+ signing_key:
287
300
  specification_version: 4
288
301
  summary: Use Roar in Rails.
289
302
  test_files: