jsonapi.rb 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +10 -10
- data/lib/jsonapi/fetching.rb +3 -1
- data/lib/jsonapi/filtering.rb +3 -3
- data/lib/jsonapi/patches.rb +4 -1
- data/lib/jsonapi/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28e026528b72f7e8474b8ac1c7dd868aa4dc31c2
|
4
|
+
data.tar.gz: bef3b693f87d95ea19dee1ea5af22899585153ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc20a859dfdccfe05188360736c38b5575de904e26b7647218b27f511fc978c6ce6e546698734ba2add7c7dbfe009d32d12d192990e71122c164789be11079c4
|
7
|
+
data.tar.gz: 4b5e1a141b28cacb86e08c3276791e67cc297803b5de4632c22e5c5e89ad36812810bcb32e396d6c8e04196d1f8299184919444be125734519b6f9fc006107fa
|
data/Gemfile.lock
CHANGED
@@ -8,7 +8,7 @@ GIT
|
|
8
8
|
PATH
|
9
9
|
remote: .
|
10
10
|
specs:
|
11
|
-
jsonapi.rb (1.3.
|
11
|
+
jsonapi.rb (1.3.3)
|
12
12
|
fast_jsonapi (~> 1.5)
|
13
13
|
rack
|
14
14
|
ransack
|
@@ -70,7 +70,7 @@ GEM
|
|
70
70
|
ffaker (2.10.0)
|
71
71
|
globalid (0.4.2)
|
72
72
|
activesupport (>= 4.2.0)
|
73
|
-
i18n (1.5.
|
73
|
+
i18n (1.5.3)
|
74
74
|
concurrent-ruby (~> 1.0)
|
75
75
|
jaro_winkler (1.5.2)
|
76
76
|
json (2.1.0)
|
@@ -87,10 +87,10 @@ GEM
|
|
87
87
|
mini_portile2 (2.4.0)
|
88
88
|
minitest (5.11.3)
|
89
89
|
nio4r (2.3.1)
|
90
|
-
nokogiri (1.10.
|
90
|
+
nokogiri (1.10.1)
|
91
91
|
mini_portile2 (~> 2.4.0)
|
92
|
-
parallel (1.
|
93
|
-
parser (2.
|
92
|
+
parallel (1.13.0)
|
93
|
+
parser (2.6.0.0)
|
94
94
|
ast (~> 2.4.0)
|
95
95
|
powerpack (0.1.2)
|
96
96
|
rack (2.0.6)
|
@@ -139,7 +139,7 @@ GEM
|
|
139
139
|
rspec-mocks (3.8.0)
|
140
140
|
diff-lcs (>= 1.2.0, < 2.0)
|
141
141
|
rspec-support (~> 3.8.0)
|
142
|
-
rspec-rails (3.8.
|
142
|
+
rspec-rails (3.8.2)
|
143
143
|
actionpack (>= 3.0)
|
144
144
|
activesupport (>= 3.0)
|
145
145
|
railties (>= 3.0)
|
@@ -148,7 +148,7 @@ GEM
|
|
148
148
|
rspec-mocks (~> 3.8.0)
|
149
149
|
rspec-support (~> 3.8.0)
|
150
150
|
rspec-support (3.8.0)
|
151
|
-
rubocop (0.
|
151
|
+
rubocop (0.63.1)
|
152
152
|
jaro_winkler (~> 1.5.1)
|
153
153
|
parallel (~> 1.10)
|
154
154
|
parser (>= 2.5, != 2.5.1.1)
|
@@ -156,7 +156,7 @@ GEM
|
|
156
156
|
rainbow (>= 2.2.2, < 4.0)
|
157
157
|
ruby-progressbar (~> 1.7)
|
158
158
|
unicode-display_width (~> 1.4.0)
|
159
|
-
rubocop-rails_config (0.4.
|
159
|
+
rubocop-rails_config (0.4.2)
|
160
160
|
railties (>= 3.0)
|
161
161
|
rubocop (~> 0.58)
|
162
162
|
ruby-progressbar (1.10.0)
|
@@ -181,7 +181,7 @@ GEM
|
|
181
181
|
websocket-driver (0.7.0)
|
182
182
|
websocket-extensions (>= 0.1.0)
|
183
183
|
websocket-extensions (0.1.3)
|
184
|
-
yard (0.9.
|
184
|
+
yard (0.9.18)
|
185
185
|
yardstick (0.9.9)
|
186
186
|
yard (~> 0.8, >= 0.8.7.2)
|
187
187
|
|
@@ -202,4 +202,4 @@ DEPENDENCIES
|
|
202
202
|
yardstick
|
203
203
|
|
204
204
|
BUNDLED WITH
|
205
|
-
1.
|
205
|
+
1.17.3
|
data/lib/jsonapi/fetching.rb
CHANGED
@@ -9,8 +9,10 @@ module JSONAPI
|
|
9
9
|
#
|
10
10
|
# @return [Hash]
|
11
11
|
def jsonapi_fields
|
12
|
+
return {} unless params[:fields].respond_to?(:each_pair)
|
13
|
+
|
12
14
|
ActiveSupport::HashWithIndifferentAccess.new.tap do |h|
|
13
|
-
|
15
|
+
params[:fields].each do |k, v|
|
14
16
|
h[k] = v.split(',').map(&:strip).compact
|
15
17
|
end
|
16
18
|
end
|
data/lib/jsonapi/filtering.rb
CHANGED
@@ -8,7 +8,7 @@ module JSONAPI
|
|
8
8
|
#
|
9
9
|
# @param requested_field [String] the field to parse
|
10
10
|
# @return [Array] with the fields and the predicate
|
11
|
-
def self.
|
11
|
+
def self.extract_attributes_and_predicates(requested_field)
|
12
12
|
predicates = []
|
13
13
|
field_name = requested_field.to_s.dup
|
14
14
|
|
@@ -55,7 +55,7 @@ module JSONAPI
|
|
55
55
|
|
56
56
|
requested.each_pair do |requested_field, to_filter|
|
57
57
|
field_names, predicates = JSONAPI::Filtering
|
58
|
-
.
|
58
|
+
.extract_attributes_and_predicates(requested_field)
|
59
59
|
|
60
60
|
if to_filter.is_a?(String) && to_filter.include?(',')
|
61
61
|
to_filter = to_filter.split(',')
|
@@ -87,7 +87,7 @@ module JSONAPI
|
|
87
87
|
end
|
88
88
|
|
89
89
|
field_names, predicates = JSONAPI::Filtering
|
90
|
-
.
|
90
|
+
.extract_attributes_and_predicates(requested_field)
|
91
91
|
|
92
92
|
next unless (field_names - allowed_fields).empty?
|
93
93
|
next if !options[:sort_with_expressions] && predicates.any?
|
data/lib/jsonapi/patches.rb
CHANGED
@@ -50,7 +50,10 @@ Ransack::Visitor.class_eval do
|
|
50
50
|
valid = (binded.valid? if binded.respond_to?(:valid?)) || true
|
51
51
|
return unless binded.present? && valid
|
52
52
|
|
53
|
-
binded.arel_predicate
|
53
|
+
arel_pred = binded.arel_predicate
|
54
|
+
# Remove any alias when sorting...
|
55
|
+
arel_pred.alias = nil if arel_pred.respond_to?(:alias=)
|
56
|
+
arel_pred.public_send(node.dir)
|
54
57
|
end
|
55
58
|
end
|
56
59
|
|
data/lib/jsonapi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonapi.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stas Suscov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fast_jsonapi
|