ordy 1.1.0
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 +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +23 -0
- data/Appraisals +14 -0
- data/Dockerfile +18 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +89 -0
- data/LICENSE +21 -0
- data/Rakefile +8 -0
- data/VERSION +1 -0
- data/docker-compose.yml +6 -0
- data/gemfiles/rails_4.gemfile +8 -0
- data/gemfiles/rails_4.gemfile.lock +97 -0
- data/gemfiles/rails_5_0.gemfile +8 -0
- data/gemfiles/rails_5_0.gemfile.lock +91 -0
- data/gemfiles/rails_5_2.gemfile +8 -0
- data/gemfiles/rails_5_2.gemfile.lock +91 -0
- data/lib/config/settings.rb +9 -0
- data/lib/config/settings.yml +5 -0
- data/lib/ordy/helpers/action_view/orderable_link_helper.rb +61 -0
- data/lib/ordy/orm/active_record/orderable/by_association.rb +17 -0
- data/lib/ordy/orm/active_record/orderable/by_column.rb +17 -0
- data/lib/ordy/orm/active_record/orderable/by_specified.rb +23 -0
- data/lib/ordy/orm/active_record/orderable.rb +188 -0
- data/lib/ordy.rb +9 -0
- data/ordy.gemspec +32 -0
- data/readme.md +138 -0
- data/spec/ordy/orm/active_record/orderable_spec.rb +151 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/support/orm/active_record/active_record_test_db.rb +95 -0
- metadata +172 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9a18d7ee28d5acf5e956eda544faceca2a4adfbcdac6cbf336321e122d4a1289
|
4
|
+
data.tar.gz: b66298976ba46066cd502c42285a1d329df9323759c2290a750ab221153dd285
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2c0ffebb475c6cf9d2474704f3351d29196c1961a8c63d1d561af143e5e79671723d20050b5add6df2aa3ab47c6ed2c8e86a14066bd6fb0308ad24ad4cde2c56
|
7
|
+
data.tar.gz: a99c583ae31449767d042dbfaccfc0f2bef34289cb2ee2f9c7bfb519786565ce1b077e86a5a1693ce66d3a31a90c7ae73404f3ecd4c9f77c4a5487132a48315c
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/.travis.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
rvm:
|
4
|
+
- 2.1.2
|
5
|
+
- 2.2.5
|
6
|
+
- 2.3.1
|
7
|
+
- 2.3.4
|
8
|
+
- 2.4.1
|
9
|
+
gemfile:
|
10
|
+
- gemfiles/rails_4.gemfile
|
11
|
+
- gemfiles/rails_5_0.gemfile
|
12
|
+
- gemfiles/rails_5_2.gemfile
|
13
|
+
script:
|
14
|
+
- bundle exec rake spec
|
15
|
+
before_install:
|
16
|
+
- gem cleanup bundler
|
17
|
+
- gem install bundler -v 1.17.3
|
18
|
+
matrix:
|
19
|
+
exclude:
|
20
|
+
- rvm: 2.1.2
|
21
|
+
gemfile: gemfiles/rails_5_0.gemfile
|
22
|
+
- rvm: 2.1.2
|
23
|
+
gemfile: gemfiles/rails_5_2.gemfile
|
data/Appraisals
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
appraise "rails_4" do
|
2
|
+
gem "activerecord", "4.2.0"
|
3
|
+
gem "actionview", "4.2.0"
|
4
|
+
end
|
5
|
+
|
6
|
+
appraise "rails_5_0" do
|
7
|
+
gem "activerecord", "5.0.0"
|
8
|
+
gem "actionview", "5.0.0"
|
9
|
+
end
|
10
|
+
|
11
|
+
appraise "rails_5_2" do
|
12
|
+
gem "activerecord", "5.2.0"
|
13
|
+
gem "actionview", "5.2.0"
|
14
|
+
end
|
data/Dockerfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
ARG RUBY_VERSION=2.3.4
|
2
|
+
FROM ruby:${RUBY_VERSION}
|
3
|
+
LABEL maintainer="engineering@nine.ch"
|
4
|
+
|
5
|
+
# Setup sqlite3 db
|
6
|
+
RUN apt-get update
|
7
|
+
RUN apt-get install -y sqlite3 libsqlite3-dev
|
8
|
+
|
9
|
+
# Copy gemfile
|
10
|
+
COPY Gemfile Gemfile.lock ordy.gemspec Appraisals ./
|
11
|
+
COPY gemfiles ./gemfiles
|
12
|
+
|
13
|
+
# Cache bundle install
|
14
|
+
RUN bundle install -j $(nproc)
|
15
|
+
RUN bundle exec appraisal install
|
16
|
+
|
17
|
+
# Copy the main application.
|
18
|
+
COPY . /app/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ordy (0.0.0)
|
5
|
+
actionview (>= 4.0.0)
|
6
|
+
activerecord (>= 4.0.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionview (5.2.1.1)
|
12
|
+
activesupport (= 5.2.1.1)
|
13
|
+
builder (~> 3.1)
|
14
|
+
erubi (~> 1.4)
|
15
|
+
rails-dom-testing (~> 2.0)
|
16
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
17
|
+
activemodel (5.2.1.1)
|
18
|
+
activesupport (= 5.2.1.1)
|
19
|
+
activerecord (5.2.1.1)
|
20
|
+
activemodel (= 5.2.1.1)
|
21
|
+
activesupport (= 5.2.1.1)
|
22
|
+
arel (>= 9.0)
|
23
|
+
activesupport (5.2.1.1)
|
24
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
25
|
+
i18n (>= 0.7, < 2)
|
26
|
+
minitest (~> 5.1)
|
27
|
+
tzinfo (~> 1.1)
|
28
|
+
appraisal (2.2.0)
|
29
|
+
bundler
|
30
|
+
rake
|
31
|
+
thor (>= 0.14.0)
|
32
|
+
arel (9.0.0)
|
33
|
+
builder (3.2.3)
|
34
|
+
coderay (1.1.2)
|
35
|
+
concurrent-ruby (1.1.4)
|
36
|
+
crass (1.0.4)
|
37
|
+
diff-lcs (1.3)
|
38
|
+
erubi (1.8.0)
|
39
|
+
i18n (1.3.0)
|
40
|
+
concurrent-ruby (~> 1.0)
|
41
|
+
loofah (2.2.3)
|
42
|
+
crass (~> 1.0.2)
|
43
|
+
nokogiri (>= 1.5.9)
|
44
|
+
method_source (0.9.2)
|
45
|
+
mini_portile2 (2.4.0)
|
46
|
+
minitest (5.11.3)
|
47
|
+
nokogiri (1.9.1)
|
48
|
+
mini_portile2 (~> 2.4.0)
|
49
|
+
pry (0.12.2)
|
50
|
+
coderay (~> 1.1.0)
|
51
|
+
method_source (~> 0.9.0)
|
52
|
+
rails-dom-testing (2.0.3)
|
53
|
+
activesupport (>= 4.2.0)
|
54
|
+
nokogiri (>= 1.6)
|
55
|
+
rails-html-sanitizer (1.0.4)
|
56
|
+
loofah (~> 2.2, >= 2.2.2)
|
57
|
+
rake (12.3.1)
|
58
|
+
rspec (3.8.0)
|
59
|
+
rspec-core (~> 3.8.0)
|
60
|
+
rspec-expectations (~> 3.8.0)
|
61
|
+
rspec-mocks (~> 3.8.0)
|
62
|
+
rspec-core (3.8.0)
|
63
|
+
rspec-support (~> 3.8.0)
|
64
|
+
rspec-expectations (3.8.2)
|
65
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
+
rspec-support (~> 3.8.0)
|
67
|
+
rspec-mocks (3.8.0)
|
68
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
69
|
+
rspec-support (~> 3.8.0)
|
70
|
+
rspec-support (3.8.0)
|
71
|
+
sqlite3 (1.3.13)
|
72
|
+
thor (0.20.3)
|
73
|
+
thread_safe (0.3.6)
|
74
|
+
tzinfo (1.2.5)
|
75
|
+
thread_safe (~> 0.1)
|
76
|
+
|
77
|
+
PLATFORMS
|
78
|
+
ruby
|
79
|
+
|
80
|
+
DEPENDENCIES
|
81
|
+
appraisal
|
82
|
+
bundler
|
83
|
+
ordy!
|
84
|
+
pry
|
85
|
+
rspec
|
86
|
+
sqlite3
|
87
|
+
|
88
|
+
BUNDLED WITH
|
89
|
+
1.17.1
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 nine
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/Rakefile
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.1.0
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
ordy (0.0.0)
|
5
|
+
actionview (>= 4.0.0)
|
6
|
+
activerecord (>= 4.0.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionview (4.2.0)
|
12
|
+
activesupport (= 4.2.0)
|
13
|
+
builder (~> 3.1)
|
14
|
+
erubis (~> 2.7.0)
|
15
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
16
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
17
|
+
activemodel (4.2.0)
|
18
|
+
activesupport (= 4.2.0)
|
19
|
+
builder (~> 3.1)
|
20
|
+
activerecord (4.2.0)
|
21
|
+
activemodel (= 4.2.0)
|
22
|
+
activesupport (= 4.2.0)
|
23
|
+
arel (~> 6.0)
|
24
|
+
activesupport (4.2.0)
|
25
|
+
i18n (~> 0.7)
|
26
|
+
json (~> 1.7, >= 1.7.7)
|
27
|
+
minitest (~> 5.1)
|
28
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
29
|
+
tzinfo (~> 1.1)
|
30
|
+
appraisal (2.2.0)
|
31
|
+
bundler
|
32
|
+
rake
|
33
|
+
thor (>= 0.14.0)
|
34
|
+
arel (6.0.4)
|
35
|
+
builder (3.2.3)
|
36
|
+
coderay (1.1.2)
|
37
|
+
concurrent-ruby (1.1.4)
|
38
|
+
crass (1.0.4)
|
39
|
+
diff-lcs (1.3)
|
40
|
+
erubis (2.7.0)
|
41
|
+
i18n (0.9.5)
|
42
|
+
concurrent-ruby (~> 1.0)
|
43
|
+
json (1.8.6)
|
44
|
+
loofah (2.2.3)
|
45
|
+
crass (~> 1.0.2)
|
46
|
+
nokogiri (>= 1.5.9)
|
47
|
+
method_source (0.9.2)
|
48
|
+
mini_portile2 (2.4.0)
|
49
|
+
minitest (5.11.3)
|
50
|
+
nokogiri (1.9.1)
|
51
|
+
mini_portile2 (~> 2.4.0)
|
52
|
+
pry (0.12.2)
|
53
|
+
coderay (~> 1.1.0)
|
54
|
+
method_source (~> 0.9.0)
|
55
|
+
rails-deprecated_sanitizer (1.0.3)
|
56
|
+
activesupport (>= 4.2.0.alpha)
|
57
|
+
rails-dom-testing (1.0.9)
|
58
|
+
activesupport (>= 4.2.0, < 5.0)
|
59
|
+
nokogiri (~> 1.6)
|
60
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
61
|
+
rails-html-sanitizer (1.0.4)
|
62
|
+
loofah (~> 2.2, >= 2.2.2)
|
63
|
+
rake (12.3.2)
|
64
|
+
rspec (3.8.0)
|
65
|
+
rspec-core (~> 3.8.0)
|
66
|
+
rspec-expectations (~> 3.8.0)
|
67
|
+
rspec-mocks (~> 3.8.0)
|
68
|
+
rspec-core (3.8.0)
|
69
|
+
rspec-support (~> 3.8.0)
|
70
|
+
rspec-expectations (3.8.2)
|
71
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
72
|
+
rspec-support (~> 3.8.0)
|
73
|
+
rspec-mocks (3.8.0)
|
74
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
75
|
+
rspec-support (~> 3.8.0)
|
76
|
+
rspec-support (3.8.0)
|
77
|
+
sqlite3 (1.3.13)
|
78
|
+
thor (0.20.3)
|
79
|
+
thread_safe (0.3.6)
|
80
|
+
tzinfo (1.2.5)
|
81
|
+
thread_safe (~> 0.1)
|
82
|
+
|
83
|
+
PLATFORMS
|
84
|
+
ruby
|
85
|
+
|
86
|
+
DEPENDENCIES
|
87
|
+
actionview (= 4.2.0)
|
88
|
+
activerecord (= 4.2.0)
|
89
|
+
appraisal
|
90
|
+
bundler
|
91
|
+
ordy!
|
92
|
+
pry
|
93
|
+
rspec
|
94
|
+
sqlite3
|
95
|
+
|
96
|
+
BUNDLED WITH
|
97
|
+
1.3.0
|
@@ -0,0 +1,91 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
ordy (0.0.0)
|
5
|
+
actionview (>= 4.0.0)
|
6
|
+
activerecord (>= 4.0.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionview (5.0.0)
|
12
|
+
activesupport (= 5.0.0)
|
13
|
+
builder (~> 3.1)
|
14
|
+
erubis (~> 2.7.0)
|
15
|
+
rails-dom-testing (~> 2.0)
|
16
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
17
|
+
activemodel (5.0.0)
|
18
|
+
activesupport (= 5.0.0)
|
19
|
+
activerecord (5.0.0)
|
20
|
+
activemodel (= 5.0.0)
|
21
|
+
activesupport (= 5.0.0)
|
22
|
+
arel (~> 7.0)
|
23
|
+
activesupport (5.0.0)
|
24
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
25
|
+
i18n (~> 0.7)
|
26
|
+
minitest (~> 5.1)
|
27
|
+
tzinfo (~> 1.1)
|
28
|
+
appraisal (2.2.0)
|
29
|
+
bundler
|
30
|
+
rake
|
31
|
+
thor (>= 0.14.0)
|
32
|
+
arel (7.1.4)
|
33
|
+
builder (3.2.3)
|
34
|
+
coderay (1.1.2)
|
35
|
+
concurrent-ruby (1.1.4)
|
36
|
+
crass (1.0.4)
|
37
|
+
diff-lcs (1.3)
|
38
|
+
erubis (2.7.0)
|
39
|
+
i18n (0.9.5)
|
40
|
+
concurrent-ruby (~> 1.0)
|
41
|
+
loofah (2.2.3)
|
42
|
+
crass (~> 1.0.2)
|
43
|
+
nokogiri (>= 1.5.9)
|
44
|
+
method_source (0.9.2)
|
45
|
+
mini_portile2 (2.4.0)
|
46
|
+
minitest (5.11.3)
|
47
|
+
nokogiri (1.9.1)
|
48
|
+
mini_portile2 (~> 2.4.0)
|
49
|
+
pry (0.12.2)
|
50
|
+
coderay (~> 1.1.0)
|
51
|
+
method_source (~> 0.9.0)
|
52
|
+
rails-dom-testing (2.0.3)
|
53
|
+
activesupport (>= 4.2.0)
|
54
|
+
nokogiri (>= 1.6)
|
55
|
+
rails-html-sanitizer (1.0.4)
|
56
|
+
loofah (~> 2.2, >= 2.2.2)
|
57
|
+
rake (12.3.2)
|
58
|
+
rspec (3.8.0)
|
59
|
+
rspec-core (~> 3.8.0)
|
60
|
+
rspec-expectations (~> 3.8.0)
|
61
|
+
rspec-mocks (~> 3.8.0)
|
62
|
+
rspec-core (3.8.0)
|
63
|
+
rspec-support (~> 3.8.0)
|
64
|
+
rspec-expectations (3.8.2)
|
65
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
+
rspec-support (~> 3.8.0)
|
67
|
+
rspec-mocks (3.8.0)
|
68
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
69
|
+
rspec-support (~> 3.8.0)
|
70
|
+
rspec-support (3.8.0)
|
71
|
+
sqlite3 (1.3.13)
|
72
|
+
thor (0.20.3)
|
73
|
+
thread_safe (0.3.6)
|
74
|
+
tzinfo (1.2.5)
|
75
|
+
thread_safe (~> 0.1)
|
76
|
+
|
77
|
+
PLATFORMS
|
78
|
+
ruby
|
79
|
+
|
80
|
+
DEPENDENCIES
|
81
|
+
actionview (= 5.0.0)
|
82
|
+
activerecord (= 5.0.0)
|
83
|
+
appraisal
|
84
|
+
bundler
|
85
|
+
ordy!
|
86
|
+
pry
|
87
|
+
rspec
|
88
|
+
sqlite3
|
89
|
+
|
90
|
+
BUNDLED WITH
|
91
|
+
1.3.0
|
@@ -0,0 +1,91 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
ordy (0.0.0)
|
5
|
+
actionview (>= 4.0.0)
|
6
|
+
activerecord (>= 4.0.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionview (5.2.0)
|
12
|
+
activesupport (= 5.2.0)
|
13
|
+
builder (~> 3.1)
|
14
|
+
erubi (~> 1.4)
|
15
|
+
rails-dom-testing (~> 2.0)
|
16
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
17
|
+
activemodel (5.2.0)
|
18
|
+
activesupport (= 5.2.0)
|
19
|
+
activerecord (5.2.0)
|
20
|
+
activemodel (= 5.2.0)
|
21
|
+
activesupport (= 5.2.0)
|
22
|
+
arel (>= 9.0)
|
23
|
+
activesupport (5.2.0)
|
24
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
25
|
+
i18n (>= 0.7, < 2)
|
26
|
+
minitest (~> 5.1)
|
27
|
+
tzinfo (~> 1.1)
|
28
|
+
appraisal (2.2.0)
|
29
|
+
bundler
|
30
|
+
rake
|
31
|
+
thor (>= 0.14.0)
|
32
|
+
arel (9.0.0)
|
33
|
+
builder (3.2.3)
|
34
|
+
coderay (1.1.2)
|
35
|
+
concurrent-ruby (1.1.4)
|
36
|
+
crass (1.0.4)
|
37
|
+
diff-lcs (1.3)
|
38
|
+
erubi (1.8.0)
|
39
|
+
i18n (1.3.0)
|
40
|
+
concurrent-ruby (~> 1.0)
|
41
|
+
loofah (2.2.3)
|
42
|
+
crass (~> 1.0.2)
|
43
|
+
nokogiri (>= 1.5.9)
|
44
|
+
method_source (0.9.2)
|
45
|
+
mini_portile2 (2.4.0)
|
46
|
+
minitest (5.11.3)
|
47
|
+
nokogiri (1.9.1)
|
48
|
+
mini_portile2 (~> 2.4.0)
|
49
|
+
pry (0.12.2)
|
50
|
+
coderay (~> 1.1.0)
|
51
|
+
method_source (~> 0.9.0)
|
52
|
+
rails-dom-testing (2.0.3)
|
53
|
+
activesupport (>= 4.2.0)
|
54
|
+
nokogiri (>= 1.6)
|
55
|
+
rails-html-sanitizer (1.0.4)
|
56
|
+
loofah (~> 2.2, >= 2.2.2)
|
57
|
+
rake (12.3.2)
|
58
|
+
rspec (3.8.0)
|
59
|
+
rspec-core (~> 3.8.0)
|
60
|
+
rspec-expectations (~> 3.8.0)
|
61
|
+
rspec-mocks (~> 3.8.0)
|
62
|
+
rspec-core (3.8.0)
|
63
|
+
rspec-support (~> 3.8.0)
|
64
|
+
rspec-expectations (3.8.2)
|
65
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
+
rspec-support (~> 3.8.0)
|
67
|
+
rspec-mocks (3.8.0)
|
68
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
69
|
+
rspec-support (~> 3.8.0)
|
70
|
+
rspec-support (3.8.0)
|
71
|
+
sqlite3 (1.3.13)
|
72
|
+
thor (0.20.3)
|
73
|
+
thread_safe (0.3.6)
|
74
|
+
tzinfo (1.2.5)
|
75
|
+
thread_safe (~> 0.1)
|
76
|
+
|
77
|
+
PLATFORMS
|
78
|
+
ruby
|
79
|
+
|
80
|
+
DEPENDENCIES
|
81
|
+
actionview (= 5.2.0)
|
82
|
+
activerecord (= 5.2.0)
|
83
|
+
appraisal
|
84
|
+
bundler
|
85
|
+
ordy!
|
86
|
+
pry
|
87
|
+
rspec
|
88
|
+
sqlite3
|
89
|
+
|
90
|
+
BUNDLED WITH
|
91
|
+
1.3.0
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ordy
|
4
|
+
module Helpers
|
5
|
+
module ActionView
|
6
|
+
module OrderableLinkHelper
|
7
|
+
ORDER_ASC = 'asc'
|
8
|
+
ORDER_DESC = 'desc'
|
9
|
+
|
10
|
+
# order_link(Alert, :event, :asc)
|
11
|
+
#
|
12
|
+
# @param [String] title
|
13
|
+
# @param [Symbol] order_by
|
14
|
+
# @param [Symbol] direction
|
15
|
+
def order_link(title, order_by, direction = ORDER_ASC)
|
16
|
+
current_orderable, current_direction = request_params.values_at(:order_by, :direction)
|
17
|
+
|
18
|
+
direction = if current_direction.present?
|
19
|
+
current_direction == ORDER_ASC ? ORDER_DESC : ORDER_ASC
|
20
|
+
else
|
21
|
+
direction
|
22
|
+
end
|
23
|
+
|
24
|
+
icon_html = if current_orderable.present? && order_by.to_s == current_orderable
|
25
|
+
icon(direction)
|
26
|
+
else
|
27
|
+
icon(nil)
|
28
|
+
end
|
29
|
+
|
30
|
+
title = "#{title} #{icon_html}".html_safe
|
31
|
+
url_params = request_params.merge(order_by: "#{order_by}-#{direction}")
|
32
|
+
|
33
|
+
link_to(title, url_params)
|
34
|
+
end
|
35
|
+
|
36
|
+
# NOTE: In case you don't use Awesome Font override this method
|
37
|
+
#
|
38
|
+
# icon('asc')
|
39
|
+
#
|
40
|
+
# @param [String] direction
|
41
|
+
# @return [String]
|
42
|
+
def icon(direction = nil)
|
43
|
+
icon, html_class = if direction.nil?
|
44
|
+
[config.icon.sort, class: config.icon.inactive]
|
45
|
+
else
|
46
|
+
[direction == ORDER_DESC ? config.icon.up : config.icon.down, nil]
|
47
|
+
end
|
48
|
+
icon_class = "fa-#{icon}"
|
49
|
+
|
50
|
+
"<i class=\"fa #{icon_class} #{html_class}\"></i>"
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def request_params
|
56
|
+
request.params
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Ordy
|
2
|
+
module Orm
|
3
|
+
module ActiveRecord
|
4
|
+
module Orderable
|
5
|
+
class ByAssociation
|
6
|
+
# @param [Model::ActiveRecord_Relation] scope
|
7
|
+
# @param [Hash] args (:table, :column, :direction)
|
8
|
+
def self.call(scope, args)
|
9
|
+
table, column, direction = args.values_at(:table, :column, :direction)
|
10
|
+
|
11
|
+
scope.includes(args[:association]).order("#{table}.#{column} #{direction}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Ordy
|
2
|
+
module Orm
|
3
|
+
module ActiveRecord
|
4
|
+
module Orderable
|
5
|
+
class ByColumn
|
6
|
+
# @param [Model::ActiveRecord_Relation] scope
|
7
|
+
# @param [Hash] args (:table, :column, :direction)
|
8
|
+
def self.call(scope, args)
|
9
|
+
table, column, direction = args.values_at(:table, :column, :direction)
|
10
|
+
|
11
|
+
scope.order("#{table}.#{column} #{direction}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Ordy
|
2
|
+
module Orm
|
3
|
+
module ActiveRecord
|
4
|
+
module Orderable
|
5
|
+
class BySpecified
|
6
|
+
# @param [Model::ActiveRecord_Relation] scope
|
7
|
+
# @param [Hash] args (:table, :column)
|
8
|
+
def self.call(scope, args)
|
9
|
+
connection = scope.connection
|
10
|
+
table = connection.quote_table_name(args[:table])
|
11
|
+
column = connection.quote_column_name(args[:column])
|
12
|
+
values = args[:values].map { |value| connection.quote(value) }
|
13
|
+
|
14
|
+
sql = values.map { |value| "#{table}.#{column}=#{value} DESC" }.join(',')
|
15
|
+
|
16
|
+
connection.quote(sql)
|
17
|
+
scope.order(Arel.sql(sql))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|