pluckers 1.0.0 → 1.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.
- checksums.yaml +4 -4
- data/Appraisals +8 -2
- data/CHANGELOG +5 -0
- data/Gemfile.lock +2 -2
- data/lib/pluckers/base.rb +2 -0
- data/lib/pluckers/features/active_record_5_1/belongs_to_reflections.rb +15 -0
- data/lib/pluckers/features/active_record_5_1/globalize.rb +11 -0
- data/lib/pluckers/features/active_record_5_1/has_and_belongs_to_many_reflections.rb +39 -0
- data/lib/pluckers/features/active_record_5_1/has_many_reflections.rb +15 -0
- data/lib/pluckers/features/active_record_5_1/has_many_through_reflections.rb +17 -0
- data/lib/pluckers/features/active_record_5_1/has_one_reflections.rb +16 -0
- data/lib/pluckers/features/active_record_5_1/has_one_through_reflections.rb +17 -0
- data/lib/pluckers/features/active_record_5_1/pluck.rb +11 -0
- data/lib/pluckers/features/active_record_5_1/renaming.rb +11 -0
- data/lib/pluckers/features/active_record_5_1/simple_attributes.rb +11 -0
- data/lib/pluckers/features/active_record_5_1.rb +10 -0
- data/lib/pluckers/version.rb +1 -1
- data/pluckers.gemspec +1 -1
- metadata +15 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10653c054f2f3f14416d637e63f0bc16e4edb2e2
|
4
|
+
data.tar.gz: 5e95ef0ad68d42be2f1d9441643f406af2470182
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90895821d10b8c43a6228bbdc5430e44056b5ee6f3c955a4c4d453d71cf1d87f79f5b3b8c5ca6aa780096bcb99e8c0487ebc9d7a0f7b8d1ba8b9fbff8af37993
|
7
|
+
data.tar.gz: 67ed05fd97c758af0d3cbdd0920e161c6b66ed843f49ae018e1224fb4ab1256f8e83c6c7632641b7ef9e479be429bc36ff871834df1473b602807851a45a16a0
|
data/Appraisals
CHANGED
@@ -11,12 +11,18 @@ appraise "activerecord-4-1" do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
appraise "activerecord-4-2" do
|
14
|
-
gem "activerecord", "= 4.2.
|
14
|
+
gem "activerecord", "= 4.2.9"
|
15
15
|
gem "minitest-matchers_vaccine"
|
16
16
|
end
|
17
17
|
|
18
18
|
appraise "activerecord-5-0" do
|
19
|
-
gem "activerecord", "= 5.0.
|
19
|
+
gem "activerecord", "= 5.0.5"
|
20
|
+
gem "globalize", github: 'globalize/globalize'
|
21
|
+
gem "minitest-matchers_vaccine"
|
22
|
+
end
|
23
|
+
|
24
|
+
appraise "activerecord-5-1" do
|
25
|
+
gem "activerecord", "= 5.1.3"
|
20
26
|
gem "globalize", github: 'globalize/globalize'
|
21
27
|
gem "minitest-matchers_vaccine"
|
22
28
|
end
|
data/CHANGELOG
CHANGED
data/Gemfile.lock
CHANGED
data/lib/pluckers/base.rb
CHANGED
@@ -8,6 +8,8 @@ elsif active_record_version > Gem::Version.new("4.0") && active_record_version <
|
|
8
8
|
require_relative 'features/active_record_4_0'
|
9
9
|
elsif active_record_version > Gem::Version.new("5.0") && active_record_version < Gem::Version.new("5.1")
|
10
10
|
require_relative 'features/active_record_5_0'
|
11
|
+
elsif active_record_version > Gem::Version.new("5.1") && active_record_version < Gem::Version.new("5.2")
|
12
|
+
require_relative 'features/active_record_5_1'
|
11
13
|
elsif active_record_version > Gem::Version.new("3.2") && active_record_version < Gem::Version.new("4.0")
|
12
14
|
require_relative 'features/active_record_3_2'
|
13
15
|
else
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative '../base/belongs_to_reflections'
|
2
|
+
|
3
|
+
module Pluckers
|
4
|
+
module Features
|
5
|
+
module BelongsToReflections
|
6
|
+
|
7
|
+
def active_record_belongs_to_reflection? reflection
|
8
|
+
reflection.is_a?(ActiveRecord::Reflection::BelongsToReflection)
|
9
|
+
end
|
10
|
+
|
11
|
+
include Pluckers::Features::Base::BelongsToReflections
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative '../base/has_and_belongs_to_many_reflections'
|
2
|
+
|
3
|
+
module Pluckers
|
4
|
+
module Features
|
5
|
+
module HasAndBelongsToManyReflections
|
6
|
+
|
7
|
+
def active_record_has_and_belongs_to_many_reflection? reflection
|
8
|
+
reflection.is_a? ActiveRecord::Reflection::HasAndBelongsToManyReflection
|
9
|
+
end
|
10
|
+
|
11
|
+
def has_and_belongs_to_many_ids klass_reflection
|
12
|
+
|
13
|
+
# First, we get the the join table
|
14
|
+
join_table = Arel::Table.new(klass_reflection.join_table)
|
15
|
+
|
16
|
+
# And now, the foreign_keys.
|
17
|
+
# In our example with BlogPost and Category they would be:
|
18
|
+
# model_foreign_key = blog_post_id
|
19
|
+
# related_model_foreign_key = category_id
|
20
|
+
model_foreign_key = klass_reflection.foreign_key
|
21
|
+
related_model_foreign_key = klass_reflection.association_foreign_key
|
22
|
+
|
23
|
+
# Now we query the join table so we get the two ids
|
24
|
+
ids_query = join_table.where(
|
25
|
+
join_table[model_foreign_key].in(@results.map{|_, r| Arel::Nodes::Quoted.new(r[:id]) })
|
26
|
+
).project(
|
27
|
+
join_table[related_model_foreign_key],
|
28
|
+
join_table[model_foreign_key]
|
29
|
+
)
|
30
|
+
|
31
|
+
join_results = ActiveRecord::Base.connection.execute(ids_query.to_sql)
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
include Pluckers::Features::Base::HasAndBelongsToManyReflections
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative '../base/has_many_reflections'
|
2
|
+
|
3
|
+
module Pluckers
|
4
|
+
module Features
|
5
|
+
module HasManyReflections
|
6
|
+
|
7
|
+
def active_record_has_many_reflection? reflection
|
8
|
+
reflection.is_a? ActiveRecord::Reflection::HasManyReflection
|
9
|
+
end
|
10
|
+
|
11
|
+
include Pluckers::Features::Base::HasManyReflections
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative '../base/has_many_through_reflections'
|
2
|
+
|
3
|
+
module Pluckers
|
4
|
+
module Features
|
5
|
+
module HasManyThroughReflections
|
6
|
+
|
7
|
+
def active_record_has_many_through_reflection? reflection
|
8
|
+
reflection.is_a?(ActiveRecord::Reflection::ThroughReflection) &&
|
9
|
+
reflection.delegate_reflection.is_a?(ActiveRecord::Reflection::HasManyReflection)
|
10
|
+
end
|
11
|
+
|
12
|
+
include Pluckers::Features::Base::HasManyThroughReflections
|
13
|
+
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative '../base/has_one_reflections'
|
2
|
+
|
3
|
+
module Pluckers
|
4
|
+
module Features
|
5
|
+
module HasOneReflections
|
6
|
+
|
7
|
+
def active_record_has_one_reflection? reflection
|
8
|
+
reflection.is_a? ActiveRecord::Reflection::HasOneReflection
|
9
|
+
end
|
10
|
+
|
11
|
+
include Pluckers::Features::Base::HasOneReflections
|
12
|
+
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative '../base/has_one_through_reflections'
|
2
|
+
|
3
|
+
module Pluckers
|
4
|
+
module Features
|
5
|
+
module HasOneThroughReflections
|
6
|
+
|
7
|
+
def active_record_has_one_through_reflection? reflection
|
8
|
+
reflection.is_a?(ActiveRecord::Reflection::ThroughReflection) &&
|
9
|
+
reflection.delegate_reflection.is_a?(ActiveRecord::Reflection::HasOneReflection)
|
10
|
+
end
|
11
|
+
|
12
|
+
include Pluckers::Features::Base::HasOneThroughReflections
|
13
|
+
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require_relative 'active_record_5_0/simple_attributes'
|
2
|
+
require_relative 'active_record_5_0/belongs_to_reflections'
|
3
|
+
require_relative 'active_record_5_0/has_many_reflections'
|
4
|
+
require_relative 'active_record_5_0/has_many_through_reflections'
|
5
|
+
require_relative 'active_record_5_0/has_and_belongs_to_many_reflections'
|
6
|
+
require_relative 'active_record_5_0/has_one_reflections'
|
7
|
+
require_relative 'active_record_5_0/has_one_through_reflections'
|
8
|
+
require_relative 'active_record_5_0/renaming'
|
9
|
+
require_relative 'active_record_5_0/globalize'
|
10
|
+
require_relative 'active_record_5_0/pluck'
|
data/lib/pluckers/version.rb
CHANGED
data/pluckers.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
|
-
spec.add_dependency "activerecord", "> 3.2", "< 5.
|
30
|
+
spec.add_dependency "activerecord", "> 3.2", "< 5.2"
|
31
31
|
|
32
32
|
spec.add_development_dependency "rake", "~> 10.0"
|
33
33
|
spec.add_development_dependency "minitest"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pluckers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David J. Brenes
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '3.2'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '5.
|
22
|
+
version: '5.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '3.2'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '5.
|
32
|
+
version: '5.2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rake
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -195,6 +195,17 @@ files:
|
|
195
195
|
- lib/pluckers/features/active_record_5_0/pluck.rb
|
196
196
|
- lib/pluckers/features/active_record_5_0/renaming.rb
|
197
197
|
- lib/pluckers/features/active_record_5_0/simple_attributes.rb
|
198
|
+
- lib/pluckers/features/active_record_5_1.rb
|
199
|
+
- lib/pluckers/features/active_record_5_1/belongs_to_reflections.rb
|
200
|
+
- lib/pluckers/features/active_record_5_1/globalize.rb
|
201
|
+
- lib/pluckers/features/active_record_5_1/has_and_belongs_to_many_reflections.rb
|
202
|
+
- lib/pluckers/features/active_record_5_1/has_many_reflections.rb
|
203
|
+
- lib/pluckers/features/active_record_5_1/has_many_through_reflections.rb
|
204
|
+
- lib/pluckers/features/active_record_5_1/has_one_reflections.rb
|
205
|
+
- lib/pluckers/features/active_record_5_1/has_one_through_reflections.rb
|
206
|
+
- lib/pluckers/features/active_record_5_1/pluck.rb
|
207
|
+
- lib/pluckers/features/active_record_5_1/renaming.rb
|
208
|
+
- lib/pluckers/features/active_record_5_1/simple_attributes.rb
|
198
209
|
- lib/pluckers/features/base/belongs_to_reflections.rb
|
199
210
|
- lib/pluckers/features/base/globalize.rb
|
200
211
|
- lib/pluckers/features/base/has_and_belongs_to_many_reflections.rb
|