solr_wrapper 0.10.0 → 0.11.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: 7916cf546d675d2a3f008f4a271aa4fc2cf7b8ae
4
- data.tar.gz: 3d2e1456ff74edb606a60cef2fa1731ae5a74351
3
+ metadata.gz: e09bf11e0bdc4b5b491f07d8a186d1a7b8a5f114
4
+ data.tar.gz: 7624c4541d2769a337b2388a5613b97223f4422d
5
5
  SHA512:
6
- metadata.gz: ff2b8b312c13c8b68c233f0799c68f36761109beea56fe2648485a89be28980b53d16d5646479ce58c0575cdde11025ff9ed74b81c923eb923953dcfbcf862cf
7
- data.tar.gz: 58a248017fd9ec7330af89ca300d686710a6c71c36d96d9af5cd1967e8c1a703be7618835d30d3f5f7066958e1046fef686f3fa2b0d2d308e3c8f4990c3963fe
6
+ metadata.gz: 4e39cd0114a9e4c0811d29507e111daebc58a10ac669ee2e83accc7730670ef77fd274522acdd128c5737e90729c969d39c4426dafe237c30c2ba5b941bab37e
7
+ data.tar.gz: 9a293c7571d72fc9b107bacf127bc6bc9b81872fd0726650699a3c72ea80a484bd7d779edcaaa52ec39e29c0165af9b524826958aa6204bef082ac832fe5eeb5
data/README.md CHANGED
@@ -35,7 +35,8 @@ Options:
35
35
  | version | Solr version to download and install |
36
36
  | port | port to run Solr on |
37
37
  | version_file | Local path to store the currently installed version |
38
- | download_path | Local path for storing the downloaded Solr zip file |
38
+ | download_dir | Local path for storing the downloaded Solr zip file |
39
+ | solr_zip_path | Local path to the Solr zip file |
39
40
  | md5sum | Path/URL to MD5 checksum |
40
41
  | solr_xml | Path to Solr configuration |
41
42
  | verbose | (Boolean) |
data/exe/solr_wrapper CHANGED
@@ -32,8 +32,8 @@ args = OptionParser.new do |opts|
32
32
  options[:cloud] = c
33
33
  end
34
34
 
35
- opts.on("--download_path PATH", "Download/use solr at the given path") do |d|
36
- options[:download_path] = d
35
+ opts.on("--solr_zip_path PATH", "Download/use solr at the given path") do |d|
36
+ options[:solr_zip_path] = d
37
37
  end
38
38
 
39
39
  opts.on("-iDIR", "--instance_directory DIR", "Install/use solr at the given directory") do |d|
@@ -52,6 +52,10 @@ args = OptionParser.new do |opts|
52
52
  collection_options[:dir] = d
53
53
  end
54
54
 
55
+ opts.on("--[no-]persist", "Persist the solr connection data") do |d|
56
+ collection_options[:persist] = d
57
+ end
58
+
55
59
  opts.on("--no-checksum", "Skip running checksum validation on the downloaded file") do |d|
56
60
  options[:ignore_md5sum] = true
57
61
  end
@@ -46,8 +46,8 @@ module SolrWrapper
46
46
  options[:zookeeper_port]
47
47
  end
48
48
 
49
- def download_path
50
- options[:download_path]
49
+ def solr_zip_path
50
+ options[:solr_zip_path]
51
51
  end
52
52
 
53
53
  def download_dir
@@ -96,7 +96,7 @@ module SolrWrapper
96
96
 
97
97
  def collection_options
98
98
  hash = options.fetch(:collection, {})
99
- Configuration.slice(convert_keys(hash), :name, :dir)
99
+ Configuration.slice(convert_keys(hash), :name, :dir, :persist)
100
100
  end
101
101
 
102
102
  def configsets
@@ -22,8 +22,8 @@ module SolrWrapper
22
22
  # @option options [String] :port port to run Solr on
23
23
  # @option options [Boolean] :cloud Run solr in cloud mode
24
24
  # @option options [String] :version_file Local path to store the currently installed version
25
- # @option options [String] :download_dir Local directory to store the downloaded Solr zip and its md5 file in (overridden by :download_path)
26
- # @option options [String] :download_path Local path for storing the downloaded Solr zip file
25
+ # @option options [String] :download_dir Local directory to store the downloaded Solr zip and its md5 file in (overridden by :solr_zip_path)
26
+ # @option options [String] :solr_zip_path Local path for storing the downloaded Solr zip file
27
27
  # @option options [Boolean] :validate Should solr_wrapper download a new md5 and (re-)validate the zip file? (default: trueF)
28
28
  # @option options [String] :md5sum Path/URL to MD5 checksum
29
29
  # @option options [String] :solr_xml Path to Solr configuration
@@ -208,7 +208,7 @@ module SolrWrapper
208
208
  begin
