order_with_null 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 92b2dbd0eae9350c582063b4e1ccecc9c3dc0e56
4
+ data.tar.gz: ed0dfee090bff51717867aba3a68f1b19a08eb45
5
+ SHA512:
6
+ metadata.gz: 035c65a04fcd4ac0d0d9d0f69cc3f67adfd4905feef43d4b8ec9730914ffbbcc733fb548ec542ccdc23a1246320ccf03dcf8ca6d933dadaba575fa60e2d79b7e
7
+ data.tar.gz: 1919c0d6c6414a4505db9dc37ab9e190a80aa78b2f6f6cf7f96dbf5abbdabcb0d313ccbaf7e051e78f56d2bfbc698fd9216295716068f8d687f247203912ec15
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in order_with_null.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 smoriwaki
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,33 @@
1
+ # OrderWithNull
2
+
3
+ Add support options of ordering about null values for PostgreSQL.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'order_with_null'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install order_with_null
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ User.order(User.arel_table[:age].desc.nulls_last)
25
+ User.order(User.arel_table[:name].asc.nulls_first)
26
+ Product.order(Arel::Nodes::InfixOperation.new('*', Product.arel_table[:price], Product.arel_table[:quantity]).desc.nulls_last)
27
+ Product.order(Arel::Nodes::NullsFirst.new(Arel::Nodes::Descending.new(Product.arel_table[:quantity])))
28
+ ```
29
+
30
+ ## Contributing
31
+
32
+ Bug reports and pull requests are accepted on GitHub at https://github.com/smoriwaki/order_with_null.
33
+
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "order_with_null"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,6 @@
1
+ module Arel
2
+ module Nodes
3
+ class NullsFirst < Unary
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Arel
2
+ module Nodes
3
+ class NullsLast < Unary
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,11 @@
1
+ module Arel
2
+ module NullsOrderPredications
3
+ def nulls_last
4
+ Nodes::NullsLast.new self
5
+ end
6
+
7
+ def nulls_first
8
+ Nodes::NullsFirst.new self
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ module Arel
2
+ module Visitors
3
+ class PostgreSQL
4
+ private
5
+ def visit_Arel_Nodes_NullsFirst(o, collector)
6
+ visit(o.expr, collector) << ' NULLS FIRST'
7
+ end
8
+
9
+ def visit_Arel_Nodes_NullsLast(o, collector)
10
+ visit(o.expr, collector) << ' NULLS LAST'
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ require 'order_with_null/version'
2
+ require 'arel'
3
+ require 'arel/nodes/nulls_first'
4
+ require 'arel/nodes/nulls_last'
5
+ require 'arel/visitors/postgresql_with_null'
6
+ require 'arel/nulls_order_predications'
7
+
8
+ module Arel
9
+ module Nodes
10
+ class Ordering
11
+ include NullsOrderPredications
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module OrderWithNull
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'order_with_null/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'order_with_null'
8
+ spec.version = OrderWithNull::VERSION
9
+ spec.authors = ['smoriwaki']
10
+ spec.email = ['smoriwaki@cuon.co.jp']
11
+
12
+ spec.summary = %q{Add support options of ordering about null values.}
13
+ spec.description = %q{Add support options of ordering about null values for PostgreSQL.}
14
+ spec.homepage = 'https://github.com/smoriwaki/order_with_null'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_dependency 'arel'
25
+ spec.add_development_dependency 'bundler'
26
+ spec.add_development_dependency 'rake'
27
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: order_with_null
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - smoriwaki
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-08-02 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Add support options of ordering about null values for PostgreSQL.
56
+ email:
57
+ - smoriwaki@cuon.co.jp
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - bin/console
68
+ - bin/setup
69
+ - lib/arel/nodes/nulls_first.rb
70
+ - lib/arel/nodes/nulls_last.rb
71
+ - lib/arel/nulls_order_predications.rb
72
+ - lib/arel/visitors/postgresql_with_null.rb
73
+ - lib/order_with_null.rb
74
+ - lib/order_with_null/version.rb
75
+ - order_with_null.gemspec
76
+ homepage: https://github.com/smoriwaki/order_with_null
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.6.11
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Add support options of ordering about null values.
100
+ test_files: []