sortable-by 0.13.1 → 0.13.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/{ruby.yml → test.yml} +2 -2
- data/Gemfile.lock +19 -25
- data/README.md +7 -5
- data/lib/sortable_by.rb +1 -1
- data/sortable-by.gemspec +1 -1
- data/spec/active_record/sortable_by_spec.rb +10 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6412f520dea934585eaa16b0ec4f4b45fb088ed0274057de0c9c4ad38bd05d2c
|
4
|
+
data.tar.gz: 76a714b65c57e5c3b56ded227be2cfe80f66e469435b3d7f0c94bd11f1364493
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eefaafc008737c4f728164566d6a73a23fb845f04e84660eed18b6ba9770c8b3649c4d7d26b7376cf1f2b24e84e5054bed6038cf0a6ad863cce5db2985dc804d
|
7
|
+
data.tar.gz: 06acb810e43171c8a8e3687c9ebfde4f193750aed2449b5360d7bcc9bffb660b7dc574cbd01f1b6af8923dfb3b7a5bb873a1532f4227b8e16c4a18a770bd2095
|
data/Gemfile.lock
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sortable-by (0.13.
|
4
|
+
sortable-by (0.13.2)
|
5
5
|
activerecord
|
6
6
|
activesupport
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (6.1.3)
|
12
|
-
activesupport (= 6.1.3)
|
13
|
-
activerecord (6.1.3)
|
14
|
-
activemodel (= 6.1.3)
|
15
|
-
activesupport (= 6.1.3)
|
16
|
-
activesupport (6.1.3)
|
11
|
+
activemodel (6.1.3.2)
|
12
|
+
activesupport (= 6.1.3.2)
|
13
|
+
activerecord (6.1.3.2)
|
14
|
+
activemodel (= 6.1.3.2)
|
15
|
+
activesupport (= 6.1.3.2)
|
16
|
+
activesupport (6.1.3.2)
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
18
|
i18n (>= 1.6, < 2)
|
19
19
|
minitest (>= 5.1)
|
@@ -22,17 +22,16 @@ GEM
|
|
22
22
|
ast (2.4.2)
|
23
23
|
concurrent-ruby (1.1.8)
|
24
24
|
diff-lcs (1.4.4)
|
25
|
-
i18n (1.8.
|
25
|
+
i18n (1.8.10)
|
26
26
|
concurrent-ruby (~> 1.0)
|
27
27
|
minitest (5.14.4)
|
28
28
|
parallel (1.20.1)
|
29
|
-
parser (3.0.
|
29
|
+
parser (3.0.1.1)
|
30
30
|
ast (~> 2.4.1)
|
31
|
-
rack (2.2.3)
|
32
31
|
rainbow (3.0.0)
|
33
32
|
rake (13.0.3)
|
34
33
|
regexp_parser (2.1.1)
|
35
|
-
rexml (3.2.
|
34
|
+
rexml (3.2.5)
|
36
35
|
rspec (3.10.0)
|
37
36
|
rspec-core (~> 3.10.0)
|
38
37
|
rspec-expectations (~> 3.10.0)
|
@@ -46,33 +45,28 @@ GEM
|
|
46
45
|
diff-lcs (>= 1.2.0, < 2.0)
|
47
46
|
rspec-support (~> 3.10.0)
|
48
47
|
rspec-support (3.10.2)
|
49
|
-
rubocop (1.
|
48
|
+
rubocop (1.16.0)
|
50
49
|
parallel (~> 1.10)
|
51
50
|
parser (>= 3.0.0.0)
|
52
51
|
rainbow (>= 2.2.2, < 4.0)
|
53
52
|
regexp_parser (>= 1.8, < 3.0)
|
54
53
|
rexml
|
55
|
-
rubocop-ast (>= 1.
|
54
|
+
rubocop-ast (>= 1.7.0, < 2.0)
|
56
55
|
ruby-progressbar (~> 1.7)
|
57
56
|
unicode-display_width (>= 1.4.0, < 3.0)
|
58
|
-
rubocop-ast (1.
|
59
|
-
parser (>=
|
60
|
-
rubocop-bsm (0.
|
57
|
+
rubocop-ast (1.7.0)
|
58
|
+
parser (>= 3.0.1.1)
|
59
|
+
rubocop-bsm (0.6.0)
|
61
60
|
rubocop (~> 1.0)
|
62
61
|
rubocop-performance
|
63
|
-
rubocop-rails
|
64
62
|
rubocop-rake
|
65
63
|
rubocop-rspec
|
66
|
-
rubocop-performance (1.
|
67
|
-
rubocop (>=
|
64
|
+
rubocop-performance (1.11.3)
|
65
|
+
rubocop (>= 1.7.0, < 2.0)
|
68
66
|
rubocop-ast (>= 0.4.0)
|
69
|
-
rubocop-rails (2.9.1)
|
70
|
-
activesupport (>= 4.2.0)
|
71
|
-
rack (>= 1.1)
|
72
|
-
rubocop (>= 0.90.0, < 2.0)
|
73
67
|
rubocop-rake (0.5.1)
|
74
68
|
rubocop
|
75
|
-
rubocop-rspec (2.
|
69
|
+
rubocop-rspec (2.3.0)
|
76
70
|
rubocop (~> 1.0)
|
77
71
|
rubocop-ast (>= 1.1.0)
|
78
72
|
ruby-progressbar (1.11.0)
|
@@ -94,4 +88,4 @@ DEPENDENCIES
|
|
94
88
|
sqlite3
|
95
89
|
|
96
90
|
BUNDLED WITH
|
97
|
-
2.
|
91
|
+
2.2.19
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Sortable By
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![Test](https://github.com/bsm/sortable-by/actions/workflows/test.yml/badge.svg)](https://github.com/bsm/sortable-by/actions/workflows/test.yml)
|
4
4
|
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
|
5
5
|
|
6
6
|
ActiveRecord plugin to parse the sort order from a query parameter, match against a white-list and generate a scope. Useful for [JSON-API][jsonapi] compatibility.
|
@@ -20,10 +20,12 @@ class Post < ActiveRecord::Base
|
|
20
20
|
sortable_by :title, :id
|
21
21
|
end
|
22
22
|
|
23
|
-
Post.sorted_by('title')
|
24
|
-
Post.sorted_by('-title')
|
25
|
-
Post.sorted_by('
|
26
|
-
Post.sorted_by(
|
23
|
+
Post.sorted_by('title') # => ORDER BY LOWER(posts.title) ASC
|
24
|
+
Post.sorted_by('-title') # => ORDER BY LOWER(posts.title) DESC
|
25
|
+
Post.sorted_by('title,-id') # => ORDER BY LOWER(posts.title) ASC, id DESC
|
26
|
+
Post.sorted_by(['title', '-id']) # => ORDER BY LOWER(posts.title) ASC, id DESC
|
27
|
+
Post.sorted_by('bad,title') # => ORDER BY LOWER(posts.title) ASC
|
28
|
+
Post.sorted_by(nil) # => ORDER BY LOWER(posts.title) ASC
|
27
29
|
```
|
28
30
|
|
29
31
|
Case-sensitive:
|
data/lib/sortable_by.rb
CHANGED
data/sortable-by.gemspec
CHANGED
@@ -24,7 +24,7 @@ describe ActiveRecord::SortableBy do
|
|
24
24
|
expect(Product._sortable_by_config._default).to eq('shop,name')
|
25
25
|
end
|
26
26
|
|
27
|
-
it '
|
27
|
+
it 'supports simple ordering' do
|
28
28
|
Post.create! title: 'A', created_at: Time.at(1515151500)
|
29
29
|
Post.create! title: 'b', created_at: Time.at(1515151600)
|
30
30
|
Post.create! title: 'C', created_at: Time.at(1515151400)
|
@@ -41,6 +41,15 @@ describe ActiveRecord::SortableBy do
|
|
41
41
|
expect(Post.sorted_by(' title ').pluck(:title)).to eq(%w[A C b])
|
42
42
|
end
|
43
43
|
|
44
|
+
it 'supports array params' do
|
45
|
+
Post.create! title: 'A', created_at: Time.at(1515151500)
|
46
|
+
Post.create! title: 'C', created_at: Time.at(1515151400)
|
47
|
+
Post.create! title: 'B', created_at: Time.at(1515151400)
|
48
|
+
|
49
|
+
expect(Post.sorted_by(['created', '-title']).pluck(:title)).to eq(%w[C B A])
|
50
|
+
expect(Post.sorted_by(['created , -title']).pluck(:title)).to eq(%w[C B A])
|
51
|
+
end
|
52
|
+
|
44
53
|
it 'supports STI inheritance and overrides' do
|
45
54
|
SubPost.create! title: 'A', created_at: Time.at(1515151700)
|
46
55
|
SubPost.create! title: 'b', created_at: Time.at(1515151600)
|
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.13.
|
4
|
+
version: 0.13.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitrij Denissenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03
|
11
|
+
date: 2021-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -115,7 +115,7 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
-
- ".github/workflows/
|
118
|
+
- ".github/workflows/test.yml"
|
119
119
|
- ".gitignore"
|
120
120
|
- ".rubocop.yml"
|
121
121
|
- Gemfile
|
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
147
|
- !ruby/object:Gem::Version
|
148
148
|
version: '0'
|
149
149
|
requirements: []
|
150
|
-
rubygems_version: 3.
|
150
|
+
rubygems_version: 3.2.15
|
151
151
|
signing_key:
|
152
152
|
specification_version: 4
|
153
153
|
summary: Generate white-listed sort scopes from URL parameter values
|