her 0.10.4 → 1.0.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: 98705b664b962e3d5edb1a1762bbbba49b9562d7
4
- data.tar.gz: e96212e3b5c29c4e2af4bf4680065f8dd87d3692
3
+ metadata.gz: 72114f9b29011146dffc658a0e7d4e4982ded486
4
+ data.tar.gz: c2118def58a8024890fba2115b921adeee329783
5
5
  SHA512:
6
- metadata.gz: a393eb7b400fa99287eb4e1acc0a37b5858bd82ff632651458aa2b2fc8dbde102b76fba8c557f5fc4a43276628b513b27fc0a0299899a0701f8729d96e9b9bd4
7
- data.tar.gz: ea27adf4fd43563df33b34070d7c7dc4964adb840f3a9270d3db03bd64fcb90dd8d503a70d612343305106131d9f9090fc2e0e0cb457d5e0b0e8f9af1bde3af8
6
+ metadata.gz: 110eb7da65e83503c0922e787999ea4125886d105ea0e70f23abed9539ea6342f288953c69445b1664b7680c2e96884777ef2aaf5af1bbfda9b629c67fa557ea
7
+ data.tar.gz: 39020447959095c9b29b270102f64648b272520e4d88f7e2e3f4ae7e3f8212b74c07e323b44b8702272d79237d20f3a5386e8436d5a367bfa9f87f7d830f0bb7
@@ -3,18 +3,39 @@ language: ruby
3
3
  sudo: false
4
4
 
5
5
  rvm:
6
- - 2.4.2
7
- - 2.3.5
8
- - 2.2.8
9
- - 2.1.6
10
- - 2.0.0
11
6
  - 1.9.3
7
+ - 2.0.0
8
+ - 2.1.6
9
+ - 2.2.8
10
+ - 2.3.5
11
+ - 2.4.2
12
12
 
13
13
  gemfile:
14
14
  - gemfiles/Gemfile.activemodel-4.2
15
- - gemfiles/Gemfile.activemodel-4.1
16
- - gemfiles/Gemfile.activemodel-4.0
17
- - gemfiles/Gemfile.activemodel-3.2.x
15
+ - gemfiles/Gemfile.activemodel-5.0
16
+ - gemfiles/Gemfile.activemodel-5.1
17
+ - gemfiles/Gemfile.activemodel-5.2
18
+
19
+ matrix:
20
+ exclude:
21
+ - gemfile: gemfiles/Gemfile.activemodel-5.0
22
+ rvm: 1.9.3
23
+ - gemfile: gemfiles/Gemfile.activemodel-5.0
24
+ rvm: 2.0.0
25
+ - gemfile: gemfiles/Gemfile.activemodel-5.0
26
+ rvm: 2.1.6
27
+ - gemfile: gemfiles/Gemfile.activemodel-5.1
28
+ rvm: 1.9.3
29
+ - gemfile: gemfiles/Gemfile.activemodel-5.1
30
+ rvm: 2.0.0
31
+ - gemfile: gemfiles/Gemfile.activemodel-5.1
32
+ rvm: 2.1.6
33
+ - gemfile: gemfiles/Gemfile.activemodel-5.2
34
+ rvm: 1.9.3
35
+ - gemfile: gemfiles/Gemfile.activemodel-5.2
36
+ rvm: 2.0.0
37
+ - gemfile: gemfiles/Gemfile.activemodel-5.2
38
+ rvm: 2.1.6
18
39
 
19
40
  before_install:
20
41
  - gem install bundler
@@ -3,5 +3,4 @@ source "https://rubygems.org"
3
3
  gemspec :path => "../"
4
4
 
5
5
  gem 'activemodel', '~> 4.2.0'
6
- gem 'activesupport', '~> 4.2.0'
7
6
  gem 'faraday', '~> 0.8.9'
@@ -2,6 +2,5 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec :path => "../"
4
4
 
