solr_wrapper 0.7.1 → 0.7.2
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 +4 -4
- data/lib/solr_wrapper/configuration.rb +19 -16
- data/lib/solr_wrapper/version.rb +1 -1
- data/spec/fixtures/sample_config.yml +1 -0
- data/spec/lib/solr_wrapper/configuration_spec.rb +11 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5611bbe18707e3c1151ebc12b5534beddaaf2bbf
|
4
|
+
data.tar.gz: 4ff113c6e11117820fcfce18c8314c2a1c9d5714
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
86
|
+
config_file ||= path if File.exist? path
|
88
87
|
end
|
89
88
|
|
90
|
-
|
91
|
-
$stdout.puts "
|
92
|
-
|
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
|
data/lib/solr_wrapper/version.rb
CHANGED
@@ -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.
|
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-
|
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.
|
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:
|