active-record-streamer 0.0.1 → 0.0.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: 5d8b5c1fec28a6f974455ccce6fbd52a0fc12c50
4
- data.tar.gz: 18f069f74884669921e18ba2de93e35bef73b4e4
3
+ metadata.gz: 0109c5a9442a68bb7f3e62685d8d415b126edb9f
4
+ data.tar.gz: 14db767e20d9e3eeaaed277a7e5c60728d5b63e4
5
5
  SHA512:
6
- metadata.gz: f58bb3295ba5ff75b6f60ae52fa962868cc14c55be11502a413b10ca5419c45863fe11426b50f1fa239676a62006c682dba4e2ef238c514917c56ab6f0942601
7
- data.tar.gz: 237fc4af6c15458651d28d37418ba5aca3e9edc9e9bfde211e98a1908b13a89542c7c98dc51f9ca8dc856861871779194571b027a3ba2e94f6370aafc52ccec5
6
+ metadata.gz: 7b1603127f1b1100efd4114c1954ebddfb6f96afc63b49a00ca434de2f57d7b87b88280dd3d391a13a29c620bbfb63ef563de55b7f2268f7523a3129ee329f6b
7
+ data.tar.gz: cd3a12cc4776eb0f36e231fd842365cbab1ca83e66dc4f1ebc2667b86081c4d8057ec953741dd9df69bc9e6c072a88d66f5692242a8148bcac208a6cc3e2f496
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source "http://rubygems.org"
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
 
6
- gem 'baza', '~> 0.0.17'
6
+ gem 'baza', '>= 0.0.19'
7
7
 
8
8
  # Add dependencies to develop your gem here.
9
9
  # Include everything needed to run rake, tests, features, etc.
@@ -16,9 +16,9 @@ GEM
16
16
  tzinfo (~> 1.1)
17
17
  addressable (2.3.8)
18
18
  arel (6.0.0)
19
- array_enumerator (0.0.7)
20
- baza (0.0.17)
21
- array_enumerator (~> 0.0.7)
19
+ array_enumerator (0.0.10)
20
+ baza (0.0.19)
21
+ array_enumerator (~> 0.0.10)
22
22
  datet (~> 0.0.25)
23
23
  event_handler (~> 0.0.0)
24
24
  string-cases (~> 0.0.1)
@@ -104,7 +104,7 @@ PLATFORMS
104
104
 
105
105
  DEPENDENCIES
106
106
  activerecord (= 4.2.1)
107
- baza (~> 0.0.17)
107
+ baza (>= 0.0.19)
108
108
  bundler (~> 1.0)
109
109
  jeweler (~> 2.0.1)
110
110
  mysql2 (= 0.3.18)
@@ -112,3 +112,6 @@ DEPENDENCIES
112
112
  rdoc (~> 3.12)
113
113
  rspec (~> 2.8.0)
114
114
  simplecov
115
+
116
+ BUNDLED WITH
117
+ 1.10.5
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: active-record-streamer 0.0.1 ruby lib
5
+ # stub: active-record-streamer 0.0.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "active-record-streamer"
9
- s.version = "0.0.1"
9
+ s.version = "0.0.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["kaspernj"]
14
- s.date = "2015-05-31"
14
+ s.date = "2015-08-05"
15
15
  s.description = "Stream ActiveRecord results"
16
16
  s.email = "k@spernj.org"
17
17
  s.extra_rdoc_files = [
@@ -34,14 +34,14 @@ Gem::Specification.new do |s|
34
34
  ]
35
35
  s.homepage = "http://github.com/kaspernj/active-record-streamer"
36
36
  s.licenses = ["MIT"]
37
- s.rubygems_version = "2.2.2"
37
+ s.rubygems_version = "2.4.0"
38
38
  s.summary = "Stream ActiveRecord results"
39
39
 
40
40
  if s.respond_to? :specification_version then
41
41
  s.specification_version = 4
42
42
 