5
- gem 'activemodel', '~> 3.2.0'
6
- gem 'activesupport', '~> 3.2.0'
5
+ gem 'activemodel', '~> 5.0.0'
7
6
  gem 'faraday', '~> 0.8.9'
@@ -2,6 +2,5 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec :path => "../"
4
4
 
5
- gem 'activemodel', '~> 4.0.0'
6
- gem 'activesupport', '~> 4.0.0'
5
+ gem 'activemodel', '~> 5.1.0'
7
6
  gem 'faraday', '~> 0.8.9'
@@ -2,6 +2,5 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec :path => "../"
4
4
 
5
- gem 'activemodel', '~> 4.1.0'
6
- gem 'activesupport', '~> 4.1.0'
5
+ gem 'activemodel', '~> 5.2.0'
7
6
  gem 'faraday', '~> 0.8.9'
@@ -21,8 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.add_development_dependency "rspec", "~> 3.5"
22
22
  s.add_development_dependency "json", "~> 1.8"
23
23
 
24
- s.add_runtime_dependency "activemodel", ">= 3.0.0", "< 5.2.0"
25
- s.add_runtime_dependency "activesupport", ">= 3.0.0", "< 5.2.0"
24
+ s.add_runtime_dependency "activemodel", ">= 4.2.1"
26
25
  s.add_runtime_dependency "faraday", ">= 0.8", "< 1.0"
27
26
  s.add_runtime_dependency "multi_json", "~> 1.7"
28
27
  end
@@ -80,7 +80,7 @@ module Her
80
80
  return @parent.attributes[@name] unless @params.any? || @parent.attributes[@name].blank?
81
81
 
82
82
  path_params = @parent.attributes.merge(@params.merge(@klass.primary_key => foreign_key_value))
83
- path = build_association_path -> { @klass.build_request_path(@opts[:path], path_params) }
83
+ path = build_association_path lambda { @klass.build_request_path(path_params) }
84
84
  @klass.get_resource(path, @params).tap do |result|
85
85
  @cached_result = result if @params.blank?
86
86
  end
@@ -162,7 +162,7 @@ module Her
162
162
  attributes = klass.parse(record).merge(_metadata: parsed_data[:metadata],
163
163
  _errors: parsed_data[:errors])
164
164
  klass.new(attributes).tap do |record|
165
- record.instance_variable_set(:@changed_attributes, {})
165
+ record.send :clear_changes_information
166
166
  record.run_callbacks :find
167
167
  end
168
168
  end
@@ -44,10 +44,7 @@ module Her
44
44
  self.class.request(to_params.merge(:_method => method, :_path => request_path)) do |parsed_data, response|
45
45
  load_from_parsed_data(parsed_data)
46
46
  return false if !response.success? || @response_errors.any?
47
- if self.changed_attributes.present?
48
- @previously_changed = self.changes.clone
49
- self.changed_attributes.clear
50
- end
47
+ changes_applied
51
48
  end
52
49
  end
53
50
  end
@@ -145,8 +145,7 @@ module Her
145
145
 
146
146
  # @private
147
147
  def root_element_included?(data)
148
- element = data[parsed_root_element]
149
- element.is_a?(Hash) || element.is_a?(Array)
148
+ data.keys.to_s.include? @_her_root_element.to_s
150
149
  end
151
150
 
152
151
  # @private
@@ -1,3 +1,3 @@
1
1
  module Her
2
- VERSION = "0.10.4"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -661,7 +661,8 @@ describe Her::Model::Associations do
661
661
  builder.adapter :test do |stub|
662
662
  stub.get("/users/1") { [200, {}, { id: 1, name: "Tobias Fünke", organization: { id: 1, name: "Bluth Company Inc." }, organization_id: 1 }.to_json] }
663
663
  stub.get("/users/4") { [200, {}, { id: 1, name: "Tobias Fünke", organization: { id: 1, name: "Bluth Company Inc." } }.to_json] }
