solr_wrapper 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 670f1eb6c506211a4b48b0e9d9dfd323bb84d795f9fa6ff92f2b5215b957b7c2
4
- data.tar.gz: 684817a09ede9dbd1d91175660ea9ac3a570443de19a50a328ef6e0d77947f15
3
+ metadata.gz: 8990953af5f4056ffa716a2d1187995684efdbeb41e3c54e7c1f6056d5875c9d
4
+ data.tar.gz: 80c77a4af17402b1a5743b263bd6ffeeaddb366d13723b64071e50035a313d16
5
5
  SHA512:
6
- metadata.gz: 52615ab1fec5e78d0ea585642940696b25ae185b0c31d925fadcf715821004b65da77abe9e666cf120021ef1b52676d0e8ffee078f1a889d2bc2b3bca9cd0f8a
7
- data.tar.gz: 03316f12ece3f78901e293dbe2cbd65406b103af0d1575fa6a135c98677ae5ec94040b3682a4007f37315d28e7997d031e50c25583e2334a2f3aefd872baaa62
6
+ metadata.gz: 4f8e1736239ffdd87d5327743cc5baab237f56e4b90264ed87b18272a6be225e55f04bfa29fe2fd757f9be32f12a437dbed127b9ed6341fba4100ba03c30cc51
7
+ data.tar.gz: ef4b72a613031cd55d745cb57c76b26f3331e6d877e36133dd72bd859129578dbbbdce07ac05dc5415fac3e5667a73f9ad1d720c1721fda2a1ef1f1956275ac8
data/README.md CHANGED
@@ -46,6 +46,7 @@ SolrWrapper.wrap port: 8983,
46
46
  | solr_options | (Hash) |
47
47
  | env | (Hash) |
48
48
  | persist | (Boolean) Preserves the data in you collection between startups |
49
+ | contrib | (Array<Hash>) |
49
50
 
50
51
  ```ruby
51
52
  solr.with_collection(name: 'collection_name', dir: 'path_to_solr_configs')
@@ -145,18 +145,22 @@ module SolrWrapper
145
145
 
146
146
  def collection_options
147
147
  hash = options.fetch(:collection, {})
148
- Configuration.slice(convert_keys(hash), :name, :dir, :persist)
148
+ Configuration.slice(hash.transform_keys(&:to_sym), :name, :dir, :persist)
149
149
  end
150
150
 
151
151
  def configsets
152
152
  configsets = options[:configsets] || []
153
- configsets.map { |x| convert_keys(x) }
153
+ configsets.map { |x| x.transform_keys(&:to_sym) }
154
154
  end
155
155
 
156
156
  def poll_interval
157
157
  options.fetch(:poll_interval, 1)
158
158
  end
159
159
 
160
+ def contrib
161
+ options.fetch(:contrib, [])
162
+ end
163
+
160
164
  private
161
165
 
162
166
  def self.slice(source, *keys)
@@ -182,11 +186,22 @@ module SolrWrapper
182
186
  $stderr.puts "Unable to parse config #{config_file}" if verbose?
183
187
  return {}
184
188
  end
185
- convert_keys(config)
189
+ config.transform_keys(&:to_sym)
190
+ absoluteize_paths(config, root: File.dirname(config_file))
186
191
  end
187
192
 
188
- def convert_keys(hash)
189
- hash.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
193
+ def absoluteize_paths(config, root: Dir.pwd)
194
+ return config unless config[:contrib]
195
+
196
+ config = config.dup
197
+
198
+ config[:contrib] = config[:contrib].map do |mapping|
199
+ mapping = mapping.transform_keys(&:to_sym)
200
+ mapping[:from] = File.expand_path(mapping[:from], root)
201
+ mapping[:to] ||= 'contrib/'
202
+ end
203
+
204
+ config
190
205
  end
191
206
 
192
207
  def default_configuration_paths
@@ -244,6 +244,14 @@ module SolrWrapper
244
244
  raise_error_unless_extracted
245
245
  FileUtils.cp config.solr_xml, File.join(config.instance_dir, 'server', 'solr', 'solr.xml') if config.solr_xml
246
246
  FileUtils.cp_r File.join(config.extra_lib_dir, '.'), File.join(config.instance_dir, 'server', 'solr', 'lib') if config.extra_lib_dir
247
+
248
+ config.contrib.each do |mapping|
249
+ if File.directory? mapping[:from]
250
+ FileUtils.cp_r mapping[:from], File.join(config.instance_dir, mapping[:to])
251
+ else
252
+ FileUtils.cp mapping[:from], File.join(config.instance_dir, mapping[:to])
253
+ end
254
+ end
247
255
  end
248
256
 
249
257
  def extract_and_configure
@@ -1,4 +1,4 @@
1
- require 'rubygems/package'
1
+ require 'minitar'
2
2
  require 'zlib'
3
3
 
4
4
  module SolrWrapper
@@ -13,29 +13,7 @@ module SolrWrapper
13
13
  end
14
14
 
15
15
  def extract!
16
- Gem::Package::TarReader.new(Zlib::GzipReader.open(file)) do |tar|
17
- dest = nil
18
- tar.each do |entry|
19
- if entry.full_name == TAR_LONGLINK
20
- dest = File.join destination, entry.read.strip
21
- next
22
- end
23
- dest ||= File.join destination, entry.full_name
24
- if entry.directory?
25
- File.delete dest if File.file? dest
26
- FileUtils.mkdir_p dest, mode: entry.header.mode, verbose: false
27
- elsif entry.file?
28
- FileUtils.rm_rf dest if File.directory? dest
29
- File.open dest, 'wb' do |f|
30
- f.print entry.read
31
- end
32
- FileUtils.chmod entry.header.mode, dest, verbose: false
33
- elsif entry.header.typeflag == '2' # Symlink!
34
- File.symlink entry.header.linkname, dest
35
- end
36
- dest = nil
37
- end
38
- end
16
+ Minitar.unpack(Zlib::GzipReader.open(file), destination)
39
17
  rescue StandardError => e
40
18
  abort "Unable to extract #{file} into #{destination}: #{e.message}"
41
19
  end
@@ -1,3 +1,3 @@
1
1
  module SolrWrapper
2
- VERSION = '4.0.0'
2
+ VERSION = '4.0.1'
3
3
  end
data/solr_wrapper.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "http"
22
+ spec.add_dependency "minitar"
22
23
  spec.add_dependency "ruby-progressbar"
23
24
  spec.add_dependency "retriable"
24
25
 
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: 4.0.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-20 00:00:00.000000000 Z
11
+ date: 2022-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitar
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: ruby-progressbar
29
43
  requirement: !ruby/object:Gem::Requirement