elastics-client 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/elastics/prog_bar.rb +14 -11
  3. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.8
1
+ 1.0.9
@@ -33,28 +33,31 @@ module Elastics
33
33
  attr_reader :pbar, :total_count
34
34
 
35
35
  def initialize(total_count, batch_size=nil, prefix_message=nil)
36
- bar_style = [:green, :reversed, :bold]
37
36
  @successful_count = 0
38
37
  @failed_count = 0
39
- format = Dye.dye(' processing... ', 'processing... ', bar_style) +
40
- Dye.dye('%b%i', '|%b%i|', bar_style) +
41
- Dye.dye(' %p%% %E ', ' %p%% %E', bar_style)
42
- @pbar = ::ProgressBar.create(:total => total_count,
43
- :progress_mark => Dye.dye(' ', '|', bar_style),
44
- :format => format )
38
+ # we use the title to pass the sgr start style codes
39
+ start_style = Dye.color? ? "#{Dye.sgr(:clear, :green, :reversed, :bold)} " : ''
40
+ format = '%t%c/%C %p%% %E %b'
41
+ format += Dye.sgr(:clear) if Dye.color?
42
+ progress_mark = Dye.color? ? ' ' : '|'
43
+ @pbar = ::ProgressBar.create(:title => start_style,
44
+ :total => total_count,
45
+ :progress_mark => progress_mark,
46
+ :format => format )
45
47
  @pbar.clear
46
- Prompter.say_log '_' * @pbar.send(:length)
48
+ puts
47
49
  message = "#{prefix_message}Processing #{total_count} documents"
48
- message << " in batches of #{batch_size}:" unless batch_size.nil?
50
+ message << " in batches of #{batch_size}" unless batch_size.nil?
49
51
  Prompter.say_log message
50
52
  @pbar.start
51
53
  end
52
54
 
53
55
  def process_result(result, inc)
54
56
  unless result.nil? || result.empty?
55
- unless result.failed.size == 0
57
+ if result.failed.size > 0
56
58
  Conf.logger.error "Failed load:\n#{result.failed.to_yaml}"
57
- @pbar.progress_mark = Dye.dye(' ', 'F', :reed, :reversed, :bold)
59
+ @pbar.title = "#{Dye.sgr(:clear, :red, :reversed, :bold)} " if Dye.color?
60
+ @pbar.progress_mark = 'F' unless Dye.color?
58
61
  end
59
62
  @failed_count += result.failed.size
60
63
  @successful_count += result.successful.size
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastics-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
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-08-24 00:00:00.000000000 Z
12
+ date: 2013-08-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json