elastics-models 1.0.10 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -29,4 +29,4 @@ Special thanks for their sponsorship to [Escalate Media](http://www.escalatemedi
29
29
  ## Copyright
30
30
 
31
31
  Copyright (c) 2012-2013 by [Domizio Demichelis](mailto://dd.nexus@gmail.com)<br>
32
- See [LICENSE](https://github.com/elastics/elastics/blob/master/elastics-models/LICENSE) for details.
32
+ See [LICENSE](https://github.com/elastics/elastics/blob/master/elastics/LICENSE) for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.10
1
+ 1.1.0
@@ -1,5 +1,6 @@
1
1
  require 'date'
2
- version = File.read(File.expand_path('../VERSION', __FILE__)).strip
2
+ version_path = %w[../VERSION ../../VERSION].detect{|v| File.exist?(File.expand_path(v, __FILE__))}
3
+ version = File.read(File.expand_path(version_path, __FILE__)).strip
3
4
 
4
5
  Gem::Specification.new do |s|
5
6
  s.name = 'elastics-models'
@@ -8,7 +9,7 @@ Gem::Specification.new do |s|
8
9
  s.homepage = 'http://elastics.github.io/elastics'
9
10
  s.authors = ["Domizio Demichelis"]
10
11
  s.email = 'dd.nexus@gmail.com'
11
- s.files = `git ls-files -z`.split("\0")
12
+ s.files = `git ls-files -z`.split("\0") + %w[VERSION LICENSE]
12
13
  s.version = version
13
14
  s.date = Date.today.to_s
14
15
  s.required_rubygems_version = ">= 1.3.6"
@@ -7,6 +7,18 @@ module Elastics
7
7
  @elastics.extend(ClassProxy::ModelSyncer)
8
8
  @elastics.extend(ClassProxy::ModelIndexer).init
9
9
  def self.elastics; @elastics end
10
+ case
11
+ when respond_to?(:find_in_batches)
12
+ def self.elastics_in_batches(options={}, &block)
13
+ find_in_batches(options, &block)
14
+ end
15
+ when defined?(Mongoid::Document) && include?(Mongoid::Document)
16
+ def self.elastics_in_batches(options={}, &block)
17
+ 0.step(count, options[:batch_size]) do |offset|
18
+ block.call limit(options[:batch_size]).skip(offset).to_a
19
+ end
20
+ end
21
+ end
10
22
  end
11
23
  end
12
24
 
@@ -23,5 +35,4 @@ module Elastics
23
35
  end
24
36
 
25
37
  end
26
-
27
38
  end
@@ -76,22 +76,9 @@ module Elastics
76
76
  Prompter.say_ok "#{index} index created" if options[:verbose]
77
77
  end
78
78
 
79
- if defined?(Mongoid::Document) && model.include?(Mongoid::Document)
80
- def model.find_in_batches(options={})
81
- 0.step(count, options[:batch_size]) do |offset|
82
- yield limit(options[:batch_size]).skip(offset).to_a
83
- end
84
- end
85
- end
86
-
87
- unless model.respond_to?(:find_in_batches)
88
- Conf.logger.error "Model #{model} does not respond to :find_in_batches. Skipped."
89
- next
90
- end
91
-
92
79
  pbar = ProgBar.new(model.count, options[:batch_size], "Model #{model}: ") if options[:verbose]
93
80
 
94
- model.find_in_batches(:batch_size => options[:batch_size]) do |batch|
81
+ model.elastics_in_batches(:batch_size => options[:batch_size]) do |batch|
95
82
  result = Elastics.post_bulk_collection(batch, options[:import_options]) || next
96
83
  pbar.process_result(result, batch.size) if options[:verbose]
97
84
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastics-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-03 00:00:00.000000000 Z
12
+ date: 2013-09-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: elastics-client
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.0.10
21
+ version: 1.1.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 1.0.10
29
+ version: 1.1.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: elastics-scopes
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - '='
36
36
  - !ruby/object:Gem::Version
37
- version: 1.0.10
37
+ version: 1.1.0
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - '='
44
44
  - !ruby/object:Gem::Version
45
- version: 1.0.10
45
+ version: 1.1.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: active_attr
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -67,9 +67,7 @@ executables: []
67
67
  extensions: []
68
68
  extra_rdoc_files: []
69
69
  files:
70
- - LICENSE
71
70
  - README.md
72
- - VERSION
73
71
  - elastics-models.gemspec
74
72
  - lib/elastics-models.rb
75
73
  - lib/elastics/active_model.rb
@@ -93,6 +91,8 @@ files:
93
91
  - lib/elastics/result/search_loader.rb
94
92
  - lib/elastics/struct/mergeable.rb
95
93
  - lib/tasks.rake
94
+ - VERSION
95
+ - LICENSE
96
96
  homepage: http://elastics.github.io/elastics
97
97
  licenses:
98
98
  - MIT