waistband 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/waistband/configuration.rb +5 -1
- data/lib/waistband/index.rb +13 -3
- data/lib/waistband/version.rb +1 -1
- data/spec/config/waistband/waistband_search.yml +1 -0
- data/spec/lib/index_spec.rb +30 -0
- data/spec/spec_helper.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDE2ZWE0ODU1NDM1YzMzM2UwOGIxMDlhZDRhODUxZWI5NDIxMDc3Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGE4YjJhNjc2NDNhMjQ1Zjc3MDU5ZTE4MjZhNTY2ZWIxYjFjZGJiNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTA4NzM4Zjk5YTk0NjZmOGE3OTk4OGUyZGQzYTMyZDkxODFlZGFhNzM2ZDM1
|
10
|
+
NzU0NWU4ZGJiNDk2YzA0ZWM2Zjc1MDJkNzcyYjcxZDRlYTQzNzQ0ZWIxMTYy
|
11
|
+
Y2U4NDA5NDVkMTJhYmU0MTkxMzhmOGUyZjA4YjM4ZmI5MGI4MjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGMwMzA4MGIxZjAyNmIyMzMyMWQxMzllZTM3YzJlZTM3YjI4MDBjOTU2MjRl
|
14
|
+
ZmZjZDlmZDJkZjhiOGMzNThlZDAwNDhhN2QxN2JlNDY1MzNjNzIwYmEwM2E0
|
15
|
+
MDk5NTc0MWVkNzZkOGE2YzE2MGI1NDcyZjIwODU1OTcwMjE3ZGY=
|
@@ -10,7 +10,7 @@ module Waistband
|
|
10
10
|
|
11
11
|
attr_accessor :config_dir
|
12
12
|
attr_writer :timeout
|
13
|
-
attr_reader :env
|
13
|
+
attr_reader :env, :logger
|
14
14
|
|
15
15
|
def initialize
|
16
16
|
@yml_config = {}
|
@@ -68,6 +68,10 @@ module Waistband
|
|
68
68
|
remove_instance_variable '@timeout'
|
69
69
|
end
|
70
70
|
|
71
|
+
def logger=(logger)
|
72
|
+
@logger = logger
|
73
|
+
end
|
74
|
+
|
71
75
|
private
|
72
76
|
|
73
77
|
def load_yml_with_erb(file)
|
data/lib/waistband/index.rb
CHANGED
@@ -12,7 +12,8 @@ module Waistband
|
|
12
12
|
options = options.stringify_keys
|
13
13
|
|
14
14
|
@index_name = index_name
|
15
|
-
@stringify
|
15
|
+
@stringify = config['stringify']
|
16
|
+
@log_level = config['log_level']
|
16
17
|
|
17
18
|
# subindexes checks
|
18
19
|
if options['version'].present?
|
@@ -67,7 +68,7 @@ module Waistband
|
|
67
68
|
end
|
68
69
|
|
69
70
|
def create!
|
70
|
-
client.indices.create index: config_name, body: config.except('name', 'stringify')
|
71
|
+
client.indices.create index: config_name, body: config.except('name', 'stringify', 'log_level')
|
71
72
|
rescue Elasticsearch::Transport::Transport::Errors::BadRequest => ex
|
72
73
|
raise ex unless ex.message.to_s =~ /IndexAlreadyExistsException/
|
73
74
|
raise ::Waistband::Errors::IndexExists.new("Index already exists")
|
@@ -194,7 +195,16 @@ module Waistband
|
|
194
195
|
end
|
195
196
|
|
196
197
|
def client
|
197
|
-
@client ||=
|
198
|
+
@client ||= begin
|
199
|
+
_client = ::Waistband.config.client
|
200
|
+
|
201
|
+
if @log_level && Waistband.config.logger
|
202
|
+
_client.transport.logger = Waistband.config.logger
|
203
|
+
_client.transport.logger.level = @log_level
|
204
|
+
end
|
205
|
+
|
206
|
+
_client
|
207
|
+
end
|
198
208
|
end
|
199
209
|
|
200
210
|
private
|
data/lib/waistband/version.rb
CHANGED
data/spec/lib/index_spec.rb
CHANGED
@@ -323,4 +323,34 @@ describe Waistband::Index do
|
|
323
323
|
|
324
324
|
end
|
325
325
|
|
326
|
+
describe 'logging' do
|
327
|
+
|
328
|
+
class FakeLog
|
329
|
+
attr_reader :level
|
330
|
+
|
331
|
+
def level=(val)
|
332
|
+
@level = val
|
333
|
+
end
|
334
|
+
|
335
|
+
def info(val); end
|
336
|
+
def debug(val); end
|
337
|
+
def fatal(val); end
|
338
|
+
end
|
339
|
+
|
340
|
+
before do
|
341
|
+
Waistband.config.logger = FakeLog.new
|
342
|
+
end
|
343
|
+
|
344
|
+
it "sets the index's client transport logger" do
|
345
|
+
expect(index2.client.transport.logger).to be_a FakeLog
|
346
|
+
expect(index2.client.transport.logger.level).to eql 2
|
347
|
+
end
|
348
|
+
|
349
|
+
it "logs" do
|
350
|
+
expect(Waistband.config.logger).to receive(:info).with(kind_of(String)).once
|
351
|
+
index2.search({})
|
352
|
+
end
|
353
|
+
|
354
|
+
end
|
355
|
+
|
326
356
|
end
|
data/spec/spec_helper.rb
CHANGED