elastics-client 1.0.7 → 1.0.8
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.
- data/VERSION +1 -1
- data/elastics-client.gemspec +3 -1
- data/lib/elastics-client.rb +2 -1
- data/lib/elastics/class_proxy/templates/doc.rb +2 -2
- data/lib/elastics/configuration.rb +9 -1
- data/lib/elastics/logger.rb +0 -9
- data/lib/elastics/prog_bar.rb +47 -10
- data/lib/elastics/utility_methods.rb +1 -1
- metadata +23 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.8
|
data/elastics-client.gemspec
CHANGED
@@ -4,7 +4,8 @@ version = File.read(File.expand_path('../VERSION', __FILE__)).strip
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'elastics-client'
|
6
6
|
s.summary = 'Client gem for elasticsearch'
|
7
|
-
s.description = 'Core gem used by all the elastics gems.
|
7
|
+
s.description = 'Core gem used by all the elastics gems. Provides the core resources: HTTP clients,
|
8
|
+
Elasticsearch API Methods, Templating System, Cascading Variables Management, Result Extenders, Logging & Debugging, Self-documenting Tool, Rake Tasks, ...'
|
8
9
|
s.homepage = 'http://elastics.github.io/elastics'
|
9
10
|
s.authors = ['Domizio Demichelis']
|
10
11
|
s.email = 'dd.nexus@gmail.com'
|
@@ -30,4 +31,5 @@ EOM
|
|
30
31
|
s.add_runtime_dependency 'multi_json', '>= 1.3.4'
|
31
32
|
s.add_runtime_dependency 'ruby-progressbar', '>= 1.2.0'
|
32
33
|
s.add_runtime_dependency 'dye', '~> 0.1.4'
|
34
|
+
s.add_runtime_dependency 'prompter', '~> 0.1.6'
|
33
35
|
end
|
data/lib/elastics-client.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'dye'
|
2
|
+
require 'prompter'
|
3
|
+
require 'ruby-progressbar'
|
2
4
|
require 'yaml'
|
3
5
|
require 'ostruct'
|
4
6
|
require 'erb'
|
@@ -42,7 +44,6 @@ require 'elastics/http_clients/loader'
|
|
42
44
|
require 'elastics/configuration'
|
43
45
|
require 'elastics/utility_methods'
|
44
46
|
|
45
|
-
require 'ruby-progressbar'
|
46
47
|
require 'elastics/prog_bar'
|
47
48
|
require 'elastics/client_live_reindex'
|
48
49
|
|
@@ -38,12 +38,12 @@ end
|
|
38
38
|
|
39
39
|
meth
|
40
40
|
end
|
41
|
-
|
41
|
+
Prompter.say_log doc
|
42
42
|
end
|
43
43
|
|
44
44
|
def usage(name)
|
45
45
|
meth_call = [context, name].join('.')
|
46
|
-
|
46
|
+
Prompter.say_log build_usage(meth_call, templates[name])
|
47
47
|
end
|
48
48
|
|
49
49
|
private
|
@@ -10,7 +10,7 @@ module Elastics
|
|
10
10
|
:params => {},
|
11
11
|
:no_pruning => [] ),
|
12
12
|
:config_file => './config/elastics.yml',
|
13
|
-
:elastics_dir
|
13
|
+
:elastics_dir => './elastics',
|
14
14
|
:http_client => HttpClients::Loader.new_http_client
|
15
15
|
|
16
16
|
# shorter alias
|
@@ -20,6 +20,14 @@ module Elastics
|
|
20
20
|
def configure
|
21
21
|
yield self
|
22
22
|
end
|
23
|
+
# force color in console (used with jruby)
|
24
|
+
def ansi=(bool)
|
25
|
+
Dye.color = bool
|
26
|
+
end
|
27
|
+
|
28
|
+
def ansi
|
29
|
+
Dye.color?
|
30
|
+
end
|
23
31
|
end
|
24
32
|
|
25
33
|
end
|
data/lib/elastics/logger.rb
CHANGED
data/lib/elastics/prog_bar.rb
CHANGED
@@ -1,21 +1,52 @@
|
|
1
|
+
class ProgressBar
|
2
|
+
module Format
|
3
|
+
class Base
|
4
|
+
# see https://github.com/jfelchner/ruby-progressbar/pull/50
|
5
|
+
def process(environment)
|
6
|
+
processed_string = @format_string.dup
|
7
|
+
|
8
|
+
non_bar_molecules.each do |molecule|
|
9
|
+
processed_string.gsub!("%#{molecule.key}", environment.send(molecule.method_name).to_s)
|
10
|
+
end
|
11
|
+
|
12
|
+
remaining_molecules = bar_molecules.size
|
13
|
+
placeholder_length = remaining_molecules * 2
|
14
|
+
|
15
|
+
processed_string.gsub! '%%', '%'
|
16
|
+
processed_string_length = processed_string.gsub(/\e\[[\d;]+m/, '').length
|
17
|
+
leftover_bar_length = environment.send(:length) - processed_string_length + placeholder_length
|
18
|
+
leftover_bar_length = leftover_bar_length < 0 ? 0 : leftover_bar_length
|
19
|
+
|
20
|
+
bar_molecules.each do |molecule|
|
21
|
+
processed_string.gsub!("%#{molecule.key}", environment.send(molecule.method_name, leftover_bar_length).to_s)
|
22
|
+
end
|
23
|
+
|
24
|
+
processed_string
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
1
30
|
module Elastics
|
2
31
|
class ProgBar
|
3
32
|
|
4
33
|
attr_reader :pbar, :total_count
|
5
34
|
|
6
35
|
def initialize(total_count, batch_size=nil, prefix_message=nil)
|
7
|
-
|
36
|
+
bar_style = [:green, :reversed, :bold]
|
8
37
|
@successful_count = 0
|
9
38
|
@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)
|
10
42
|
@pbar = ::ProgressBar.create(:total => total_count,
|
11
|
-
:progress_mark => '|',
|
12
|
-
:format =>
|
13
|
-
:length => 80)
|
43
|
+
:progress_mark => Dye.dye(' ', '|', bar_style),
|
44
|
+
:format => format )
|
14
45
|
@pbar.clear
|
15
|
-
|
46
|
+
Prompter.say_log '_' * @pbar.send(:length)
|
16
47
|
message = "#{prefix_message}Processing #{total_count} documents"
|
17
48
|
message << " in batches of #{batch_size}:" unless batch_size.nil?
|
18
|
-
|
49
|
+
Prompter.say_log message
|
19
50
|
@pbar.start
|
20
51
|
end
|
21
52
|
|
@@ -23,18 +54,24 @@ module Elastics
|
|
23
54
|
unless result.nil? || result.empty?
|
24
55
|
unless result.failed.size == 0
|
25
56
|
Conf.logger.error "Failed load:\n#{result.failed.to_yaml}"
|
26
|
-
@pbar.progress_mark = 'F'
|
57
|
+
@pbar.progress_mark = Dye.dye(' ', 'F', :reed, :reversed, :bold)
|
27
58
|
end
|
28
59
|
@failed_count += result.failed.size
|
29
60
|
@successful_count += result.successful.size
|
30
61
|
end
|
31
|
-
@pbar.progress
|
62
|
+
new_progress = @pbar.progress + inc
|
63
|
+
# avoids an error in case progress > total (may happen in import)
|
64
|
+
@pbar.total = (new_progress + 1) if new_progress > @pbar.total
|
65
|
+
@pbar.progress = new_progress
|
32
66
|
end
|
33
67
|
|
34
68
|
def finish
|
35
69
|
@pbar.finish unless @pbar.finished?
|
36
|
-
|
37
|
-
|
70
|
+
Prompter.say_log "Processed #{@pbar.total}. "
|
71
|
+
Prompter.say_ok "Successful #{@successful_count}. "
|
72
|
+
Prompter.say_notice "Skipped #{@pbar.total - @successful_count - @failed_count}. "
|
73
|
+
Prompter.say_warning "Failed #{@failed_count}.", :mute => true
|
74
|
+
Prompter.say_warning "See the log for the details about the #{@failed_count} failures." unless @failed_count == 0
|
38
75
|
end
|
39
76
|
|
40
77
|
end
|
@@ -116,7 +116,7 @@ module Elastics
|
|
116
116
|
|
117
117
|
def to_bulk_string(meta, source, options)
|
118
118
|
action = options[:action] || 'index'
|
119
|
-
return '' if source.nil? || source.empty?
|
119
|
+
return '' if (source.nil? || source.empty?) && (action != 'delete')
|
120
120
|
meta['_index'] = LiveReindex.prefix_index(meta['_index']) if LiveReindex.should_prefix_index?
|
121
121
|
bulk_string = MultiJson.encode(action => meta) + "\n"
|
122
122
|
unless action == 'delete'
|
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.
|
4
|
+
version: 1.0.8
|
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-
|
12
|
+
date: 2013-08-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
@@ -59,7 +59,27 @@ dependencies:
|
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.1.4
|
62
|
-
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: prompter
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.1.6
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.1.6
|
78
|
+
description: ! 'Core gem used by all the elastics gems. Provides the core resources:
|
79
|
+
HTTP clients,
|
80
|
+
|
81
|
+
Elasticsearch API Methods, Templating System, Cascading Variables Management, Result
|
82
|
+
Extenders, Logging & Debugging, Self-documenting Tool, Rake Tasks, ...'
|
63
83
|
email: dd.nexus@gmail.com
|
64
84
|
executables: []
|
65
85
|
extensions: []
|