http_api_tools 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/README.md +10 -0
- data/http_api_tools.gemspec +3 -3
- data/lib/http_api_tools/nesting/relation_loader.rb +2 -1
- data/lib/http_api_tools/sideloading/relation_sideloader.rb +2 -1
- data/lib/http_api_tools/version.rb +1 -1
- data/spec/http_api_tools/nesting/json_serializer_spec.rb +1 -1
- data/spec/http_api_tools/relation_includes_spec.rb +3 -3
- data/spec/http_api_tools/sideloading/json_serializer_spec.rb +1 -1
- metadata +25 -26
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YjVkOGRjZTg4ZGVjMDI4NTU3MDRkYTQxZGVjZGE3ZTQ0MzdiNzY2Mw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b45b69c786e42150e206e38361b5fcbe2c8a2b85
|
4
|
+
data.tar.gz: 41c5cc90921186f517d4e390d3a00942ff06a0a1
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
YTBhNjZkMDIwNjVlNDE3MTc1YmU2YTYwZmE0ZDJiMDEyNThmODc5Yzk2MWFm
|
11
|
-
NDM0YzRjNzcwZGUxNmZiZGI1ODI2ZGM0NGYyYTBmMWJjYTU5ZDg=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YWZmZmI0MDZkMjUxODFmYWZmMGEwNjIzYWE5MTliNDQ4ZmYwZDQzNGU4MjY1
|
14
|
-
ZTdiMWRiZDQ0NTkxNjc4NDBkMGZlZjEyNTBmYzgyMzk5OWFkMmM3ZjZjZmFm
|
15
|
-
MjJhOTk0ZTY5MDgxZWQxZThlYjlhMGMzZWZlYTBlOGUyZWVhN2I=
|
6
|
+
metadata.gz: acb7d8f9897ba7e4492bce39d77001a0b5f2e1106b7993f36505f1e6932ad5188591ba5852e996dadcf504259027155c27cf61dbee7d2743aa2276a85da08286
|
7
|
+
data.tar.gz: 7fbbbca72cebd7ba286f7fb0d76c427055a50ed444c15200918550b06dce6bbb6ac73c94478fbbf31acb2c97194970448a9d691f1178a4302eb2f046addc26e5
|
data/README.md
CHANGED
@@ -19,11 +19,21 @@ Or install it yourself as:
|
|
19
19
|
|
20
20
|
$ gem install http_api_tools
|
21
21
|
|
22
|
+
|
22
23
|
## Usage
|
23
24
|
At a high level this gem provides serialization of models (active model or otherwise), deserialization of the serialized json and a way to declaritively create basic models in clients with basic type coercion.
|
24
25
|
|
25
26
|
It has been written to work as a whole where the producer and client of the api are both maintained by the same development team. Conventions are used throughout to keep things simple. At this stage, breaking these conventions isn't supported in many cases but the gem can be extended towards this goal as the needs arise. Please see the note on performance in the section on contributing at the end of this document.
|
26
27
|
|
28
|
+
|
29
|
+
### Config
|
30
|
+
|
31
|
+
Create an app initializer in `config/initializers/http_api_tools.rb` with the following.
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
HttpApiTools::SerializerLoader.preload
|
35
|
+
```
|
36
|
+
|
27
37
|
### Serialization
|
28
38
|
There are two supported serialization formats - sideloading and nesting. Both formats maintain an identical api and
|
29
39
|
usage pattern while serializing in different ways. While it is possible to provide both formats in an application, it's likely you'd stick to one as the general philosophy is http_api_tools a resource should always be represented in the same way.
|
data/http_api_tools.gemspec
CHANGED
@@ -20,10 +20,10 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "activesupport"
|
24
|
-
spec.add_development_dependency
|
23
|
+
spec.add_development_dependency "activesupport", '~> 4.1'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.1'
|
25
25
|
spec.add_development_dependency "pry"
|
26
|
-
spec.add_development_dependency "pry-
|
26
|
+
spec.add_development_dependency "pry-byebug"
|
27
27
|
spec.add_development_dependency "ruby-prof"
|
28
28
|
|
29
29
|
end
|
@@ -81,7 +81,8 @@ module HttpApiTools
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def serializer_class_for(serializable)
|
84
|
-
HttpApiTools::SerializerRegistry.instance.get(:nesting, serializable.class)
|
84
|
+
serializer_class = HttpApiTools::SerializerRegistry.instance.get(:nesting, serializable.class)
|
85
|
+
serializer_class || raise("No Serializer found for #{serializable.class}")
|
85
86
|
end
|
86
87
|
|
87
88
|
end
|
@@ -70,7 +70,8 @@ module HttpApiTools
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def serializer_class_for(serializable)
|
73
|
-
HttpApiTools::SerializerRegistry.instance.get(:sideloading, serializable.class)
|
73
|
+
serializer_class = HttpApiTools::SerializerRegistry.instance.get(:sideloading, serializable.class)
|
74
|
+
serializer_class || raise("No Serializer found for #{serializable.class}")
|
74
75
|
end
|
75
76
|
|
76
77
|
|
@@ -36,7 +36,7 @@ module HttpApiTools
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'expect basic attributes with no value' do
|
39
|
-
expect(serialized_person.
|
39
|
+
expect(serialized_person).to have_key(:dob)
|
40
40
|
end
|
41
41
|
|
42
42
|
it "serializes attributes defined as methods on the serializer" do
|
@@ -139,15 +139,15 @@ module HttpApiTools
|
|
139
139
|
let(:includes) { RelationIncludes.new(:a, { b: [:c] }) }
|
140
140
|
|
141
141
|
it "includes correct relations when a symbol" do
|
142
|
-
expect(includes.includes_relation?(:a)).to
|
142
|
+
expect(includes.includes_relation?(:a)).to be_truthy
|
143
143
|
end
|
144
144
|
|
145
145
|
it "includes relations when key of object" do
|
146
|
-
expect(includes.includes_relation?(:b)).to
|
146
|
+
expect(includes.includes_relation?(:b)).to be_truthy
|
147
147
|
end
|
148
148
|
|
149
149
|
it "does not include unspecified relations" do
|
150
|
-
expect(includes.includes_relation?(:x)).to
|
150
|
+
expect(includes.includes_relation?(:x)).to be_falsey
|
151
151
|
end
|
152
152
|
|
153
153
|
end
|
@@ -36,7 +36,7 @@ module HttpApiTools
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'expect basic attributes with no value' do
|
39
|
-
expect(serialized_person.
|
39
|
+
expect(serialized_person).to have_key(:dob)
|
40
40
|
end
|
41
41
|
|
42
42
|
it "serializes attributes defined as methods on the serializer" do
|
metadata
CHANGED
@@ -1,111 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http_api_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Monie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: activesupport
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '4.1'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '4.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '3.1'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '3.1'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: pry
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name: pry-
|
84
|
+
name: pry-byebug
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: ruby-prof
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
description: Http API Tools
|
@@ -115,8 +115,8 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
-
- .gitignore
|
119
|
-
- .rspec
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
120
|
- Gemfile
|
121
121
|
- LICENSE.txt
|
122
122
|
- README.md
|
@@ -177,12 +177,12 @@ require_paths:
|
|
177
177
|
- lib
|
178
178
|
required_ruby_version: !ruby/object:Gem::Requirement
|
179
179
|
requirements:
|
180
|
-
- -
|
180
|
+
- - ">="
|
181
181
|
- !ruby/object:Gem::Version
|
182
182
|
version: '0'
|
183
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- -
|
185
|
+
- - ">="
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: '0'
|
188
188
|
requirements: []
|
@@ -212,4 +212,3 @@ test_files:
|
|
212
212
|
- spec/http_api_tools/support/spec_sideloading_serializers.rb
|
213
213
|
- spec/http_api_tools/type_key_resolver_spec.rb
|
214
214
|
- spec/spec_helper.rb
|
215
|
-
has_rdoc:
|