jsonapi_compliable 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.travis.yml +11 -3
  4. data/.yardopts +1 -0
  5. data/README.md +10 -1
  6. data/Rakefile +1 -0
  7. data/docs/JsonapiCompliable.html +202 -0
  8. data/docs/JsonapiCompliable/Adapters.html +119 -0
  9. data/docs/JsonapiCompliable/Adapters/Abstract.html +2285 -0
  10. data/docs/JsonapiCompliable/Adapters/ActiveRecord.html +2151 -0
  11. data/docs/JsonapiCompliable/Adapters/ActiveRecordSideloading.html +582 -0
  12. data/docs/JsonapiCompliable/Adapters/Null.html +1682 -0
  13. data/docs/JsonapiCompliable/Base.html +1395 -0
  14. data/docs/JsonapiCompliable/Deserializer.html +835 -0
  15. data/docs/JsonapiCompliable/Errors.html +115 -0
  16. data/docs/JsonapiCompliable/Errors/BadFilter.html +124 -0
  17. data/docs/JsonapiCompliable/Errors/StatNotFound.html +266 -0
  18. data/docs/JsonapiCompliable/Errors/UnsupportedPageSize.html +264 -0
  19. data/docs/JsonapiCompliable/Errors/ValidationError.html +124 -0
  20. data/docs/JsonapiCompliable/Extensions.html +117 -0
  21. data/docs/JsonapiCompliable/Extensions/BooleanAttribute.html +212 -0
  22. data/docs/JsonapiCompliable/Extensions/BooleanAttribute/ClassMethods.html +229 -0
  23. data/docs/JsonapiCompliable/Extensions/ExtraAttribute.html +242 -0
  24. data/docs/JsonapiCompliable/Extensions/ExtraAttribute/ClassMethods.html +237 -0
  25. data/docs/JsonapiCompliable/Query.html +1099 -0
  26. data/docs/JsonapiCompliable/Rails.html +211 -0
  27. data/docs/JsonapiCompliable/Resource.html +5241 -0
  28. data/docs/JsonapiCompliable/Scope.html +703 -0
  29. data/docs/JsonapiCompliable/Scoping.html +117 -0
  30. data/docs/JsonapiCompliable/Scoping/Base.html +843 -0
  31. data/docs/JsonapiCompliable/Scoping/DefaultFilter.html +318 -0
  32. data/docs/JsonapiCompliable/Scoping/ExtraFields.html +301 -0
  33. data/docs/JsonapiCompliable/Scoping/Filter.html +313 -0
  34. data/docs/JsonapiCompliable/Scoping/Filterable.html +364 -0
  35. data/docs/JsonapiCompliable/Scoping/Paginate.html +613 -0
  36. data/docs/JsonapiCompliable/Scoping/Sort.html +454 -0
  37. data/docs/JsonapiCompliable/SerializableTempId.html +216 -0
  38. data/docs/JsonapiCompliable/Sideload.html +2484 -0
  39. data/docs/JsonapiCompliable/Stats.html +117 -0
  40. data/docs/JsonapiCompliable/Stats/DSL.html +999 -0
  41. data/docs/JsonapiCompliable/Stats/Payload.html +391 -0
  42. data/docs/JsonapiCompliable/Util.html +117 -0
  43. data/docs/JsonapiCompliable/Util/FieldParams.html +228 -0
  44. data/docs/JsonapiCompliable/Util/Hash.html +471 -0
  45. data/docs/JsonapiCompliable/Util/IncludeParams.html +299 -0
  46. data/docs/JsonapiCompliable/Util/Persistence.html +435 -0
  47. data/docs/JsonapiCompliable/Util/RelationshipPayload.html +563 -0
  48. data/docs/JsonapiCompliable/Util/RenderOptions.html +250 -0
  49. data/docs/JsonapiCompliable/Util/ValidationResponse.html +532 -0
  50. data/docs/_index.html +527 -0
  51. data/docs/class_list.html +51 -0
  52. data/docs/css/common.css +1 -0
  53. data/docs/css/full_list.css +58 -0
  54. data/docs/css/style.css +492 -0
  55. data/docs/file.README.html +99 -0
  56. data/docs/file_list.html +56 -0
  57. data/docs/frames.html +17 -0
  58. data/docs/index.html +99 -0
  59. data/docs/js/app.js +248 -0
  60. data/docs/js/full_list.js +216 -0
  61. data/docs/js/jquery.js +4 -0
  62. data/docs/method_list.html +1731 -0
  63. data/docs/top-level-namespace.html +110 -0
  64. data/gemfiles/rails_5.gemfile +1 -1
  65. data/lib/jsonapi_compliable/adapters/abstract.rb +267 -4
  66. data/lib/jsonapi_compliable/adapters/active_record.rb +23 -1
  67. data/lib/jsonapi_compliable/adapters/null.rb +43 -3
  68. data/lib/jsonapi_compliable/base.rb +182 -33
  69. data/lib/jsonapi_compliable/deserializer.rb +90 -21
  70. data/lib/jsonapi_compliable/extensions/boolean_attribute.rb +12 -0
  71. data/lib/jsonapi_compliable/extensions/extra_attribute.rb +32 -0
  72. data/lib/jsonapi_compliable/extensions/temp_id.rb +11 -0
  73. data/lib/jsonapi_compliable/query.rb +94 -2
  74. data/lib/jsonapi_compliable/rails.rb +8 -0
  75. data/lib/jsonapi_compliable/resource.rb +548 -11
  76. data/lib/jsonapi_compliable/scope.rb +43 -1
  77. data/lib/jsonapi_compliable/scoping/base.rb +59 -8
  78. data/lib/jsonapi_compliable/scoping/default_filter.rb +33 -0
  79. data/lib/jsonapi_compliable/scoping/extra_fields.rb +33 -0
  80. data/lib/jsonapi_compliable/scoping/filter.rb +29 -2
  81. data/lib/jsonapi_compliable/scoping/filterable.rb +4 -0
  82. data/lib/jsonapi_compliable/scoping/paginate.rb +33 -0
  83. data/lib/jsonapi_compliable/scoping/sort.rb +18 -0
  84. data/lib/jsonapi_compliable/sideload.rb +229 -1
  85. data/lib/jsonapi_compliable/stats/dsl.rb +44 -0
  86. data/lib/jsonapi_compliable/stats/payload.rb +20 -0
  87. data/lib/jsonapi_compliable/util/field_params.rb +1 -0
  88. data/lib/jsonapi_compliable/util/hash.rb +18 -0
  89. data/lib/jsonapi_compliable/util/include_params.rb +22 -0
  90. data/lib/jsonapi_compliable/util/persistence.rb +13 -3
  91. data/lib/jsonapi_compliable/util/relationship_payload.rb +2 -0
  92. data/lib/jsonapi_compliable/util/render_options.rb +2 -0
  93. data/lib/jsonapi_compliable/util/validation_response.rb +16 -0
  94. data/lib/jsonapi_compliable/version.rb +1 -1
  95. metadata +60 -5
  96. data/gemfiles/rails_4.gemfile.lock +0 -208
  97. data/gemfiles/rails_5.gemfile.lock +0 -212
  98. data/lib/jsonapi_compliable/write.rb +0 -93
