her 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +19 -1279
  3. data/.rubocop_todo.yml +232 -0
  4. data/README.md +16 -0
  5. data/her.gemspec +3 -2
  6. data/lib/her/api.rb +8 -7
  7. data/lib/her/collection.rb +2 -1
  8. data/lib/her/errors.rb +3 -1
  9. data/lib/her/json_api/model.rb +8 -12
  10. data/lib/her/middleware.rb +1 -1
  11. data/lib/her/middleware/accept_json.rb +1 -0
  12. data/lib/her/middleware/first_level_parse_json.rb +6 -5
  13. data/lib/her/middleware/json_api_parser.rb +6 -5
  14. data/lib/her/middleware/parse_json.rb +2 -1
  15. data/lib/her/middleware/second_level_parse_json.rb +6 -5
  16. data/lib/her/model/associations.rb +6 -6
  17. data/lib/her/model/associations/association.rb +7 -9
  18. data/lib/her/model/associations/association_proxy.rb +2 -3
  19. data/lib/her/model/associations/belongs_to_association.rb +1 -1
  20. data/lib/her/model/attributes.rb +6 -6
  21. data/lib/her/model/base.rb +2 -2
  22. data/lib/her/model/http.rb +1 -1
  23. data/lib/her/model/introspection.rb +5 -3
  24. data/lib/her/model/nested_attributes.rb +1 -1
  25. data/lib/her/model/orm.rb +9 -8
  26. data/lib/her/model/parse.rb +9 -12
  27. data/lib/her/model/paths.rb +3 -4
  28. data/lib/her/model/relation.rb +5 -4
  29. data/lib/her/version.rb +1 -1
  30. data/spec/api_spec.rb +3 -0
  31. data/spec/middleware/accept_json_spec.rb +1 -0
  32. data/spec/middleware/first_level_parse_json_spec.rb +2 -1
  33. data/spec/middleware/json_api_parser_spec.rb +1 -0
  34. data/spec/middleware/second_level_parse_json_spec.rb +1 -0
  35. data/spec/model/associations/association_proxy_spec.rb +1 -0
  36. data/spec/model/associations_spec.rb +4 -3
  37. data/spec/model/attributes_spec.rb +5 -3
  38. data/spec/model/callbacks_spec.rb +14 -15
  39. data/spec/model/dirty_spec.rb +1 -0
  40. data/spec/model/http_spec.rb +1 -0
  41. data/spec/model/introspection_spec.rb +3 -2
  42. data/spec/model/nested_attributes_spec.rb +1 -0
  43. data/spec/model/orm_spec.rb +22 -16
  44. data/spec/model/parse_spec.rb +3 -0
  45. data/spec/model/paths_spec.rb +1 -0
  46. data/spec/model/relation_spec.rb +3 -2
  47. data/spec/model/validations_spec.rb +1 -0
  48. data/spec/model_spec.rb +1 -0
  49. data/spec/support/extensions/array.rb +1 -0
  50. data/spec/support/extensions/hash.rb +1 -0
  51. metadata +12 -11
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require File.join(File.dirname(__FILE__), "../spec_helper.rb")
3
4
 
4
5
  describe Her::Model::Parse do
@@ -251,6 +252,7 @@ describe Her::Model::Parse do
251
252
 
252
253
  it "parse the data with the symbol" do
253
254
  @new_user = Foo::User.create(fullname: "Lindsay Fünke")
255
+ expect(@new_user.id).to eq(1)
254
256
  expect(@new_user.fullname).to eq("Lindsay Fünke")
255
257
  end
256
258
  end
@@ -264,6 +266,7 @@ describe Her::Model::Parse do
264
266
 
265
267
  spawn_model("Foo::Model") { parse_root_in_json true, format: :active_model_serializers }
266
268
  class User < Foo::Model
269
+
267
270
  collection_path "/users"
268
271
  end
269
272
 
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require File.join(File.dirname(__FILE__), "../spec_helper.rb")
3
4
 
4
5
  describe Her::Model::Paths do
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require File.join(File.dirname(__FILE__), "../spec_helper.rb")
3
4
 
4
5
  describe Her::Model::Relation do
@@ -194,7 +195,7 @@ describe Her::Model::Relation do
194
195
  builder.use Her::Middleware::FirstLevelParseJSON
195
196
  builder.use Faraday::Request::UrlEncoded
196
197
  builder.adapter :test do |stub|
197
- stub.post("/users") { |env| ok! id: 3, active: (params(env)[:active] == "true" ? true : false) }
198
+ stub.post("/users") { |env| ok! id: 3, active: (params(env)[:active] == "true") }
198
199
  end
199
200
  end
200
201
 
@@ -212,7 +213,7 @@ describe Her::Model::Relation do
212
213
  builder.use Her::Middleware::FirstLevelParseJSON
213
214
  builder.use Faraday::Request::UrlEncoded
214
215
  builder.adapter :test do |stub|
215
- stub.get("/users?active=true") { |env| ok! [{ id: 3, active: (params(env)[:active] == "true" ? true : false) }] }
216
+ stub.get("/users?active=true") { |env| ok! [{ id: 3, active: (params(env)[:active] == "true") }] }
216
217
  end
217
218
  end
218
219
 
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require File.join(File.dirname(__FILE__), "../spec_helper.rb")
3
4
 
4
5
  describe "Her::Model and ActiveModel::Validations" do
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require "spec_helper"
3
4
 
4
5
  describe Her::Model do
@@ -1,4 +1,5 @@
1
1
  class Array
2
+
2
3
  def to_json
3
4
  MultiJson.dump(self)
4
5
  end
@@ -1,4 +1,5 @@
1
1
  class Hash
2
+
2
3
  def to_json
3
4
  MultiJson.dump(self)
4
5
  end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: her
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
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-04-30 00:00:00.000000000 Z
11
+ date: 2018-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rake
14
+ name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '10.0'
19
+ version: '1.8'
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
- version: '10.0'
26
+ version: '1.8'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rspec
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.5'
33
+ version: '10.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
- version: '3.5'
40
+ version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: json
42
+ name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.8'
47
+ version: '3.5'
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: '1.8'
54
+ version: '3.5'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activemodel
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -110,6 +110,7 @@ files:
110
110
  - ".gitignore"
111
111
  - ".rspec"
112
112
  - ".rubocop.yml"
113
+ - ".rubocop_todo.yml"
113
114
  - ".travis.yml"
114
115
  - ".yardopts"
115
116
  - CONTRIBUTING.md