fcrepo_wrapper 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a144f4c282130ef794aacb6218cf8134b563c8ef
4
- data.tar.gz: 49d5805fc67970698545245d9707a832e5f5c57b
3
+ metadata.gz: 32ab8e3c5f45580a33497d826bf7b1b709b51780
4
+ data.tar.gz: 40bf4c99f37dfb5dd1e0a3c669e656d4a7757831
5
5
  SHA512:
6
- metadata.gz: 1514aa19a011b30e50864ca5d00cd3d493b5a4297fd066ce1eccec5c6843061ac62fe76046f6e7c4ce365f909d3818671efb2dccd0df9610eef1c828384de2af
7
- data.tar.gz: e13cda2c8ca4211ab18bb3e1c4515c66fd533140c03a2d6cf9494e3f09ffaec4640abe07add3ef69e54377b90db7e57922e0ebecd4632bc14b919e471c87cb06
6
+ metadata.gz: 7bb4083970b80e8c68b3421d93b2af097d77d2629fcbcfa1ea655f0a537d42242705e347b83893550fdba64380f6c858c09ac5827c21b93b1a6ad68dc673e9f9
7
+ data.tar.gz: 4140735815d94087e4f7b93adbe981fdbb99e33ed7e7fe75720db8c173e64be028dd5927615d4badef76e5816207f204e1561c559a1b35fedffdaee34c6cc16c
data/.gitignore CHANGED
@@ -33,3 +33,5 @@ build/
33
33
 
34
34
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
35
  .rvmrc
36
+
37
+ /fcrepo4-data
data/README.md CHANGED
@@ -11,5 +11,5 @@ end
11
11
  ## Basic Options
12
12
 
13
13
  ```ruby
14
- FcrepoWrapper.wrap port: 8983, verbose: true, managed: true
14
+ FcrepoWrapper.wrap port: 8983, verbose: true, managed: true
15
15
  ```
data/exe/fcrepo_wrapper CHANGED
@@ -8,6 +8,10 @@ options = {}
8
8
  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|
12
+ options[:config] = v
13
+ end
14
+
11
15
  opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
12
16
  options[:verbose] = v
13
17
  end
@@ -20,7 +24,7 @@ OptionParser.new do |opts|
20
24
  options[:version] = v
21
25
  end
22
26
 
23
- opts.on("-pPORT", "--port PORT", "Specify the port fcrepo should run at (default: 8983)") do |p|
27
+ opts.on("-pPORT", "--port PORT", "Specify the port fcrepo should run at (default: 8080)") do |p|
24
28
  if p == 'random'
25
29
  options[:port] = nil
26
30
  else
