solr_wrapper 2.0.0 → 3.0.2

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
- SHA1:
3
- metadata.gz: 3991dd503c5902e6012328a4663edff78f669fbf
4
- data.tar.gz: 7d17c2fcc21fa1e370a4903c393de8b3ae207f76
2
+ SHA256:
3
+ metadata.gz: a5473b8362859de2a2eb8a07ef3d6763ea79ffa2ebcb05a415e9b2433c3564f0
4
+ data.tar.gz: 7708aa3b496183092ddf62cb75e571bfd2b7c7c61f87d7879f03f9682fbc5446
5
5
  SHA512:
6
- metadata.gz: 650abf178f6f41be0f6a96c01699edbdee09a82d6bcca41223ce0c185524bc0d59ec549c669232abab75e85ce187bdb03acf759f94033b0fb2cdd2071b0e1a99
7
- data.tar.gz: 29f4b23edfee5ee869b1626c0f88775468106dff2ae5a2059ef1d805cc3d7f03e76d9c285f9e0822583026190160db0d1ae8a361745b8b45a599e70d01f35e1a
6
+ metadata.gz: 80a8c8d2fc20ed98f740f4e797e80f83a8a00617c02b6676ae6474003c0a5b5927c4e0c3fddc03caee6d7cfbd116e87c8a15291865958b50e0e5a8f66cc02955
7
+ data.tar.gz: b709788733088394e43d352b551e5dee97354fec73d6827140823927dbc3c503512333d6411995190a23d396c2cbc5c28cafbd87330933e59da7d3a5a005ca16
@@ -0,0 +1,29 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby:
15
+ - 2.7
16
+ - 3.0
17
+ - jruby-9.2.14.0
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby }}
24
+ - name: Install dependencies
25
+ run: bundle install
26
+ - name: Run tests
27
+ run: bundle exec rake
28
+ env:
29
+ ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test'
data/README.md CHANGED
@@ -67,7 +67,7 @@ By default, it looks for configuration files at `.solr_wrapper` and `~/.solr_wra
67
67
 
68
68
  You can also specify a configuration file when launching from the command line as follows:
69
69
  ```
