solr_wrapper 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/solr_wrapper/configuration.rb +15 -2
- data/lib/solr_wrapper/instance.rb +1 -0
- data/lib/solr_wrapper/version.rb +1 -1
- data/spec/fixtures/sample_config.yml +3 -0
- data/spec/lib/solr_wrapper/configuration_spec.rb +9 -0
- data/spec/lib/solr_wrapper/instance_spec.rb +22 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e4d41ab3bd1b628c5f948717dcf7f48d76d1106
|
4
|
+
data.tar.gz: 204dcf436957092b4f9e787f60ebcd3af028b390
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d234f9ac3315f4a09edd69c759c174305e81ac55ff50165cffcb4a62d2a275fde28acb1c36dd500da796f24120e6ecc668ef70f130a0b9b2a003974e96673893
|
7
|
+
data.tar.gz: 2df041374409128b007c738f2824806bd249a3fce6a10c6400bd2da2273fbe2bb75dd63dc7848c977b57cc2b0e7c54e3b4117c485f7b519b71b99926817d389d
|
@@ -35,7 +35,7 @@ module SolrWrapper
|
|
35
35
|
# Check if the port option has been explicitly set to nil.
|
36
36
|
# this means to start solr wrapper on a random open port
|
37
37
|
return nil if options.key?(:port) && !options[:port]
|
38
|
-
options
|
38
|
+
options.fetch(:port) { SolrWrapper.default_instance_options[:port] }.to_s
|
39
39
|
end
|
40
40
|
|
41
41
|
def download_path
|
@@ -78,8 +78,17 @@ module SolrWrapper
|
|
78
78
|
options[:version_file]
|
79
79
|
end
|
80
80
|
|
81
|
+
def collection_options
|
82
|
+
hash = options.fetch(:collection, {})
|
83
|
+
Configuration.slice(convert_keys(hash), :name, :dir)
|
84
|
+
end
|
85
|
+
|
81
86
|
private
|
82
87
|
|
88
|
+
def self.slice(source, *keys)
|
89
|
+
keys.each_with_object({}) { |k, hash| hash[k] = source[k] if source.has_key?(k) }
|
90
|
+
end
|
91
|
+
|
83
92
|
def read_config(config_file, verbose)
|
84
93
|
default_configuration_paths.each do |p|
|
85
94
|
path = File.expand_path(p)
|
@@ -97,7 +106,11 @@ module SolrWrapper
|
|
97
106
|
$stderr.puts "Unable to parse config #{config_file}" if verbose
|
98
107
|
return {}
|
99
108
|
end
|
100
|
-
config
|
109
|
+
convert_keys(config)
|
110
|
+
end
|
111
|
+
|
112
|
+
def convert_keys(hash)
|
113
|
+
hash.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
101
114
|
end
|
102
115
|
|
103
116
|
def default_configuration_paths
|
data/lib/solr_wrapper/version.rb
CHANGED
@@ -30,6 +30,15 @@ describe SolrWrapper::Configuration do
|
|
30
30
|
it "uses values from the config file" do
|
31
31
|
expect(config.port).to eq '9999'
|
32
32
|
end
|
33
|
+
end
|
33
34
|
|
35
|
+
describe "#collection_options" do
|
36
|
+
before do
|
37
|
+
allow(config).to receive(:default_configuration_paths).and_return([])
|
38
|
+
end
|
39
|
+
let(:options) { { config: 'spec/fixtures/sample_config.yml' } }
|
40
|
+
it "uses values from the config file" do
|
41
|
+
expect(config.collection_options).to eq(name: 'project-development', dir: 'solr/config/')
|
42
|
+
end
|
34
43
|
end
|
35
44
|
end
|
@@ -6,17 +6,32 @@ describe SolrWrapper::Instance do
|
|
6
6
|
let(:client) { SimpleSolrClient::Client.new(subject.url) }
|
7
7
|
|
8
8
|
describe "#with_collection" do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
context "without a name" do
|
10
|
+
it "creates a new anonymous collection" do
|
11
|
+
subject.wrap do |solr|
|
12
|
+
solr.with_collection(dir: File.join(FIXTURES_DIR, "basic_configs")) do |collection_name|
|
13
|
+
core = client.core(collection_name)
|
14
|
+
unless defined? JRUBY_VERSION
|
15
|
+
expect(core.schema.field('id').name).to eq 'id'
|
16
|
+
expect(core.schema.field('id').stored).to eq true
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
22
|
+
context "with a config file" do
|
23
|
+
before do
|
24
|
+
allow(solr_instance.config).to receive(:collection_options)
|
25
|
+
.and_return(name: 'project-development', dir: 'solr/config/')
|
26
|
+
allow(solr_instance).to receive(:delete)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "creates a new collection with options from the config" do
|
30
|
+
expect(solr_instance).to receive(:create).with(
|
31
|
+
hash_including(name: "project-development", dir: anything))
|
32
|
+
solr_instance.with_collection(dir: File.join(FIXTURES_DIR, "basic_configs")) {}
|
33
|
+
end
|
34
|
+
end
|
20
35
|
end
|
21
36
|
|
22
37
|
describe 'exec' do
|
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.3
|
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-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|