other_joins 0.1.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5fc5fca16149be9cfc985e91180e80e8e7f892db
4
- data.tar.gz: 92bae71a9765043014239839bc621f0f082fdb65
3
+ metadata.gz: a73d9a260ced47f210e7474ab90894a7e1c8f2db
4
+ data.tar.gz: 235e1bf010a329e310c4ea916060e7d9985dd5df
5
5
  SHA512:
6
- metadata.gz: 35b737680fc429cc1e541a7af53dd867ab366eb76a51004996dae8ef234afb7c1df0405205fb23239c0f2ae66215ea9d9cb7159d32cf60bd5fcf1b70a1e9eaa8
7
- data.tar.gz: 4a98a5e7a3575308749de1ae276e9642ac83c70c8bbaf3a551fe21029faae35d351128fdc89a10b3b3990b9de0726927a6f57b608107bd02f9fccab4c8420528
6
+ metadata.gz: 363489393067329e34763120aa32510869cd1320fc5cadeb0a9f44faf770b17d84a2b1bcaf8e72d9a4ec19483a4754ae84859db057c334573196737b72be4c91
7
+ data.tar.gz: 7a2c00c9c9c787d0d7ef9e1b8b081d4d3a46d162d710d2998ed45d7840ff3711b3c1339cb35746d665d550cd0c692cb6af12e94bd6553d6d390d07ee18a75d02
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
  *~
11
11
  .*.swp
12
12
  *.gem
13
+ *.lock
data/.travis.yml CHANGED
@@ -1,4 +1,14 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.2.3
4
+ gemfile:
5
+ - gemfiles/activerecord_3.0.gemfile
6
+ - gemfiles/activerecord_3.2_.gemfile
7
+ - gemfiles/activerecord_4.0.gemfile
8
+ - gemfiles/activerecord_4.2_.gemfile
9
+ - gemfiles/activerecord_3.1.gemfile
10
+ - gemfiles/activerecord_3.2.gemfile
11
+ - gemfiles/activerecord_4.1.gemfile
12
+ - gemfiles/activerecord_4.2.gemfile
4
13
  before_install: gem install bundler -v 1.10.6
14
+ script: bundle exec rake test
data/Appraisals ADDED
@@ -0,0 +1,35 @@
1
+ appraise "activerecord-3.0" do
2
+ gem "activerecord", "~> 3.0.0"
3
+ gem "minitest"
4
+ end
5
+
6
+ appraise "activerecord-3.1" do
7
+ gem "activerecord", "~> 3.1.0"
8
+ gem "minitest"
9
+ end
10
+
11
+ appraise "activerecord-3.2" do
12
+ gem "activerecord", "~> 3.2.0"
13
+ gem "minitest"
14
+ end
15
+
16
+ appraise "activerecord-3.2+" do
17
+ gem "activerecord", "~> 3.2"
18
+ gem "minitest"
19
+ end
20
+
21
+ appraise "activerecord-4.0" do
22
+ gem "activerecord", "~> 4.0.0"
23
+ end
24
+
25
+ appraise "activerecord-4.1" do
26
+ gem "activerecord", "~> 4.1.0"
27
+ end
28
+
29
+ appraise "activerecord-4.2" do
30
+ gem "activerecord", "~> 4.2.0"
31
+ end
32
+
33
+ appraise "activerecord-4.2+" do
34
+ gem "activerecord", "~> 4.2"
35
+ end
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # OtherJoins
2
2
 
3
- Add obvious `left_joins`, `outer_joins`, `full_joins` methods to ActiveRecord as plain way to join tables.
3
+ Add obvious `left_joins`, `outer_joins` methods to ActiveRecord as plain way to join tables.
4
+
5
+ This version works with ActiveRecord (3.0.x - 4.2.x).
4
6
 
5
7
  ## Introdution
6
8
  Usually to join tables in Rails app you use something like this:
@@ -33,11 +35,9 @@ Not difficult, but it is bored and ungracefully. Instinctively we want to use `l
33
35
  ## Installation
34
36
 
35
37
  Add this line to your application's Gemfile:
36
-
37
38
  ```ruby
38
39
  gem 'other_joins'
39
40
  ```
40
-
41
41
  And then execute:
42
42
 
43
43
  $ bundle
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
1
3
  require "bundler/gem_tasks"
2
4
  require "rake/testtask"
3
5
 
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 3.0.0"
6
+ gem "minitest"
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 3.1.0"
6
+ gem "minitest"
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 3.2.0"
6
+ gem "minitest"
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 3.2"
6
+ gem "minitest"
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 4.0.0"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 4.1.0"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 4.2.0"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 4.2"
6
+
7
+ gemspec :path => "../"
data/lib/other_joins.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'active_record'
2
2
  require 'other_joins/version'
3
- require 'other_joins/other_joins_methods'
4
- require 'other_joins/active_record'
5
- require 'other_joins/left_join_dependency'
3
+ require 'other_joins/other_joins_way'
4
+ require "other_joins/activerecord-#{ActiveRecord::OTHER_JOINS_WAY}/other_joins_methods"
5
+ require "other_joins/activerecord-#{ActiveRecord::OTHER_JOINS_WAY}/other_joins_methods"
6
+ require "other_joins/activerecord-#{ActiveRecord::OTHER_JOINS_WAY}/active_record"
7
+ require "other_joins/activerecord-#{ActiveRecord::OTHER_JOINS_WAY}/left_join_dependency"
@@ -0,0 +1,13 @@
1
+ require 'active_support/core_ext/module'
2
+ module ActiveRecord
3
+
4
+ class Relation
5
+ include OtherJoinsMethods
6
+ end
7
+
8
+ class Base
9
+ class << self # Class methods
10
+ delegate :left_joins, :outer_joins, to: :scoped
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ module ActiveRecord
2
+ module Associations
3
+ module ClassMethods
4
+ class LeftJoinDependency < JoinDependency
5
+
6
+ protected
7
+ def build(associations, parent = nil, join_type = Arel::OuterJoin)
8
+ super
9
+ end
10
+
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ module OtherJoinsMethods
2
+ extend ActiveSupport::Concern
3
+
4
+ def left_joins(*args)
5
+ join_dependency = ActiveRecord::Associations::ClassMethods::LeftJoinDependency.new(
6
+ @klass,
7
+ args,
8
+ []
9
+ )
10
+ joins(join_dependency.join_associations)
11
+ end
12
+
13
+ alias outer_joins left_joins
14
+
15
+ end
@@ -0,0 +1,12 @@
1
+ module ActiveRecord
2
+ module Associations
3
+ class LeftJoinDependency < JoinDependency
4
+
5
+ protected
6
+ def build(associations, parent = nil, join_type = Arel::OuterJoin)
7
+ super
8
+ end
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ module OtherJoinsMethods
2
+ extend ActiveSupport::Concern
3
+
4
+ def left_joins(*args)
5
+ join_dependency = ActiveRecord::Associations::LeftJoinDependency.new(
6
+ @klass,
7
+ args,
8
+ []
9
+ )
10
+ joins(join_dependency.join_associations)
11
+ end
12
+
13
+
14
+ alias outer_joins left_joins
15
+
16
+ end
@@ -0,0 +1,11 @@
1
+ module ActiveRecord
2
+
3
+ class Relation
4
+ include OtherJoinsMethods
5
+ end
6
+
7
+ module Querying
8
+ delegate :left_joins, :outer_joins, to: :all
9
+ end
10
+
11
+ end
@@ -0,0 +1,17 @@
1
+ module ActiveRecord
2
+
3
+ class InvalidActiveRecordVersion < StandardError
4
+ end
5
+
6
+ OTHER_JOINS_WAY =
7
+ case
8
+ when ActiveRecord::VERSION::STRING =~ /^3/
9
+ 3
10
+ when ActiveRecord::VERSION::STRING =~ /^4.0/
11
+ 4.0
12
+ when ActiveRecord::VERSION::STRING =~ /^4.[1,2]/
13
+ 4.1
14
+ else
15
+ raise InvalidActiveRecordVersion, "Gem 'other_joins #{OtherJoins::VERSION}' cannot work with 'activerecord #{ActiveRecord.version}'"
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module OtherJoins
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/other_joins.gemspec CHANGED
@@ -19,8 +19,9 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency 'activerecord', '~> 4.1'
22
+ spec.add_dependency 'activerecord', '>= 3.0', '< 5'
23
23
 
24
+ spec.add_development_dependency 'appraisal'
24
25
  spec.add_development_dependency 'bundler', '~> 1.10'
25
26
  spec.add_development_dependency 'rake', '~> 11.1'
26
27
  spec.add_development_dependency 'sqlite3', '~> 1.3'
metadata CHANGED
@@ -1,29 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: other_joins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Levanevski-Perevozchikov Ilya
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-01 00:00:00.000000000 Z
11
+ date: 2016-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: '4.1'
22
+ version: '5'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5'
33
+ - !ruby/object:Gem::Dependency
34
+ name: appraisal
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
25
45
  - !ruby/object:Gem::Version
26
- version: '4.1'
46
+ version: '0'
27
47
  - !ruby/object:Gem::Dependency
28
48
  name: bundler
29
49
  requirement: !ruby/object:Gem::Requirement
@@ -78,6 +98,7 @@ extra_rdoc_files: []
78
98
  files:
79
99
  - ".gitignore"
80
100
  - ".travis.yml"
101
+ - Appraisals
81
102
  - CODE_OF_CONDUCT.md
82
103
  - Gemfile
83
104
  - LICENSE.txt
@@ -85,10 +106,25 @@ files:
85
106
  - Rakefile
86
107
  - bin/console
87
108
  - bin/setup
109
+ - gemfiles/activerecord_3.0.gemfile
110
+ - gemfiles/activerecord_3.1.gemfile
111
+ - gemfiles/activerecord_3.2.gemfile
112
+ - gemfiles/activerecord_3.2_.gemfile
113
+ - gemfiles/activerecord_4.0.gemfile
114
+ - gemfiles/activerecord_4.1.gemfile
115
+ - gemfiles/activerecord_4.2.gemfile
116
+ - gemfiles/activerecord_4.2_.gemfile
88
117
  - lib/other_joins.rb
89
- - lib/other_joins/active_record.rb
90
- - lib/other_joins/left_join_dependency.rb
91
- - lib/other_joins/other_joins_methods.rb
118
+ - lib/other_joins/activerecord-3/active_record.rb
119
+ - lib/other_joins/activerecord-3/left_join_dependency.rb
120
+ - lib/other_joins/activerecord-3/other_joins_methods.rb
121
+ - lib/other_joins/activerecord-4.0/active_record.rb
122
+ - lib/other_joins/activerecord-4.0/left_join_dependency.rb
123
+ - lib/other_joins/activerecord-4.0/other_joins_methods.rb
124
+ - lib/other_joins/activerecord-4.1/active_record.rb
125
+ - lib/other_joins/activerecord-4.1/left_join_dependency.rb
126
+ - lib/other_joins/activerecord-4.1/other_joins_methods.rb
127
+ - lib/other_joins/other_joins_way.rb
92
128
  - lib/other_joins/version.rb
93
129
  - other_joins.gemspec
94
130
  homepage: https://github.com/ilp416/other_joins
@@ -111,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
147
  version: '0'
112
148
  requirements: []
113
149
  rubyforge_project:
114
- rubygems_version: 2.4.8
150
+ rubygems_version: 2.4.3
115
151
  signing_key:
116
152
  specification_version: 4
117
153
  summary: Some joins methods for ActiveRecord