solr_wrapper 2.1.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +29 -0
- data/README.md +1 -1
- data/lib/solr_wrapper/checksum_validator.rb +1 -1
- 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/instance.rb +1 -1
- data/lib/solr_wrapper/settings.rb +0 -1
- data/lib/solr_wrapper/version.rb +1 -1
- data/solr_wrapper.gemspec +5 -5
- data/spec/lib/solr_wrapper/configuration_spec.rb +13 -1
- data/spec/lib/solr_wrapper/instance_spec.rb +9 -0
- data/spec/lib/solr_wrapper_spec.rb +9 -0
- metadata +28 -18
- data/.travis.yml +0 -14
- data/coveralls.yml +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 215848180bd8aaa7ba6b0817f682d6ba2c0debda6bbaec6945ecd4573dd2bba1
|
4
|
+
data.tar.gz: 3c253198a29f2623d579e9299c68ff31f8895567cf569db35b9c01771386bdd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b1e4948fd49eb9ec0d069c71d60057a3ad1636d9eae592707266403b73e4f9bd2f2d3e76e88267f9e8be9a136fa10da529faef256ef846c4847977a11422f4a
|
7
|
+
data.tar.gz: ef378700ce2e1fbafa6bcf88fec33f0cf11799a89105bede4372660543cce5d82dd20976bc9e231381dc73c36f1f8ede6a4a2712bd5bc02e4146d2d68076dbe2
|
@@ -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
|
70
|
+
$ solr_wrapper --config <path_to_config_file>
|
71
71
|
```
|
72
72
|
|
73
73
|
### Cleaning your repository from the command line
|
@@ -28,7 +28,7 @@ module SolrWrapper
|
|
28
28
|
if config.default_download_url == config.static_config.archive_download_url
|
29
29
|
"#{config.default_download_url}.#{suffix}"
|
30
30
|
else
|
31
|
-
"
|
31
|
+
"https://archive.apache.org/dist/lucene/solr/#{config.static_config.version}/solr-#{config.static_config.version}.zip.#{suffix}"
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
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[/
|
189
|
+
response = HTTP.follow.get(options.fetch(:latest_version_url, 'https://solr.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, '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
|
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
|
@@ -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
|
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,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 "
|
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", "
|
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://
|
78
|
+
stub_request(:get, 'https://solr.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 }
|
@@ -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.1.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-03-03 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
|
- - ">="
|
@@ -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:
|
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:
|
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
|
-
|
222
|
-
|
223
|
-
signing_key:
|
232
|
+
rubygems_version: 3.2.3
|
233
|
+
signing_key:
|
224
234
|
specification_version: 4
|
225
|
-
summary: Solr
|
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
data/coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
service_name: travis-ci
|