@@ -0,0 +1,147 @@
1
+ module FcrepoWrapper
2
+ class Configuration
3
+ attr_reader :options
4
+ def initialize(options)
5
+ @options = read_config(options[:config], options[:verbose])
6
+ .merge options
7
+ end
8
+
9
+ def instance_dir
10
+ @instance_dir ||= options.fetch(:instance_dir, File.join(Dir.tmpdir, File.basename(download_url, ".jar")))
11
+ end
12
+
13
+ def download_url
14
+ @download_url ||= options.fetch(:url, default_download_url)
15
+ end
16
+
17
+ def default_download_path
18
+ File.join(download_dir, File.basename(download_url))
19
+ end
20
+
21
+ def download_path
22
+ @download_path ||= options.fetch(:download_path, default_download_path)
23
+ end
24
+
25
+ def md5sum_path
26
+ File.join(download_dir, File.basename(md5url))
27
+ end
28
+
29
+ def tmp_save_dir
30
+ @tmp_save_dir ||= Dir.mktmpdir
31
+ end
32
+
33
+ def version
34
+ @version ||= options.fetch(:version, FcrepoWrapper.default_fcrepo_version)
35
+ end
36
+
37
+ def version_file
38
+ options.fetch(:version_file, File.join(instance_dir, "VERSION"))
39
+ end
40
+
41
+ def binary_path
42
+ File.join(instance_dir, "fcrepo-webapp-#{version}-jetty-console.jar")
43
+ end
44
+
45
+ def md5url
46
+ "https://github.com/fcrepo4/fcrepo4/releases/download/fcrepo-#{version}/fcrepo-webapp-#{version}-jetty-console.jar.md5"
47
+ end
48
+
49
+ def fcrepo_options
50
+ options.fetch(:fcrepo_options, headless: nil)
51
+ end
52
+
53
+ def env
54
+ options.fetch(:env, {})
55
+ end
56
+
57
+ def verbose?
58
+ !!options.fetch(:verbose, false)
59
+ end
60
+
61
+ def managed?
62
+ File.exists?(instance_dir)
63
+ end
64
+
65
+ # @return a list of arguments to pass to the JVM
66
+ def java_options
67
+ options.fetch(:java_options, default_java_options) + ['-jar', binary_path]
68
+ end
69
+
70
+ def default_java_options
71
+ ['-Dfcrepo.log.http.api=WARN',
72
+ # To avoid "WARN: The namespace of predicate:
73
+ # info:fedora/fedora-system:def/relations-external#isPartOf
74
+ # was possibly misinterpreted as:
75
+ # info:fedora/fedora-system:def/relations-external#."
76
+ '-Dfcrepo.log.kernel=ERROR',
77
+ ("-Dfcrepo.home=#{fcrepo_home_dir}" if fcrepo_home_dir),
78
+ ("-Dfcrepo.spring.jms.configuration=#{spring_noop_file}" unless jms_enabled?),
79
+ '-Xmx512m'].compact
80
+ end
81
+
82
+ def fcrepo_home_dir
83
+ options[:fcrepo_home_dir]
84
+ end
85
+
86
+ def port
87
+ # Check if the port option has been explicitly set to nil.
88
+ # this means to start fcrepo_wrapper on a random open port
89
+ return nil if options.key?(:port) && !options[:port]
90
+ options[:port] || FcrepoWrapper.default_instance_options[:port]
91
+ end
92
+
93
+ private
94
+
95
+ def read_config(config_file, verbose)
96
+ default_configuration_paths.each do |p|
97
+ path = File.expand_path(p)
98
+ config_file ||= path if File.exist? path
99
+ end
100
+
101
+ unless config_file
102
+ $stdout.puts "No config specified" if verbose
103
+ return {}
104
+ end
105
+
106
+ $stdout.puts "Loading configuration from #{config_file}" if verbose
107
+ config = YAML.load(ERB.new(IO.read(config_file)).result(binding))
108
+ unless config
109
+ $stderr.puts "Unable to parse config #{config_file}" if verbose
110
+ return {}
111
+ end
112
+ config.each_with_object({}) { |(k, v), h| h[k.to_sym] = v.to_s }
113
+ end
114
+
115
+ def default_configuration_paths
116
+ ['.fcrepo_wrapper', '~/.fcrepo_wrapper']
117
+ end
118
+
119
+ def download_dir
120
+ @download_dir ||= options.fetch(:download_dir, Dir.tmpdir)
121
+ FileUtils.mkdir_p @download_dir
122
+ @download_dir
123
+ end
124
+
125
+ def default_download_url
126
+ @default_url ||= "https://github.com/fcrepo4/fcrepo4/releases/download/fcrepo-#{version}/fcrepo-webapp-#{version}-jetty-console.jar"
127
+ end
128
+
129
+ def random_open_port
130
+ socket = Socket.new(:INET, :STREAM, 0)
131
+ begin
132
+ socket.bind(Addrinfo.tcp('127.0.0.1', 0))
133
+ socket.local_address.ip_port
134
+ ensure
135
+ socket.close
136
+ end
137
+ end
138
+
139
+ def spring_noop_file
140
+ 'file://' + File.expand_path('../../../data/spring-noop.xml', __FILE__)
141
+ end
142
+
143
+ def jms_enabled?
144
+ options.fetch(:enable_jms, true)
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,18 @@
1
+ module FcrepoWrapper
2
+ class Downloader
3
+ def self.fetch_with_progressbar(url, output)
4
+ pbar = ProgressBar.create(title: File.basename(url), total: nil, format: "%t: |%B| %p%% (%e )")
5
+ open(url, content_length_proc: lambda do|t|
6
+ if t && 0 < t
7
+ pbar.total = t
8
+ end
9
+ end,
10
+ progress_proc: lambda do|s|
11
+ pbar.progress = s
12
+ end) do |io|
13
+ IO.copy_stream(io, output)
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -1,6 +1,7 @@
1
1
  require 'digest'
