activerecord-pluck_in_batches 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: 6e0b5b345ebd97751b243a5f25ea23c62dea6664
4
- data.tar.gz: 0e24a1ab3dfe73569905b9cb897eac47da67c4e8
3
+ metadata.gz: 90f7a60d8f5b9a3a0c1bd73b7b3f412d7187a012
4
+ data.tar.gz: 00a1217df487fdb017e73b92437be29ddab5ff76
5
5
  SHA512:
6
- metadata.gz: 323d894d9d44b20564f58eabebfc8f3a68e6916acc911701cae53a933cdf62b55ab627d5c9928074a89d89f43888b16e7250c6fdb83995fdc818f3ef582cb9e2
7
- data.tar.gz: 8e6062d9b6d4c95cd6807cef84cf4f311100cd6609a10ffa648c9d660566e9e219b5a5ca80f6552a251ceb422b67ccbfc2aa10a3f6f45e39a09ddc0e9b55c0f9
6
+ metadata.gz: 3d91c11cbbb6ddf89ae27b61117269f7b442f77ddd6135a068ab6e0f115a4841471e8cfa3a22a0efaae5d2c892915493a12d9dde4e3ebe44d2d7ca7850bca94a
7
+ data.tar.gz: ab58d876b50d3e5b396c4ee484dc69e2bfe3d7bb07d78df44cf72dca6c2a961995eefaf1a210403d126c5cb6601946481c2c5a2a3f830eb5c60586be56f30489
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_dependency "activerecord"
20
+ spec.add_dependency "activerecord", ">= 4.2.7", "< 5.1.0"
21
21
 
22
22
  spec.add_development_dependency "bundler", "~> 1.10"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
@@ -1,18 +1,8 @@
1
1
  require "activerecord/pluck_in_batches/version"
2
2
  require "active_record/relation"
3
3
 
4
- module PluckInBatches
5
- def pluck_in_batches(*args, &block)
6
- options = args.extract_options!
7
- in_batches(options) do |batch|
8
- batch.pluck(*args).each(&block)
9
- end
10
- end
11
-
12
- def in_batches(options = {})
13
- options.assert_valid_keys(:batch_size)
14
-
15
- batch_size = options[:batch_size] || 1000
4
+ module InBatches
5
+ def in_batches(of: 1000)
16
6
  batches = (count / batch_size.to_f).ceil
17
7
 
18
8
  relation = reorder("#{quoted_table_name}.#{quoted_primary_key} ASC").limit(batch_size)
@@ -27,4 +17,14 @@ module PluckInBatches
27
17
  end
28
18
  end
29
19
 
20
+ module PluckInBatches
21
+ def pluck_in_batches(*args, &block)
22
+ options = args.extract_options!
23
+ in_batches(options) do |batch|
24
+ batch.pluck(*args).each(&block)
25
+ end
26
+ end
27
+ end
28
+
29
+ ActiveRecord::Relation.send :include, InBatches if Rails.version < "5.0.0"
30
30
  ActiveRecord::Relation.send :include, PluckInBatches
@@ -1,5 +1,5 @@
1
1
  module Activerecord
2
2
  module PluckInBatches
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-pluck_in_batches
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
  - Bob Lail
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-06 00:00:00.000000000 Z
11
+ date: 2016-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 4.2.7
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 5.1.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '0'
29
+ version: 4.2.7
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 5.1.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: bundler
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -88,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
94
  version: '0'
89
95
  requirements: []
90
96
  rubyforge_project:
91
- rubygems_version: 2.4.8
97
+ rubygems_version: 2.5.1
92
98
  signing_key:
93
99
  specification_version: 4
94
100
  summary: Like find_each or find_in_batches but for pluck