sortable-by 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +4 -23
- data/.travis.yml +2 -2
- data/Gemfile.lock +32 -32
- data/lib/sortable_by.rb +5 -9
- data/sortable-by.gemspec +3 -4
- data/spec/spec_helper.rb +1 -1
- metadata +4 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f74bd1b80f7d18fe84542fd593e14be0d8dc552bb0a5936fd733d5cf9c93018e
|
|
4
|
+
data.tar.gz: f44b03bfeb96d7bbdfda93013a10614d394e2731dcf57b0a68233005ba25f063
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c9ee512ce1eeeb0e4230ee8fe43e01f2bb5695a0b3633dae440f5231ddb53aa6d7cc3e65a97353f3fd344e5838a89340f72349ab43a53dfba9ad50918ac43bd7
|
|
7
|
+
data.tar.gz: 32bcfed467633bfe35825501e1d8abd6fdf4e48a931e71d66499b705cef73834a20cf62814d40db765e9223bd3338549319cf31b785f6cf6fb0c35ddccb05650
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,29 +1,10 @@
|
|
|
1
|
+
inherit_from:
|
|
2
|
+
- https://gitlab.com/bsm/misc/raw/master/rubocop/default.yml
|
|
3
|
+
|
|
1
4
|
AllCops:
|
|
2
|
-
TargetRubyVersion: 2.
|
|
5
|
+
TargetRubyVersion: 2.4
|
|
3
6
|
|
|
4
7
|
Naming/MemoizedInstanceVariableName:
|
|
5
8
|
Enabled: false
|
|
6
|
-
|
|
7
|
-
Metrics/AbcSize:
|
|
8
|
-
Enabled: false
|
|
9
|
-
Metrics/CyclomaticComplexity:
|
|
10
|
-
Enabled: false
|
|
11
|
-
Metrics/PerceivedComplexity:
|
|
12
|
-
Enabled: false
|
|
13
9
|
Naming/FileName:
|
|
14
10
|
Exclude: [lib/sortable-by.rb]
|
|
15
|
-
Metrics/BlockLength:
|
|
16
|
-
Exclude: [spec/**]
|
|
17
|
-
Metrics/MethodLength:
|
|
18
|
-
Enabled: false
|
|
19
|
-
Metrics/LineLength:
|
|
20
|
-
Max: 120
|
|
21
|
-
|
|
22
|
-
Style/NumericLiterals:
|
|
23
|
-
Exclude: [spec/**]
|
|
24
|
-
Style/TrailingCommaInArguments:
|
|
25
|
-
EnforcedStyleForMultiline: consistent_comma
|
|
26
|
-
Style/TrailingCommaInArrayLiteral:
|
|
27
|
-
EnforcedStyleForMultiline: consistent_comma
|
|
28
|
-
Style/TrailingCommaInHashLiteral:
|
|
29
|
-
EnforcedStyleForMultiline: consistent_comma
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
sortable-by (0.11.
|
|
4
|
+
sortable-by (0.11.1)
|
|
5
5
|
activerecord
|
|
6
6
|
activesupport
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: http://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
activemodel (5.2.
|
|
12
|
-
activesupport (= 5.2.
|
|
13
|
-
activerecord (5.2.
|
|
14
|
-
activemodel (= 5.2.
|
|
15
|
-
activesupport (= 5.2.
|
|
11
|
+
activemodel (5.2.3)
|
|
12
|
+
activesupport (= 5.2.3)
|
|
13
|
+
activerecord (5.2.3)
|
|
14
|
+
activemodel (= 5.2.3)
|
|
15
|
+
activesupport (= 5.2.3)
|
|
16
16
|
arel (>= 9.0)
|
|
17
|
-
activesupport (5.2.
|
|
17
|
+
activesupport (5.2.3)
|
|
18
18
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
19
19
|
i18n (>= 0.7, < 2)
|
|
20
20
|
minitest (~> 5.1)
|
|
21
21
|
tzinfo (~> 1.1)
|
|
22
22
|
arel (9.0.0)
|
|
23
23
|
ast (2.4.0)
|
|
24
|
-
concurrent-ruby (1.
|
|
24
|
+
concurrent-ruby (1.1.5)
|
|
25
25
|
diff-lcs (1.3)
|
|
26
|
-
i18n (1.
|
|
26
|
+
i18n (1.6.0)
|
|
27
27
|
concurrent-ruby (~> 1.0)
|
|
28
|
+
jaro_winkler (1.5.3)
|
|
28
29
|
minitest (5.11.3)
|
|
29
|
-
parallel (1.
|
|
30
|
-
parser (2.
|
|
30
|
+
parallel (1.17.0)
|
|
31
|
+
parser (2.6.3.0)
|
|
31
32
|
ast (~> 2.4.0)
|
|
32
|
-
powerpack (0.1.1)
|
|
33
33
|
rainbow (3.0.0)
|
|
34
|
-
rake (12.3.
|
|
35
|
-
rspec (3.
|
|
36
|
-
rspec-core (~> 3.
|
|
37
|
-
rspec-expectations (~> 3.
|
|
38
|
-
rspec-mocks (~> 3.
|
|
39
|
-
rspec-core (3.
|
|
40
|
-
rspec-support (~> 3.
|
|
41
|
-
rspec-expectations (3.
|
|
34
|
+
rake (12.3.2)
|
|
35
|
+
rspec (3.8.0)
|
|
36
|
+
rspec-core (~> 3.8.0)
|
|
37
|
+
rspec-expectations (~> 3.8.0)
|
|
38
|
+
rspec-mocks (~> 3.8.0)
|
|
39
|
+
rspec-core (3.8.2)
|
|
40
|
+
rspec-support (~> 3.8.0)
|
|
41
|
+
rspec-expectations (3.8.4)
|
|
42
42
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
43
|
-
rspec-support (~> 3.
|
|
44
|
-
rspec-mocks (3.
|
|
43
|
+
rspec-support (~> 3.8.0)
|
|
44
|
+
rspec-mocks (3.8.1)
|
|
45
45
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
46
|
-
rspec-support (~> 3.
|
|
47
|
-
rspec-support (3.
|
|
48
|
-
rubocop (0.
|
|
46
|
+
rspec-support (~> 3.8.0)
|
|
47
|
+
rspec-support (3.8.2)
|
|
48
|
+
rubocop (0.72.0)
|
|
49
|
+
jaro_winkler (~> 1.5.1)
|
|
49
50
|
parallel (~> 1.10)
|
|
50
|
-
parser (>= 2.
|
|
51
|
-
powerpack (~> 0.1)
|
|
51
|
+
parser (>= 2.6)
|
|
52
52
|
rainbow (>= 2.2.2, < 4.0)
|
|
53
53
|
ruby-progressbar (~> 1.7)
|
|
54
|
-
unicode-display_width (
|
|
55
|
-
ruby-progressbar (1.
|
|
56
|
-
sqlite3 (1.
|
|
54
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
|
55
|
+
ruby-progressbar (1.10.1)
|
|
56
|
+
sqlite3 (1.4.1)
|
|
57
57
|
thread_safe (0.3.6)
|
|
58
58
|
tzinfo (1.2.5)
|
|
59
59
|
thread_safe (~> 0.1)
|
|
60
|
-
unicode-display_width (1.
|
|
60
|
+
unicode-display_width (1.6.0)
|
|
61
61
|
|
|
62
62
|
PLATFORMS
|
|
63
63
|
ruby
|
|
@@ -71,4 +71,4 @@ DEPENDENCIES
|
|
|
71
71
|
sqlite3
|
|
72
72
|
|
|
73
73
|
BUNDLED WITH
|
|
74
|
-
1.
|
|
74
|
+
1.17.2
|
data/lib/sortable_by.rb
CHANGED
|
@@ -17,7 +17,7 @@ module ActiveRecord # :nodoc:
|
|
|
17
17
|
duplicate
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
def field(name, opts
|
|
20
|
+
def field(name, opts={})
|
|
21
21
|
name = name.to_s
|
|
22
22
|
@_fields[name] = Field.new(name, opts)
|
|
23
23
|
@_default ||= name
|
|
@@ -36,7 +36,7 @@ module ActiveRecord # :nodoc:
|
|
|
36
36
|
|
|
37
37
|
protected
|
|
38
38
|
|
|
39
|
-
def order(relation, expr, fallback
|
|
39
|
+
def order(relation, expr, fallback=true)
|
|
40
40
|
matched = false
|
|
41
41
|
expr.to_s.split(',').each do |name|
|
|
42
42
|
name.strip!
|
|
@@ -60,15 +60,13 @@ module ActiveRecord # :nodoc:
|
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
class Field # :nodoc:
|
|
63
|
-
def initialize(name, opts
|
|
63
|
+
def initialize(name, opts={})
|
|
64
64
|
@cols = Array.wrap(opts[:as])
|
|
65
65
|
@eager_load = Array.wrap(opts[:eager_load]).presence
|
|
66
66
|
|
|
67
67
|
# validate custom_scope
|
|
68
68
|
@custom_scope = opts[:scope]
|
|
69
|
-
if @custom_scope && !@custom_scope.is_a?(Proc)
|
|
70
|
-
raise ArgumentError, "Invalid sortable-by field '#{name}': scope must be a Proc."
|
|
71
|
-
end
|
|
69
|
+
raise ArgumentError, "Invalid sortable-by field '#{name}': scope must be a Proc." if @custom_scope && !@custom_scope.is_a?(Proc)
|
|
72
70
|
|
|
73
71
|
# normalize cols
|
|
74
72
|
@cols.push name if @cols.empty?
|
|
@@ -77,9 +75,7 @@ module ActiveRecord # :nodoc:
|
|
|
77
75
|
when String, Symbol, Arel::Attributes::Attribute, Arel::Nodes::Node
|
|
78
76
|
next
|
|
79
77
|
when Proc
|
|
80
|
-
unless col.arity == 2
|
|
81
|
-
raise ArgumentError, "Invalid sortable-by field '#{name}': proc must accept 2 arguments."
|
|
82
|
-
end
|
|
78
|
+
raise ArgumentError, "Invalid sortable-by field '#{name}': proc must accept 2 arguments." unless col.arity == 2
|
|
83
79
|
else
|
|
84
80
|
raise ArgumentError, "Invalid sortable-by field '#{name}': invalid type #{col.class}."
|
|
85
81
|
end
|
data/sortable-by.gemspec
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
1
|
Gem::Specification.new do |s|
|
|
3
2
|
s.name = 'sortable-by'
|
|
4
|
-
s.version = '0.11.
|
|
3
|
+
s.version = '0.11.1'
|
|
5
4
|
s.authors = ['Dimitrij Denissenko']
|
|
6
5
|
s.email = ['dimitrij@blacksquaremedia.com']
|
|
7
6
|
s.summary = 'Generate white-listed sort scopes from URL parameter values'
|
|
@@ -9,10 +8,10 @@ Gem::Specification.new do |s|
|
|
|
9
8
|
s.homepage = 'https://github.com/bsm/sortable-by'
|
|
10
9
|
s.license = 'MIT'
|
|
11
10
|
|
|
12
|
-
s.files = `git ls-files -z`.split("\x0").reject {
|
|
11
|
+
s.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^spec/}) }
|
|
13
12
|
s.test_files = `git ls-files -z -- spec/*`.split("\x0")
|
|
14
13
|
s.require_paths = ['lib']
|
|
15
|
-
s.required_ruby_version = '>= 2.
|
|
14
|
+
s.required_ruby_version = '>= 2.4'
|
|
16
15
|
|
|
17
16
|
s.add_dependency 'activerecord'
|
|
18
17
|
s.add_dependency 'activesupport'
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sortable-by
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.11.
|
|
4
|
+
version: 0.11.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dimitrij Denissenko
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2019-07-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -140,15 +140,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
140
140
|
requirements:
|
|
141
141
|
- - ">="
|
|
142
142
|
- !ruby/object:Gem::Version
|
|
143
|
-
version: 2.
|
|
143
|
+
version: '2.4'
|
|
144
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
145
|
requirements:
|
|
146
146
|
- - ">="
|
|
147
147
|
- !ruby/object:Gem::Version
|
|
148
148
|
version: '0'
|
|
149
149
|
requirements: []
|
|
150
|
-
|
|
151
|
-
rubygems_version: 2.7.3
|
|
150
|
+
rubygems_version: 3.0.3
|
|
152
151
|
signing_key:
|
|
153
152
|
specification_version: 4
|
|
154
153
|
summary: Generate white-listed sort scopes from URL parameter values
|