2
2
  require 'fileutils'
3
3
  require 'json'
4
+ require 'net/http'
4
5
  require 'open-uri'
5
6
  require 'ruby-progressbar'
6
7
  require 'securerandom'
@@ -10,7 +11,7 @@ require 'tmpdir'
10
11
 
11
12
  module FcrepoWrapper
12
13
  class Instance
13
- attr_reader :options, :pid
14
+ attr_reader :config, :pid
14
15
 
15
16
  ##
16
17
  # @param [Hash] options
@@ -28,7 +29,11 @@ module FcrepoWrapper
28
29
  # @option options [Hash] :fcrepo_options
29
30
  # @option options [Hash] :env
30
31
  def initialize(options = {})
31
- @options = options
32
+ @config = Settings.new(Configuration.new(options))
33
+ end
34
+
35
+ def md5
36
+ @md5 ||= MD5.new(config)
32
37
  end
33
38
 
34
39
  def wrap(&_block)
@@ -39,30 +44,9 @@ module FcrepoWrapper
39
44
  stop
40
45
  end
41
46
 
42
- # @return a list of arguments to pass to the JVM
43
- def java_options
44
- options.fetch(:java_options, default_java_options) + ['-jar', binary_path]
45
- end
46
-
47
- def default_java_options
48
- ['-Dfcrepo.log.http.api=WARN',
49
- # To avoid "WARN: The namespace of predicate:
50
- # info:fedora/fedora-system:def/relations-external#isPartOf
51
- # was possibly misinterpreted as:
52
- # info:fedora/fedora-system:def/relations-external#."
53
- '-Dfcrepo.log.kernel=ERROR',
54
- ("-Dfcrepo.home=#{fcrepo_home_dir}" if fcrepo_home_dir),
55
- ("-Dfcrepo.spring.jms.configuration=#{spring_noop_file}" unless jms_enabled?),
56
- '-Xmx512m'].compact
57
- end
58
-
59
- def fcrepo_home_dir
60
- options[:fcrepo_home_dir]
61
- end
62
-
63
47
  def process_arguments
64
- ["java"] + java_options +
65
- fcrepo_options.merge(port: port)
48
+ ["java"] + config.java_options +
49
+ config.fcrepo_options.merge(port: port)
66
50
  .map { |k, v| ["--#{k}", "#{v}"].reject(&:empty?) }.flatten
67
51
  end
68
52
 
@@ -70,8 +54,8 @@ module FcrepoWrapper
70
54
  # Start fcrepo and wait for it to become available
71
55
  def start
72
56
  extract_and_configure
73
- if managed?
74
- @pid = spawn(env, *process_arguments)
57
+ if config.managed?
58
+ @pid = spawn(config.env, *process_arguments)
75
59
 
76
60
  # Wait for fcrepo to start
77
61
  while !status
@@ -83,7 +67,7 @@ module FcrepoWrapper
83
67
  ##
84
68
  # Stop fcrepo and wait for it to finish exiting
85
69
  def stop
86
- if managed? && started?
70
+ if config.managed? && started?
87
71
  Process.kill 'HUP', pid
88
72
 
89
73
  # Wait for fcrepo to stop
@@ -100,7 +84,7 @@ module FcrepoWrapper
100
84
  ##
101
85
  # Stop fcrepo and wait for it to finish exiting
102
86
  def restart
103
- if managed? && started?
87
+ if config.managed? && started?
104
88
  stop
105
89
  start
106
90
  end
