api-model 1.0.1 → 1.1.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
2
  SHA1:
3
- metadata.gz: 73d9deb33b32e4fa619eea2bb1c268e4f3ab885b
4
- data.tar.gz: 33b7cadeba5a48095b8f3c5817bf240dfcff121d
3
+ metadata.gz: 04b7b32dcafe097cfa189677e7433df6e93bb9d8
4
+ data.tar.gz: 86d040b5103c7a250594d95631abf9ba2490a628
5
5
  SHA512:
6
- metadata.gz: 50ab1de85de04b518dc8deaf7966f70735fab6962dde39a79d6d6dd673a62d35ac926bc16205f1c6e878a676ab97aeec8f8e92cdd0dd581d833a51180468b21b
7
- data.tar.gz: e9abbedbedacc988511f559fdcbd8a81ff6d690b03854ebcbf09bacec69bae70bc164bad463b28a12cc7487a9b4d2869f2a6183e2ee0816f4b24bfd86e57d830
6
+ metadata.gz: 1768b6cb9cfd663679e7f5be0ac69ec6010dbc28f0b18f960a281f2a44445f8f51215374059c59e94bc081427bae9c5d7336bdbd2b6f785a8f9ba8809737dadf
7
+ data.tar.gz: 4293c20c24147003fdb13769283fa1f046031c8efcacfa0c40e3cc6e2da814003354642ee28439421b2236f9bf544676c999e43b6c220254d28094141a307814
@@ -1,32 +1,32 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- api-model (1.0.1)
5
- activemodel
6
- activesupport
7
- hashie
8
- typhoeus
4
+ api-model (1.1.0)
5
+ activemodel (~> 4.0.3)
6
+ activesupport (~> 4.0.3)
7
+ hashie (~> 2.0.5)
8
+ typhoeus (~> 0.6.7)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- activemodel (4.0.2)
14
- activesupport (= 4.0.2)
13
+ activemodel (4.0.3)
14
+ activesupport (= 4.0.3)
15
15
  builder (~> 3.1.0)
16
- activesupport (4.0.2)
16
+ activesupport (4.0.3)
17
17
  i18n (~> 0.6, >= 0.6.4)
18
18
  minitest (~> 4.2)
19
19
  multi_json (~> 1.3)
20
20
  thread_safe (~> 0.1)
21
21
  tzinfo (~> 0.3.37)
22
22
  addressable (2.3.5)
23
- atomic (1.1.14)
23
+ atomic (1.1.15)
24
24
  builder (3.1.4)
25
25
  coderay (1.0.9)
26
26
  crack (0.4.1)
27
27
  safe_yaml (~> 0.9.0)
28
28
  diff-lcs (1.2.5)
29
- ethon (0.6.2)
29
+ ethon (0.6.3)
30
30
  ffi (>= 1.3.0)
31
31
  mime-types (~> 1.18)
32
32
  ffi (1.9.3)
@@ -50,8 +50,8 @@ GEM
50
50
  rspec-mocks (2.14.4)
51
51
  safe_yaml (0.9.7)
52
52
  slop (3.4.6)
53
- thread_safe (0.1.3)
54
- atomic
53
+ thread_safe (0.2.0)
54
+ atomic (>= 1.1.7, < 2)
55
55
  typhoeus (0.6.7)
56
56
  ethon (~> 0.6.2)
57
57
  tzinfo (0.3.38)
@@ -2,21 +2,22 @@ $:.push File.expand_path("../lib", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "api-model"
5
- s.version = "1.0.1"
5
+ s.version = "1.1.0"
6
6
  s.authors = ["Damien Timewell"]
7
7
  s.email = ["mail@damientimewell.com"]
8
+ s.licenses = ['MIT']
8
9
  s.homepage = "https://github.com/iZettle/api-model"
9
10
  s.summary = "A simple way of interacting with rest APIs"
10
11
  s.description = "API model is a simple wrapper for interacting with external APIs. It tries to make it very simple and easy to make API calls and map the responses into objects."
11
12
 
12
- s.add_dependency 'activesupport'
13
- s.add_dependency 'activemodel'
14
- s.add_dependency 'typhoeus'
15
- s.add_dependency 'hashie'
13
+ s.add_dependency 'activesupport', '~> 4.0'
14
+ s.add_dependency 'activemodel', '~> 4.0'
15
+ s.add_dependency 'typhoeus', '~> 0.6'
16
+ s.add_dependency 'hashie', '~> 2.0'
16
17
 
17
- s.add_development_dependency "rspec"
18
- s.add_development_dependency "pry"
19
- s.add_development_dependency "vcr"
18
+ s.add_development_dependency "rspec", '~> 2.14'
19
+ s.add_development_dependency "pry", '~> 0.9'
20
+ s.add_development_dependency "vcr", '2.8.0'
20
21
  s.add_development_dependency "webmock", "1.15.0"
21
22
 
22
23
  s.files = `git ls-files`.split("\n")
@@ -7,6 +7,7 @@ require 'typhoeus'
7
7
  require 'ostruct'
8
8
 
9
9
  require 'api_model/core_extensions/hash'
10
+ require 'api_model/core_extensions/hashie'
10
11
 
11
12
  require 'api_model/assignment'
12
13
  require 'api_model/initializer'
@@ -0,0 +1,8 @@
1
+ Hashie::Dash.class_eval do
2
+
3
+ # Prevent hashie from raising errors when trying to set properties which have not been defined.
4
+ def assert_property_exists!(property)
5
+ super rescue NoMethodError
6
+ end
7
+
8
+ end
@@ -15,8 +15,7 @@ module ApiModel
15
15
  def property_exists?(property_name)
16
16
  super property_name
17
17
  rescue NoMethodError
18
- Log.debug "Could not set #{property_name} on #{self.class.name}. Defining it now."
19
- self.class.property property_name.to_sym
18
+ Log.debug "Could not set #{property_name} on #{self.class.name}"
20
19
  end
21
20
 
22
21
  # Convenience method to handle error hashes and set them as ActiveModel errors on instances.
@@ -119,20 +119,6 @@ describe ApiModel do
119
119
  cars.last.name.should eq "Ford"
120
120
  end
121
121
  end
122
-
123
- describe "with a single object which has properties which are undefined" do
124
- let(:new_car) { VCR.use_cassette('cars') { Car.get_json "http://cars.com/new_model" } }
125
-
126
- it "should not raise an exception" do
127
- expect {
128
- new_car
129
- }.to_not raise_error
130
- end
131
-
132
- it 'should define the missing property on the fly' do
133
- new_car.shiney.should eq true
134
- end
135
- end
136
122
  end
137
123
 
138
124
  describe "setting errors from a hash" do
metadata CHANGED
@@ -1,113 +1,113 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damien Timewell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-04 00:00:00.000000000 Z
11
+ date: 2014-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '4.0'
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: '0'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activemodel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '4.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '4.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: typhoeus
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '0.6'
48
48
  type: :runtime
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: '0'
54
+ version: '0.6'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: hashie
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '2.0'
62
62
  type: :runtime
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: '0'
68
+ version: '2.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '2.14'
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
- version: '0'
82
+ version: '2.14'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: pry
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '0.9'
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
- version: '0'
96
+ version: '0.9'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: vcr
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: 2.8.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
- version: '0'
110
+ version: 2.8.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: webmock
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -145,6 +145,7 @@ files:
145
145
  - lib/api_model/class_methods.rb
146
146
  - lib/api_model/configuration.rb
147
147
  - lib/api_model/core_extensions/hash.rb
148
+ - lib/api_model/core_extensions/hashie.rb
148
149
  - lib/api_model/http_request.rb
149
150
  - lib/api_model/initializer.rb
150
151
  - lib/api_model/instance_methods.rb
@@ -167,7 +168,8 @@ files:
167
168
  - spec/support/mock_models/multiple_hosts.rb
168
169
  - spec/support/mock_models/user.rb
169
170
  homepage: https://github.com/iZettle/api-model
170
- licenses: []
171
+ licenses:
172
+ - MIT
171
173
  metadata: {}
172
174
  post_install_message:
173
175
  rdoc_options: []
@@ -185,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
187
  version: '0'
186
188
  requirements: []
187
189
  rubyforge_project:
188
- rubygems_version: 2.2.1
190
+ rubygems_version: 2.2.2
189
191
  signing_key:
190
192
  specification_version: 4
191
193
  summary: A simple way of interacting with rest APIs