sorted 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/gemfiles/mongoid_30.gemfile +1 -6
- data/gemfiles/mongoid_30.gemfile.lock +63 -73
- data/lib/sorted/orms/active_record.rb +19 -3
- data/lib/sorted/toggler.rb +1 -1
- data/lib/sorted/version.rb +1 -1
- data/spec/sorted/orms/active_record_spec.rb +6 -0
- metadata +18 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc893cb851e4226ef3548dcba99ae5e44592d9c6
|
4
|
+
data.tar.gz: 9ee8b89780d7f29798643338f186846e58756508
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f0d30cbf53dfabf7d54f46c391218dd81674758655decf875531c014111ec2f1c6841c0a6e73af56249b41d8538525f064744574ece3e4e717b96d59eb5de86
|
7
|
+
data.tar.gz: 3f95d6fb84711892c6838a529f9caef5c006279322576c7dacd3ac2b0eb2e9167642880974f95983e82ebf64d8895828c3b303435fc22464610b68fac3148fca
|
data/.gitignore
CHANGED
data/gemfiles/mongoid_30.gemfile
CHANGED
@@ -1,12 +1,7 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
gem 'railties', '>= 4'
|
4
|
-
gem 'mongoid', '~> 4'
|
4
|
+
gem 'mongoid', '~> 4'
|
5
5
|
gem 'rspec-rails', '>= 2.0'
|
6
|
-
gem 'origin'
|
7
|
-
gem 'moped'
|
8
|
-
gem 'nokogiri'
|
9
|
-
gem 'xpath'
|
10
|
-
gem 'mime-types'
|
11
6
|
|
12
7
|
gemspec path: '../'
|
@@ -1,89 +1,84 @@
|
|
1
|
-
GIT
|
2
|
-
remote: git://github.com/mongoid/mongoid.git
|
3
|
-
revision: 9b3bc1264032209b7a6c0e82d0ca656f401e476b
|
4
|
-
specs:
|
5
|
-
mongoid (4.0.0)
|
6
|
-
activemodel (~> 4.0.0)
|
7
|
-
moped (~> 2.0.beta3)
|
8
|
-
origin (~> 1.0)
|
9
|
-
tzinfo (~> 0.3.37)
|
10
|
-
|
11
1
|
PATH
|
12
|
-
remote:
|
2
|
+
remote: ../
|
13
3
|
specs:
|
14
4
|
sorted (1.0.0)
|
15
5
|
|
16
6
|
GEM
|
17
7
|
remote: https://rubygems.org/
|
18
8
|
specs:
|
19
|
-
actionpack (4.
|
20
|
-
|
21
|
-
|
22
|
-
erubis (~> 2.7.0)
|
9
|
+
actionpack (4.1.4)
|
10
|
+
actionview (= 4.1.4)
|
11
|
+
activesupport (= 4.1.4)
|
23
12
|
rack (~> 1.5.2)
|
24
13
|
rack-test (~> 0.6.2)
|
25
|
-
|
26
|
-
activesupport (= 4.
|
27
|
-
builder (~> 3.1
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
14
|
+
actionview (4.1.4)
|
15
|
+
activesupport (= 4.1.4)
|
16
|
+
builder (~> 3.1)
|
17
|
+
erubis (~> 2.7.0)
|
18
|
+
activemodel (4.1.4)
|
19
|
+
activesupport (= 4.1.4)
|
20
|
+
builder (~> 3.1)
|
21
|
+
activesupport (4.1.4)
|
22
|
+
i18n (~> 0.6, >= 0.6.9)
|
23
|
+
json (~> 1.7, >= 1.7.7)
|
24
|
+
minitest (~> 5.1)
|
32
25
|
thread_safe (~> 0.1)
|
33
|
-
tzinfo (~>
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
diff-lcs (1.2.4)
|
26
|
+
tzinfo (~> 1.1)
|
27
|
+
bson (2.3.0)
|
28
|
+
bson (2.3.0-java)
|
29
|
+
builder (3.2.2)
|
30
|
+
connection_pool (2.0.0)
|
31
|
+
diff-lcs (1.2.5)
|
40
32
|
erubis (2.7.0)
|
41
|
-
i18n (0.6.
|
42
|
-
|
43
|
-
|
44
|
-
minitest (4.
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
33
|
+
i18n (0.6.9)
|
34
|
+
json (1.8.1)
|
35
|
+
json (1.8.1-java)
|
36
|
+
minitest (5.4.0)
|
37
|
+
mongoid (4.0.0)
|
38
|
+
activemodel (~> 4.0)
|
39
|
+
moped (~> 2.0.0)
|
40
|
+
origin (~> 2.1)
|
41
|
+
tzinfo (>= 0.3.37)
|
42
|
+
moped (2.0.0)
|
43
|
+
bson (~> 2.2)
|
44
|
+
connection_pool (~> 2.0)
|
45
|
+
optionable (~> 0.2.0)
|
46
|
+
optionable (0.2.0)
|
47
|
+
origin (2.1.1)
|
55
48
|
rack (1.5.2)
|
56
49
|
rack-test (0.6.2)
|
57
50
|
rack (>= 1.0)
|
58
|
-
railties (4.
|
59
|
-
actionpack (= 4.
|
60
|
-
activesupport (= 4.
|
51
|
+
railties (4.1.4)
|
52
|
+
actionpack (= 4.1.4)
|
53
|
+
activesupport (= 4.1.4)
|
61
54
|
rake (>= 0.8.7)
|
62
55
|
thor (>= 0.18.1, < 2.0)
|
63
|
-
rake (10.
|
64
|
-
rspec (
|
65
|
-
rspec-core (~>
|
66
|
-
rspec-expectations (~>
|
67
|
-
rspec-mocks (~>
|
68
|
-
rspec-core (
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
56
|
+
rake (10.3.2)
|
57
|
+
rspec (3.0.0)
|
58
|
+
rspec-core (~> 3.0.0)
|
59
|
+
rspec-expectations (~> 3.0.0)
|
60
|
+
rspec-mocks (~> 3.0.0)
|
61
|
+
rspec-core (3.0.2)
|
62
|
+
rspec-support (~> 3.0.0)
|
63
|
+
rspec-expectations (3.0.2)
|
64
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
65
|
+
rspec-support (~> 3.0.0)
|
66
|
+
rspec-mocks (3.0.2)
|
67
|
+
rspec-support (~> 3.0.0)
|
68
|
+
rspec-rails (3.0.1)
|
73
69
|
actionpack (>= 3.0)
|
74
70
|
activesupport (>= 3.0)
|
75
71
|
railties (>= 3.0)
|
76
|
-
rspec-core (~>
|
77
|
-
rspec-expectations (~>
|
78
|
-
rspec-mocks (~>
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
thread_safe (0.
|
83
|
-
|
84
|
-
tzinfo (
|
85
|
-
|
86
|
-
nokogiri (~> 1.3)
|
72
|
+
rspec-core (~> 3.0.0)
|
73
|
+
rspec-expectations (~> 3.0.0)
|
74
|
+
rspec-mocks (~> 3.0.0)
|
75
|
+
rspec-support (~> 3.0.0)
|
76
|
+
rspec-support (3.0.2)
|
77
|
+
thor (0.19.1)
|
78
|
+
thread_safe (0.3.4)
|
79
|
+
thread_safe (0.3.4-java)
|
80
|
+
tzinfo (1.2.1)
|
81
|
+
thread_safe (~> 0.1)
|
87
82
|
|
88
83
|
PLATFORMS
|
89
84
|
java
|
@@ -93,14 +88,9 @@ DEPENDENCIES
|
|
93
88
|
actionpack (>= 3.0.0)
|
94
89
|
activesupport (>= 3.0.0)
|
95
90
|
bundler (>= 1.0.0)
|
96
|
-
|
97
|
-
mongoid (~> 4)!
|
98
|
-
moped
|
99
|
-
nokogiri
|
100
|
-
origin
|
91
|
+
mongoid (~> 4)
|
101
92
|
railties (>= 4)
|
102
93
|
rake
|
103
94
|
rspec (>= 2.0.0)
|
104
95
|
rspec-rails (>= 2.0)
|
105
96
|
sorted!
|
106
|
-
xpath
|
@@ -8,9 +8,25 @@ module Sorted
|
|
8
8
|
|
9
9
|
included do
|
10
10
|
def self.sorted(sort, default_order = nil)
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
order sort_sql(sort, default_order)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.resorted(sort, default_order = nil)
|
15
|
+
reorder sort_sql(sort, default_order)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def self.sort_sql(sort, default_order)
|
21
|
+
sorter(sort, default_order).to_sql(quoter)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.sorter(sort, default_order)
|
25
|
+
::Sorted::Parser.new(sort, default_order)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.quoter
|
29
|
+
->(frag) { connection.quote_column_name(frag) }
|
14
30
|
end
|
15
31
|
end
|
16
32
|
end
|
data/lib/sorted/toggler.rb
CHANGED
data/lib/sorted/version.rb
CHANGED
@@ -16,6 +16,7 @@ if defined? ActiveRecord
|
|
16
16
|
|
17
17
|
it "should integrate with ActiveRecord::Base" do
|
18
18
|
SortedActiveRecordTest.should respond_to(:sorted)
|
19
|
+
SortedActiveRecordTest.should respond_to(:resorted)
|
19
20
|
end
|
20
21
|
|
21
22
|
it "should play nice with other scopes" do
|
@@ -23,5 +24,10 @@ if defined? ActiveRecord
|
|
23
24
|
SortedActiveRecordTest.where(:name => 'bob').page.sorted(nil, 'name ASC').to_sql.should == sql
|
24
25
|
SortedActiveRecordTest.page.sorted(nil, 'name ASC').where(:name => 'bob').to_sql.should == sql
|
25
26
|
end
|
27
|
+
|
28
|
+
it "should override the provided order" do
|
29
|
+
sql = "SELECT \"sorted_active_record_tests\".* FROM \"sorted_active_record_tests\" WHERE \"sorted_active_record_tests\".\"name\" = 'bob' ORDER BY \"name\" ASC LIMIT 50"
|
30
|
+
SortedActiveRecordTest.page.where(:name => 'bob').order(:id).sorted(nil, 'name DESC').resorted(nil, 'name ASC').to_sql.should == sql
|
31
|
+
end
|
26
32
|
end
|
27
33
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sorted
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rufus Post
|
@@ -9,76 +9,76 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-08-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: bundler
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: 1.0.0
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: 1.0.0
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: 2.0.0
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: 2.0.0
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: activesupport
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: 3.0.0
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: 3.0.0
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: actionpack
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: 3.0.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- -
|
81
|
+
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: 3.0.0
|
84
84
|
description: Allows you to sort large datasets over many pages, without losing state.
|
@@ -89,9 +89,9 @@ executables: []
|
|
89
89
|
extensions: []
|
90
90
|
extra_rdoc_files: []
|
91
91
|
files:
|
92
|
-
- .gitignore
|
93
|
-
- .rspec
|
94
|
-
- .travis.yml
|
92
|
+
- ".gitignore"
|
93
|
+
- ".rspec"
|
94
|
+
- ".travis.yml"
|
95
95
|
- Gemfile
|
96
96
|
- LICENSE
|
97
97
|
- README.md
|
@@ -125,17 +125,17 @@ require_paths:
|
|
125
125
|
- lib
|
126
126
|
required_ruby_version: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
|
-
- -
|
128
|
+
- - ">="
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
132
|
requirements:
|
133
|
-
- -
|
133
|
+
- - ">="
|
134
134
|
- !ruby/object:Gem::Version
|
135
135
|
version: 1.3.6
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project: sorted
|
138
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.2.0
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: Data sorting library
|