@@ -109,12 +93,16 @@ module FcrepoWrapper
109
93
  ##
110
94
  # Check the status of a managed fcrepo service
111
95
  def status
112
- return true unless managed?
96
+ return true unless config.managed?
113
97
  return false if pid.nil?
114
98
 
115
99
  begin
116
100
  Process.getpgid(pid)
101
+ rescue Errno::ESRCH
102
+ return false
103
+ end
117
104
 
105
+ begin
118
106
  TCPSocket.new(host, port).close
119
107
 
120
108
  Net::HTTP.start(host, port) do |http|
@@ -122,7 +110,7 @@ module FcrepoWrapper
122
110
  end
123
111
 
124
112
  true
125
- rescue Errno::ESRCH, Errno::ECONNREFUSED
113
+ rescue Errno::ECONNREFUSED, Errno::EINVAL
126
114
  false
127
115
  end
128
116
  end
@@ -139,11 +127,18 @@ module FcrepoWrapper
139
127
  '127.0.0.1'
140
128
  end
141
129
 
142
- ##
143
- # Get the port this fcrepo instance is running at
144
130
  def port
145
- @port ||= options[:port]
146
- @port ||= random_open_port.to_s
131
+ config.port
132
+ end
133
+
134
+ ##
135
+ # Get a (likely) URL to the fcrepo instance
136
+ def url
137
+ "http://#{host}:#{port}/"
138
+ end
139
+
140
+ def version
141
+ config.version
147
142
  end
148
143
 
149
144
  ##
@@ -151,32 +146,22 @@ module FcrepoWrapper
151
146
  def clean!
152
147
  stop
153
148
  remove_instance_dir!
154
- FileUtils.remove_entry(download_path) if File.exists?(download_path)
155
- FileUtils.remove_entry(tmp_save_dir, true) if File.exists? tmp_save_dir
156
- FileUtils.remove_entry(md5sum_path) if File.exists? md5sum_path
157
- FileUtils.remove_entry(version_file) if File.exists? version_file
149
+ FileUtils.remove_entry(config.download_path) if File.exists?(config.download_path)
150
+ FileUtils.remove_entry(config.tmp_save_dir, true) if File.exists? config.tmp_save_dir
151
+ md5.clean!
152
+ FileUtils.remove_entry(config.version_file) if File.exists? config.version_file
158
153
  end
159
154
 
160
155
  ##
161
156
  # Clean up any files in the fcrepo instance dir
162
157
  def remove_instance_dir!
163
- FileUtils.remove_entry(instance_dir, true) if File.exists? instance_dir
164
- end
165
-
166
- ##
167
- # Get a (likely) URL to the fcrepo instance
168
- def url
169
- "http://#{host}:#{port}/"
158
+ FileUtils.remove_entry(config.instance_dir, true) if File.exists? config.instance_dir
170
159
  end
171
160
 
172
161
  def configure
173
162
  raise_error_unless_extracted
174
163
  end
175
164
 
176
- def instance_dir
177
- @instance_dir ||= options.fetch(:instance_dir, File.join(Dir.tmpdir, File.basename(download_url, ".jar")))
178
- end
179
-
180
165
  def extract_and_configure
181
166
  instance_dir = extract
182
167
  configure
@@ -187,164 +172,46 @@ module FcrepoWrapper
187
172
  # Does noting if fcrepo already exists at instance_dir
188
173
  # @return [String] instance_dir Directory where fcrepo has been installed
189
174
  def extract
190
- return instance_dir if extracted?
175
+ return config.instance_dir if extracted?
191
176
 
192
177
  jar_file = download
193
178
 
194
- FileUtils.mkdir_p instance_dir
195
- FileUtils.cp jar_file, binary_path
196
- self.extracted_version = version
179
+ FileUtils.mkdir_p config.instance_dir
180
+ FileUtils.cp jar_file, config.binary_path
181
+ self.extracted_version = config.version
197
182
 
198
- instance_dir
183
+ config.instance_dir
199
184
  end
200
185
  # rubocop:enable Lint/RescueException
201
186
 
202
- def version
203
- @version ||= options.fetch(:version, FcrepoWrapper.default_fcrepo_version)
204
- end
205
-
206
187
  protected
207
188
 
208
189
  def extracted?
209
- File.exists?(binary_path) && extracted_version == version
190
+ File.exists?(config.binary_path) && extracted_version == config.version
210
191
  end
211
192
 
212
193
  def download
213
- unless File.exists?(download_path) && validate?(download_path)
214
- fetch_with_progressbar download_url, download_path
215
- validate! download_path
216
- end
217
- download_path
218
- end
219
-
220
- def validate?(file)
221
- return true if options[:validate] == false
222
-
223
- Digest::MD5.file(file).hexdigest == expected_md5sum
224
- end
225
-
226
- def validate!(file)
227
- unless validate? file
228
- raise "MD5 mismatch" unless options[:ignore_md5sum]
194
+ unless File.exists?(config.download_path) && validate?(config.download_path)
195
+ Downloader.fetch_with_progressbar config.download_url, config.download_path
196
+ validate! config.download_path
229
197
  end
198
+ config.download_path
230
199
  end
231
200
 
232
201
  private
233
202
 
234
- def download_url
235
- @download_url ||= options.fetch(:url, default_download_url)
236
- end
237
-
238
- def default_download_url
239
- @default_url ||= "https://github.com/fcrepo4/fcrepo4/releases/download/fcrepo-#{version}/fcrepo-webapp-#{version}-jetty-console.jar"
240
- end
241
-
242
- def md5url
243
- "https://github.com/fcrepo4/fcrepo4/releases/download/fcrepo-#{version}/fcrepo-webapp-#{version}-jetty-console.jar.md5"
244
- end
245
-
246
- def fcrepo_options
247
- options.fetch(:fcrepo_options, headless: nil)
248
- end
249
-
250
- def env
251
- options.fetch(:env, {})
252
- end
253
-
254
- def download_path
255
- @download_path ||= options.fetch(:download_path, default_download_path)
256
- end
257
-
258
- def default_download_path
259
- File.join(download_dir, File.basename(download_url))
260
- end
261
-
262
- def download_dir
263
- @download_dir ||= options.fetch(:download_dir, Dir.tmpdir)
264
- FileUtils.mkdir_p @download_dir
265
- @download_dir
266
- end
267
-
268
- def verbose?
269
- !!options.fetch(:verbose, false)
270
- end
271
-
272
- def managed?
273
- File.exists?(instance_dir)
274
- end
275
-
276
- def version_file
277
- options.fetch(:version_file, File.join(instance_dir, "VERSION"))
278
- end
279
-
280
- def expected_md5sum
281
- @md5sum ||= options.fetch(:md5sum, open(md5file).read.split(" ").first)
282
- end
283
-
284
- def binary_path
285
- File.join(instance_dir, "fcrepo-webapp-#{version}-jetty-console.jar")
286
- end
287
-
288
- def md5sum_path
289
- File.join(download_dir, File.basename(md5url))
290
- end
291
-
292
- def tmp_save_dir
293
- @tmp_save_dir ||= Dir.mktmpdir
294
- end
295
-
296
- def fetch_with_progressbar(url, output)
297
- pbar = ProgressBar.create(title: File.basename(url), total: nil, format: "%t: |%B| %p%% (%e )")
298
- open(url, content_length_proc: lambda do|t|
299
- if t && 0 < t
300
- pbar.total = t
301
- end
302
- end,
303
- progress_proc: lambda do|s|
304
- pbar.progress = s
305
- end) do |io|
306
- IO.copy_stream(io, output)
307
- end
308
- end
309
-
310
- def md5file
311
- unless File.exists? md5sum_path
312
- fetch_with_progressbar md5url, md5sum_path
313
- end
314
-
315
- md5sum_path
316
- end
317
-
318
203
  def extracted_version
319
- File.read(version_file).strip if File.exists? version_file
204
+ File.read(config.version_file).strip if File.exists? config.version_file
320
205
  end
