solr_wrapper 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02e09a40b71a00bd7d2d4781cfbc997755b05f7e
4
- data.tar.gz: 6172a2f652b6fd0b731f7f9f7ca71dd28a190807
3
+ metadata.gz: 5611bbe18707e3c1151ebc12b5534beddaaf2bbf
4
+ data.tar.gz: 4ff113c6e11117820fcfce18c8314c2a1c9d5714
5
5
  SHA512:
6
- metadata.gz: 29cc339f0a9e697345e832a03b1927e8f3749d7039d168f60cc7f13bed1920b94677a6821f8913b5c5faf39c84a45e39d0ca5a1ece16de23eb2bf8d82d956113
7
- data.tar.gz: 451b5c6f30a7b3265abe2ee8ad117598497001b0b2deb8da31d0141c14633aa9b380e6358a18a4b06d233bf5925d97e353e9ab943944372315ed466e113f99b6
6
+ metadata.gz: 57e9df554289cddd628c8b3a87926119821fd7ca66c41ab4444208b409df33663142b4d787df79bf7116b8280458e77e5fe5e4e7fd28615d98ad0914df6730e9
7
+ data.tar.gz: c9d28c85027dc87f57b584190e4a2257cb2af14df5cf5cd3825e10a9eed98955f8509e565238b42dc02c99de01092e276736bf628c76ee176d42a0769a7ee91e
@@ -3,8 +3,8 @@ module SolrWrapper
3
3
  attr_reader :options
4
4
 
5
5
  def initialize(options)
6
- @options = options
7
- read_config
6
+ @options = read_config(options[:config], options[:verbose])
7
+ .merge options
8
8
  end
9
9
 
10
10
  def solr_xml
@@ -80,25 +80,28 @@ module SolrWrapper
80
80
 
81
81
  private
82
82
 
83
- def read_config
84
- default_configuration_paths = ['.solr_wrapper', '~/.solr_wrapper']
83
+ def read_config(config_file, verbose)
85
84
  default_configuration_paths.each do |p|
86
85
  path = File.expand_path(p)
87
- options[:config] ||= path if File.exist? path
86
+ config_file ||= path if File.exist? path
88
87
  end
89
88
 
90
- if options[:config]
91
- $stdout.puts "Loading configuration from #{options[:config]}" if verbose?
92
- config = YAML.load(ERB.new(IO.read(options[:config])).result(binding))
93
- unless config
94
- $stderr.puts "Unable to parse config #{options[:config]}" if verbose?
95
- return
96
- end
97
- collection_config = config.delete(:collection) || {}
98
- @options = config.merge(options)
99
- elsif verbose?
100
- $stdout.puts "No config specified"
89
+ unless config_file
90
+ $stdout.puts "No config specified" if verbose
91
+ return {}
101
92
  end
93
+
94
+ $stdout.puts "Loading configuration from #{config_file}" if verbose
95
+ config = YAML.load(ERB.new(IO.read(config_file)).result(binding))
96
+ unless config
97
+ $stderr.puts "Unable to parse config #{config_file}" if verbose
98
+ return {}
99
+ end
100
+ config.each_with_object({}) { |(k, v), h| h[k.to_sym] = v.to_s }
101
+ end
102
+
103
+ def default_configuration_paths
104
+ ['.solr_wrapper', '~/.solr_wrapper']
102
105
  end
103
106
  end
104
107
  end
@@ -1,3 +1,3 @@
1
1
  module SolrWrapper
2
- VERSION = '0.7.1'
2
+ VERSION = '0.7.2'
3
3
  end
@@ -0,0 +1 @@
1
+ port: 9999
@@ -21,4 +21,15 @@ describe SolrWrapper::Configuration do
21
21
  it { is_expected.to eq '8888' }
22
22
  end
23
23
  end
24
+
25
+ describe "#read_config" do
26
+ before do
27
+ allow(config).to receive(:default_configuration_paths).and_return([])
28
+ end
29
+ let(:options) { { config: 'spec/fixtures/sample_config.yml' } }
30
+ it "uses values from the config file" do
31
+ expect(config.port).to eq '9999'
32
+ end
33
+
34
+ end
24
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solr_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-15 00:00:00.000000000 Z
11
+ date: 2016-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -146,6 +146,7 @@ files:
146
146
  - spec/fixtures/basic_configs/solrconfig.xml
147
147
  - spec/fixtures/basic_configs/stopwords.txt
148
148
  - spec/fixtures/basic_configs/synonyms.txt
149
+ - spec/fixtures/sample_config.yml
149
150
  - spec/lib/solr_wrapper/configuration_spec.rb
150
151
  - spec/lib/solr_wrapper/instance_spec.rb
151
152
  - spec/lib/solr_wrapper_spec.rb
@@ -170,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
171
  version: '0'
171
172
  requirements: []
172
173
  rubyforge_project:
173
- rubygems_version: 2.4.5.1
174
+ rubygems_version: 2.5.1
174
175
  signing_key:
175
176
  specification_version: 4
176
177
  summary: Solr 5 service wrapper
@@ -183,7 +184,9 @@ test_files:
183
184
  - spec/fixtures/basic_configs/solrconfig.xml
184
185
  - spec/fixtures/basic_configs/stopwords.txt
185
186
  - spec/fixtures/basic_configs/synonyms.txt
187
+ - spec/fixtures/sample_config.yml
186
188
  - spec/lib/solr_wrapper/configuration_spec.rb
187
189
  - spec/lib/solr_wrapper/instance_spec.rb
188
190
  - spec/lib/solr_wrapper_spec.rb
189
191
  - spec/spec_helper.rb
192
+ has_rdoc: