json-pie 0.0.3 → 0.0.6

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
  SHA256:
3
- metadata.gz: edcde33d7c1de58eea685a86544b43bcc4492abda2b9a8807efa2848afe1336d
4
- data.tar.gz: 2882246fa32e1f7c37a250fc5ccd6fc6ecabe79965f6199256af408e92f24ff6
3
+ metadata.gz: 04d3235140b1e5fa044a6eb3fed537982d37cfd4b48442dbaab75eedcd64c607
4
+ data.tar.gz: 3f1e7eb4c84e025b2473c0135ccba9d3a923857e72690e009d3881ad27c8cf3a
5
5
  SHA512:
6
- metadata.gz: 97e5df38f0da9985fc9dad48410f8786d4d65826db6ece95e9e62a39a18591300dadab1fc995e772d3a4dac8c153d94b9a4e8c73c3b5fee99b09d96aa747fac8
7
- data.tar.gz: 1596d7b4116c18a288932cd2cf66534c3cec05778ca24a610e879cacb9e82366cdf99a35c3d2e0db70ec36bc5fd5180c812bbe7f8230b6d0918db3fc5618f134
6
+ metadata.gz: 8f0a828af23abb1b87c7e3c0d572a4772670771b953bf321782f73de8592756279aeea9fe8bc042a661a2591a005a15884def9ac9ea64e50af2fdb0f82b5ca65
7
+ data.tar.gz: b55ee8335191378b3de70085ccf0d4f0a76652acc2736b7e258f9a5f300fa57566fc89987547dc79144b0dc4173dd4e0503c0a0ca90bf19fb59531989d269720
data/.rubocop.yml CHANGED
@@ -24,3 +24,4 @@ Metrics/BlockLength:
24
24
  Exclude:
25
25
  - Guardfile
26
26
  - "**/*_spec.rb"
27
+ - json-pie.gemspec
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [unreleased]
2
2
 
3
+ ## [0.0.5] - 2022-03-14
4
+
5
+ - Handles nullifying relationships
6
+
7
+ ## [0.0.4] - 2022-03-03
8
+
9
+ - Imporved public description of the gem
10
+
3
11
  ## [0.0.3] - 2022-03-03
4
12
 
5
13
  - Allow data structure to define resource ID when creating a new resource.
