solr_wrapper 0.13.2 → 0.14.0
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5211f8f7af81378325cf44e24cb8f93f06662e53
|
4
|
+
data.tar.gz: 0251f3cdb0be7e96b17873f50671a73f3bd60214
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc74ab3b9c410159b831eebbfbc289ffbd0bd33d83d241c4c8d7ee907cab31f81e869eb7f0cd96db830de8ab6a6cf4944490b22afdfc83218c0b1b26864ecbba
|
7
|
+
data.tar.gz: 7c1e5a503b6834218d6621f6a95a4abd744f74b5f68e26846f472cad50ee6276ad588235a91c80209c51ae43bc59d4ba648582f342f13d485a320a48e0845d8d
|
@@ -2,9 +2,11 @@ module SolrWrapper
|
|
2
2
|
class Configuration
|
3
3
|
attr_reader :options
|
4
4
|
|
5
|
-
def initialize(options)
|
6
|
-
@
|
7
|
-
|
5
|
+
def initialize(options = {})
|
6
|
+
@config = options[:config]
|
7
|
+
@verbose = options[:verbose]
|
8
|
+
|
9
|
+
@options = load_configs(Array(options[:config])).merge(options)
|
8
10
|
end
|
9
11
|
|
10
12
|
def solr_xml
|
@@ -87,7 +89,7 @@ module SolrWrapper
|
|
87
89
|
end
|
88
90
|
|
89
91
|
def verbose?
|
90
|
-
!!options.fetch(:verbose, false)
|
92
|
+
@verbose || (options && !!options.fetch(:verbose, false))
|
91
93
|
end
|
92
94
|
|
93
95
|
def version_file
|
@@ -114,21 +116,23 @@ module SolrWrapper
|
|
114
116
|
keys.each_with_object({}) { |k, hash| hash[k] = source[k] if source.has_key?(k) }
|
115
117
|
end
|
116
118
|
|
117
|
-
def
|
118
|
-
|
119
|
+
def load_configs(config_files)
|
120
|
+
config = {}
|
121
|
+
|
122
|
+
(default_configuration_paths + config_files.compact).each do |p|
|
119
123
|
path = File.expand_path(p)
|
120
|
-
|
124
|
+
next unless File.exist? path
|
125
|
+
config.merge!(read_config(path))
|
121
126
|
end
|
122
127
|
|
123
|
-
|
124
|
-
|
125
|
-
return {}
|
126
|
-
end
|
128
|
+
config
|
129
|
+
end
|
127
130
|
|
128
|
-
|
131
|
+
def read_config(config_file)
|
132
|
+
$stdout.puts "Loading configuration from #{config_file}" if verbose?
|
129
133
|
config = YAML.load(ERB.new(IO.read(config_file)).result(binding))
|
130
134
|
unless config
|
131
|
-
$stderr.puts "Unable to parse config #{config_file}" if verbose
|
135
|
+
$stderr.puts "Unable to parse config #{config_file}" if verbose?
|
132
136
|
return {}
|
133
137
|
end
|
134
138
|
convert_keys(config)
|
@@ -139,7 +143,7 @@ module SolrWrapper
|
|
139
143
|
end
|
140
144
|
|
141
145
|
def default_configuration_paths
|
142
|
-
['.
|
146
|
+
['~/.solr_wrapper.yml', '~/.solr_wrapper', '.solr_wrapper.yml', '.solr_wrapper']
|
143
147
|
end
|
144
148
|
end
|
145
149
|
end
|
data/lib/solr_wrapper/version.rb
CHANGED
@@ -22,13 +22,22 @@ describe SolrWrapper::Configuration do
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
describe "#
|
25
|
+
describe "#load_configs" do
|
26
26
|
before do
|
27
27
|
allow(config).to receive(:default_configuration_paths).and_return([])
|
28
28
|
end
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
context 'with a single config file' do
|
30
|
+
let(:options) { { config: 'spec/fixtures/sample_config.yml' } }
|
31
|
+
it "uses values from the config file" do
|
32
|
+
expect(config.port).to eq '9999'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
context 'with multiple config files' do
|
36
|
+
let(:options) { { config: ['spec/fixtures/sample_config.yml', 'spec/fixtures/another_sample_config.yml'] } }
|
37
|
+
it "uses values from the config file" do
|
38
|
+
expect(config.port).to eq '9998'
|
39
|
+
expect(config.verbose?).to eq true
|
40
|
+
end
|
32
41
|
end
|
33
42
|
end
|
34
43
|
|
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.
|
4
|
+
version: 0.14.0
|
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-07-
|
11
|
+
date: 2016-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -167,6 +167,7 @@ files:
|
|
167
167
|
- lib/solr_wrapper/tasks/solr_wrapper.rake
|
168
168
|
- lib/solr_wrapper/version.rb
|
169
169
|
- solr_wrapper.gemspec
|
170
|
+
- spec/fixtures/another_sample_config.yml
|
170
171
|
- spec/fixtures/basic_configs/_rest_managed.json
|
171
172
|
- spec/fixtures/basic_configs/currency.xml
|
172
173
|
- spec/fixtures/basic_configs/lang/stopwords_en.txt
|
@@ -206,6 +207,7 @@ signing_key:
|
|
206
207
|
specification_version: 4
|
207
208
|
summary: Solr 5 service wrapper
|
208
209
|
test_files:
|
210
|
+
- spec/fixtures/another_sample_config.yml
|
209
211
|
- spec/fixtures/basic_configs/_rest_managed.json
|
210
212
|
- spec/fixtures/basic_configs/currency.xml
|
211
213
|
- spec/fixtures/basic_configs/lang/stopwords_en.txt
|