waistband 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,6 +24,7 @@ module Waistband
24
24
 
25
25
  @env ||= ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
26
26
  @yml_config = YAML.load_file("#{config_dir}/waistband.yml")[@env].with_indifferent_access
27
+ @adapter = @yml_config.delete('adapter')
27
28
  end
28
29
 
29
30
  def index(name)
@@ -42,18 +43,21 @@ module Waistband
42
43
  end
43
44
 
44
45
  def client
45
- Elasticsearch::Client.new(
46
- hosts: hosts,
47
- randomize_hosts: true,
48
- retry_on_failure: retries,
49
- reload_on_failure: reload_on_failure,
50
- transport_options: {
51
- request: {
52
- open_timeout: @yml_config['timeout'],
53
- timeout: @yml_config['timeout']
54
- }
55
- }
56
- )
46
+ client_hash = {
47
+ adapter: @adapter,
48
+ hosts: hosts,
49
+ randomize_hosts: true,
50
+ retry_on_failure: retries,
51
+ reload_on_failure: reload_on_failure,
52
+ transport_options: {
53
+ request: {
54
+ open_timeout: @yml_config['timeout'],
55
+ timeout: @yml_config['timeout']
56
+ }
57
+ }
58
+ }
59
+
60
+ Elasticsearch::Client.new client_hash
57
61
  end
58
62
 
59
63
  private
@@ -1,3 +1,3 @@
1
1
  module Waistband
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.4"
3
3
  end
@@ -23,6 +23,17 @@ describe Waistband::Configuration do
23
23
  expect(::Waistband.client).to be_a ::Elasticsearch::Transport::Client
24
24
  end
25
25
 
26
+ it "permits passing in an adapter to use to the client" do
27
+ original_config = YAML.load_file(File.join(::Waistband.config.config_dir, 'waistband.yml'))['test']
28
+
29
+ expect(::Waistband.config.instance_variable_get('@adapter')).to be_nil
30
+
31
+ YAML.stub(:load_file).and_return({'test' => original_config.merge({'adapter' => :net_http})})
32
+ ::Waistband.config.setup
33
+ expect(::Waistband.config.instance_variable_get('@adapter')).to eql :net_http
34
+ expect(::Waistband.client.transport.options[:adapter]).to eql :net_http
35
+ end
36
+
26
37
  describe '#hosts' do
27
38
 
28
39
  it "returns array of all available servers' configs" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waistband
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
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: 2014-03-17 00:00:00.000000000 Z
12
+ date: 2014-03-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport