sorted-activerecord 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -6
- data/.travis.yml +16 -1
- data/Guardfile +2 -2
- data/lib/sorted/active_record/builder.rb +7 -3
- data/lib/sorted/active_record/helper.rb +0 -1
- data/lib/sorted/active_record/version.rb +1 -1
- data/lib/sorted/active_record.rb +1 -1
- data/sorted-activerecord.gemspec +2 -2
- data/spec/sorted/active_record_spec.rb +3 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9856512bf3a6ea77c80b2e533a1eb9f9733b6581
|
4
|
+
data.tar.gz: 5c64bec217bea4dd89b953e591eb4ff18ea75fd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1fb82ad13affa7e882956be1f74a910bdf9e4b47a22cae92b5cbc0651b4e2af8e4ccc9732c9fa099e14477ab09b5056859a3276a6dfa73009a7e3280bd034aa
|
7
|
+
data.tar.gz: 6d1b300d549bc2dabde078e722ffda9a31ca3ded35abc1244d874b21a91f7a3c503baeb692083a1fb40739a11ae7c5523765b9b368d541d857ab61dbfb3c4f75
|
data/.rubocop.yml
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
# Offense count: 5
|
2
|
-
# Configuration parameters: AllowURI, URISchemes.
|
3
1
|
Metrics/LineLength:
|
4
2
|
Max: 174
|
5
3
|
|
6
|
-
# Offense count: 5
|
7
4
|
Style/Documentation:
|
8
5
|
Enabled: false
|
9
6
|
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
SignalException:
|
8
|
+
# prefer raise to fail
|
9
|
+
EnforcedStyle: only_raise
|
10
|
+
|
11
|
+
Lint/HandleExceptions:
|
12
|
+
Exclude:
|
13
|
+
- 'lib/sorted/active_record.rb'
|
data/.travis.yml
CHANGED
@@ -1,7 +1,22 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
3
|
- 2.0.0
|
4
|
-
- 2.1
|
4
|
+
- 2.1
|
5
|
+
- 2.2
|
5
6
|
- ruby-head
|
7
|
+
- jruby-19mode
|
8
|
+
- jruby-head
|
9
|
+
|
10
|
+
before_install:
|
11
|
+
- gem update bundler
|
6
12
|
|
7
13
|
script: bundle exec rake spec
|
14
|
+
|
15
|
+
matrix:
|
16
|
+
allow_failures:
|
17
|
+
- rvm: ruby-head
|
18
|
+
- rvm: jruby-head
|
19
|
+
fast_finish: true
|
20
|
+
|
21
|
+
notifications:
|
22
|
+
email: false
|
data/Guardfile
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
require 'sorted'
|
1
|
+
require 'sorted/set'
|
2
|
+
require 'sorted/sql_query'
|
3
|
+
require 'sorted/uri_query'
|
2
4
|
|
3
5
|
module Sorted
|
4
6
|
module ActiveRecord
|
@@ -42,14 +44,16 @@ module Sorted
|
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
47
|
+
# rubocop:disable Metrics/MethodLength
|
48
|
+
# rubocop:disable Metrics/AbcSize
|
45
49
|
def parse(values)
|
46
50
|
values.inject(Sorted::Set.new) do |memo, value|
|
47
51
|
case value.class.name
|
48
52
|
when 'Hash'
|
49
|
-
memo
|
53
|
+
memo += parse(value.to_a)
|
50
54
|
when 'String'
|
51
55
|
@return_hash = false
|
52
|
-
memo
|
56
|
+
memo += ::Sorted::SQLQuery.parse(value)
|
53
57
|
when 'Symbol'
|
54
58
|
memo = memo << [value.to_s, 'asc']
|
55
59
|
when 'Array'
|
data/lib/sorted/active_record.rb
CHANGED
data/sorted-activerecord.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = 'sorted-activerecord'
|
8
8
|
spec.version = Sorted::ActiveRecord::VERSION
|
9
9
|
spec.authors = ['Rufus Post']
|
10
|
-
spec.email = ['
|
10
|
+
spec.email = ['rufuspost@gmail.com']
|
11
11
|
spec.summary = 'Activerecord scoped for sorted.'
|
12
12
|
spec.description = 'Allows the use of the sorted gem with Activerecord.'
|
13
13
|
spec.homepage = ''
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency 'activerecord', '>= 4.0.0'
|
22
22
|
spec.add_dependency 'activesupport'
|
23
|
-
spec.add_dependency 'sorted', '~> 2.
|
23
|
+
spec.add_dependency 'sorted', '~> 2.1.2'
|
24
24
|
|
25
25
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
26
26
|
spec.add_development_dependency 'rake', '~> 10.0'
|
@@ -56,19 +56,19 @@ describe Sorted::ActiveRecord do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'should allow hash as order' do
|
59
|
-
expected = subject.order(
|
59
|
+
expected = subject.order(created_at: :desc).to_sql
|
60
60
|
actual = subject.sorted(order: [{ created_at: :desc }]).to_sql
|
61
61
|
expect(actual).to match(expected)
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'should allow hash as sort' do
|
65
|
-
expected = subject.order(
|
65
|
+
expected = subject.order(created_at: :desc).to_sql
|
66
66
|
actual = subject.sorted(sort: [{ created_at: :desc }]).to_sql
|
67
67
|
expect(actual).to match(expected)
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'should allow symbols and hash as order' do
|
71
|
-
expected = subject.order(:orders_count,
|
71
|
+
expected = subject.order(:orders_count, created_at: :desc).to_sql
|
72
72
|
actual = subject.sorted(sort: [:orders_count, { created_at: :desc }]).to_sql
|
73
73
|
expect(actual).to match(expected)
|
74
74
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sorted-activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rufus Post
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.
|
47
|
+
version: 2.1.2
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
54
|
+
version: 2.1.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,7 +152,7 @@ dependencies:
|
|
152
152
|
version: 1.3.5
|
153
153
|
description: Allows the use of the sorted gem with Activerecord.
|
154
154
|
email:
|
155
|
-
-
|
155
|
+
- rufuspost@gmail.com
|
156
156
|
executables: []
|
157
157
|
extensions: []
|
158
158
|
extra_rdoc_files: []
|