solr_wrapper 2.2.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +29 -0
- data/lib/solr_wrapper/client.rb +4 -7
- data/lib/solr_wrapper/configuration.rb +7 -8
- data/lib/solr_wrapper/downloader.rb +16 -6
- data/lib/solr_wrapper/settings.rb +0 -1
- data/lib/solr_wrapper/version.rb +1 -1
- data/solr_wrapper.gemspec +2 -2
- data/spec/lib/solr_wrapper/instance_spec.rb +9 -0
- data/spec/lib/solr_wrapper_spec.rb +9 -0
- metadata +10 -11
- data/.travis.yml +0 -13
- data/coveralls.yml +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 375a30420891aefb1b28895bdea108a53af69c668514c3157cd3fb150b7f616a
|
4
|
+
data.tar.gz: 7980d452b1f499809904c844dfcc1000e0e15b30d80cb223af08c329052a57ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7ebfeaa76e02a58df27d460a2dc8375c3e66d4d4e4ab92e9ce9cb11954a4926bf349187d2434d1a324b6f95a0f8f4407b17645dc3fbadbbca10e34b83fd1bde
|
7
|
+
data.tar.gz: a8cbb45b871e3dc18b842f24a97a9f0335f1a31f52dcfedbeb5bb9303d97416f61697a069face9a85d2646413a3fde560a25517feb185904312cff6456e7d9f5
|
@@ -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/lib/solr_wrapper/client.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
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 =
|
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 =
|
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 '
|
1
|
+
require 'http'
|
2
2
|
|
3
3
|
module SolrWrapper
|
4
4
|
class Configuration
|
@@ -102,19 +102,18 @@ module SolrWrapper
|
|
102
102
|
options[:mirror_url] + "lucene/solr/#{version}/solr-#{version}.zip"
|
103
103
|
else
|
104
104
|
begin
|
105
|
-
json =
|
105
|
+
json = HTTP.get(closest_mirror_url).body
|
106
106
|
doc = JSON.parse(json)
|
107
107
|
url = doc['preferred'] + doc['path_info']
|
108
108
|
|
109
|
-
response =
|
109
|
+
response = HTTP.head(url)
|
110
110
|
|
111
|
-
if response.success?
|
111
|
+
if response.status.success?
|
112
112
|
url
|
113
113
|
else
|
114
114
|
archive_download_url
|
115
115
|
end
|
116
|
-
|
117
|
-
rescue Errno::ECONNRESET, SocketError, Faraday::Error
|
116
|
+
rescue Errno::ECONNRESET, SocketError, HTTP::Error
|
118
117
|
archive_download_url
|
119
118
|
end
|
120
119
|
end
|
@@ -187,8 +186,8 @@ module SolrWrapper
|
|
187
186
|
end
|
188
187
|
|
189
188
|
def fetch_latest_version
|
190
|
-
response =
|
191
|
-
response.body[/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+/]
|
192
191
|
end
|
193
192
|
end
|
194
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
|
-
|
8
|
-
|
8
|
+
|
9
|
+
response = HTTP.follow.get(url)
|
10
|
+
pbar.total = response.headers['content-length'].to_i
|
11
|
+
|
12
|
+
File.open(output, 'w') 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
|
11
|
-
raise SolrWrapperError, "Unable to download solr from #{url}\n#{e
|
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
|
31
|
+
super if new_total && new_total >= 0
|
22
32
|
end
|
23
33
|
end
|
24
34
|
end
|
data/lib/solr_wrapper/version.rb
CHANGED
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
|
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,7 +18,7 @@ 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 "
|
21
|
+
spec.add_dependency "http"
|
22
22
|
spec.add_dependency "rubyzip"
|
23
23
|
spec.add_dependency "ruby-progressbar"
|
24
24
|
spec.add_dependency "retriable"
|
@@ -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 }
|
@@ -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:
|
4
|
+
version: 3.0.0
|
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:
|
11
|
+
date: 2021-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: http
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -162,7 +162,7 @@ dependencies:
|
|
162
162
|
- - ">="
|
163
163
|
- !ruby/object:Gem::Version
|
164
164
|
version: '0'
|
165
|
-
description:
|
165
|
+
description:
|
166
166
|
email:
|
167
167
|
- chris@cbeer.info
|
168
168
|
executables:
|
@@ -170,17 +170,16 @@ executables:
|
|
170
170
|
extensions: []
|
171
171
|
extra_rdoc_files: []
|
172
172
|
files:
|
173
|
+
- ".github/workflows/ci.yml"
|
173
174
|
- ".gitignore"
|
174
175
|
- ".hound.yml"
|
175
176
|
- ".rspec"
|
176
177
|
- ".rubocop.yml"
|
177
178
|
- ".rubocop_todo.yml"
|
178
|
-
- ".travis.yml"
|
179
179
|
- Gemfile
|
180
180
|
- LICENSE
|
181
181
|
- README.md
|
182
182
|
- Rakefile
|
183
|
-
- coveralls.yml
|
184
183
|
- exe/solr_wrapper
|
185
184
|
- lib/solr_wrapper.rb
|
186
185
|
- lib/solr_wrapper/checksum_validator.rb
|
@@ -215,7 +214,7 @@ homepage: https://github.com/cbeer/solr_wrapper
|
|
215
214
|
licenses:
|
216
215
|
- MIT
|
217
216
|
metadata: {}
|
218
|
-
post_install_message:
|
217
|
+
post_install_message:
|
219
218
|
rdoc_options: []
|
220
219
|
require_paths:
|
221
220
|
- lib
|
@@ -230,10 +229,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
230
229
|
- !ruby/object:Gem::Version
|
231
230
|
version: '0'
|
232
231
|
requirements: []
|
233
|
-
rubygems_version: 3.
|
234
|
-
signing_key:
|
232
|
+
rubygems_version: 3.2.3
|
233
|
+
signing_key:
|
235
234
|
specification_version: 4
|
236
|
-
summary: Solr
|
235
|
+
summary: Solr service wrapper
|
237
236
|
test_files:
|
238
237
|
- spec/fixtures/another_sample_config.yml
|
239
238
|
- spec/fixtures/basic_configs/_rest_managed.json
|
data/.travis.yml
DELETED
data/coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
service_name: travis-ci
|