left_join 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +102 -0
- data/LICENSE.txt +20 -0
- data/README.md +43 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/left_join.gemspec +72 -0
- data/lib/left_join.rb +23 -0
- data/lib/left_join/adapters/active_record_adapter.rb +43 -0
- data/lib/left_join/node.rb +1 -0
- data/spec/left_join_spec.rb +50 -0
- data/spec/spec_helper.rb +48 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c226ac4666aed1a80fcc689ace520632c2ea831f
|
4
|
+
data.tar.gz: 402f3e1674f93254b76a6c79bb01c4617899b96e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: acf5969fefa5c6a2a89ad968e45e6e860dd645582e361be7716ce543f5c0379ebde0620c0c3aa6f45d39994bc946ed2636c7d0360b571cdced988e5c4e62777f
|
7
|
+
data.tar.gz: 85e33528364c50b89d5c02ef42882d5111e69263bcecbe31b4625adeb8fcc5ab81021edd63dd2cdb698c54538b7eced80e8637b22ce6b27db467aa0fcae5c2f9
|
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
# Add dependencies to develop your gem here.
|
4
|
+
# Include everything needed to run rake, tests, features, etc.
|
5
|
+
group :development do
|
6
|
+
gem 'rspec', '~> 3.3.0'
|
7
|
+
gem 'rdoc', '~> 3.12'
|
8
|
+
gem 'bundler', '~> 1.0'
|
9
|
+
gem 'jeweler', '~> 2.0.1'
|
10
|
+
gem 'simplecov', '>= 0'
|
11
|
+
gem 'sqlite3'
|
12
|
+
gem 'activerecord'
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activemodel (4.2.4)
|
5
|
+
activesupport (= 4.2.4)
|
6
|
+
builder (~> 3.1)
|
7
|
+
activerecord (4.2.4)
|
8
|
+
activemodel (= 4.2.4)
|
9
|
+
activesupport (= 4.2.4)
|
10
|
+
arel (~> 6.0)
|
11
|
+
activesupport (4.2.4)
|
12
|
+
i18n (~> 0.7)
|
13
|
+
json (~> 1.7, >= 1.7.7)
|
14
|
+
minitest (~> 5.1)
|
15
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
16
|
+
tzinfo (~> 1.1)
|
17
|
+
addressable (2.3.8)
|
18
|
+
arel (6.0.3)
|
19
|
+
builder (3.2.2)
|
20
|
+
descendants_tracker (0.0.4)
|
21
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
22
|
+
diff-lcs (1.2.5)
|
23
|
+
docile (1.1.5)
|
24
|
+
faraday (0.9.2)
|
25
|
+
multipart-post (>= 1.2, < 3)
|
26
|
+
git (1.2.9.1)
|
27
|
+
github_api (0.12.4)
|
28
|
+
addressable (~> 2.3)
|
29
|
+
descendants_tracker (~> 0.0.4)
|
30
|
+
faraday (~> 0.8, < 0.10)
|
31
|
+
hashie (>= 3.4)
|
32
|
+
multi_json (>= 1.7.5, < 2.0)
|
33
|
+
nokogiri (~> 1.6.6)
|
34
|
+
oauth2
|
35
|
+
hashie (3.4.2)
|
36
|
+
highline (1.7.7)
|
37
|
+
i18n (0.7.0)
|
38
|
+
jeweler (2.0.1)
|
39
|
+
builder
|
40
|
+
bundler (>= 1.0)
|
41
|
+
git (>= 1.2.5)
|
42
|
+
github_api
|
43
|
+
highline (>= 1.6.15)
|
44
|
+
nokogiri (>= 1.5.10)
|
45
|
+
rake
|
46
|
+
rdoc
|
47
|
+
json (1.8.3)
|
48
|
+
jwt (1.5.1)
|
49
|
+
mini_portile (0.6.2)
|
50
|
+
minitest (5.8.0)
|
51
|
+
multi_json (1.11.2)
|
52
|
+
multi_xml (0.5.5)
|
53
|
+
multipart-post (2.0.0)
|
54
|
+
nokogiri (1.6.6.2)
|
55
|
+
mini_portile (~> 0.6.0)
|
56
|
+
oauth2 (1.0.0)
|
57
|
+
faraday (>= 0.8, < 0.10)
|
58
|
+
jwt (~> 1.0)
|
59
|
+
multi_json (~> 1.3)
|
60
|
+
multi_xml (~> 0.5)
|
61
|
+
rack (~> 1.2)
|
62
|
+
rack (1.6.4)
|
63
|
+
rake (10.4.2)
|
64
|
+
rdoc (3.12.2)
|
65
|
+
json (~> 1.4)
|
66
|
+
rspec (3.3.0)
|
67
|
+
rspec-core (~> 3.3.0)
|
68
|
+
rspec-expectations (~> 3.3.0)
|
69
|
+
rspec-mocks (~> 3.3.0)
|
70
|
+
rspec-core (3.3.2)
|
71
|
+
rspec-support (~> 3.3.0)
|
72
|
+
rspec-expectations (3.3.1)
|
73
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
74
|
+
rspec-support (~> 3.3.0)
|
75
|
+
rspec-mocks (3.3.2)
|
76
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
77
|
+
rspec-support (~> 3.3.0)
|
78
|
+
rspec-support (3.3.0)
|
79
|
+
simplecov (0.10.0)
|
80
|
+
docile (~> 1.1.0)
|
81
|
+
json (~> 1.8)
|
82
|
+
simplecov-html (~> 0.10.0)
|
83
|
+
simplecov-html (0.10.0)
|
84
|
+
sqlite3 (1.3.10)
|
85
|
+
thread_safe (0.3.5)
|
86
|
+
tzinfo (1.2.2)
|
87
|
+
thread_safe (~> 0.1)
|
88
|
+
|
89
|
+
PLATFORMS
|
90
|
+
ruby
|
91
|
+
|
92
|
+
DEPENDENCIES
|
93
|
+
activerecord
|
94
|
+
bundler (~> 1.0)
|
95
|
+
jeweler (~> 2.0.1)
|
96
|
+
rdoc (~> 3.12)
|
97
|
+
rspec (~> 3.3.0)
|
98
|
+
simplecov
|
99
|
+
sqlite3
|
100
|
+
|
101
|
+
BUNDLED WITH
|
102
|
+
1.10.6
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2015 Diego Aguir Selzlein
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# left_join
|
2
|
+
|
3
|
+
This gem helps you doing `LEFT JOIN`s between your ActiveRecord associations, so
|
4
|
+
you can do this:
|
5
|
+
|
6
|
+
```ruby
|
7
|
+
Book.left_join(:category)
|
8
|
+
# SELECT "books".* FROM "books"
|
9
|
+
# LEFT OUTER JOIN "categories"
|
10
|
+
# ON "books"."category_id" = "categories"."id"
|
11
|
+
```
|
12
|
+
|
13
|
+
## Why?
|
14
|
+
|
15
|
+
See [this blog post](http://nerde.github.io/posts/a-better-left-join-with-active-record/)
|
16
|
+
for details.
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
Add to your Gemfile:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
gem 'left_join'
|
24
|
+
```
|
25
|
+
|
26
|
+
Or install it manually
|
27
|
+
|
28
|
+
```
|
29
|
+
gem install left_join
|
30
|
+
```
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
* Fork the project.
|
35
|
+
* Start a feature/bugfix branch.
|
36
|
+
* Commit and push until you are happy with your contribution.
|
37
|
+
* Make sure to add tests for it. This is important so I don't break it in a
|
38
|
+
future version unintentionally.
|
39
|
+
* Create a pull request.
|
40
|
+
|
41
|
+
## Copyright
|
42
|
+
|
43
|
+
Copyright (c) 2015 Diego Aguir Selzlein. See LICENSE.txt for further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts 'Run `bundle install` to install missing gems'
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification...
|
17
|
+
# see http://guides.rubygems.org/specification-reference/ for more options
|
18
|
+
gem.name = 'left_join'
|
19
|
+
gem.homepage = 'http://github.com/nerde/left_join'
|
20
|
+
gem.license = 'MIT'
|
21
|
+
gem.summary = 'LEFT JOIN with ActiveRecord'
|
22
|
+
gem.description = 'This gem helps doing LEFT JOIN\'s between ActiveRecord '\
|
23
|
+
'associations'
|
24
|
+
gem.email = 'diegoselzlein@gmail.com'
|
25
|
+
gem.authors = ['Diego Aguir Selzlein']
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rspec/core'
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
32
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'Code coverage detail'
|
36
|
+
task :simplecov do
|
37
|
+
ENV['COVERAGE'] = 'true'
|
38
|
+
Rake::Task['spec'].execute
|
39
|
+
end
|
40
|
+
|
41
|
+
task default: :spec
|
42
|
+
|
43
|
+
require 'rdoc/task'
|
44
|
+
Rake::RDocTask.new do |rdoc|
|
45
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ''
|
46
|
+
|
47
|
+
rdoc.rdoc_dir = 'rdoc'
|
48
|
+
rdoc.title = "left_join #{version}"
|
49
|
+
rdoc.rdoc_files.include('README*')
|
50
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
51
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/left_join.gemspec
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: left_join 0.1.0 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "left_join"
|
9
|
+
s.version = "0.1.0"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.authors = ["Diego Aguir Selzlein"]
|
14
|
+
s.date = "2015-10-09"
|
15
|
+
s.description = "This gem helps doing LEFT JOIN's between ActiveRecord associations"
|
16
|
+
s.email = "diegoselzlein@gmail.com"
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".rspec",
|
24
|
+
"Gemfile",
|
25
|
+
"Gemfile.lock",
|
26
|
+
"LICENSE.txt",
|
27
|
+
"README.md",
|
28
|
+
"Rakefile",
|
29
|
+
"VERSION",
|
30
|
+
"left_join.gemspec",
|
31
|
+
"lib/left_join.rb",
|
32
|
+
"lib/left_join/adapters/active_record_adapter.rb",
|
33
|
+
"lib/left_join/node.rb",
|
34
|
+
"spec/left_join_spec.rb",
|
35
|
+
"spec/spec_helper.rb"
|
36
|
+
]
|
37
|
+
s.homepage = "http://github.com/nerde/left_join"
|
38
|
+
s.licenses = ["MIT"]
|
39
|
+
s.rubygems_version = "2.4.5.1"
|
40
|
+
s.summary = "LEFT JOIN with ActiveRecord"
|
41
|
+
|
42
|
+
if s.respond_to? :specification_version then
|
43
|
+
s.specification_version = 4
|
44
|
+
|
45
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
46
|
+
s.add_development_dependency(%q<rspec>, ["~> 3.3.0"])
|
47
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
48
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
49
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
50
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
51
|
+
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
52
|
+
s.add_development_dependency(%q<activerecord>, [">= 0"])
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<rspec>, ["~> 3.3.0"])
|
55
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
56
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
57
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
58
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
59
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
60
|
+
s.add_dependency(%q<activerecord>, [">= 0"])
|
61
|
+
end
|
62
|
+
else
|
63
|
+
s.add_dependency(%q<rspec>, ["~> 3.3.0"])
|
64
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
65
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
66
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
67
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
68
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
69
|
+
s.add_dependency(%q<activerecord>, [">= 0"])
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
data/lib/left_join.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module LeftJoin
|
2
|
+
autoload :Node, 'left_join/node'
|
3
|
+
|
4
|
+
def self.parse_to_nodes(arguments, context)
|
5
|
+
[].tap do |result|
|
6
|
+
case arguments
|
7
|
+
when Hash
|
8
|
+
arguments.each do |key, value|
|
9
|
+
result.concat parse_to_nodes(key, context)
|
10
|
+
result.concat parse_to_nodes(value, context.left_join_subcontext(key))
|
11
|
+
end
|
12
|
+
when Array
|
13
|
+
arguments.each do |value|
|
14
|
+
result.concat parse_to_nodes(value, context)
|
15
|
+
end
|
16
|
+
else
|
17
|
+
result << context.node_for_left_join(arguments)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'left_join/adapters/active_record_adapter'
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module LeftJoin
|
2
|
+
module Adapters
|
3
|
+
module ActiveRecordAdapter
|
4
|
+
# Does a left join through an association. Usage:
|
5
|
+
#
|
6
|
+
# Book.left_join(:category)
|
7
|
+
# # SELECT "books".* FROM "books"
|
8
|
+
# # LEFT OUTER JOIN "categories"
|
9
|
+
# # ON "books"."category_id" = "categories"."id"
|
10
|
+
#
|
11
|
+
# It also works through association's associations, like `joins` does:
|
12
|
+
#
|
13
|
+
# Book.left_join(category: :master_category)
|
14
|
+
def left_join(*columns)
|
15
|
+
LeftJoin.parse_to_nodes(columns, self).inject(all) do |acc, association|
|
16
|
+
table = association.active_record.arel_table
|
17
|
+
join_table = association.klass.arel_table
|
18
|
+
foreign_key = association.foreign_key
|
19
|
+
primary_key = association.association_primary_key.to_sym
|
20
|
+
unless association.belongs_to?
|
21
|
+
foreign_key, primary_key = primary_key, foreign_key
|
22
|
+
end
|
23
|
+
|
24
|
+
arel_join = table.join(join_table, Arel::Nodes::OuterJoin) \
|
25
|
+
.on(table[foreign_key].eq(join_table[primary_key]))
|
26
|
+
acc.joins(arel_join.join_sources)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def node_for_left_join(key)
|
31
|
+
reflect_on_association(key) ||
|
32
|
+
fail("#{self} has no association: #{key}.")
|
33
|
+
end
|
34
|
+
|
35
|
+
def left_join_subcontext(key)
|
36
|
+
node_for_left_join(key).klass
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
ActiveRecord::Base.extend ActiveRecordAdapter if defined?(ActiveRecord)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
LeftJoin::Node = Struct.new(:key, :context)
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
class Category < ActiveRecord::Base
|
4
|
+
has_many :books
|
5
|
+
end
|
6
|
+
|
7
|
+
class Author < ActiveRecord::Base
|
8
|
+
has_many :books
|
9
|
+
end
|
10
|
+
|
11
|
+
class Book < ActiveRecord::Base
|
12
|
+
belongs_to :author
|
13
|
+
belongs_to :category
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'LeftJoin' do
|
17
|
+
it 'generates a LEFT OUTER JOIN SQL' do
|
18
|
+
expect(Book.left_join(:category).to_sql).to eq(
|
19
|
+
"SELECT \"books\".* FROM \"books\" LEFT OUTER JOIN \"categories\" ON "\
|
20
|
+
"\"books\".\"category_id\" = \"categories\".\"id\"")
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'works with nested associations' do
|
24
|
+
expect(Category.left_join(books: :author).to_sql).to eq(
|
25
|
+
"SELECT \"categories\".* FROM \"categories\" "\
|
26
|
+
"LEFT OUTER JOIN \"books\" ON "\
|
27
|
+
"\"categories\".\"id\" = \"books\".\"category_id\" "\
|
28
|
+
"LEFT OUTER JOIN \"authors\" ON "\
|
29
|
+
"\"books\".\"author_id\" = \"authors\".\"id\"")
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'parses single argument to nodes' do
|
33
|
+
expect(LeftJoin.parse_to_nodes(:category, Book)).to eq [
|
34
|
+
Book.reflect_on_association(:category)]
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'parses array argument to nodes' do
|
38
|
+
expect(LeftJoin.parse_to_nodes([:category, :author], Book)).to eq [
|
39
|
+
Book.reflect_on_association(:category),
|
40
|
+
Book.reflect_on_association(:author)
|
41
|
+
]
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'parses hash argument to nodes' do
|
45
|
+
expect(LeftJoin.parse_to_nodes({ books: :author }, Category)).to eq [
|
46
|
+
Category.reflect_on_association(:books),
|
47
|
+
Book.reflect_on_association(:author)
|
48
|
+
]
|
49
|
+
end
|
50
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
module SimpleCov::Configuration
|
4
|
+
def clean_filters
|
5
|
+
@filters = []
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
SimpleCov.configure do
|
10
|
+
clean_filters
|
11
|
+
load_profile 'test_frameworks'
|
12
|
+
end
|
13
|
+
|
14
|
+
ENV['COVERAGE'] && SimpleCov.start do
|
15
|
+
add_filter '/.rvm/'
|
16
|
+
add_filter '/.rbenv/'
|
17
|
+
end
|
18
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
19
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
20
|
+
|
21
|
+
require 'active_record'
|
22
|
+
require 'left_join'
|
23
|
+
require 'rspec'
|
24
|
+
|
25
|
+
# Requires supporting files with custom matchers and macros, etc,
|
26
|
+
# in ./support/ and its subdirectories.
|
27
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
28
|
+
|
29
|
+
RSpec.configure do |config|
|
30
|
+
config.before(:suite) do
|
31
|
+
ActiveRecord::Base.establish_connection adapter: 'sqlite3',
|
32
|
+
database: ':memory:'
|
33
|
+
ActiveRecord::Schema.define do
|
34
|
+
create_table :books do |t|
|
35
|
+
t.string :name
|
36
|
+
t.integer :category_id
|
37
|
+
end
|
38
|
+
|
39
|
+
create_table :authors do |t|
|
40
|
+
t.string :name
|
41
|
+
end
|
42
|
+
|
43
|
+
create_table :categories do |t|
|
44
|
+
t.string :name
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: left_join
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Diego Aguir Selzlein
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.3.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.3.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jeweler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.0.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.0.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sqlite3
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: activerecord
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: This gem helps doing LEFT JOIN's between ActiveRecord associations
|
112
|
+
email: diegoselzlein@gmail.com
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files:
|
116
|
+
- LICENSE.txt
|
117
|
+
- README.md
|
118
|
+
files:
|
119
|
+
- ".document"
|
120
|
+
- ".rspec"
|
121
|
+
- Gemfile
|
122
|
+
- Gemfile.lock
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- VERSION
|
127
|
+
- left_join.gemspec
|
128
|
+
- lib/left_join.rb
|
129
|
+
- lib/left_join/adapters/active_record_adapter.rb
|
130
|
+
- lib/left_join/node.rb
|
131
|
+
- spec/left_join_spec.rb
|
132
|
+
- spec/spec_helper.rb
|
133
|
+
homepage: http://github.com/nerde/left_join
|
134
|
+
licenses:
|
135
|
+
- MIT
|
136
|
+
metadata: {}
|
137
|
+
post_install_message:
|
138
|
+
rdoc_options: []
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
requirements: []
|
152
|
+
rubyforge_project:
|
153
|
+
rubygems_version: 2.4.5.1
|
154
|
+
signing_key:
|
155
|
+
specification_version: 4
|
156
|
+
summary: LEFT JOIN with ActiveRecord
|
157
|
+
test_files: []
|