activerecord-count_loader 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8489adecb44640ee21f220153382a63fded5759d
4
- data.tar.gz: 49b3d38e965877df8269225787e5d234356aad8d
3
+ metadata.gz: e96fba115f86ec9df8e6b61b9e46963db8863389
4
+ data.tar.gz: c133bf5dbdc42da2033c895edbafb54aad6503d4
5
5
  SHA512:
6
- metadata.gz: 455eafc3a74e192add146c9459bbec579ab4bc54d5021678ae2f9116a8c97af82df618dbaf5d58fbf6fb20d44c37cf283b4bff0daf90ab3cea6528da7aa95082
7
- data.tar.gz: 2579d3db7c17e70aab0008fcbdac5978510e1a087974ab53b5144ef25acab4b83b18bc7b21e675727c950900b4ef1cf7fcbdaae23400bc2a952091e1851c780c
6
+ metadata.gz: 1fb324c9b4c13172114fa47337949bda6a45418e9fe6ebd4ef2d2702c1dc03df576220e014bf05d3069414063b384d17a649b345b48d0cc1f6baaf44afaee783
7
+ data.tar.gz: 0d5d2aaa5ebd82d0a60a8fee3b94fbce338072af25333fc173620f4b8f0e28f33725cd67c9656f56a991cdc69507cc5c12139826820f6bd2ad78fc4e0e3cb329
data/.travis.yml CHANGED
@@ -1,5 +1,12 @@
1
+ script: ci/travis.rb
1
2
  language: ruby
2
3
  rvm:
3
- - 2.1.0
4
4
  - 2.1.5
5
- - ruby-head
5
+ gemfile:
6
+ - ci/Gemfile.activerecord-3.2.x
7
+ - ci/Gemfile.activerecord-4.0.x
8
+ - ci/Gemfile.activerecord-4.1.x
9
+ env:
10
+ - ARCONN=sqlite3
11
+ - ARCONN=mysql2
12
+ - ARCONN=postgresql
data/README.md CHANGED
@@ -63,6 +63,19 @@ Since it is association, you can preload nested `count_loader` association.
63
63
  end
64
64
  ```
65
65
 
66
+ ## Supported Versions
67
+
68
+ - Ruby
69
+ - 2.1
70
+ - Rails
71
+ - 3.2, 4.0, 4.1
72
+
73
+ ### Databases
74
+
75
+ - sqlite
76
+ - mysql
77
+ - postgresql
78
+
66
79
  ## Testing
67
80
 
68
81
  ```bash
@@ -18,10 +18,12 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.required_ruby_version = ">= 2.1"
20
20
  spec.add_runtime_dependency "activerecord", ">= 3.2.0"
21
- spec.add_development_dependency "minitest", ">= 5.4"
21
+ spec.add_development_dependency "minitest"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "erubis"
24
24
  spec.add_development_dependency "bundler"
25
25
  spec.add_development_dependency "sqlite3"
26
+ spec.add_development_dependency "mysql2"
27
+ spec.add_development_dependency "postgres"
26
28
  spec.add_development_dependency "pry"
27
29
  end
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'activerecord', '~> 3.2.0'
4
+ gemspec path: '..'
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'activerecord', '~> 4.0.0'
4
+ gemspec path: '..'
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'rails', '~> 4.1.0'
4
+ gemspec path: '..'
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'rails', '~> 4.2.0.beta4'
4
+ gemspec path: '..'
data/ci/travis.rb ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ commands = [
4
+ 'mysql -e "create database activerecord_unittest;"',
5
+ 'mysql -e "create database activerecord_unittest2;"',
6
+ 'psql -c "create database activerecord_unittest;" -U postgres',
7
+ 'psql -c "create database activerecord_unittest2;" -U postgres'
8
+ ]
9
+
10
+ commands.each do |command|
11
+ system("#{command} > /dev/null 2>&1")
12
+ end
@@ -36,19 +36,6 @@ module ActiveRecord
36
36
  scope.where(association_key.in(ids)).pluck(association_key_name)
37
37
  end
38
38
  end
39
-
40
- private
41
-
42
- def preloader_for_with_count_loader(reflection, owners, rhs_klass)
43
- preloader = preloader_for_without_count_loader(reflection, owners, rhs_klass)
44
- return preloader if preloader
45
-
46
- case reflection.macro
47
- when :count_loader
48
- CountLoader
49
- end
50
- end
51
- alias_method_chain :preloader_for, :count_loader
52
39
  end
53
40
  end
54
41
  end
@@ -1,6 +1,7 @@
1
1
  ActiveSupport.on_load(:active_record) do
2
2
  module ActiveRecord
3
3
  Reflection.prepend(CountLoader::ReflectionExtension)
4
+ Associations::Preloader.prepend(CountLoader::PreloaderExtension)
4
5
  Associations::JoinDependency.prepend(CountLoader::JoinDependencyExtension)
5
6
  Associations::Builder::HasMany.prepend(CountLoader::Builder::HasManyExtension)
6
7
  Reflection::AssociationReflection.prepend(CountLoader::AssociationReflectionExtension)
@@ -0,0 +1,15 @@
1
+ module ActiveRecord
2
+ module CountLoader
3
+ module PreloaderExtension
4
+ def preloader_for(reflection, owners, rhs_klass)
5
+ preloader = super(reflection, owners, rhs_klass)
6
+ return preloader if preloader
7
+
8
+ case reflection.macro
9
+ when :count_loader
10
+ Associations::Preloader::CountLoader
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module CountLoader
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
@@ -7,5 +7,6 @@ require "active_record/associations/preloader/count_loader"
7
7
 
8
8
  require "active_record/count_loader/has_many_extension"
9
9
  require "active_record/count_loader/join_dependency_extension"
10
+ require "active_record/count_loader/preloader_extension"
10
11
  require "active_record/count_loader/reflection_extension"
11
12
  require "active_record/count_loader/extend"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-count_loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '5.4'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '5.4'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,34 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: mysql2
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
+ - !ruby/object:Gem::Dependency
112
+ name: postgres
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: pry
99
127
  requirement: !ruby/object:Gem::Requirement
@@ -122,12 +150,18 @@ files:
122
150
  - README.md
123
151
  - Rakefile
124
152
  - activerecord-count_loader.gemspec
153
+ - ci/Gemfile.activerecord-3.2.x
154
+ - ci/Gemfile.activerecord-4.0.x
155
+ - ci/Gemfile.activerecord-4.1.x
156
+ - ci/Gemfile.activerecord-4.2.x
157
+ - ci/travis.rb
125
158
  - lib/active_record/associations/builder/count_loader.rb
126
159
  - lib/active_record/associations/count_loader.rb
127
160
  - lib/active_record/associations/preloader/count_loader.rb
128
161
  - lib/active_record/count_loader/extend.rb
129
162
  - lib/active_record/count_loader/has_many_extension.rb
130
163
  - lib/active_record/count_loader/join_dependency_extension.rb
164
+ - lib/active_record/count_loader/preloader_extension.rb
131
165
  - lib/active_record/count_loader/reflection_extension.rb
132
166
  - lib/active_record/count_loader/version.rb
133
167
  - lib/activerecord-count_loader.rb