209
209
  yield name
210
210
  ensure
211
- delete name
211
+ delete name unless options[:persist]
212
212
  end
213
213
  end
214
214
 
@@ -217,7 +217,7 @@ module SolrWrapper
217
217
  def clean!
218
218
  stop
219
219
  remove_instance_dir!
220
- FileUtils.remove_entry(config.download_path) if File.exists?(config.download_path)
220
+ FileUtils.remove_entry(config.download_dir, true) if File.exists?(config.download_dir)
221
221
  FileUtils.remove_entry(config.tmp_save_dir, true) if File.exists? config.tmp_save_dir
222
222
  md5.clean!
223
223
  FileUtils.remove_entry(config.version_file) if File.exists? config.version_file
@@ -285,11 +285,11 @@ module SolrWrapper
285
285
  end
286
286
 
287
287
  def download
288
- unless File.exists?(config.download_path) && md5.validate?(config.download_path)
289
- Downloader.fetch_with_progressbar config.download_url, config.download_path
290
- md5.validate! config.download_path
288
+ unless File.exists?(config.solr_zip_path) && md5.validate?(config.solr_zip_path)
289
+ Downloader.fetch_with_progressbar config.download_url, config.solr_zip_path
290
+ md5.validate! config.solr_zip_path
291
291
  end
292
- config.download_path
292
+ config.solr_zip_path
293
293
  end
294
294
 
295
295
  ##
@@ -63,9 +63,9 @@ module SolrWrapper
63
63
  @download_url ||= default_download_url
64
64
  end
65
65
 
66
- def download_path
67
- @download_path ||= static_config.download_path
68
- @download_path ||= default_download_path
66
+ def solr_zip_path
67
+ @solr_zip_path ||= static_config.solr_zip_path
68
+ @solr_zip_path ||= default_solr_zip_path
69
69
  end
70
70
 
71
71
  def version_file
@@ -90,7 +90,7 @@ module SolrWrapper
90
90
 
91
91
  private
92
92
 
93
- def default_download_path
93
+ def default_solr_zip_path
94
94
  File.join(download_dir, File.basename(download_url))
95
95
  end
96
96
 
@@ -4,7 +4,7 @@ require 'solr_wrapper'
4
4
  namespace :solr do
5
5
  desc "Load the solr options and solr instance"
6
6
  task :environment do
7
- @solr_instance = SolrWrapper.instance
7
+ @solr_instance = SolrWrapper.default_instance
8
8
  end
9
9
 
10
10
  desc 'Install a clean version of solr. Replaces the existing copy if there is one.'
@@ -17,7 +17,7 @@ namespace :solr do
17
17
  desc 'start solr'
18
18
  task start: :environment do
19
19
  begin
20
- puts "Starting solr at #{File.expand_path(@solr_instance.instance_dir)} with options #{@solr_instance.options}"
20
+ puts "Starting solr at #{@solr_instance.config.url}"
21
21
  @solr_instance.start
22
22
  rescue => e
23
23
  if e.message.include?("Port #{@solr_instance.port} is already being used by another process")
@@ -1,3 +1,3 @@
1
1
  module SolrWrapper
2
- VERSION = '0.10.0'
2
+ VERSION = '0.11.0'
3
3
  end
@@ -2,6 +2,7 @@ port: 9999
2
2
  collection:
3
3
  dir: solr/config/
4
4
  name: project-development
5
+ persist: false
5
6
  configsets:
6
7
  - dir: solr/config/
7
8
  name: project-development-configset
@@ -38,7 +38,7 @@ describe SolrWrapper::Configuration do
38
38
  end
39
39
  let(:options) { { config: 'spec/fixtures/sample_config.yml' } }
40
40
  it "uses values from the config file" do
41
- expect(config.collection_options).to eq(name: 'project-development', dir: 'solr/config/')
41
+ expect(config.collection_options).to eq(name: 'project-development', dir: 'solr/config/', persist: false)
42
42
  end
43
43
  end
44
44
 
@@ -34,6 +34,15 @@ describe SolrWrapper::Instance do
34
34
  solr_instance.with_collection(dir: File.join(FIXTURES_DIR, "basic_configs")) {}
35
35
  end
36
36
  end
37
+
38
+ context 'persistent collections' do
39
+ it "creates a new collection with options from the config" do
40
+ expect(solr_instance).to receive(:create).with(
41
+ hash_including(name: 'project-development'))
42
+ expect(solr_instance).not_to receive(:delete)
43
+ solr_instance.with_collection(name: 'project-development', dir: 'solr/config/', persist: true) {}
44
+ end
45
+ end
37
46
  end
38
47
 
39
48
  context 'with a SolrCloud instance' 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.10.0
4
+ version: 0.11.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-04-21 00:00:00.000000000 Z
11
+ date: 2016-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip