fcrepo_wrapper 0.3.0 → 0.4.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 +4 -4
- data/README.md +37 -2
- data/exe/fcrepo_wrapper +18 -5
- data/lib/fcrepo_wrapper/configuration.rb +26 -2
- data/lib/fcrepo_wrapper/instance.rb +11 -3
- data/lib/fcrepo_wrapper/settings.rb +1 -0
- data/lib/fcrepo_wrapper/tasks/fcrepo_wrapper.rake +0 -1
- data/lib/fcrepo_wrapper/version.rb +1 -1
- data/lib/fcrepo_wrapper.rb +3 -10
- data/spec/lib/fcrepo_wrapper/configuration_spec.rb +17 -1
- data/spec/lib/fcrepo_wrapper/instance_spec.rb +10 -1
- data/spec/lib/fcrepo_wrapper/md5_spec.rb +24 -0
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c13336376dbcb9d568acba19a92fd5555595af05
|
|
4
|
+
data.tar.gz: 597e66ac22ce559f7a028a54e9c74f6f0a247a2d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2bbdc8828cdf9b44c4d32fc026c1e8b99a1cb86373b61a885aa1e6cf4a34127c27c0422f0b2c9a177449ee10054b19dfe5b2aab902075e56dce45a48503d3a15
|
|
7
|
+
data.tar.gz: 52a8673487e434d352d70a6b7b6244eb63bfd6416b27f536fd12b57e2594539412f3306c0f700533054c0ef357b1225fa80e34433a3dd5207bf838fa18bc1ad7
|
data/README.md
CHANGED
|
@@ -8,8 +8,43 @@ FcrepoWrapper.wrap do |solr|
|
|
|
8
8
|
end
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Configuration Options
|
|
12
12
|
|
|
13
|
+
### Command Line
|
|
14
|
+
To see a list of valid options when using fcrepo_wrapper to launch an Fcrepo instance from the command line:
|
|
15
|
+
```
|
|
16
|
+
$ fcrepo_wrapper -h
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Ruby
|
|
13
20
|
```ruby
|
|
14
|
-
FcrepoWrapper.wrap port: 8983, verbose: true, managed: true
|
|
21
|
+
FcrepoWrapper.wrap( port: 8983, verbose: true, managed: true )
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Configuration file
|
|
25
|
+
FcrepoWrapper can read configuration options from a YAML configuration file.
|
|
26
|
+
By default, it looks for configuration files at `.fcrepo_wrapper` and `~/.fcrepo_wrapper`.
|
|
27
|
+
|
|
28
|
+
You can also specify a configuration file when launching from the command line as follows:
|
|
29
|
+
```
|
|
30
|
+
$ fcrepo_wrapper -config <path_to_config_file>
|
|
15
31
|
```
|
|
32
|
+
|
|
33
|
+
### Valid ruby and YAML options
|
|
34
|
+
|Option | Description |
|
|
35
|
+
|-----------------|-----------------------------------------|
|
|
36
|
+
| download_dir | Local path for storing the downloaded jar & md5 file |
|
|
37
|
+
| env | *(Hash)* |
|
|
38
|
+
| fcrepo_home_dir | Directory to store fedora repoistory data files |
|
|
39
|
+
| fedora_options | *(Hash)* |
|
|
40
|
+
| ignore_md5sum | *(Boolean)* suppress checksum error messages |
|
|
41
|
+
| instance_dir | Directory to store the fedora jar file |
|
|
42
|
+
| md5sum | Path/URL to MD5 checksum |
|
|
43
|
+
| port | Port to run Fedora on |
|
|
44
|
+
| url | URL of the jar file to download |
|
|
45
|
+
| validate | *(Boolean)* download a new md5 and (re-)validate the jar file? (default: true) |
|
|
46
|
+
| verbose | *(Boolean)* return verbose info when running fcrepo commands (default: false) |
|
|
47
|
+
| version | Fedora version to download and install |
|
|
48
|
+
| version_file | Local path to store the currently installed version number |
|
|
49
|
+
|
|
50
|
+
|
data/exe/fcrepo_wrapper
CHANGED
|
@@ -5,10 +5,10 @@ require 'optparse'
|
|
|
5
5
|
|
|
6
6
|
options = {}
|
|
7
7
|
|
|
8
|
-
OptionParser.new do |opts|
|
|
8
|
+
args = OptionParser.new do |opts|
|
|
9
9
|
opts.banner = "Usage: fcrepo_wrapper [options]"
|
|
10
10
|
|
|
11
|
-
opts.on("--config", "Load configuration from a file") do |v|
|
|
11
|
+
opts.on("--config FILE", "Load configuration from a file") do |v|
|
|
12
12
|
options[:config] = v
|
|
13
13
|
end
|
|
14
14
|
|
|
@@ -16,7 +16,7 @@ OptionParser.new do |opts|
|
|
|
16
16
|
options[:verbose] = v
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
opts.on("--[no-]jms", "Run
|
|
19
|
+
opts.on("--[no-]jms", "Run with[or witout] JMS") do |v|
|
|
20
20
|
options[:enable_jms] = v
|
|
21
21
|
end
|
|
22
22
|
|
|
@@ -24,7 +24,7 @@ OptionParser.new do |opts|
|
|
|
24
24
|
options[:version] = v
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
opts.on("-pPORT", "--port PORT", "Specify the port fcrepo should run at (default:
|
|
27
|
+
opts.on("-pPORT", "--port PORT", "Specify the port fcrepo should run at (default: #{FcrepoWrapper.default_fcrepo_port})") do |p|
|
|
28
28
|
if p == 'random'
|
|
29
29
|
options[:port] = nil
|
|
30
30
|
else
|
|
@@ -39,7 +39,20 @@ OptionParser.new do |opts|
|
|
|
39
39
|
opts.on("-dDIR", "--fcrepo_home DIR", "Store fcrepo at the given directory") do |d|
|
|
40
40
|
options[:fcrepo_home_dir] = d
|
|
41
41
|
end
|
|
42
|
-
|
|
42
|
+
|
|
43
|
+
opts.on("-h", "--help", "Show these usage options") do
|
|
44
|
+
puts opts
|
|
45
|
+
exit
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
begin
|
|
50
|
+
args.parse!
|
|
51
|
+
rescue => error
|
|
52
|
+
$stderr.puts "ERROR: #{error}\n"
|
|
53
|
+
$stderr.puts "#{args.help}\n"
|
|
54
|
+
exit 1
|
|
55
|
+
end
|
|
43
56
|
|
|
44
57
|
# default to verbose
|
|
45
58
|
options[:verbose] = true if options[:verbose].nil?
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
require 'yaml'
|
|
2
|
+
require 'erb'
|
|
3
|
+
require 'socket'
|
|
4
|
+
|
|
1
5
|
module FcrepoWrapper
|
|
2
6
|
class Configuration
|
|
3
7
|
attr_reader :options
|
|
@@ -22,6 +26,10 @@ module FcrepoWrapper
|
|
|
22
26
|
@download_path ||= options.fetch(:download_path, default_download_path)
|
|
23
27
|
end
|
|
24
28
|
|
|
29
|
+
def ignore_md5sum
|
|
30
|
+
options.fetch(:ignore_md5sum, false)
|
|
31
|
+
end
|
|
32
|
+
|
|
25
33
|
def md5sum_path
|
|
26
34
|
File.join(download_dir, File.basename(md5url))
|
|
27
35
|
end
|
|
@@ -87,7 +95,15 @@ module FcrepoWrapper
|
|
|
87
95
|
# Check if the port option has been explicitly set to nil.
|
|
88
96
|
# this means to start fcrepo_wrapper on a random open port
|
|
89
97
|
return nil if options.key?(:port) && !options[:port]
|
|
90
|
-
options[:port] || FcrepoWrapper.
|
|
98
|
+
options[:port] || FcrepoWrapper.default_fcrepo_port
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def validate
|
|
102
|
+
options.fetch(:validate, true)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def md5sum
|
|
106
|
+
options.fetch(:md5sum, nil)
|
|
91
107
|
end
|
|
92
108
|
|
|
93
109
|
private
|
|
@@ -116,8 +132,16 @@ module FcrepoWrapper
|
|
|
116
132
|
['.fcrepo_wrapper', '~/.fcrepo_wrapper']
|
|
117
133
|
end
|
|
118
134
|
|
|
135
|
+
def default_download_dir
|
|
136
|
+
if defined? Rails
|
|
137
|
+
File.join(Rails.root, 'tmp')
|
|
138
|
+
else
|
|
139
|
+
Dir.tmpdir
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
119
143
|
def download_dir
|
|
120
|
-
@download_dir ||= options.fetch(:download_dir,
|
|
144
|
+
@download_dir ||= options.fetch(:download_dir, default_download_dir)
|
|
121
145
|
FileUtils.mkdir_p @download_dir
|
|
122
146
|
@download_dir
|
|
123
147
|
end
|
|
@@ -22,7 +22,7 @@ module FcrepoWrapper
|
|
|
22
22
|
# @option options [String] :version_file Local path to store the currently installed version
|
|
23
23
|
# @option options [String] :download_dir Local directory to store the downloaded fcrepo jar and its md5 file in (overridden by :download_path)
|
|
24
24
|
# @option options [String] :download_path Local path for storing the downloaded fcrepo jar file
|
|
25
|
-
# @option options [Boolean] :validate Should fcrepo_wrapper download a new md5 and (re-)
|
|
25
|
+
# @option options [Boolean] :validate Should fcrepo_wrapper download a new md5 and (re-)false the zip file? (default: trueF)
|
|
26
26
|
# @option options [String] :md5sum Path/URL to MD5 checksum
|
|
27
27
|
# @option options [Boolean] :verbose return verbose info when running fcrepo commands
|
|
28
28
|
# @option options [Boolean] :ignore_md5sum
|
|
@@ -141,6 +141,14 @@ module FcrepoWrapper
|
|
|
141
141
|
config.version
|
|
142
142
|
end
|
|
143
143
|
|
|
144
|
+
def instance_dir
|
|
145
|
+
config.instance_dir
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def options
|
|
149
|
+
config.options
|
|
150
|
+
end
|
|
151
|
+
|
|
144
152
|
##
|
|
145
153
|
# Clean up any files fcrepo_wrapper may have downloaded
|
|
146
154
|
def clean!
|
|
@@ -191,9 +199,9 @@ module FcrepoWrapper
|
|
|
191
199
|
end
|
|
192
200
|
|
|
193
201
|
def download
|
|
194
|
-
unless File.exists?(config.download_path) && validate?(config.download_path)
|
|
202
|
+
unless File.exists?(config.download_path) && md5.validate?(config.download_path)
|
|
195
203
|
Downloader.fetch_with_progressbar config.download_url, config.download_path
|
|
196
|
-
validate! config.download_path
|
|
204
|
+
md5.validate! config.download_path
|
|
197
205
|
end
|
|
198
206
|
config.download_path
|
|
199
207
|
end
|
|
@@ -4,7 +4,6 @@ require 'fcrepo_wrapper'
|
|
|
4
4
|
namespace :fcrepo do
|
|
5
5
|
desc "Load the fcrepo options and fcrepo instance"
|
|
6
6
|
task :environment do
|
|
7
|
-
FcrepoWrapper.default_instance_options[:download_dir] ||= Rails.root.to_s + '/tmp' if defined? Rails
|
|
8
7
|
@fcrepo_instance = FcrepoWrapper.default_instance
|
|
9
8
|
end
|
|
10
9
|
|
data/lib/fcrepo_wrapper.rb
CHANGED
|
@@ -10,19 +10,12 @@ module FcrepoWrapper
|
|
|
10
10
|
'4.5.0'
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def self.
|
|
14
|
-
|
|
15
|
-
port: '8080',
|
|
16
|
-
version: FcrepoWrapper.default_fcrepo_version
|
|
17
|
-
}
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def self.default_instance_options=(options)
|
|
21
|
-
@default_instance_options = options
|
|
13
|
+
def self.default_fcrepo_port
|
|
14
|
+
'8080'
|
|
22
15
|
end
|
|
23
16
|
|
|
24
17
|
def self.default_instance(options = {})
|
|
25
|
-
@default_instance ||= FcrepoWrapper::Instance.new
|
|
18
|
+
@default_instance ||= FcrepoWrapper::Instance.new options
|
|
26
19
|
end
|
|
27
20
|
|
|
28
21
|
##
|
|
@@ -30,7 +30,23 @@ describe FcrepoWrapper::Configuration do
|
|
|
30
30
|
it "uses values from the config file" do
|
|
31
31
|
expect(config.port).to eq '9999'
|
|
32
32
|
end
|
|
33
|
+
end
|
|
33
34
|
|
|
35
|
+
describe "#validate" do
|
|
36
|
+
let(:options) { {} }
|
|
37
|
+
subject { config.validate }
|
|
38
|
+
it { is_expected.to eq true }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
describe "#md5sum" do
|
|
42
|
+
let(:options) { {} }
|
|
43
|
+
subject { config.md5sum }
|
|
44
|
+
it { is_expected.to be nil }
|
|
34
45
|
end
|
|
35
|
-
end
|
|
36
46
|
|
|
47
|
+
describe "#ignore_md5sum" do
|
|
48
|
+
let(:options) { {} }
|
|
49
|
+
subject { config.ignore_md5sum }
|
|
50
|
+
it { is_expected.to be false }
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -27,5 +27,14 @@ describe FcrepoWrapper::Instance do
|
|
|
27
27
|
subject { wrapper.md5 }
|
|
28
28
|
it { is_expected.to be_instance_of FcrepoWrapper::MD5 }
|
|
29
29
|
end
|
|
30
|
-
end
|
|
31
30
|
|
|
31
|
+
describe "#instance_dir" do
|
|
32
|
+
subject { File.exists?(wrapper.instance_dir) }
|
|
33
|
+
it { is_expected.to be true }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe "#options" do
|
|
37
|
+
subject { wrapper.options }
|
|
38
|
+
it { is_expected.to eq({}) }
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe FcrepoWrapper::MD5 do
|
|
4
|
+
let(:options) { {} }
|
|
5
|
+
let(:config) { FcrepoWrapper::Configuration.new options }
|
|
6
|
+
let(:md5) { described_class.new(config) }
|
|
7
|
+
let(:file) { 'spec/fixtures/sample_config.yml' }
|
|
8
|
+
|
|
9
|
+
describe "#validate!" do
|
|
10
|
+
subject { md5.validate!(file) }
|
|
11
|
+
context "with a checksum mismatch" do
|
|
12
|
+
it "raises an error" do
|
|
13
|
+
expect { subject }.to raise_error "MD5 mismatch"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
context "with a correct checksum" do
|
|
18
|
+
let(:options) { { md5sum: 'de0b8ccf94db635e149b4c01027b34c1' } }
|
|
19
|
+
it "doesn't raise an error" do
|
|
20
|
+
expect { subject }.not_to raise_error
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fcrepo_wrapper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.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-
|
|
11
|
+
date: 2016-04-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ruby-progressbar
|
|
@@ -127,6 +127,7 @@ files:
|
|
|
127
127
|
- spec/fixtures/sample_config.yml
|
|
128
128
|
- spec/lib/fcrepo_wrapper/configuration_spec.rb
|
|
129
129
|
- spec/lib/fcrepo_wrapper/instance_spec.rb
|
|
130
|
+
- spec/lib/fcrepo_wrapper/md5_spec.rb
|
|
130
131
|
- spec/lib/fcrepo_wrapper_spec.rb
|
|
131
132
|
- spec/spec_helper.rb
|
|
132
133
|
homepage: https://github.com/cbeer/fcrepo_wrapper
|
|
@@ -149,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
149
150
|
version: '0'
|
|
150
151
|
requirements: []
|
|
151
152
|
rubyforge_project:
|
|
152
|
-
rubygems_version: 2.5.1
|
|
153
|
+
rubygems_version: 2.4.5.1
|
|
153
154
|
signing_key:
|
|
154
155
|
specification_version: 4
|
|
155
156
|
summary: Solr 5 service wrapper
|
|
@@ -157,6 +158,6 @@ test_files:
|
|
|
157
158
|
- spec/fixtures/sample_config.yml
|
|
158
159
|
- spec/lib/fcrepo_wrapper/configuration_spec.rb
|
|
159
160
|
- spec/lib/fcrepo_wrapper/instance_spec.rb
|
|
161
|
+
- spec/lib/fcrepo_wrapper/md5_spec.rb
|
|
160
162
|
- spec/lib/fcrepo_wrapper_spec.rb
|
|
161
163
|
- spec/spec_helper.rb
|
|
162
|
-
has_rdoc:
|