43
43
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
- s.add_runtime_dependency(%q<baza>, ["~> 0.0.17"])
44
+ s.add_runtime_dependency(%q<baza>, [">= 0.0.19"])
45
45
  s.add_development_dependency(%q<activerecord>, ["= 4.2.1"])
46
46
  s.add_development_dependency(%q<mysql2>, ["= 0.3.18"])
47
47
  s.add_development_dependency(%q<pry>, [">= 0"])
@@ -51,7 +51,7 @@ Gem::Specification.new do |s|
51
51
  s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
52
52
  s.add_development_dependency(%q<simplecov>, [">= 0"])
53
53
  else
54
- s.add_dependency(%q<baza>, ["~> 0.0.17"])
54
+ s.add_dependency(%q<baza>, [">= 0.0.19"])
55
55
  s.add_dependency(%q<activerecord>, ["= 4.2.1"])
56
56
  s.add_dependency(%q<mysql2>, ["= 0.3.18"])
57
57
  s.add_dependency(%q<pry>, [">= 0"])
@@ -62,7 +62,7 @@ Gem::Specification.new do |s|
62
62
  s.add_dependency(%q<simplecov>, [">= 0"])
63
63
  end
64
64
  else
65
- s.add_dependency(%q<baza>, ["~> 0.0.17"])
65
+ s.add_dependency(%q<baza>, [">= 0.0.19"])
66
66
  s.add_dependency(%q<activerecord>, ["= 4.2.1"])
67
67
  s.add_dependency(%q<mysql2>, ["= 0.3.18"])
68
68
  s.add_dependency(%q<pry>, [">= 0"])
@@ -8,16 +8,30 @@ class ActiveRecordStreamer
8
8
  @includes = @args[:query].includes_values
9
9
  end
10
10
 
11
+ def rails4?
12
+ @@rails4 ||= ActiveRecord::VERSION::STRING.start_with?('4')
13
+ end
14
+
11
15
  def each(&blk)
12
- @baza_db = Baza::Cloner.from_active_record_connection(@klass.connection)
16
+ if @klass.respond_to?(:connection_without_octopus)
17
+ @baza_db = Baza::Cloner.from_active_record_connection(@klass.connection_without_octopus)
18
+ else
19
+ @baza_db = Baza::Cloner.from_active_record_connection(@klass.connection)
20
+ end
13
21
 
14
22
  begin
15
23
  cache = []
16
24
 
17
25
  @baza_db.query_ubuf(@sql) do |data|
18
26
  model = @klass.new
19
- model.instance_variable_set(:@new_record, false)
20
- model.instance_variable_set(:@attributes, data.stringify_keys!)
27
+
28
+ if rails4?
29
+ model.assign_attributes(data)
30
+ model.instance_variable_set(:@new_record, false)
31
+ else
32
+ model.instance_variable_set(:@new_record, false)
33
+ model.instance_variable_set(:@attributes, data.stringify_keys!)
34
+ end
21
35
 
22
36
  cache << model
23
37
 
@@ -36,7 +50,11 @@ class ActiveRecordStreamer
36
50
  private
37
51
 
38
52
  def yield_cache(cache)
39
- ActiveRecord::Associations::Preloader.new(cache, @includes).run
53
+ if rails4?
54
+ ActiveRecord::Associations::Preloader.new.preload(cache, @includes)
55
+ else
56
+ ActiveRecord::Associations::Preloader.new(cache, @includes).run
57
+ end
40
58
 
41
59
  cache.each do |model|
42
60
  yield model
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-record-streamer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaspernj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-31 00:00:00.000000000 Z
11
+ date: 2015-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: baza
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.17
19
+ version: 0.0.19
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.0.17
26
+ version: 0.0.19
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  version: '0'
177
177
  requirements: []
178
178
  rubyforge_project:
179
- rubygems_version: 2.2.2
179
+ rubygems_version: 2.4.0
180
180
  signing_key:
181
181
  specification_version: 4
182
182
  summary: Stream ActiveRecord results