json-pie 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a63d4d0b3a9e543fbb77724003a4e00b54b4019fc4aa96effde7517ea40967bf
4
+ data.tar.gz: a355d4b17fe3ae44c243073d86da4766825d2db1b52d876d7e8fe034be90ecfe
5
+ SHA512:
6
+ metadata.gz: 0a295acde72a3e8d5b6b5fb2161e3112041948e3979a740782b7b50df0b8a601f189e3f0fbebf11601a6f2096078acccbbf370298a24618952f4b47fe6f8cd44
7
+ data.tar.gz: a6fb5a2ee5cb6c2ca9473fc3b2295c313302d58154a7378091168445df000bdf6d7344f3ecb84c75df205e1f9907aba493145ec274eff1966979beb018e88eba
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,26 @@
1
+ require:
2
+ - rubocop-rspec
3
+ - rubocop-rake
4
+
5
+ AllCops:
6
+ NewCops: enable
7
+ TargetRubyVersion: 2.6
8
+
9
+ Style/StringLiterals:
10
+ Enabled: true
11
+ EnforcedStyle: double_quotes
12
+
13
+ Style/StringLiteralsInInterpolation:
14
+ Enabled: true
15
+ EnforcedStyle: double_quotes
16
+
17
+ Layout/LineLength:
18
+ Max: 120
19
+
20
+ Style/Documentation:
21
+ Enabled: false
22
+
23
+ Metrics/BlockLength:
24
+ Exclude:
25
+ - Guardfile
26
+ - "**/*_spec.rb"
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-02-27
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec
5
+
6
+ group :develoment, :test do
7
+ gem "guard-rspec"
8
+ gem "rake", "~> 13.0"
9
+ gem "rspec", "~> 3.0"
10
+ gem "rspec-its"
11
+ gem "rubocop", "~> 1.21"
12
+ gem "rubocop-rake"
13
+ gem "rubocop-rspec"
14
+ gem "sqlite3"
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,244 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ json-pie (0.0.1)
5
+ rails (<= 7.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (7.0.2.2)
11
+ actionpack (= 7.0.2.2)
12
+ activesupport (= 7.0.2.2)
13
+ nio4r (~> 2.0)
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)
21
+ mail (>= 2.7.1)
22
+ net-imap
23
+ net-pop
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)
30
+ mail (~> 2.5, >= 2.5.4)
31
+ net-imap
32
+ net-pop
33
+ net-smtp
34
+ rails-dom-testing (~> 2.0)
35
+ actionpack (7.0.2.2)
36
+ actionview (= 7.0.2.2)
37
+ activesupport (= 7.0.2.2)
38
+ rack (~> 2.0, >= 2.2.0)
39
+ rack-test (>= 0.6.3)
40
+ rails-dom-testing (~> 2.0)
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)
47
+ globalid (>= 0.6.0)
48
+ nokogiri (>= 1.8.5)
49
+ actionview (7.0.2.2)
50
+ activesupport (= 7.0.2.2)
51
+ builder (~> 3.1)
52
+ erubi (~> 1.4)
53
+ rails-dom-testing (~> 2.0)
54
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
55
+ activejob (7.0.2.2)
56
+ activesupport (= 7.0.2.2)
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)
68
+ marcel (~> 1.0)
69
+ mini_mime (>= 1.1.0)
70
+ activesupport (7.0.2.2)
71
+ concurrent-ruby (~> 1.0, >= 1.0.2)
72
+ i18n (>= 1.6, < 2)
73
+ minitest (>= 5.1)
74
+ tzinfo (~> 2.0)
75
+ ast (2.4.2)
76
+ builder (3.2.4)
77
+ coderay (1.1.3)
78
+ concurrent-ruby (1.1.9)
79
+ crass (1.0.6)
80
+ diff-lcs (1.5.0)
81
+ digest (3.1.0)
82
+ erubi (1.10.0)
83
+ ffi (1.15.5)
84
+ formatador (1.1.0)
85
+ globalid (1.0.0)
86
+ activesupport (>= 5.0)
87
+ guard (2.18.0)
88
+ formatador (>= 0.2.4)
89
+ listen (>= 2.7, < 4.0)
90
+ lumberjack (>= 1.0.12, < 2.0)
91
+ nenv (~> 0.1)
92
+ notiffany (~> 0.0)
93
+ pry (>= 0.13.0)
94
+ shellany (~> 0.0)
95
+ thor (>= 0.18.1)
96
+ guard-compat (1.2.1)
97
+ guard-rspec (4.7.3)
98
+ guard (~> 2.1)
99
+ guard-compat (~> 1.1)
100
+ rspec (>= 2.99.0, < 4.0)
101
+ i18n (1.10.0)
102
+ concurrent-ruby (~> 1.0)
103
+ io-wait (0.2.1)
104
+ listen (3.7.1)
105
+ rb-fsevent (~> 0.10, >= 0.10.3)
106
+ rb-inotify (~> 0.9, >= 0.9.10)
107
+ loofah (2.14.0)
108
+ crass (~> 1.0.2)
109
+ nokogiri (>= 1.5.9)
110
+ lumberjack (1.2.8)
111
+ mail (2.7.1)
112
+ mini_mime (>= 0.1.1)
113
+ marcel (1.0.2)
114
+ method_source (1.0.0)
115
+ mini_mime (1.1.2)
116
+ mini_portile2 (2.8.0)
117
+ minitest (5.15.0)
118
+ nenv (0.3.0)
119
+ net-imap (0.2.3)
120
+ digest
121
+ net-protocol
122
+ strscan
123
+ net-pop (0.1.1)
124
+ digest
125
+ net-protocol
126
+ timeout
127
+ net-protocol (0.1.2)
128
+ io-wait
129
+ timeout
130
+ net-smtp (0.3.1)
131
+ digest
132
+ net-protocol
133
+ timeout
134
+ nio4r (2.5.8)
135
+ nokogiri (1.13.3)
136
+ mini_portile2 (~> 2.8.0)
137
+ racc (~> 1.4)
138
+ notiffany (0.1.3)
139
+ nenv (~> 0.1)
140
+ shellany (~> 0.0)
141
+ parallel (1.21.0)
142
+ parser (3.1.1.0)
143
+ ast (~> 2.4.1)
144
+ pry (0.14.1)
145
+ coderay (~> 1.1)
146
+ method_source (~> 1.0)
147
+ racc (1.6.0)
148
+ rack (2.2.3)
149
+ rack-test (1.1.0)
150
+ 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)
163
+ bundler (>= 1.15.0)
164
+ railties (= 7.0.2.2)
165
+ rails-dom-testing (2.0.3)
166
+ activesupport (>= 4.2.0)
167
+ nokogiri (>= 1.6)
168
+ rails-html-sanitizer (1.4.2)
169
+ loofah (~> 2.3)
170
+ railties (7.0.2.2)
171
+ actionpack (= 7.0.2.2)
172
+ activesupport (= 7.0.2.2)
173
+ method_source
174
+ rake (>= 12.2)
175
+ thor (~> 1.0)
176
+ zeitwerk (~> 2.5)
177
+ rainbow (3.1.1)
178
+ rake (13.0.6)
179
+ rb-fsevent (0.11.1)
180
+ rb-inotify (0.10.1)
181
+ ffi (~> 1.0)
182
+ regexp_parser (2.2.1)
183
+ rexml (3.2.5)
184
+ rspec (3.11.0)
185
+ rspec-core (~> 3.11.0)
186
+ rspec-expectations (~> 3.11.0)
187
+ rspec-mocks (~> 3.11.0)
188
+ rspec-core (3.11.0)
189
+ rspec-support (~> 3.11.0)
190
+ rspec-expectations (3.11.0)
191
+ diff-lcs (>= 1.2.0, < 2.0)
192
+ rspec-support (~> 3.11.0)
193
+ rspec-its (1.3.0)
194
+ rspec-core (>= 3.0.0)
195
+ rspec-expectations (>= 3.0.0)
196
+ rspec-mocks (3.11.0)
197
+ diff-lcs (>= 1.2.0, < 2.0)
198
+ rspec-support (~> 3.11.0)
199
+ rspec-support (3.11.0)
200
+ rubocop (1.25.1)
201
+ parallel (~> 1.10)
202
+ parser (>= 3.1.0.0)
203
+ rainbow (>= 2.2.2, < 4.0)
204
+ regexp_parser (>= 1.8, < 3.0)
205
+ rexml
206
+ rubocop-ast (>= 1.15.1, < 2.0)
207
+ ruby-progressbar (~> 1.7)
208
+ unicode-display_width (>= 1.4.0, < 3.0)
209
+ rubocop-ast (1.16.0)
210
+ parser (>= 3.1.1.0)
211
+ rubocop-rake (0.6.0)
212
+ rubocop (~> 1.0)
213
+ rubocop-rspec (2.9.0)
214
+ rubocop (~> 1.19)
215
+ ruby-progressbar (1.11.0)
216
+ shellany (0.0.1)
217
+ sqlite3 (1.4.2)
218
+ strscan (3.0.1)
219
+ thor (1.2.1)
220
+ timeout (0.2.0)
221
+ tzinfo (2.0.4)
222
+ concurrent-ruby (~> 1.0)
223
+ unicode-display_width (2.1.0)
224
+ websocket-driver (0.7.5)
225
+ websocket-extensions (>= 0.1.0)
226
+ websocket-extensions (0.1.5)
227
+ zeitwerk (2.5.4)
228
+
229
+ PLATFORMS
230
+ ruby
231
+
232
+ DEPENDENCIES
233
+ guard-rspec
234
+ json-pie!
235
+ rake (~> 13.0)
236
+ rspec (~> 3.0)
237
+ rspec-its
238
+ rubocop (~> 1.21)
239
+ rubocop-rake
240
+ rubocop-rspec
241
+ sqlite3
242
+
243
+ BUNDLED WITH
244
+ 2.3.6
data/Guardfile ADDED
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A sample Guardfile
4
+ # More info at https://github.com/guard/guard#readme
5
+
6
+ ## Uncomment and set this to only include directories you want to watch
7
+ # directories %w(app lib config test spec features) \
8
+ # .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
9
+
10
+ ## Note: if you are using the `directories` clause above and you are not
11
+ ## watching the project directory ('.'), then you will want to move
12
+ ## the Guardfile to a watched dir and symlink it back, e.g.
13
+ #
14
+ # $ mkdir config
15
+ # $ mv Guardfile config/
16
+ # $ ln -s config/Guardfile .
17
+ #
18
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
19
+
20
+ # NOTE: The cmd option is now required due to the increasing number of ways
21
+ # rspec may be run, below are examples of the most common uses.
22
+ # * bundler: 'bundle exec rspec'
23
+ # * bundler binstubs: 'bin/rspec'
24
+ # * spring: 'bin/rspec' (This will use spring if running and you have
25
+ # installed the spring binstubs per the docs)
26
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
27
+ # * 'just' rspec: 'rspec'
28
+
29
+ guard :rspec, cmd: "bundle exec rspec", all_on_start: true, all_after_pass: true do
30
+ require "guard/rspec/dsl"
31
+ dsl = Guard::RSpec::Dsl.new(self)
32
+
33
+ # Feel free to open issues for suggestions and improvements
34
+
35
+ # RSpec files
36
+ rspec = dsl.rspec
37
+ watch(rspec.spec_helper) { rspec.spec_dir }
38
+ watch(rspec.spec_support) { rspec.spec_dir }
39
+ watch(rspec.spec_files)
40
+
41
+ # Ruby files
42
+ ruby = dsl.ruby
43
+ dsl.watch_spec_files_for(ruby.lib_files)
44
+
45
+ # Rails files
46
+ rails = dsl.rails(view_extensions: %w[erb haml slim])
47
+ dsl.watch_spec_files_for(rails.app_files)
48
+ dsl.watch_spec_files_for(rails.views)
49
+
50
+ watch(rails.controllers) do |m|
51
+ [
52
+ rspec.spec.call("routing/#{m[1]}_routing"),
53
+ rspec.spec.call("controllers/#{m[1]}_controller"),
54
+ rspec.spec.call("acceptance/#{m[1]}")
55
+ ]
56
+ end
57
+
58
+ # Rails config changes
59
+ watch(rails.spec_helper) { rspec.spec_dir }
60
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
61
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
62
+
63
+ # Capybara features specs
64
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
65
+ watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
66
+
67
+ # Turnip features and steps
68
+ watch(%r{^spec/acceptance/(.+)\.feature$})
69
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
70
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
71
+ end
72
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Emil Kampp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Json::Pie
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/json/pie`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'json-pie'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install json-pie
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/json-pie.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JSON
4
+ module Pie
5
+ class ResourceIdentity
6
+ attr_reader :instance
7
+
8
+ def self.find_or_initialize(type:, id: nil, **options)
9
+ new(type: type, id: id, **options).instance
10
+ rescue ArgumentError
11
+ raise JSON::Pie::MissingType
12
+ end
13
+
14
+ def initialize(type:, id: nil, **options)
15
+ @options = options
16
+ klass = determine_type(type).to_s.classify.constantize
17
+ @instance = id ? klass.find(id) : klass.new
18
+ rescue NameError
19
+ pp options
20
+ raise JSON::Pie::InvalidType, "#{type}(#{id})"
21
+ end
22
+
23
+ private
24
+
25
+ attr_reader :options
26
+
27
+ def determine_type(type)
28
+ options.dig(:type_map, type).presence || type
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/all"
4
+ require_relative "./resource_identity"
5
+ require_relative "./resource_relationships"
6
+
7
+ module JSON
8
+ module Pie
9
+ class ResourceObject
10
+ def self.parse(data, **options)
11
+ new(data, **options).tap(&:parse).instance
12
+ end
13
+
14
+ def initialize(data, **options)
15
+ @data = data
16
+ @options = options
17
+ end
18
+
19
+ def parse
20
+ case data
21
+ when Hash then parse_as_object
22
+ when Array then parse_as_array
23
+ end
24
+ end
25
+
26
+ def instance
27
+ @instance ||= JSON::Pie::ResourceIdentity.find_or_initialize(**data.slice(:id, :type), **options)
28
+ end
29
+
30
+ private
31
+
32
+ attr_reader :data, :options
33
+
34
+ def parse_as_object
35
+ assign_attributes!
36
+ assign_relationships!
37
+ end
38
+
39
+ def parse_as_array
40
+ @instance = data.collect { |d| ResourceObject.parse(d, **options) }
41
+ end
42
+
43
+ def assign_attributes!
44
+ instance.attributes = data.fetch :attributes, {}
45
+ rescue ActiveModel::UnknownAttributeError
46
+ raise JSON::Pie::InvalidAttribute
47
+ end
48
+
49
+ def assign_relationships!
50
+ JSON::Pie::ResourceRelationships.assign \
51
+ instance: instance,
52
+ relationships: data.fetch(:relationships, {})
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/all"
4
+ require_relative "./resource_object"
5
+
6
+ module JSON
7
+ module Pie
8
+ class ResourceRelationships
9
+ attr_reader :instance
10
+
11
+ def self.assign(**kwargs)
12
+ new(**kwargs).assign
13
+ end
14
+
15
+ def initialize(instance:, relationships: {})
16
+ @instance = instance
17
+ @relationships = relationships
18
+ end
19
+
20
+ def assign
21
+ relationships.each do |rel, data|
22
+ relationship_instance = ResourceObject.parse data.fetch(:data)
23
+ instance.public_send "#{rel}=", relationship_instance
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ attr_reader :relationships
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "./resource_object"
4
+
5
+ module JSON
6
+ module Pie
7
+ class TopLevel
8
+ attr_accessor :instance
9
+
10
+ def self.parse(params, **options)
11
+ new(params).tap { |i| i.parse(**options) }.instance
12
+ end
13
+
14
+ def initialize(params)
15
+ params = params.permit!.to_h.deep_symbolize_keys if params.respond_to?(:permit!)
16
+ @params = params
17
+ end
18
+
19
+ def parse(**options)
20
+ @options = options
21
+ data = params.fetch(:data)
22
+ self.instance = case data
23
+ when Array then parse_as_array
24
+ else parse_as_object
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ attr_reader :params, :options
31
+
32
+ def parse_as_array
33
+ params.fetch(:data).collect do |resurce_object|
34
+ parse_as_object resurce_object
35
+ end
36
+ end
37
+
38
+ def parse_as_object(resurce_object = params.fetch(:data))
39
+ JSON::Pie::ResourceObject.parse(resurce_object, **options)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JSON
4
+ module Pie
5
+ VERSION = "0.0.1"
6
+ end
7
+ end
data/lib/json/pie.rb ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "pie/version"
4
+ require_relative "pie/top_level"
5
+
6
+ module JSON
7
+ module Pie
8
+ Error = Class.new StandardError
9
+ MissingType = Class.new Error
10
+ InvalidType = Class.new Error
11
+ InvalidAttribute = Class.new Error
12
+
13
+ module_function
14
+
15
+ def parse(params)
16
+ JSON::Pie::TopLevel.parse params
17
+ end
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: json-pie
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Emil Kampp
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-02-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "<="
18
+ - !ruby/object:Gem::Version
19
+ version: '7.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "<="
25
+ - !ruby/object:Gem::Version
26
+ version: '7.1'
27
+ description: Allow a Rails API to use the JSON:API interface
28
+ email:
29
+ - emil@kampp.me
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rspec"
35
+ - ".rubocop.yml"
36
+ - CHANGELOG.md
37
+ - Gemfile
38
+ - Gemfile.lock
39
+ - Guardfile
40
+ - LICENSE.txt
41
+ - README.md
42
+ - Rakefile
43
+ - lib/json/pie.rb
44
+ - lib/json/pie/resource_identity.rb
45
+ - lib/json/pie/resource_object.rb
46
+ - lib/json/pie/resource_relationships.rb
47
+ - lib/json/pie/top_level.rb
48
+ - lib/json/pie/version.rb
49
+ homepage: https://github.com/ekampp/json-pie
50
+ licenses:
51
+ - MIT
52
+ metadata:
53
+ allowed_push_host: https://rubygems.org
54
+ homepage_uri: https://github.com/ekampp/json-pie
55
+ source_code_uri: https://github.com/ekampp/json-pie
56
+ changelog_uri: https://github.com/ekampp/json-pie/CHANGELOG.md
57
+ rubygems_mfa_required: 'true'
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 2.6.0
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubygems_version: 3.2.32
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: JSON:API rails plugin
77
+ test_files: []