elastics-client 1.0.9 → 1.0.10

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 +24 -10
  3. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.9
1
+ 1.0.10
@@ -35,15 +35,10 @@ module Elastics
35
35
  def initialize(total_count, batch_size=nil, prefix_message=nil)
36
36
  @successful_count = 0
37
37
  @failed_count = 0
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 )
38
+ @pbar = ::ProgressBar.create(:title => title(:ok),
39
+ :total => total_count,
40
+ :progress_mark => (Dye.color? ? ' ' : '|'),
41
+ :format => ('%t%c/%C %p%% %E %b' + dye(:background, '%i', '%i')))
47
42
  @pbar.clear
48
43
  puts
49
44
  message = "#{prefix_message}Processing #{total_count} documents"
@@ -56,7 +51,7 @@ module Elastics
56
51
  unless result.nil? || result.empty?
57
52
  if result.failed.size > 0
58
53
  Conf.logger.error "Failed load:\n#{result.failed.to_yaml}"
59
- @pbar.title = "#{Dye.sgr(:clear, :red, :reversed, :bold)} " if Dye.color?
54
+ @pbar.title = title(:failed)
60
55
  @pbar.progress_mark = 'F' unless Dye.color?
61
56
  end
62
57
  @failed_count += result.failed.size
@@ -77,5 +72,24 @@ module Elastics
77
72
  Prompter.say_warning "See the log for the details about the #{@failed_count} failures." unless @failed_count == 0
78
73
  end
79
74
 
75
+ private
76
+
77
+ def title(how)
78
+ return '' unless Dye.color?
79
+ Dye.sgr(:clear, color(how), :reversed, :bold) + ' '
80
+ end
81
+
82
+ def dye(how, colored, plain)
83
+ Dye.dye colored, plain, :reversed, :bold, color(how)
84
+ end
85
+
86
+ def color(how)
87
+ case how
88
+ when :background then :blue
89
+ when :ok then :green
90
+ when :failed then :red
91
+ end
92
+ end
93
+
80
94
  end
81
95
  end
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.9
4
+ version: 1.0.10
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-27 00:00:00.000000000 Z
12
+ date: 2013-09-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json