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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b953a7e7e5eba1a9cb24e6b7e4eb11a3d992b1f9
4
- data.tar.gz: d082592d88b8b2e6a87ecc02f83ae5a4b9c8dc82
3
+ metadata.gz: 28e026528b72f7e8474b8ac1c7dd868aa4dc31c2
4
+ data.tar.gz: bef3b693f87d95ea19dee1ea5af22899585153ca
5
5
  SHA512:
6
- metadata.gz: b4ceecb9f9765f5b1f6ba3c765163871b9d5a1e898fb81f6a4ca356ff365230b188cc103da845e6ea5e237be3d17ee413d217d4bca926803c00b564a20eefad0
7
- data.tar.gz: c05b90c5b9853652f7111a4d323a6e9489f6df405b121e3219fcd0c8479960c534de8bbe616fdbe59042367b2a8f570095203ef922aa73f080009dc4f8e5d40c
6
+ metadata.gz: bc20a859dfdccfe05188360736c38b5575de904e26b7647218b27f511fc978c6ce6e546698734ba2add7c7dbfe009d32d12d192990e71122c164789be11079c4
7
+ data.tar.gz: 4b5e1a141b28cacb86e08c3276791e67cc297803b5de4632c22e5c5e89ad36812810bcb32e396d6c8e04196d1f8299184919444be125734519b6f9fc006107fa
@@ -8,7 +8,7 @@ GIT
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- jsonapi.rb (1.3.2)
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.1)
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.0)
90
+ nokogiri (1.10.1)
91
91
  mini_portile2 (~> 2.4.0)
92
- parallel (1.12.1)
93
- parser (2.5.3.0)
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.1)
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.62.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.0)
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.16)
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.16.3
205
+ 1.17.3
@@ -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
- (params[:fields] || []).each do |k, v|
15
+ params[:fields].each do |k, v|
14
16
  h[k] = v.split(',').map(&:strip).compact
15
17
  end
16
18
  end
@@ -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.extract_attributes_and_predicate(requested_field)
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
- .extract_attributes_and_predicate(requested_field)
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
- .extract_attributes_and_predicate(requested_field)
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?
@@ -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.public_send(node.dir)
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
 
@@ -1,3 +1,3 @@
1
1
  module JSONAPI
2
- VERSION = '1.3.2'
2
+ VERSION = '1.3.3'
3
3
  end
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.2
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-27 00:00:00.000000000 Z
11
+ date: 2019-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fast_jsonapi