321
206
 
322
207
  def extracted_version=(version)
323
- File.open(version_file, "w") do |f|
208
+ File.open(config.version_file, "w") do |f|
324
209
  f.puts version
325
210
  end
326
211
  end
327
212
 
328
- def random_open_port
329
- socket = Socket.new(:INET, :STREAM, 0)
330
- begin
331
- socket.bind(Addrinfo.tcp('127.0.0.1', 0))
332
- socket.local_address.ip_port
333
- ensure
334
- socket.close
335
- end
336
- end
337
-
338
213
  def raise_error_unless_extracted
339
- raise RuntimeError, "there is no fcrepo instance at #{instance_dir}. Run FcrepoWrapper.extract first." unless extracted?
340
- end
341
-
342
- def spring_noop_file
343
- 'file://' + File.expand_path('../../../data/spring-noop.xml', __FILE__)
344
- end
345
-
346
- def jms_enabled?
347
- options.fetch(:enable_jms, true)
214
+ raise RuntimeError, "there is no fcrepo instance at #{config.instance_dir}. Run FcrepoWrapper.extract first." unless extracted?
348
215
  end
349
216
  end
350
217
  end
@@ -0,0 +1,44 @@
1
+ module FcrepoWrapper
2
+ class MD5
3
+ attr_reader :config
4
+ def initialize(config)
5
+ @config = config
6
+ end
7
+
8
+ def clean!
9
+ FileUtils.remove_entry(config.md5sum_path) if File.exists? config.md5sum_path
10
+ end
11
+
12
+ def validate?(file)
13
+ return true if config.validate == false
14
+
15
+ Digest::MD5.file(file).hexdigest == expected_sum
16
+ end
17
+
18
+ def validate!(file)
19
+ unless validate? file
20
+ raise "MD5 mismatch" unless config.ignore_md5sum
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def expected_sum
27
+ @md5sum ||= config.md5sum
28
+ @md5sum ||= read_file
29
+ end
30
+
31
+ def read_file
32
+ open(md5file).read.split(" ").first
33
+ end
34
+
35
+ def md5file
36
+ unless File.exists? config.md5sum_path
37
+ Downloader.fetch_with_progressbar config.md5url, config.md5sum_path
38
+ end
39
+
40
+ config.md5sum_path
41
+ end
42
+ end
43
+ end
44
+
@@ -0,0 +1,39 @@
1
+ module FcrepoWrapper
2
+ # Configuraton that comes from static and dynamic sources.
3
+ class Settings < Delegator
4
+ def __getobj__
5
+ @static_config # return object we are delegating to, required
6
+ end
7
+
8
+ alias static_config __getobj__
9
+
10
+ def __setobj__(obj)
11
+ @static_config = obj
12
+ end
13
+
14
+ def initialize(static_config)
15
+ super
16
+ @static_config = static_config
17
+ end
18
+
19
+ ##
20
+ # Get the port this fcrepo instance is running at
21
+ def port
22
+ @port ||= static_config.port
23
+ @port ||= random_open_port.to_s
24
+ end
25
+
26
+ private
27
+
28
+ def random_open_port
29
+ socket = Socket.new(:INET, :STREAM, 0)
30
+ begin
31
+ socket.bind(Addrinfo.tcp('127.0.0.1', 0))
32
+ socket.local_address.ip_port
33
+ ensure
34
+ socket.close
35
+ end
36
+ end
37
+ end
38
+ end
39
+
@@ -1,3 +1,3 @@
1
1
  module FcrepoWrapper
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
@@ -1,4 +1,8 @@
1
1
  require 'fcrepo_wrapper/version'
2
+ require 'fcrepo_wrapper/configuration'
3
+ require 'fcrepo_wrapper/settings'
4
+ require 'fcrepo_wrapper/downloader'
5
+ require 'fcrepo_wrapper/md5'
2
6
  require 'fcrepo_wrapper/instance'
3
7
 
4
8
  module FcrepoWrapper
