solr_wrapper 0.11.0 → 0.12.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: e09bf11e0bdc4b5b491f07d8a186d1a7b8a5f114
4
- data.tar.gz: 7624c4541d2769a337b2388a5613b97223f4422d
3
+ metadata.gz: a736420ab20bd3fc03e76f752a4e9db186d0b178
4
+ data.tar.gz: 778628b88b1485249f8fd7fd7146fae12304bbf9
5
5
  SHA512:
6
- metadata.gz: 4e39cd0114a9e4c0811d29507e111daebc58a10ac669ee2e83accc7730670ef77fd274522acdd128c5737e90729c969d39c4426dafe237c30c2ba5b941bab37e
7
- data.tar.gz: 9a293c7571d72fc9b107bacf127bc6bc9b81872fd0726650699a3c72ea80a484bd7d779edcaaa52ec39e29c0165af9b524826958aa6204bef082ac832fe5eeb5
6
+ metadata.gz: 0bb64503886ff7849e6500c05d8ce4bcebcbcbe5027a7eed2925cdc1eb4793e4a2f9206ece614fd9b96c5a2c60c98d934d69e0acdb1ea0ec7ddf54511a2eab31
7
+ data.tar.gz: d5e82e93a082b919913916809b7276f1fd7a376d41662de88849a23f83337230dcadc183e1c394e60f4d86b99e9e506c5a5b7cba195054d4af72f2090bd44416
data/README.md CHANGED
@@ -26,7 +26,7 @@ SolrWrapper.wrap port: 8983,
26
26
  instance_dir: '/opt/solr'
27
27
  ```
28
28
 
29
- Options:
29
+ ### Valid ruby and YAML options
30
30
 
31
31
  |Option | |
32
32
  |---------------|-----------------------------------------|
@@ -44,6 +44,7 @@ Options:
44
44
  | ignore_md5sum | (Boolean) |
45
45
  | solr_options | (Hash) |
46
46
  | env | (Hash) |
47
+ | preserve | (Boolean) Preserves the data in you collection between startups |
47
48
 
48
49
  ```ruby
49
50
  solr.with_collection(name: 'collection_name', dir: 'path_to_solr_configs')
@@ -54,6 +55,30 @@ solr.with_collection(name: 'collection_name', dir: 'path_to_solr_configs')
54
55
  ```console
55
56
  $ solr_wrapper -p 8983
56
57
  ```
58
+ To see a list of valid options when using solr_wrapper to launch a Solr instance from the command line:
59
+ ```
60
+ $ solr_wrapper -h
61
+ ```
62
+
63
+ ### Configuration file
64
+ SolrWrapper can read configuration options from a YAML configuration file.
65
+ By default, it looks for configuration files at `.solr_wrapper` and `~/.solr_wrapper`.
66
+
67
+ You can also specify a configuration file when launching from the command line as follows:
68
+ ```
69
+ $ solr_wrapper -config <path_to_config_file>
70
+ ```
71
+
72
+ ### Cleaning your repository from the command line
73
+
74
+ By defualt SorlWrapper will clean out your data when it shuts down.
75
+ If you utilize the preserve option your data will remain between runs.
76
+
77
+ To clean out data that is being preserved explicitly run:
78
+ ```
79
+ $ solr_wrapper <configuration options> clean
80
+ ```
81
+ ***Note*** You must use the same configuration options on the clean command as you do on the run command to clean the correct instance.
57
82
 
58
83
  ## Rake tasks
59
84
 
data/exe/solr_wrapper CHANGED
@@ -5,8 +5,14 @@ require 'optparse'
5
5
 
6
6
  options = {}
7
7
  collection_options = {}
8
+ subtext = <<HELP
9
+ Commonly used command are:
10
+ clean : cleans all data from solr and configures a clean instance based on configuration options
11
+ See 'solr_wrapper COMMAND --help' for more information on a specific command.
12
+ HELP
13
+
8
14
  args = OptionParser.new do |opts|
9
- opts.banner = "Usage: solr_wrapper [options]"
15
+ opts.banner = "Usage: solr_wrapper [options] subcommand"
10
16
 
11
17
  opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
12
18
  options[:verbose] = v
@@ -59,9 +65,23 @@ args = OptionParser.new do |opts|
59
65
  opts.on("--no-checksum", "Skip running checksum validation on the downloaded file") do |d|
60
66
  options[:ignore_md5sum] = true
61
67
  end
68
+
69
+ opts.separator ""
70
+ opts.separator subtext
62
71
  end
63
72
 
73
+
74
+ subcommands = {
75
+ 'clean' => OptionParser.new do |opts|
76
+ opts.banner = "Usage: clean"
77
+ end,
78
+ }
79
+
80
+
64
81
  begin
82
+ args.order!
83
+ command = ARGV.shift
84
+ subcommands[command].order! if command
65
85
  args.parse!
66
86
  rescue => error
67
87
  $stderr.puts "ERROR: #{error}\n"
@@ -73,6 +93,17 @@ end
73
93
  options[:verbose] = true if options[:verbose].nil?
74
94
 
75
95
  instance = SolrWrapper.instance(options)
96
+
97
+ if command == 'clean'
98
+ if instance.started?
99
+ $stderr.puts "Please stop solr before cleaning"
100
+ exit 1
101
+ end
102
+ $stderr.puts "cleaning #{instance.instance_dir}..."
103
+ instance.remove_instance_dir!
104
+ exit 0
105
+ end
106
+
76
107
  $stderr.print "Starting Solr #{instance.version} on port #{instance.port} ... "
77
108
  instance.wrap do |conn|
78
109
  conn.with_collection(collection_options) do
@@ -51,7 +51,7 @@ module SolrWrapper
51
51
 
52
52
  def instance_dir
53
53
  @instance_dir ||= static_config.instance_dir
54
- @instance_dir ||= File.join(Dir.tmpdir, File.basename(download_url, ".zip"))
54
+ @instance_dir ||= File.join(tmpdir, File.basename(download_url, ".zip"))
55
55
  end
56
56
 
57
57
  def managed?
@@ -90,6 +90,14 @@ module SolrWrapper
90
90
 
91
91
  private
92
92
 
93
+ def tmpdir
94
+ if defined?(Rails) && Rails.root
95
+ File.join(Rails.root, 'tmp')
96
+ else
97
+ Dir.tmpdir
98
+ end
99
+ end
100
+
93
101
  def default_solr_zip_path
94
102
  File.join(download_dir, File.basename(download_url))
95
103
  end
@@ -1,3 +1,3 @@
1
1
  module SolrWrapper
2
- VERSION = '0.11.0'
2
+ VERSION = '0.12.0'
3
3
  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.11.0
4
+ version: 0.12.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-05-04 00:00:00.000000000 Z
11
+ date: 2016-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip