sortable-by 0.8.0 → 0.9.0

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: 9a8f7b12ede76157e3c47f2aa2e3448830ec5040
4
- data.tar.gz: 32a5f7e54e4be50111e8d9fe40b5c469d37a14b7
3
+ metadata.gz: c69dc4027db827d7339df15f6b6a82a00dd106c3
4
+ data.tar.gz: 6542aa11412834bd4360db4f6f989e2fb56358de
5
5
  SHA512:
6
- metadata.gz: 4f9fe1dec1e74a71f2d73c5b488047a56f5eba5615dcdcf72648b5acd05655467022da4fde1f8dd6aff62ea191ccaeaa3bcbbbbba6b46f7b5ce11926ea486486
7
- data.tar.gz: 1a0a02ae09216da95b603fddecbf07bb5e3578961a9f81004e09f4aa9e5976732f1919dd0fc8797b119efdd8a787b5df455bd6be705aea7b3c42a4072279df29
6
+ metadata.gz: 12165f68bf353d543f8701ed328586822a8c43d729cd514b8695821214a424926507e53e0fb443639a2051e28626733e6edcb47a5f5530949ae9bd6e9e80aa0a
7
+ data.tar.gz: 9008ae98a2a8aacb2bf807b9db1eb428fc6934e39e84ae11369919f46cbe75463c3e63ceb3897f88819cd5b125071c47591290bb0c2d33f950114c0966cd2219
data/.travis.yml CHANGED
@@ -2,5 +2,7 @@ rvm:
2
2
  - 1.9.3
3
3
  - 2.1.2
4
4
  - 2.2.2
5
+ - 2.3.2
6
+ - 2.4.0
5
7
  gemfile:
6
8
  - Gemfile
data/Gemfile.lock CHANGED
@@ -1,48 +1,45 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sortable-by (0.8.0)
4
+ sortable-by (0.9.0)
5
5
  activerecord
6
6
  activesupport
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- activemodel (4.2.3)
12
- activesupport (= 4.2.3)
13
- builder (~> 3.1)
14
- activerecord (4.2.3)
15
- activemodel (= 4.2.3)
16
- activesupport (= 4.2.3)
17
- arel (~> 6.0)
18
- activesupport (4.2.3)
11
+ activemodel (5.0.1)
12
+ activesupport (= 5.0.1)
13
+ activerecord (5.0.1)
14
+ activemodel (= 5.0.1)
15
+ activesupport (= 5.0.1)
16
+ arel (~> 7.0)
17
+ activesupport (5.0.1)
18
+ concurrent-ruby (~> 1.0, >= 1.0.2)
19
19
  i18n (~> 0.7)
20
- json (~> 1.7, >= 1.7.7)
21
20
  minitest (~> 5.1)
22
- thread_safe (~> 0.3, >= 0.3.4)
23
21
  tzinfo (~> 1.1)
24
- arel (6.0.2)
25
- builder (3.2.2)
26
- diff-lcs (1.2.5)
27
- i18n (0.7.0)
28
- json (1.8.3)
29
- minitest (5.7.0)
30
- rake (10.4.2)
31
- rspec (3.3.0)
32
- rspec-core (~> 3.3.0)
33
- rspec-expectations (~> 3.3.0)
34
- rspec-mocks (~> 3.3.0)
35
- rspec-core (3.3.2)
36
- rspec-support (~> 3.3.0)
37
- rspec-expectations (3.3.1)
22
+ arel (7.1.4)
23
+ concurrent-ruby (1.0.4)
24
+ diff-lcs (1.3)
25
+ i18n (0.8.1)
26
+ minitest (5.10.1)
27
+ rake (12.0.0)
28
+ rspec (3.5.0)
29
+ rspec-core (~> 3.5.0)
30
+ rspec-expectations (~> 3.5.0)
31
+ rspec-mocks (~> 3.5.0)
32
+ rspec-core (3.5.4)
33
+ rspec-support (~> 3.5.0)
34
+ rspec-expectations (3.5.0)
38
35
  diff-lcs (>= 1.2.0, < 2.0)
39
- rspec-support (~> 3.3.0)
40
- rspec-mocks (3.3.2)
36
+ rspec-support (~> 3.5.0)
37
+ rspec-mocks (3.5.0)
41
38
  diff-lcs (>= 1.2.0, < 2.0)
42
- rspec-support (~> 3.3.0)
43
- rspec-support (3.3.0)
44
- sqlite3 (1.3.10)
45
- thread_safe (0.3.5)
39
+ rspec-support (~> 3.5.0)
40
+ rspec-support (3.5.0)
41
+ sqlite3 (1.3.13)
42
+ thread_safe (0.3.6)
46
43
  tzinfo (1.2.2)
47
44
  thread_safe (~> 0.1)
48
45
 
@@ -57,4 +54,4 @@ DEPENDENCIES
57
54
  sqlite3
58
55
 
59
56
  BUNDLED WITH
60
- 1.10.6
57
+ 1.14.3
data/README.md CHANGED
@@ -17,9 +17,9 @@ class Foo < ActiveRecord::Base
17
17
  sortable_by :title, :updated_at, default: { updated_at: :desc }
18
18
  end
19
19
 
20
- Foo.sort_by "-updated_at,title" # => ORDER BY updated_at DESC, title ASC
21
- Foo.sort_by "bad,title" # => ORDER BY title ASC
22
- Foo.sort_by nil # => ORDER BY updated_at DESC
20
+ Foo.sorted_by "-updated_at,title" # => ORDER BY updated_at DESC, title ASC
21
+ Foo.sorted_by "bad,title" # => ORDER BY title ASC
22
+ Foo.sorted_by nil # => ORDER BY updated_at DESC
23
23
  ```
24
24
 
25
25
  ## LICENCE
data/lib/sortable_by.rb CHANGED
@@ -21,7 +21,7 @@ module ActiveRecord
21
21
 
22
22
  # @param [String] expr the sort expr
23
23
  # @return [ActiveRecord::Relation] the scoped relation
24
- def sort_by(expr)
24
+ def sorted_by(expr)
25
25
  options = {}
26
26
  expr.to_s.split(',').each do |name|
27
27
  name.strip!
data/sortable-by.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'sortable-by'
4
- s.version = '0.8.0'
4
+ s.version = '0.9.0'
5
5
  s.authors = ['Dimitrij Denissenko']
6
6
  s.email = ['dimitrij@blacksquaremedia.com']
7
7
  s.summary = 'Generate white-listed sort scopes from URL parameter values'
@@ -8,15 +8,16 @@ describe ActiveRecord::SortableByHelper do
8
8
  end
9
9
 
10
10
  it 'should generate scopes' do
11
- expect(Foo.sort_by("title").pluck(:title)).to eq(["A", "B", "B", "C"])
12
- expect(Foo.sort_by("-title").pluck(:title)).to eq(["C", "B", "B", "A"])
13
- expect(Foo.sort_by("age,title").pluck(:title)).to eq(["B", "A", "B", "C"])
14
- expect(Foo.sort_by("invalid , -age").pluck(:title)).to eq(["C", "B", "A", "B"])
15
- expect(Foo.sort_by("").pluck(:title)).to eq(["A", "B", "B", "C"])
16
- expect(Foo.sort_by(nil).pluck(:title)).to eq(["A", "B", "B", "C"])
11
+ expect(Foo.sorted_by("title").pluck(:title)).to eq(["A", "B", "B", "C"])
12
+ expect(Foo.sorted_by("-title").pluck(:title)).to eq(["C", "B", "B", "A"])
13
+ expect(Foo.sorted_by("age,title").pluck(:title)).to eq(["B", "A", "B", "C"])
14
+ expect(Foo.sorted_by("invalid , -age").pluck(:title)).to eq(["C", "B", "A", "B"])
15
+ expect(Foo.sorted_by("").pluck(:title)).to eq(["A", "B", "B", "C"])
16
+ expect(Foo.sorted_by(nil).pluck(:title)).to eq(["A", "B", "B", "C"])
17
17
 
18
- expect(Bar.sort_by("").pluck(:title)).to eq(["Y", "X"])
19
- expect(Bar.sort_by("title").pluck(:title)).to eq(["Y", "X"])
18
+ expect(Bar.sorted_by("").pluck(:title)).to eq(["Y", "X"])
19
+ expect(Bar.sorted_by("title").pluck(:title)).to eq(["Y", "X"])
20
+ expect(Bar.where(title: "X").sorted_by("title").pluck(:title)).to eq(["X"])
20
21
  end
21
22
 
22
23
  end
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.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitrij Denissenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-10 00:00:00.000000000 Z
11
+ date: 2017-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  version: '0'
133
133
  requirements: []
134
134
  rubyforge_project:
135
- rubygems_version: 2.4.8
135
+ rubygems_version: 2.6.8
136
136
  signing_key:
137
137
  specification_version: 4
138
138
  summary: Generate white-listed sort scopes from URL parameter values