data/Gemfile.lock CHANGED
@@ -1,73 +1,73 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- json-pie (0.0.2)
4
+ json-pie (0.0.5)
5
5
  rails (<= 7.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (7.0.2.2)
11
- actionpack (= 7.0.2.2)
12
- activesupport (= 7.0.2.2)
10
+ actioncable (7.0.3)
11
+ actionpack (= 7.0.3)
12
+ activesupport (= 7.0.3)
13
13
  nio4r (~> 2.0)
14
14
  websocket-driver (>= 0.6.1)
15
- actionmailbox (7.0.2.2)
16
- actionpack (= 7.0.2.2)
17
- activejob (= 7.0.2.2)
18
- activerecord (= 7.0.2.2)
19
- activestorage (= 7.0.2.2)
20
- activesupport (= 7.0.2.2)
15
+ actionmailbox (7.0.3)
16
+ actionpack (= 7.0.3)
17
+ activejob (= 7.0.3)
18
+ activerecord (= 7.0.3)
19
+ activestorage (= 7.0.3)
20
+ activesupport (= 7.0.3)
21
21
  mail (>= 2.7.1)
22
22
  net-imap
23
23
  net-pop
24
24
  net-smtp
25
- actionmailer (7.0.2.2)
26
- actionpack (= 7.0.2.2)
27
- actionview (= 7.0.2.2)
28
- activejob (= 7.0.2.2)
29
- activesupport (= 7.0.2.2)
25
+ actionmailer (7.0.3)
26
+ actionpack (= 7.0.3)
27
+ actionview (= 7.0.3)
28
+ activejob (= 7.0.3)
29
+ activesupport (= 7.0.3)
30
30
  mail (~> 2.5, >= 2.5.4)
31
31
  net-imap
32
32
  net-pop
33
33
  net-smtp
34
34
  rails-dom-testing (~> 2.0)
35
- actionpack (7.0.2.2)
36
- actionview (= 7.0.2.2)
37
- activesupport (= 7.0.2.2)
35
+ actionpack (7.0.3)
36
+ actionview (= 7.0.3)
37
+ activesupport (= 7.0.3)
38
38
  rack (~> 2.0, >= 2.2.0)
39
39
  rack-test (>= 0.6.3)
40
40
  rails-dom-testing (~> 2.0)
41
41
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
42
- actiontext (7.0.2.2)
43
- actionpack (= 7.0.2.2)
44
- activerecord (= 7.0.2.2)
45
- activestorage (= 7.0.2.2)
46
- activesupport (= 7.0.2.2)
42
+ actiontext (7.0.3)
43
+ actionpack (= 7.0.3)
44
+ activerecord (= 7.0.3)
45
+ activestorage (= 7.0.3)
46
+ activesupport (= 7.0.3)
47
47
  globalid (>= 0.6.0)
48
48
  nokogiri (>= 1.8.5)
49
- actionview (7.0.2.2)
50
- activesupport (= 7.0.2.2)
49
+ actionview (7.0.3)
50
+ activesupport (= 7.0.3)
51
51
  builder (~> 3.1)
52
52
  erubi (~> 1.4)
53
53
  rails-dom-testing (~> 2.0)
54
54
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
55
- activejob (7.0.2.2)
56
- activesupport (= 7.0.2.2)
55
+ activejob (7.0.3)
56
+ activesupport (= 7.0.3)
57
57
  globalid (>= 0.3.6)
58
- activemodel (7.0.2.2)
59
- activesupport (= 7.0.2.2)
60
- activerecord (7.0.2.2)
61
- activemodel (= 7.0.2.2)
62
- activesupport (= 7.0.2.2)
63
- activestorage (7.0.2.2)
64
- actionpack (= 7.0.2.2)
65
- activejob (= 7.0.2.2)
66
- activerecord (= 7.0.2.2)
67
- activesupport (= 7.0.2.2)
58
+ activemodel (7.0.3)
59
+ activesupport (= 7.0.3)
60
+ activerecord (7.0.3)
61
+ activemodel (= 7.0.3)
62
+ activesupport (= 7.0.3)
63
+ activestorage (7.0.3)
64
+ actionpack (= 7.0.3)
65
+ activejob (= 7.0.3)
66
+ activerecord (= 7.0.3)
67
+ activesupport (= 7.0.3)
68
68
  marcel (~> 1.0)
69
69
  mini_mime (>= 1.1.0)
70
- activesupport (7.0.2.2)
70
+ activesupport (7.0.3)
71
71
  concurrent-ruby (~> 1.0, >= 1.0.2)
72
72
  i18n (>= 1.6, < 2)
73
73
  minitest (>= 5.1)
@@ -75,7 +75,7 @@ GEM
75
75
  ast (2.4.2)
76
76
  builder (3.2.4)
77
77
  coderay (1.1.3)
78
- concurrent-ruby (1.1.9)
78
+ concurrent-ruby (1.1.10)
79
79
  crass (1.0.6)
80
80
  diff-lcs (1.5.0)
81
81
  digest (3.1.0)
@@ -100,11 +100,10 @@ GEM
100
100
  rspec (>= 2.99.0, < 4.0)
101
101
  i18n (1.10.0)
102
102
  concurrent-ruby (~> 1.0)
103
- io-wait (0.2.1)
104
103
  listen (3.7.1)
105
104
  rb-fsevent (~> 0.10, >= 0.10.3)
106
105
  rb-inotify (~> 0.9, >= 0.9.10)
107
- loofah (2.14.0)
106
+ loofah (2.18.0)
108
107
  crass (~> 1.0.2)
109
108
  nokogiri (>= 1.5.9)
110
109
  lumberjack (1.2.8)
@@ -124,15 +123,14 @@ GEM
124
123
  digest
125
124
  net-protocol
126
125
  timeout
127
- net-protocol (0.1.2)
128
- io-wait
126
+ net-protocol (0.1.3)
129
127
  timeout
130
128
  net-smtp (0.3.1)
131
129
  digest
132
130
  net-protocol
133
131
  timeout
134
132
  nio4r (2.5.8)
135
- nokogiri (1.13.3)
133
+ nokogiri (1.13.6)
136
134
  mini_portile2 (~> 2.8.0)
137
135
  racc (~> 1.4)
138
136
  notiffany (0.1.3)
@@ -148,28 +146,28 @@ GEM
148
146
  rack (2.2.3)
149
147
  rack-test (1.1.0)
150
148
  rack (>= 1.0, < 3)
151
- rails (7.0.2.2)
152
- actioncable (= 7.0.2.2)
153
- actionmailbox (= 7.0.2.2)
154
- actionmailer (= 7.0.2.2)
155
- actionpack (= 7.0.2.2)
156
- actiontext (= 7.0.2.2)
157
- actionview (= 7.0.2.2)
158
- activejob (= 7.0.2.2)
159
- activemodel (= 7.0.2.2)
160
- activerecord (= 7.0.2.2)
161
- activestorage (= 7.0.2.2)
162
- activesupport (= 7.0.2.2)
149
+ rails (7.0.3)
150
+ actioncable (= 7.0.3)
151
+ actionmailbox (= 7.0.3)
152
+ actionmailer (= 7.0.3)
153
+ actionpack (= 7.0.3)
154
+ actiontext (= 7.0.3)
155
+ actionview (= 7.0.3)
156
+ activejob (= 7.0.3)
157
+ activemodel (= 7.0.3)
158
+ activerecord (= 7.0.3)
159
+ activestorage (= 7.0.3)
160
+ activesupport (= 7.0.3)
163
161
  bundler (>= 1.15.0)
164
- railties (= 7.0.2.2)
162
+ railties (= 7.0.3)
165
163
  rails-dom-testing (2.0.3)
166
164
  activesupport (>= 4.2.0)
167
165
  nokogiri (>= 1.6)
168
166
  rails-html-sanitizer (1.4.2)
169
167
  loofah (~> 2.3)
170
- railties (7.0.2.2)
171
- actionpack (= 7.0.2.2)
172
- activesupport (= 7.0.2.2)
168
+ railties (7.0.3)
169
+ actionpack (= 7.0.3)
170
+ activesupport (= 7.0.3)
173
171
  method_source
174
172
  rake (>= 12.2)
175
173
  thor (~> 1.0)
@@ -215,7 +213,7 @@ GEM
215
213
  ruby-progressbar (1.11.0)
216
214
  shellany (0.0.1)
217
215
  sqlite3 (1.4.2)
218
- strscan (3.0.1)
216
+ strscan (3.0.3)
219
217
  thor (1.2.1)
220
218
  timeout (0.2.0)
221
219
  tzinfo (2.0.4)
@@ -24,6 +24,8 @@ module JSON
24
24
  end
25
25
 
26
26
  def instance
27
+ return nil if data.blank?
28
+
27
29
  @instance ||= JSON::Pie::ResourceIdentity.find_or_initialize(**data.slice(:id, :type), **options)
28
30
  end
29
31
 
@@ -41,7 +43,7 @@ module JSON
41
43
  end
42
44
 
43
45
  def assign_attributes!
44
- instance.attributes = attributes_tuple.to_h
46
+ instance&.attributes = attributes_tuple.to_h
45
47
  rescue ActiveModel::UnknownAttributeError
46
48
  raise JSON::Pie::InvalidAttribute
47
49
  end
@@ -19,7 +19,7 @@ module JSON
19
19
 
20
20
  def assign
21
21
  relationships.each do |rel, data|
22
- relationship_instance = ResourceObject.parse data.fetch(:data)
22
+ relationship_instance = ResourceObject.parse (data || {}).fetch(:data, {})
23
23
  instance.public_send "#{rel}=", relationship_instance
24
24
  end
25
25
  end
@@ -23,6 +23,8 @@ module JSON
23
23
  when Array then parse_as_array
24
24
  else parse_as_object
25
25
  end
26
+ rescue StandardError => error
27
+ raise JSON::Pie::MalformattedDataObject, "malformmated data structure"
26
28
  end
27
29
 
28
30
  private
@@ -2,6 +2,6 @@
2
2
 
3
3
  module JSON
4
4
  module Pie
5
- VERSION = "0.0.3"
5
+ VERSION = "0.0.6"
6
6
  end
7
7
  end
data/lib/json/pie.rb CHANGED
@@ -9,6 +9,7 @@ module JSON
9
9
  MissingType = Class.new Error
10
10
  InvalidType = Class.new Error
11
11
  InvalidAttribute = Class.new Error
12
+ MalformattedDataObject = Class.new Error
12
13
 
13
14
  module_function
14
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json-pie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emil Kampp
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-03 00:00:00.000000000 Z
11
+ date: 2022-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,7 +24,10 @@ dependencies:
24
24
  - - "<="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '7.1'
27
- description: Allow a Rails API to use the JSON:API interface
27
+ description: |
28
+ Easily parse JSON:API data structures into ActiveRecord resources.
29
+
30
+ This will parse deeply nested relationships as well as attributes.
28
31
  email:
29
32
  - emil@kampp.me
30
33
  executables: []
@@ -73,5 +76,5 @@ requirements: []
73
76
  rubygems_version: 3.2.32
74
77
  signing_key:
75
78
  specification_version: 4
76
- summary: JSON:API rails plugin
79
+ summary: Easily parse JSON:API structures into ActiveRecord resources
77
80
  test_files: []