@@ -1,212 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- jsonapi_compliable (0.6.3)
5
- jsonapi-serializable (~> 0.1)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- actioncable (5.0.0.1)
11
- actionpack (= 5.0.0.1)
12
- nio4r (~> 1.2)
13
- websocket-driver (~> 0.6.1)
14
- actionmailer (5.0.0.1)
15
- actionpack (= 5.0.0.1)
16
- actionview (= 5.0.0.1)
17
- activejob (= 5.0.0.1)
18
- mail (~> 2.5, >= 2.5.4)
19
- rails-dom-testing (~> 2.0)
20
- actionpack (5.0.0.1)
21
- actionview (= 5.0.0.1)
22
- activesupport (= 5.0.0.1)
23
- rack (~> 2.0)
24
- rack-test (~> 0.6.3)
25
- rails-dom-testing (~> 2.0)
26
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
- actionview (5.0.0.1)
28
- activesupport (= 5.0.0.1)
29
- builder (~> 3.1)
30
- erubis (~> 2.7.0)
31
- rails-dom-testing (~> 2.0)
32
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
33
- activejob (5.0.0.1)
34
- activesupport (= 5.0.0.1)
35
- globalid (>= 0.3.6)
36
- activemodel (5.0.0.1)
37
- activesupport (= 5.0.0.1)
38
- activerecord (5.0.0.1)
39
- activemodel (= 5.0.0.1)
40
- activesupport (= 5.0.0.1)
41
- arel (~> 7.0)
42
- activesupport (5.0.0.1)
43
- concurrent-ruby (~> 1.0, >= 1.0.2)
44
- i18n (~> 0.7)
45
- minitest (~> 5.1)
46
- tzinfo (~> 1.1)
47
- appraisal (2.1.0)
48
- bundler
49
- rake
50
- thor (>= 0.14.0)
51
- arel (7.1.4)
52
- builder (3.2.2)
53
- byebug (9.0.6)
54
- coderay (1.1.1)
55
- concurrent-ruby (1.0.4)
56
- database_cleaner (1.5.3)
57
- diff-lcs (1.2.5)
58
- erubis (2.7.0)
59
- ffi (1.9.14)
60
- formatador (0.2.5)
61
- globalid (0.3.7)
62
- activesupport (>= 4.1.0)
63
- guard (2.14.0)
64
- formatador (>= 0.2.4)
65
- listen (>= 2.7, < 4.0)
66
- lumberjack (~> 1.0)
67
- nenv (~> 0.1)
68
- notiffany (~> 0.0)
69
- pry (>= 0.9.12)
70
- shellany (~> 0.0)
71
- thor (>= 0.18.1)
72
- guard-compat (1.2.1)
73
- guard-rspec (4.7.3)
74
- guard (~> 2.1)
75
- guard-compat (~> 1.1)
76
- rspec (>= 2.99.0, < 4.0)
77
- i18n (0.7.0)
78
- jsonapi-deserializable (0.1.1)
79
- jsonapi-parser (= 0.1.1)
80
- jsonapi-parser (0.1.1)
81
- jsonapi-rails (0.1.1)
82
- jsonapi-rb (= 0.1.1)
83
- jsonapi-rb (0.1.1)
84
- jsonapi-deserializable (= 0.1.1)
85
- jsonapi-serializable (= 0.1.1)
86
- jsonapi-renderer (0.1.1)
87
- jsonapi-serializable (0.1.1)
88
- jsonapi-renderer (= 0.1.1)
89
- kaminari (0.17.0)
90
- actionpack (>= 3.0.0)
91
- activesupport (>= 3.0.0)
92
- listen (3.1.5)
93
- rb-fsevent (~> 0.9, >= 0.9.4)
94
- rb-inotify (~> 0.9, >= 0.9.7)
95
- ruby_dep (~> 1.2)
96
- loofah (2.0.3)
97
- nokogiri (>= 1.5.9)
98
- lumberjack (1.0.10)
99
- mail (2.6.4)
100
- mime-types (>= 1.16, < 4)
101
- method_source (0.8.2)
102
- mime-types (3.1)
103
- mime-types-data (~> 3.2015)
104
- mime-types-data (3.2016.0521)
105
- mini_portile2 (2.1.0)
106
- minitest (5.10.1)
107
- nenv (0.3.0)
108
- nio4r (1.2.1)
109
- nokogiri (1.6.8.1)
110
- mini_portile2 (~> 2.1.0)
111
- notiffany (0.1.1)
112
- nenv (~> 0.1)
113
- shellany (~> 0.0)
114
- pry (0.10.4)
115
- coderay (~> 1.1.0)
116
- method_source (~> 0.8.1)
117
- slop (~> 3.4)
118
- pry-byebug (3.4.2)
119
- byebug (~> 9.0)
120
- pry (~> 0.10)
121
- rack (2.0.1)
122
- rack-test (0.6.3)
123
- rack (>= 1.0)
124
- rails (5.0.0.1)
125
- actioncable (= 5.0.0.1)
126
- actionmailer (= 5.0.0.1)
127
- actionpack (= 5.0.0.1)
128
- actionview (= 5.0.0.1)
129
- activejob (= 5.0.0.1)
130
- activemodel (= 5.0.0.1)
131
- activerecord (= 5.0.0.1)
132
- activesupport (= 5.0.0.1)
133
- bundler (>= 1.3.0, < 2.0)
134
- railties (= 5.0.0.1)
135
- sprockets-rails (>= 2.0.0)
136
- rails-dom-testing (2.0.1)
137
- activesupport (>= 4.2.0, < 6.0)
138
- nokogiri (~> 1.6.0)
139
- rails-html-sanitizer (1.0.3)
140
- loofah (~> 2.0)
141
- railties (5.0.0.1)
142
- actionpack (= 5.0.0.1)
143
- activesupport (= 5.0.0.1)
144
- method_source
145
- rake (>= 0.8.7)
146
- thor (>= 0.18.1, < 2.0)
147
- rake (10.5.0)
148
- rb-fsevent (0.9.8)
149
- rb-inotify (0.9.7)
150
- ffi (>= 0.5.0)
151
- rspec (3.5.0)
152
- rspec-core (~> 3.5.0)
153
- rspec-expectations (~> 3.5.0)
154
- rspec-mocks (~> 3.5.0)
155
- rspec-core (3.5.4)
156
- rspec-support (~> 3.5.0)
157
- rspec-expectations (3.5.0)
158
- diff-lcs (>= 1.2.0, < 2.0)
159
- rspec-support (~> 3.5.0)
160
- rspec-mocks (3.5.0)
161
- diff-lcs (>= 1.2.0, < 2.0)
162
- rspec-support (~> 3.5.0)
163
- rspec-rails (3.5.2)
164
- actionpack (>= 3.0)
165
- activesupport (>= 3.0)
166
- railties (>= 3.0)
167
- rspec-core (~> 3.5.0)
168
- rspec-expectations (~> 3.5.0)
169
- rspec-mocks (~> 3.5.0)
170
- rspec-support (~> 3.5.0)
171
- rspec-support (3.5.0)
172
- ruby_dep (1.5.0)
173
- shellany (0.0.1)
174
- slop (3.6.0)
175
- sprockets (3.7.0)
176
- concurrent-ruby (~> 1.0)
177
- rack (> 1, < 3)
178
- sprockets-rails (3.2.0)
179
- actionpack (>= 4.0)
180
- activesupport (>= 4.0)
181
- sprockets (>= 3.0.0)
182
- sqlite3 (1.3.12)
183
- thor (0.19.4)
184
- thread_safe (0.3.5)
185
- tzinfo (1.2.2)
186
- thread_safe (~> 0.1)
187
- websocket-driver (0.6.4)
188
- websocket-extensions (>= 0.1.0)
189
- websocket-extensions (0.1.2)
190
-
191
- PLATFORMS
192
- ruby
193
-
194
- DEPENDENCIES
195
- activerecord (>= 4.1, < 6)
196
- appraisal
197
- bundler (~> 1.12)
198
- database_cleaner
199
- guard
200
- guard-rspec
201
- jsonapi-rails (~> 0.1)
202
- jsonapi_compliable!
203
- kaminari (~> 0.17)
204
- pry
205
- pry-byebug
206
- rails (~> 5.0)
207
- rake (~> 10.0)
208
- rspec-rails
209
- sqlite3
210
-
211
- BUNDLED WITH
212
- 1.14.6
@@ -1,93 +0,0 @@
1
- class JsonapiCompliable::Write
2
- attr_reader :resource
3
-
4
- def initialize(opts = {})
5
- @resource = opts[:resource]
6
- end
7
-
8
- def persist
9
-
10
- end
11
- end
12
-
13
- resource.persist(obj, persistence_query, opts)
14
-
15
- p = Persistence.new(obj, resource: resource, params: params, opts: opts)
16
- p.persist
17
-
18
-
19
- allow_nested_write :books, resource: BookResource do
20
- # rdefault to using BookResource in these
21
- # hooks, but user can override to save
22
- # via author
23
- #
24
- # assign temp id AFTER
25
- # must handle NESTING genre
26
- create do |author, book_params|
27
- book_params[:author_id] = author.id
28
- BookResource.create(book_params)
29
- #book = Book.new(book_params)
30
- #book.author_id = author.id
31
- # instance variable set new id?
32
- # # should be outside this method
33
- #book.save!
34
- #book
35
- end
36
-
37
- # HOW TO REUSE THIS ON /books
38
- # should it be? i guess update, but not create
39
- update do |author, book_params|
40
- BookResource.update(book_params)
41
- #book = Book.find(book_params[:id])
42
- #book.update_attributes(book_params)
43
- #book
44
- end
45
-
46
- # Might be fair to say you can remove rel
47
- # but not destroy it
48
- # if needed, add destroy hook later
49
- delete do |author, book_params|
50
- book_params[:author_id] = nil
51
- BookResource.update(book_params)
52
- end
53
-
54
- destroy do |author, book_params|
55
- BookResource.destroy(book_params)
56
- end
57
- end
58
-
59
- #def jsonapi_scope(scope, opts = {})
60
- #resource.build_scope(scope, query, opts)
61
- #end
62
-
63
- # controller
64
- #
65
- # book = Book.new(params)
66
- #
67
- # if jsonapi_persist(book)
68
- # render_jsonapi(book)
69
- # else
70
- # render_errors_for(book)
71
- # end
72
-
73
-
74
-
75
- class Writer
76
- def initialize(parent)
77
- end
78
-
79
- def doit
80
- relationships.each do |name, data|
81
- if has_many?
82
- created = Child.new(data, fk: fk)
83
- created.TEMP_ID = data['temp_id']
84
- created = created.save
85
- mapping {data['temp_id'] => created.id}
86
- parent.name 4<< created
87
- parent.
88
- else
89
-
90
- end
91
- end
92
- end
93
- end