arel-order 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1f0f0f8355e6d758e92a01bac027da7de12df430
4
+ data.tar.gz: a4fe1f0b030e47af735df5f485fdb6c8b92c6cb2
5
+ SHA512:
6
+ metadata.gz: 03db0038719b147756cbf40f456c186e5060c3c0cb79bdc2041328efaa6be800aa0c4d98c0d986b8691ccec8ffe27143b5f9bfdfe5bf27bcf3cd161e08488be1
7
+ data.tar.gz: ec7417711162c2b40c2539d75cd4ec7fa7c0fa1f0ac204f8edbdb6f46d03219f35f4fb243283ad0ee3d96bd764b0a6448328fb99e6a0ad30c16d9ce184702549
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ .ruby-version
4
+ pkg/
5
+ tmp/
6
+ /.idea/
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.4.0
5
+
6
+ cache: bundler
7
+
8
+ gemfile:
9
+ - gemfiles/arel_6.x.gemfile
10
+ - gemfiles/arel_8.x.gemfile
@@ -0,0 +1,10 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ appraise 'arel-6.x' do
5
+ gem 'arel', '~> 6.0'
6
+ end
7
+
8
+ appraise 'arel-8.x' do
9
+ gem 'arel', '~> 8.0'
10
+ end
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ source 'https://rubygems.org'
5
+ gemspec
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ arel-order (1.0.0)
5
+ arel (>= 6.0)
6
+ arel-to-sql (~> 1.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ appraisal (2.1.0)
12
+ bundler
13
+ rake
14
+ thor (>= 0.14.0)
15
+ arel (8.0.0)
16
+ arel-to-sql (1.0.0)
17
+ arel (>= 6.0)
18
+ power_assert (1.0.1)
19
+ rake (12.0.0)
20
+ test-unit (3.2.3)
21
+ power_assert
22
+ thor (0.19.4)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ appraisal (~> 2.1)
29
+ arel-order!
30
+ bundler (~> 1.7)
31
+ rake (~> 12.0)
32
+ test-unit (~> 3.2)
33
+
34
+ BUNDLED WITH
35
+ 1.14.3
@@ -0,0 +1,37 @@
1
+ ## Adds several methods which help to build `ORDER BY` statements.
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/arel-order.svg)](https://badge.fury.io/rb/arel-order)
4
+ [![Build Status](https://travis-ci.org/yivo/arel-order.svg?branch=master)](https://travis-ci.org/yivo/arel-order)
5
+
6
+ ## About
7
+ `Àrel::Attributes::Attribute` receives several methods which help to build `ORDER BY` statements.
8
+
9
+ ## Usage
10
+ ```ruby
11
+ # Query posts: posts with category get bigger priority.
12
+ t = Post.arel_table
13
+ Post.order("(#{t[:category_id]} > 0), #{t[:position].order_asc}")
14
+ # SELECT * FROM `posts` ORDER BY (`posts`.`category_id` IS NOT NULL), `posts`.`position` ASC
15
+ ```
16
+
17
+ ## Installing gem
18
+ Add to your Gemfile:
19
+ ```ruby
20
+ gem 'arel-order', '~> 1.0'
21
+ ```
22
+
23
+ ## Running Tests
24
+ Install bundler:
25
+ ```bash
26
+ gem install bundler
27
+ ```
28
+
29
+ Install dependencies:
30
+ ```bash
31
+ cd arel-order && bundle
32
+ ```
33
+
34
+ Run tests:
35
+ ```bash
36
+ cd arel-order && appraisal rake test
37
+ ```
@@ -0,0 +1,8 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new { |t| t.libs << 'test' }
7
+
8
+ task default: :test
@@ -0,0 +1,26 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ require File.expand_path('../lib/arel-order/version', __FILE__)
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'arel-order'
8
+ s.version = ArelOrder::VERSION
9
+ s.author = 'Yaroslav Konoplov'
10
+ s.email = 'eahome00@gmail.com'
11
+ s.summary = 'Adds several methods which help to build ORDER BY statements.'
12
+ s.description = 'Adds several methods which help to build ORDER BY statements.'
13
+ s.homepage = 'https://github.com/yivo/arel-order'
14
+ s.license = 'MIT'
15
+
16
+ s.files = `git ls-files -z`.split("\x0")
17
+ s.test_files = `git ls-files -z -- {test,spec,features}/*`.split("\x0")
18
+ s.require_paths = ['lib']
19
+
20
+ s.add_dependency 'arel', '>= 6.0'
21
+ s.add_dependency 'arel-to-sql', '~> 1.0'
22
+ s.add_development_dependency 'rake', '~> 12.0'
23
+ s.add_development_dependency 'test-unit', '~> 3.2'
24
+ s.add_development_dependency 'bundler', '~> 1.7'
25
+ s.add_development_dependency 'appraisal', '~> 2.1'
26
+ end
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "arel", "~> 6.0"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,36 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ arel-order (1.0.0)
5
+ arel (>= 6.0)
6
+ arel-to-sql (~> 1.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ appraisal (2.1.0)
12
+ bundler
13
+ rake
14
+ thor (>= 0.14.0)
15
+ arel (6.0.4)
16
+ arel-to-sql (1.0.0)
17
+ arel (>= 6.0)
18
+ power_assert (1.0.1)
19
+ rake (12.0.0)
20
+ test-unit (3.2.3)
21
+ power_assert
22
+ thor (0.19.4)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ appraisal (~> 2.1)
29
+ arel (~> 6.0)
30
+ arel-order!
31
+ bundler (~> 1.7)
32
+ rake (~> 12.0)
33
+ test-unit (~> 3.2)
34
+
35
+ BUNDLED WITH
36
+ 1.14.3
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "arel", "~> 8.0"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,36 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ arel-order (1.0.0)
5
+ arel (>= 6.0)
6
+ arel-to-sql (~> 1.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ appraisal (2.1.0)
12
+ bundler
13
+ rake
14
+ thor (>= 0.14.0)
15
+ arel (8.0.0)
16
+ arel-to-sql (1.0.0)
17
+ arel (>= 6.0)
18
+ power_assert (1.0.1)
19
+ rake (12.0.0)
20
+ test-unit (3.2.3)
21
+ power_assert
22
+ thor (0.19.4)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ appraisal (~> 2.1)
29
+ arel (~> 8.0)
30
+ arel-order!
31
+ bundler (~> 1.7)
32
+ rake (~> 12.0)
33
+ test-unit (~> 3.2)
34
+
35
+ BUNDLED WITH
36
+ 1.14.3
@@ -0,0 +1,19 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ module ArelOrder
5
+ module Extension
6
+ def order_asc
7
+ "#{to_sql} ASC"
8
+ end
9
+
10
+ def order_desc
11
+ "#{to_sql} DESC"
12
+ end
13
+ end
14
+ end
15
+
16
+ require 'arel'
17
+ require 'arel-to-sql'
18
+
19
+ Arel::Attributes::Attribute.include ArelOrder::Extension
@@ -0,0 +1,6 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ module ArelOrder
5
+ VERSION = '1.0.0'
6
+ end
@@ -0,0 +1,39 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler'
5
+ Bundler.require :default, :development, :test
6
+
7
+ class FakeRecord
8
+ class Connection
9
+ def quote_table_name(name)
10
+ "`#{name}`"
11
+ end
12
+
13
+ def quote_column_name(name)
14
+ "`#{name}`"
15
+ end
16
+
17
+ def quote(value)
18
+ String === value ? "'#{value}'" : value
19
+ end
20
+ end
21
+
22
+ class << self
23
+ attr_accessor :connection
24
+ end
25
+
26
+ self.connection = Connection.new
27
+ end
28
+
29
+ class ArelToSQLTest < Test::Unit::TestCase
30
+ def test_order
31
+ table = Arel::Table.new(:users)
32
+ assert_equal '`users`.`name` ASC', table[:name].order_asc
33
+ end
34
+
35
+ def setup
36
+ super
37
+ Arel::Table.engine = FakeRecord
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: arel-order
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Yaroslav Konoplov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: arel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '6.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '6.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: arel-to-sql
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.2'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: appraisal
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.1'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.1'
97
+ description: Adds several methods which help to build ORDER BY statements.
98
+ email: eahome00@gmail.com
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - ".gitignore"
104
+ - ".travis.yml"
105
+ - Appraisals
106
+ - Gemfile
107
+ - Gemfile.lock
108
+ - README.md
109
+ - Rakefile
110
+ - arel-order.gemspec
111
+ - gemfiles/arel_6.x.gemfile
112
+ - gemfiles/arel_6.x.gemfile.lock
113
+ - gemfiles/arel_8.x.gemfile
114
+ - gemfiles/arel_8.x.gemfile.lock
115
+ - lib/arel-order.rb
116
+ - lib/arel-order/version.rb
117
+ - test/test-arel-order.rb
118
+ homepage: https://github.com/yivo/arel-order
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.6.8
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Adds several methods which help to build ORDER BY statements.
142
+ test_files:
143
+ - test/test-arel-order.rb