@@ -0,0 +1 @@
1
+ port: 9999
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe FcrepoWrapper::Configuration do
4
+ let(:config) { described_class.new options }
5
+
6
+ describe "#port" do
7
+ subject { config.port }
8
+
9
+ context "when port is set to nil" do
10
+ let(:options) { { port: nil } }
11
+ it { is_expected.to eq nil }
12
+ end
13
+
14
+ context "when port is not set" do
15
+ let(:options) { {} }
16
+ it { is_expected.to eq '8080' }
17
+ end
18
+
19
+ context "when a port is provided" do
20
+ let(:options) { { port: '8888' } }
21
+ it { is_expected.to eq '8888' }
22
+ end
23
+ end
24
+
25
+ describe "#read_config" do
26
+ before do
27
+ allow(config).to receive(:default_configuration_paths).and_return([])
28
+ end
29
+ let(:options) { { config: 'spec/fixtures/sample_config.yml' } }
30
+ it "uses values from the config file" do
31
+ expect(config.port).to eq '9999'
32
+ end
33
+
34
+ end
35
+ end
36
+
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe FcrepoWrapper::Instance do
4
+ let(:wrapper) { described_class.new }
5
+
6
+ describe "#host" do
7
+ subject { wrapper.host }
8
+ it { is_expected.to eq '127.0.0.1' }
9
+ end
10
+
11
+ describe "#port" do
12
+ subject { wrapper.port }
13
+ it { is_expected.to eq '8080' }
14
+ end
15
+
16
+ describe "#url" do
17
+ subject { wrapper.url }
18
+ it { is_expected.to eq 'http://127.0.0.1:8080/' }
19
+ end
20
+
21
+ describe "#version" do
22
+ subject { wrapper.version }
23
+ it { is_expected.to eq '4.5.0' }
24
+ end
25
+
26
+ describe "#md5" do
27
+ subject { wrapper.md5 }
28
+ it { is_expected.to be_instance_of FcrepoWrapper::MD5 }
29
+ end
30
+ end
31
+
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.2.0
4
+ version: 0.3.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-02-05 00:00:00.000000000 Z
11
+ date: 2016-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-progressbar
@@ -116,10 +116,17 @@ files:
116
116
  - exe/fcrepo_wrapper
117
117
  - fcrepo_wrapper.gemspec
118
118
  - lib/fcrepo_wrapper.rb
119
+ - lib/fcrepo_wrapper/configuration.rb
120
+ - lib/fcrepo_wrapper/downloader.rb
119
121
  - lib/fcrepo_wrapper/instance.rb
122
+ - lib/fcrepo_wrapper/md5.rb
120
123
  - lib/fcrepo_wrapper/rake_task.rb
124
+ - lib/fcrepo_wrapper/settings.rb
121
125
  - lib/fcrepo_wrapper/tasks/fcrepo_wrapper.rake
122
126
  - lib/fcrepo_wrapper/version.rb
127
+ - spec/fixtures/sample_config.yml
128
+ - spec/lib/fcrepo_wrapper/configuration_spec.rb
129
+ - spec/lib/fcrepo_wrapper/instance_spec.rb
123
130
  - spec/lib/fcrepo_wrapper_spec.rb
124
131
  - spec/spec_helper.rb
125
132
  homepage: https://github.com/cbeer/fcrepo_wrapper
@@ -142,11 +149,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
149
  version: '0'
143
150
  requirements: []
144
151
  rubyforge_project:
145
- rubygems_version: 2.4.5.1
152
+ rubygems_version: 2.5.1
146
153
  signing_key:
147
154
  specification_version: 4
148
155
  summary: Solr 5 service wrapper
149
156
  test_files:
157
+ - spec/fixtures/sample_config.yml
158
+ - spec/lib/fcrepo_wrapper/configuration_spec.rb
159
+ - spec/lib/fcrepo_wrapper/instance_spec.rb
150
160
  - spec/lib/fcrepo_wrapper_spec.rb
151
161
  - spec/spec_helper.rb
152
162
  has_rdoc: