perforated 0.9.0 → 0.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af43ff72681ac3aa03057419afb02db11d89dcec
4
- data.tar.gz: 52f9abfc9c9239e34fbde54958e22f8bdbf3d9e7
3
+ metadata.gz: 330c81a4281ebab097c307068577fcd027ff4aec
4
+ data.tar.gz: e29c1d1b11c2e4e4b696fcd5a3c28c3828bbcc33
5
5
  SHA512:
6
- metadata.gz: 4c84edc00c26382975abd7a028687c54e9cc2f99c1717324f95a60aa2fc3bb9471acff847a1b65cead2aaa62a03509c4af0a95f7083b6c4eecf49d46b201cec3
7
- data.tar.gz: 01eba26e7cb2e63d9ac66cedebed88b2a2b7943aacbf9a928d3bfef8d6ebeaed53db168f748581cececc235c5f51643d86e1aac845c3a71ff9275ccd0204da8e
6
+ metadata.gz: 33ee71b9c0efcd1740583c7f21885ef6fa32e24b3079bc834f111fa180421ad55d059d7c3aad67a1a69151bf6644ffe79b4cfc1dbc9aadde4266d97f21e401f7
7
+ data.tar.gz: 54253903fd62fe2e050ed1545862346cd15d2190494e22cb43dbbeb168205e4290460cb633b359f159c8b6a80fc403ef6795f53ea1a2008e7e03b7a6ab06d914
data/.travis.yml CHANGED
@@ -1,6 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
3
  - 2.1.0
5
4
  services:
6
5
  script: bundle exec rspec spec
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## Version 0.9.1
2
+
3
+ * To preserve the order and limit of ActiveRecord Relations, use of
4
+ `ActiveRecord::Relation#find_in_batches` has been removed in favor of
5
+ `Enumerable#each_slice` during batch caching.
6
+
1
7
  ## Version 0.9.0
2
8
 
3
9
  * `as_json` and `to_json` now take a block. The block will be applied to each
@@ -1,12 +1,9 @@
1
1
  require 'perforated/rebuilder'
2
2
  require 'perforated/strategy'
3
- require 'perforated/compatibility/find_in_batches'
4
3
  require 'perforated/compatibility/fetch_multi'
5
4
 
6
5
  module Perforated
7
6
  class Cache
8
- using Perforated::Compatibility::FindInBatches
9
-
10
7
  attr_accessor :enumerable, :strategy
11
8
 
12
9
  def initialize(enumerable, strategy = Perforated::Strategy)
@@ -17,7 +14,7 @@ module Perforated
17
14
  def to_json(rooted: false, batch_size: 1000, &block)
18
15
  results = []
19
16
 
20
- enumerable.find_in_batches(batch_size: batch_size) do |subset|
17
+ enumerable.each_slice(batch_size) do |subset|
21
18
  keyed = key_mapped(subset)
22
19
 
23
20
  results << fetch_multi(keyed) do |key|
@@ -1,3 +1,3 @@
1
1
  module Perforated
2
- VERSION = '0.9.0'
2
+ VERSION = '0.9.1'
3
3
  end
@@ -32,7 +32,7 @@ describe Perforated do
32
32
 
33
33
  describe '.new' do
34
34
  it 'returns a new instance of Perforated::Cache' do
35
- expect(Perforated.new).to be_instance_of(Perforated::Cache)
35
+ expect(Perforated.new([])).to be_instance_of(Perforated::Cache)
36
36
  end
37
37
  end
38
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perforated
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Parker Selbert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-10 00:00:00.000000000 Z
11
+ date: 2014-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -86,14 +86,12 @@ files:
86
86
  - lib/perforated.rb
87
87
  - lib/perforated/cache.rb
88
88
  - lib/perforated/compatibility/fetch_multi.rb
89
- - lib/perforated/compatibility/find_in_batches.rb
90
89
  - lib/perforated/rebuilder.rb
91
90
  - lib/perforated/strategy.rb
92
91
  - lib/perforated/version.rb
93
92
  - perforated.gemspec
94
93
  - spec/perforated/cache_spec.rb
95
94
  - spec/perforated/compatibility/fetch_multi_spec.rb
96
- - spec/perforated/compatibility/find_in_batches_spec.rb
97
95
  - spec/perforated/rebuilder_spec.rb
98
96
  - spec/perforated_spec.rb
99
97
  - spec/spec_helper.rb
@@ -117,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
115
  version: '0'
118
116
  requirements: []
119
117
  rubyforge_project:
120
- rubygems_version: 2.3.0
118
+ rubygems_version: 2.2.2
121
119
  signing_key:
122
120
  specification_version: 4
123
121
  summary: 'The most expensive part of serving a JSON request is converting the serialized
@@ -127,7 +125,6 @@ summary: 'The most expensive part of serving a JSON request is converting the se
127
125
  test_files:
128
126
  - spec/perforated/cache_spec.rb
129
127
  - spec/perforated/compatibility/fetch_multi_spec.rb
130
- - spec/perforated/compatibility/find_in_batches_spec.rb
131
128
  - spec/perforated/rebuilder_spec.rb
132
129
  - spec/perforated_spec.rb
133
130
  - spec/spec_helper.rb
@@ -1,11 +0,0 @@
1
- module Perforated
2
- module Compatibility
3
- module FindInBatches
4
- refine Array do
5
- def find_in_batches(batch_size: 1000, &block)
6
- each_slice(batch_size, &block)
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,25 +0,0 @@
1
- require 'perforated/compatibility/find_in_batches'
2
-
3
- describe Perforated::Compatibility::FindInBatches do
4
- FindBatches = Struct.new(:array) do
5
- using Perforated::Compatibility::FindInBatches
6
-
7
- def perform(&block)
8
- array.find_in_batches(batch_size: 50, &block)
9
- end
10
- end
11
-
12
- describe '#find_in_batches' do
13
- it 'iterates over an enumerable in batches' do
14
- enumerable = [1] * 100
15
- eachable = FindBatches.new(enumerable)
16
- results = []
17
-
18
- eachable.perform do |arr|
19
- results << arr.reduce(&:+)
20
- end
21
-
22
- expect(results).to eq([50, 50])
23
- end
24
- end
25
- end