70
- $ solr_wrapper -config <path_to_config_file>
70
+ $ solr_wrapper --config <path_to_config_file>
71
71
  ```
72
72
 
73
73
  ### Cleaning your repository from the command line
@@ -2,20 +2,18 @@ module SolrWrapper
2
2
  class ChecksumValidator
3
3
  attr_reader :config
4
4
 
5
- ALGORITHM = 'sha1'
6
-
7
5
  def initialize(config)
8
6
  @config = config
9
7
  end
10
8
 
11
9
  def clean!
12
- path = checksum_path(ALGORITHM)
10
+ path = checksum_path(algorithm)
13
11
  FileUtils.remove_entry(path) if File.exist? path
14
12
  end
15
13
 
16
14
  def validate?(file)
17
15
  return true if config.validate == false
18
- Digest.const_get(ALGORITHM.upcase).file(file).hexdigest == expected_sum(ALGORITHM)
16
+ Digest.const_get(algorithm.upcase).file(file).hexdigest == expected_sum(algorithm)
19
17
  end
20
18
 
21
19
  def validate!(file)
@@ -30,7 +28,7 @@ module SolrWrapper
30
28
  if config.default_download_url == config.static_config.archive_download_url
31
29
  "#{config.default_download_url}.#{suffix}"
32
30
  else
33
- "http://www.us.apache.org/dist/lucene/solr/#{config.static_config.version}/solr-#{config.static_config.version}.zip.#{suffix}"
31
+ "https://archive.apache.org/dist/lucene/solr/#{config.static_config.version}/solr-#{config.static_config.version}.zip.#{suffix}"
34
32
  end
35
33
  end
36
34
 
@@ -53,5 +51,12 @@ module SolrWrapper
53
51
  end
54
52
  path
55
53
  end
54
+
55
+ def algorithm
56
+ return config.static_config.algorithm if config.static_config.algorithm
57
+ return 'sha1' if config.static_config.version =~ /^[1-6]/ || config.static_config.version =~ /^[7]\.[0-4]/
58
+
59
+ 'sha512'
60
+ end
56
61
  end
57
62
  end
@@ -1,4 +1,4 @@
1
- require 'faraday'
1
+ require 'http'
2
2
  require 'json'
3
3
 
4
4
  module SolrWrapper
@@ -18,19 +18,16 @@ module SolrWrapper
18
18
  private
19
19
 
20
20
  def collection?(name)
21
- response = conn.get('admin/collections?action=LIST&wt=json')
21
+ response = HTTP.get("#{url}admin/collections?action=LIST&wt=json")
22
22
  data = JSON.parse(response.body)
23
23
  return if data['error'] && data['error']['msg'] == 'Solr instance is not running in SolrCloud mode.'
24
+
24
25
  data['collections'].include? name
25
26
  end
26
27
 
27
28
  def core?(name)
28
- response = conn.get('admin/cores?action=STATUS&wt=json&core=' + name)
29
+ response = HTTP.get("#{url}admin/cores?action=STATUS&wt=json&core=#{name}")
29
30
  !JSON.parse(response.body)['status'][name].empty?
30
31
  end
31
-
32
- def conn
33
- @conn ||= Faraday.new(url: url)
34
- end
35
32
  end
36
33
  end
@@ -1,4 +1,4 @@
1
- require 'faraday'
1
+ require 'http'
2
2
 
3
3
  module SolrWrapper
4
4
  class Configuration
@@ -31,6 +31,10 @@ module SolrWrapper
31
31
  options[:checksum]
32
32
  end
33
33
 
34
+ def algorithm
35
+ options[:algorithm]
36
+ end
37
+
34
38
  def url
35
39
  options[:url]
36
40
  end
@@ -98,19 +102,18 @@ module SolrWrapper
98
102
  options[:mirror_url] + "lucene/solr/#{version}/solr-#{version}.zip"
99
103
  else
100
104
  begin
101
- json = open(closest_mirror_url).read
105
+ json = HTTP.get(closest_mirror_url).body
102
106
  doc = JSON.parse(json)
103
107
  url = doc['preferred'] + doc['path_info']
104
108
 
105
- response = Faraday.head(url)
109
+ response = HTTP.head(url)
106
110
 
107
- if response.success?
111
+ if response.status.success?
108
112
  url
109
113
  else
110
114
  archive_download_url
111
115
  end
112
-
113
- rescue Errno::ECONNRESET, SocketError, Faraday::Error
116
+ rescue Errno::ECONNRESET, SocketError, HTTP::Error
114
117
  archive_download_url
115
118
  end
116
119
  end
@@ -183,8 +186,8 @@ module SolrWrapper
183
186
  end
184
187
 
185
188
  def fetch_latest_version
186
- response = Faraday.get('https://lucene.apache.org/latestversion.html')
187
- response.body[/Apache Solr \d+\.\d+\.\d+/][/\d+\.\d+\.\d+/]
189
+ response = HTTP.get(options.fetch(:latest_version_url, 'https://lucene.apache.org/solr/downloads.html'))
190
+ response.body.to_s[/Solr \d+\.\d+\.\d+/][/\d+\.\d+\.\d+/]
188
191
  end
189
192
  end
190
193
  end
@@ -1,24 +1,34 @@
1
1
  require 'ruby-progressbar'
2
+ require 'http'
2
3
 
3
4
  module SolrWrapper
4
5
  class Downloader
5
6
  def self.fetch_with_progressbar(url, output)
6
7
  pbar = SafeProgressBar.new(title: File.basename(url), total: nil, format: '%t: |%B| %p%% (%e )')
7
- open(url, content_length_proc: ->(bytes) { pbar.total = bytes }, progress_proc: ->(bytes) { pbar.progress = bytes }) do |io|
8
- IO.copy_stream(io, output)
8
+
9
+ response = HTTP.follow.get(url)
10
+ pbar.total = response.headers['content-length'].to_i
11
+
12
+ File.open(output, 'wb') do |f|
13
+ response.body.each do |chunk|
14
+ f.write(chunk)
15
+ pbar.progress += chunk.length
16
+ end
17
+
18
+ nil
9
19
  end
10
- rescue OpenURI::HTTPError => e
11
- raise SolrWrapperError, "Unable to download solr from #{url}\n#{e.message}: #{e.io.read}"
20
+ rescue HTTP::Error => e
21
+ raise SolrWrapperError, "Unable to download solr from #{url}\n#{e}"
12
22
  end
13
23
 
14
24
  class SafeProgressBar < ProgressBar::Base
15
25
  def progress=(new_progress)
16
- self.total = new_progress if total <= new_progress
26
+ self.total = new_progress if total.to_i <= new_progress
17
27
  super
18
28
  end
19
29
 
20
30
  def total=(new_total)
21
- super if new_total && new_total > 0
31
+ super if new_total && new_total >= 0
22
32
  end
23
33
  end
24
34
  end
@@ -318,7 +318,7 @@ module SolrWrapper
318
318
  exit_status = runner.run(stringio)
319
319
 
320
320
  if exit_status != 0 && cmd != 'status'
321
- raise "Failed to execute solr #{cmd}: #{stringio.read}. Further information may be available in #{instance_dir}/logs"
321
+ raise "Failed to execute solr #{cmd}: #{stringio.read}. Further information may be available in #{instance_dir}/server/logs"
322
322
  end
323
323
 
324
324
  stringio
@@ -1,5 +1,4 @@
1
1
  require 'delegate'
2
- require 'faraday'
3
2
 
4
3
  module SolrWrapper
5
4
  # Configuraton that comes from static and dynamic sources.
@@ -1,3 +1,3 @@
1
1
  module SolrWrapper
2
- VERSION = '2.0.0'
2
+ VERSION = '3.0.2'
3
3
  end
data/solr_wrapper.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = SolrWrapper::VERSION
9
9
  spec.authors = ["Chris Beer"]
10
10
  spec.email = ["chris@cbeer.info"]
11
- spec.summary = %q{Solr 5 service wrapper}
11
+ spec.summary = %q{Solr service wrapper}
12
12
  spec.homepage = "https://github.com/cbeer/solr_wrapper"
13
13
  spec.license = "MIT"
14
14
 
@@ -18,16 +18,16 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "faraday"
21
+ spec.add_dependency "http"
22
22
  spec.add_dependency "rubyzip"
23
23
  spec.add_dependency "ruby-progressbar"
24
24
  spec.add_dependency "retriable"
25
25
 
26
- spec.add_development_dependency "bundler", "~> 1.7"
27
- spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "bundler", ">= 1.7", "< 3"
27
+ spec.add_development_dependency "rake", "~> 10.0", "< 13"
28
28
 
29
29
  spec.add_development_dependency "rspec"
30
- spec.add_development_dependency "simple_solr_client"
30
+ spec.add_development_dependency "simple_solr_client", "= 0.2.0" # 0.2.1 removed support for schema retrieval
31
31
  spec.add_development_dependency "coveralls"
32
32
  spec.add_development_dependency "webmock"
33
33
  end
@@ -75,13 +75,25 @@ describe SolrWrapper::Configuration do
75
75
  let(:options) { { version: 'latest'} }
76
76
 
77
77
  before do
78
- stub_request(:get, 'https://lucene.apache.org/latestversion.html').to_return(body: 'Apache Solr 1.2.3')
78
+ stub_request(:get, 'https://lucene.apache.org/solr/downloads.html').to_return(body: 'Solr 1.2.3 is the latest version')
79
79
  end
80
80
 
81
81
  it 'fetches the latest version number from apache' do
82
82
  expect(config.version).to eq '1.2.3'
83
83
  end
84
84
  end
85
+
86
+ context 'when it is "latest" and the latest url is configured' do
87
+ let(:options) { { version: 'latest', latest_version_url: 'https://example.com/latest.html'} }
88
+
89
+ before do
90
+ stub_request(:get, 'https://example.com/latest.html').to_return(body: 'Solr 1.2.1')
91
+ end
92
+
93
+ it 'fetches the latest version number from apache' do
94
+ expect(config.version).to eq '1.2.1'
95
+ end
96
+ end
85
97
  end
86
98
 
87
99
  describe '#mirror_url' do
@@ -1,6 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SolrWrapper::Instance do
4
+ # WebMock messes with HTTP.rbs ability to stream responses
5
+ before(:all) do
6
+ WebMock.disable!
7
+ end
8
+
9
+ after(:all) do
10
+ WebMock.enable!
11
+ end
12
+
4
13
  let(:options) { {} }
5
14
  let(:solr_instance) { SolrWrapper::Instance.new(options) }
6
15
  subject { solr_instance }
@@ -83,7 +92,8 @@ describe SolrWrapper::Instance do
83
92
  solr.downconfig name: config_name, dir: dir
84
93
  end
85
94
  solr.with_collection(config_name: config_name) do |collection_name|
86
- core = client.core(collection_name)
95
+ core_name = client.cores.select { |x| x =~ /^#{collection_name}/ }.first
96
+ core = client.core(core_name)
87
97
  unless defined? JRUBY_VERSION
88
98
  expect(core.all.size).to eq 0
89
99
  end
@@ -1,6 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SolrWrapper do
4
+ # WebMock messes with HTTP.rbs ability to stream responses
5
+ before(:all) do
6
+ WebMock.disable!
7
+ end
8
+
9
+ after(:all) do
10
+ WebMock.enable!
11
+ end
12
+
4
13
  describe ".wrap" do
5
14
  it "should launch solr" do
6
15
  SolrWrapper.wrap do |solr|
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solr_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-27 00:00:00.000000000 Z
11
+ date: 2021-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: faraday
14
+ name: http
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -70,16 +70,22 @@ dependencies:
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.7'
76
+ - - "<"
77
+ - !ruby/object:Gem::Version
78
+ version: '3'
76
79
  type: :development
77
80
  prerelease: false
78
81
  version_requirements: !ruby/object:Gem::Requirement
79
82
  requirements:
80
- - - "~>"
83
+ - - ">="
81
84
  - !ruby/object:Gem::Version
82
85
  version: '1.7'
86
+ - - "<"
87
+ - !ruby/object:Gem::Version
88
+ version: '3'
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: rake
85
91
  requirement: !ruby/object:Gem::Requirement
@@ -87,6 +93,9 @@ dependencies:
87
93
  - - "~>"
88
94
  - !ruby/object:Gem::Version
89
95
  version: '10.0'
96
+ - - "<"
97
+ - !ruby/object:Gem::Version
98
+ version: '13'
90
99
  type: :development
91
100
  prerelease: false
92
101
  version_requirements: !ruby/object:Gem::Requirement
@@ -94,6 +103,9 @@ dependencies:
94
103
  - - "~>"
95
104
  - !ruby/object:Gem::Version
96
105
  version: '10.0'
106
+ - - "<"
107
+ - !ruby/object:Gem::Version
108
+ version: '13'
97
109
  - !ruby/object:Gem::Dependency
98
110
  name: rspec
99
111
  requirement: !ruby/object:Gem::Requirement
@@ -112,16 +124,16 @@ dependencies:
112
124
  name: simple_solr_client
113
125
  requirement: !ruby/object:Gem::Requirement
114
126
  requirements:
115
- - - ">="
127
+ - - '='
116
128
  - !ruby/object:Gem::Version
117
- version: '0'
129
+ version: 0.2.0
118
130
  type: :development
119
131
  prerelease: false
120
132
  version_requirements: !ruby/object:Gem::Requirement
121
133
  requirements:
122
- - - ">="
134
+ - - '='
123
135
  - !ruby/object:Gem::Version
124
- version: '0'
136
+ version: 0.2.0
125
137
  - !ruby/object:Gem::Dependency
126
138
  name: coveralls
127
139
  requirement: !ruby/object:Gem::Requirement
@@ -150,7 +162,7 @@ dependencies:
150
162
  - - ">="
151
163
  - !ruby/object:Gem::Version
152
164
  version: '0'
153
- description:
165
+ description:
154
166
  email:
155
167
  - chris@cbeer.info
156
168
  executables:
@@ -158,17 +170,16 @@ executables:
158
170
  extensions: []
159
171
  extra_rdoc_files: []
160
172
  files:
173
+ - ".github/workflows/ci.yml"
161
174
  - ".gitignore"
162
175
  - ".hound.yml"
163
176
  - ".rspec"
164
177
  - ".rubocop.yml"
165
178
  - ".rubocop_todo.yml"
166
- - ".travis.yml"
167
179
  - Gemfile
168
180
  - LICENSE
169
181
  - README.md
170
182
  - Rakefile
171
- - coveralls.yml
172
183
  - exe/solr_wrapper
173
184
  - lib/solr_wrapper.rb
174
185
  - lib/solr_wrapper/checksum_validator.rb
@@ -203,7 +214,7 @@ homepage: https://github.com/cbeer/solr_wrapper
203
214
  licenses:
204
215
  - MIT
205
216
  metadata: {}
206
- post_install_message:
217
+ post_install_message:
207
218
  rdoc_options: []
208
219
  require_paths:
209
220
  - lib
@@ -218,11 +229,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
229
  - !ruby/object:Gem::Version
219
230
  version: '0'
220
231
  requirements: []
221
- rubyforge_project:
222
- rubygems_version: 2.6.11
223
- signing_key:
232
+ rubygems_version: 3.2.3
233
+ signing_key:
224
234
  specification_version: 4
225
- summary: Solr 5 service wrapper
235
+ summary: Solr service wrapper
226
236
  test_files:
227
237
  - spec/fixtures/another_sample_config.yml
228
238
  - spec/fixtures/basic_configs/_rest_managed.json
data/.travis.yml DELETED
@@ -1,14 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- rvm:
4
- - 2.5.0
5
- - 2.4.2
6
- - 2.3.6
7
- - jruby-9.1.16.0
8
-
9
- jdk:
10
- - oraclejdk8
11
-
12
- env:
13
- global:
14
- JRUBY_OPTS=-J-Xmx2g
data/coveralls.yml DELETED
@@ -1 +0,0 @@
1
- service_name: travis-ci