664
- stub.get("/users/3") { [200, {}, { id: 2, name: "Lindsay Fünke", organization: nil }.to_json] }
664
+ stub.get("/users/3") { [200, {}, { id: 2, name: "Lindsay Fünke", company: nil }.to_json] }
665
+ stub.get("/companies/1") { [200, {}, { id: 1, name: "Bluth Company" }.to_json] }
665
666
  end
666
667
  end
667
668
  end
@@ -698,7 +699,7 @@ describe Her::Model::Associations do
698
699
  builder.use Faraday::Request::UrlEncoded
699
700
  builder.adapter :test do |stub|
700
701
  stub.get("/users/2") { [200, {}, { id: 2, name: "Lindsay Fünke", organization_id: 1 }.to_json] }
701
- stub.get("/organizations/1") { [200, {}, { id: 1, name: "Bluth Company" }.to_json] }
702
+ stub.get("/companies/1") { [200, {}, { id: 1, name: "Bluth Company" }.to_json] }
702
703
  end
703
704
  end
704
705
  end
@@ -310,10 +310,16 @@ describe Her::Model::Attributes do
310
310
  context "when attribute methods are already defined" do
311
311
  before do
312
312
  class AbstractUser
313
- attr_accessor :fullname
313
+ def fullname
314
+ raise NotImplementedError
315
+ end
316
+
317
+ def fullname=(value)
318
+ raise NotImplementedError
319
+ end
314
320
 
315
321
  def fullname?
316
- @fullname.present?
322
+ raise NotImplementedError
317
323
  end
318
324
  end
319
325
  @spawned_models << :AbstractUser
@@ -324,72 +330,18 @@ describe Her::Model::Attributes do
324
330
  end
325
331
 
326
332
  it "overrides getter method" do
327
- expect(Foo::User.generated_attribute_methods.instance_methods).to include(:fullname)
328
- end
329
-
330
- it "overrides setter method" do
331
- expect(Foo::User.generated_attribute_methods.instance_methods).to include(:fullname=)
332
- end
333
-
334
- it "overrides predicate method" do
335
- expect(Foo::User.generated_attribute_methods.instance_methods).to include(:fullname?)
336
- end
337
-
338
- it "defines setter that affects attributes" do
339
333
  user = Foo::User.new
340
- user.fullname = "Tobias Fünke"
341
- expect(user.attributes[:fullname]).to eq("Tobias Fünke")
334
+ expect { user.fullname }.to_not raise_error(NotImplementedError)
342
335
  end
343
336
 
344
- it "defines getter that reads attributes" do
337
+ it "overrides setter method" do
345
338
  user = Foo::User.new
346
- user.attributes[:fullname] = "Tobias Fünke"
347
- expect(user.fullname).to eq("Tobias Fünke")
339
+ expect { user.fullname = "foo" }.to_not raise_error(NotImplementedError)
348
340
  end
349
341
 
350
- it "defines predicate that reads attributes" do
342
+ it "overrides predicate method" do
351
343
  user = Foo::User.new
352
- expect(user.fullname?).to be_falsey
353
- user.attributes[:fullname] = "Tobias Fünke"
354
- expect(user.fullname?).to be_truthy
355
- end
356
- end
357
-
358
- if ActiveModel::VERSION::MAJOR < 4
359
- it "creates a new mutex" do
360
- expect(Mutex).to receive(:new).once.and_call_original
361
- spawn_model "Foo::User" do
362
- attributes :fullname
363
- end
364
- expect(Foo::User.attribute_methods_mutex).not_to eq(Foo::User.generated_attribute_methods)
365
- end
366
-
367
- it "works well with Module#synchronize monkey patched by ActiveSupport" do
368
- Module.class_eval do
369
- def synchronize(*_args)
370
- raise "gotcha!"
371
- end
372
- end
373
- expect(Mutex).to receive(:new).once.and_call_original
374
- spawn_model "Foo::User" do
375
- attributes :fullname
376
- end
377
- expect(Foo::User.attribute_methods_mutex).not_to eq(Foo::User.generated_attribute_methods)
378
- Module.class_eval do
379
- undef :synchronize
380
- end
381
- end
382
- else
383
- it "uses ActiveModel's mutex" do
384
- expect(Foo::User.attribute_methods_mutex).to eq(Foo::User.generated_attribute_methods)
385
- end
386
- end
387
-
388
- it "uses a mutex" do
389
- spawn_model "Foo::User"
390
- expect(Foo::User.attribute_methods_mutex).to receive(:synchronize).once.and_call_original
391
- Foo::User.class_eval do
392
- attributes :fullname, :documents
344
+ expect { user.fullname? }.to_not raise_error(NotImplementedError)
393
345
  end
394
346
  end
395
347
  end
@@ -251,7 +251,6 @@ describe Her::Model::Parse do
251
251
 
252
252
  it "parse the data with the symbol" do
253
253
  @new_user = Foo::User.create(fullname: "Lindsay Fünke")
254
- expect(@new_user.id).to eq(1)
255
254
  expect(@new_user.fullname).to eq("Lindsay Fünke")
256
255
  end
257
256
  end
@@ -494,25 +493,4 @@ describe Her::Model::Parse do
494
493
  expect(user.to_params).to eq(model: { name: 'foo' })
495
494
  end
496
495
  end
497
-
498
- context "when attribute uses the same name as root element" do
499
- before do
500
- Her::API.setup url: "https://api.example.com" do |builder|
501
- builder.use Her::Middleware::FirstLevelParseJSON
502
- builder.use Faraday::Request::UrlEncoded
503
- end
504
-
505
- Her::API.default_api.connection.adapter :test do |stub|
506
- stub.post("/users") { |env| [200, {}, { user: "foobar", id: 1, fullname: params(env)[:fullname] }.to_json] }
507
- end
508
-
509
- spawn_model "Foo::User"
510
- end
511
-
512
- it "parses as attribute instead of root element" do
513
- user = Foo::User.create(fullname: "barfoo")
514
- expect(user.fullname).to eq "barfoo"
515
- expect(user.user).to eq "foobar"
516
- end
517
- end
518
496
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: her
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rémi Prévost
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-18 00:00:00.000000000 Z
11
+ date: 2018-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -58,40 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 3.0.0
62
- - - "<"
63
- - !ruby/object:Gem::Version
64
- version: 5.2.0
61
+ version: 4.2.1
65
62
  type: :runtime
66
63
  prerelease: false
67
64
  version_requirements: !ruby/object:Gem::Requirement
68
65
  requirements:
69
66
  - - ">="
70
67
  - !ruby/object:Gem::Version
71
- version: 3.0.0
72
- - - "<"
73
- - !ruby/object:Gem::Version
74
- version: 5.2.0
75
- - !ruby/object:Gem::Dependency
76
- name: activesupport
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: 3.0.0
82
- - - "<"
83
- - !ruby/object:Gem::Version
84
- version: 5.2.0
85
- type: :runtime
86
- prerelease: false
87
- version_requirements: !ruby/object:Gem::Requirement
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- version: 3.0.0
92
- - - "<"
93
- - !ruby/object:Gem::Version
94
- version: 5.2.0
68
+ version: 4.2.1
95
69
  - !ruby/object:Gem::Dependency
96
70
  name: faraday
97
71
  requirement: !ruby/object:Gem::Requirement
@@ -144,10 +118,10 @@ files:
144
118
  - README.md
145
119
  - Rakefile
146
120
  - UPGRADE.md
147
- - gemfiles/Gemfile.activemodel-3.2.x
148
- - gemfiles/Gemfile.activemodel-4.0
149
- - gemfiles/Gemfile.activemodel-4.1
150
121
  - gemfiles/Gemfile.activemodel-4.2
122
+ - gemfiles/Gemfile.activemodel-5.0
123
+ - gemfiles/Gemfile.activemodel-5.1
124
+ - gemfiles/Gemfile.activemodel-5.2
151
125
  - her.gemspec
152
126
  - lib/her.rb
153
127
  - lib/her/api.rb