fcrepo_wrapper 0.5.2 → 0.6.0

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
2
  SHA1:
3
- metadata.gz: a774f401463d98c36bbd1bf08e7486bf45beeda4
4
- data.tar.gz: 3714c2826c1ba2605baa0b5628b159014751dfa2
3
+ metadata.gz: f35da2e7c8fd52e646e683d3a03dfe50e0408d3e
4
+ data.tar.gz: 7e6fc71cb0050d0cdcd43284a48240d2cb318693
5
5
  SHA512:
6
- metadata.gz: 9c2b93b72738782c84a95f1ec4f3352014c5ad24ad44ab5655ab2f38f6bb33a43d73c48b373eb23a7f080e1153d9e7b548e6b2b4ed64bd0bcb369cdb1021c123
7
- data.tar.gz: a48ccbd482b42663762dc940f083f3b5ca7e25024c6eaa02a4a1d2d5980fb3a0284680579c89f552bd942b020ef7e43e1598d64af8f71de24514e83cb9c8d9da
6
+ metadata.gz: e4367738cd14d10256b4a6303390227092e126dae0582d8ece89af411341fcdcf9d296274967b74e6efdfd4847e7c67550ade76a115df8282f88c296f8f0d90b
7
+ data.tar.gz: c278c4978fd8751fa0d34556712ee9ad03c29be7b6690e0cc9e47200bb2a0ff2a880307a79609aa7af83b5008dcb501201980a85320e6cac9aeae34d72a551d3
@@ -1,11 +1,9 @@
1
1
  inherit_from:
2
- - .rubocop_hound.yml
3
2
  - .rubocop_todo.yml
4
3
 
5
4
  AllCops:
6
5
  Exclude:
7
6
  - "*.gemspec"
8
- RunRailsCops: true
9
7
 
10
8
  Metrics/LineLength:
11
9
  Enabled: false
@@ -0,0 +1,190 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-07-07 11:09:07 -0700 using RuboCop version 0.41.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ Lint/AmbiguousOperator:
11
+ Exclude:
12
+ - 'lib/fcrepo_wrapper.rb'
13
+
14
+ # Offense count: 11
15
+ # Cop supports --auto-correct.
16
+ Lint/DeprecatedClassMethods:
17
+ Exclude:
18
+ - 'lib/fcrepo_wrapper/configuration.rb'
19
+ - 'lib/fcrepo_wrapper/instance.rb'
20
+ - 'lib/fcrepo_wrapper/md5.rb'
21
+ - 'spec/lib/fcrepo_wrapper/instance_spec.rb'
22
+
23
+ # Offense count: 2
24
+ # Configuration parameters: CountComments.
25
+ Metrics/ClassLength:
26
+ Max: 135
27
+
28
+ # Offense count: 2
29
+ # Configuration parameters: CountComments.
30
+ Metrics/MethodLength:
31
+ Max: 16
32
+
33
+ # Offense count: 4
34
+ # Cop supports --auto-correct.
35
+ Style/AlignArray:
36
+ Exclude:
37
+ - 'lib/fcrepo_wrapper/configuration.rb'
38
+
39
+ # Offense count: 1
40
+ # Cop supports --auto-correct.
41
+ Style/ColonMethodCall:
42
+ Exclude:
43
+ - 'spec/lib/fcrepo_wrapper_spec.rb'
44
+
45
+ # Offense count: 1
46
+ # Cop supports --auto-correct.
47
+ # Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly.
48
+ # SupportedStyles: assign_to_condition, assign_inside_condition
49
+ Style/ConditionalAssignment:
50
+ Exclude:
51
+ - 'exe/fcrepo_wrapper'
52
+
53
+ # Offense count: 6
54
+ Style/Documentation:
55
+ Exclude:
56
+ - 'spec/**/*'
57
+ - 'test/**/*'
58
+ - 'lib/fcrepo_wrapper.rb'
59
+ - 'lib/fcrepo_wrapper/configuration.rb'
60
+ - 'lib/fcrepo_wrapper/downloader.rb'
61
+ - 'lib/fcrepo_wrapper/instance.rb'
62
+ - 'lib/fcrepo_wrapper/md5.rb'
63
+ - 'lib/fcrepo_wrapper/rake_task.rb'
64
+
65
+ # Offense count: 2
66
+ Style/DoubleNegation:
67
+ Exclude:
68
+ - 'lib/fcrepo_wrapper/configuration.rb'
69
+ - 'lib/fcrepo_wrapper/instance.rb'
70
+
71
+ # Offense count: 2
72
+ # Configuration parameters: MinBodyLength.
73
+ Style/GuardClause:
74
+ Exclude:
75
+ - 'lib/fcrepo_wrapper/instance.rb'
76
+ - 'lib/fcrepo_wrapper/md5.rb'
77
+
78
+ # Offense count: 1
79
+ # Cop supports --auto-correct.
80
+ # Configuration parameters: MaxLineLength.
81
+ Style/IfUnlessModifier:
82
+ Exclude:
83
+ - 'lib/fcrepo_wrapper/downloader.rb'
84
+
85
+ # Offense count: 1
86
+ # Cop supports --auto-correct.
87
+ # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
88
+ # SupportedStyles: special_inside_parentheses, consistent, align_braces
89
+ Style/IndentHash:
90
+ Exclude:
91
+ - 'exe/fcrepo_wrapper'
92
+
93
+ # Offense count: 14
94
+ # Cop supports --auto-correct.
95
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
96
+ # SupportedStyles: normal, rails
97
+ Style/IndentationConsistency:
98
+ Exclude:
99
+ - 'lib/fcrepo_wrapper/configuration.rb'
100
+ - 'lib/fcrepo_wrapper/md5.rb'
101
+ - 'lib/fcrepo_wrapper/settings.rb'
102
+
103
+ # Offense count: 1
104
+ # Cop supports --auto-correct.
105
+ # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
106
+ # SupportedStyles: aligned, indented, indented_relative_to_receiver
107
+ Style/MultilineMethodCallIndentation:
108
+ Exclude:
109
+ - 'lib/fcrepo_wrapper/instance.rb'
110
+
111
+ # Offense count: 1
112
+ # Cop supports --auto-correct.
113
+ Style/NegatedWhile:
114
+ Exclude:
115
+ - 'lib/fcrepo_wrapper/instance.rb'
116
+
117
+ # Offense count: 1
118
+ # Cop supports --auto-correct.
119
+ Style/RedundantException:
120
+ Exclude:
121
+ - 'lib/fcrepo_wrapper/instance.rb'
122
+
123
+ # Offense count: 1
124
+ # Cop supports --auto-correct.
125
+ Style/SpaceAfterComma:
126
+ Exclude:
127
+ - 'lib/fcrepo_wrapper/rake_task.rb'
128
+
129
+ # Offense count: 2
130
+ # Cop supports --auto-correct.
131
+ Style/SpaceAroundKeyword:
132
+ Exclude:
133
+ - 'lib/fcrepo_wrapper/downloader.rb'
134
+
135
+ # Offense count: 68
136
+ # Cop supports --auto-correct.
137
+ # Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
138
+ # SupportedStyles: single_quotes, double_quotes
139
+ Style/StringLiterals:
140
+ Exclude:
141
+ - 'exe/fcrepo_wrapper'
142
+ - 'lib/fcrepo_wrapper/configuration.rb'
143
+ - 'lib/fcrepo_wrapper/downloader.rb'
144
+ - 'lib/fcrepo_wrapper/instance.rb'
145
+ - 'lib/fcrepo_wrapper/md5.rb'
146
+ - 'lib/fcrepo_wrapper/rake_task.rb'
147
+ - 'lib/fcrepo_wrapper/tasks/fcrepo_wrapper.rake'
148
+ - 'spec/lib/fcrepo_wrapper/configuration_spec.rb'
149
+ - 'spec/lib/fcrepo_wrapper/instance_spec.rb'
150
+ - 'spec/lib/fcrepo_wrapper/md5_spec.rb'
151
+ - 'spec/lib/fcrepo_wrapper_spec.rb'
152
+ - 'spec/spec_helper.rb'
153
+
154
+ # Offense count: 3
155
+ # Cop supports --auto-correct.
156
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
157
+ # SupportedStyles: final_newline, final_blank_line
158
+ Style/TrailingBlankLines:
159
+ Exclude:
160
+ - 'lib/fcrepo_wrapper/downloader.rb'
161
+ - 'lib/fcrepo_wrapper/md5.rb'
162
+ - 'lib/fcrepo_wrapper/settings.rb'
163
+
164
+ # Offense count: 1
165
+ # Cop supports --auto-correct.
166
+ # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
167
+ # SupportedStyles: comma, consistent_comma, no_comma
168
+ Style/TrailingCommaInLiteral:
169
+ Exclude:
170
+ - 'exe/fcrepo_wrapper'
171
+
172
+ # Offense count: 1
173
+ # Cop supports --auto-correct.
174
+ Style/TrailingWhitespace:
175
+ Exclude:
176
+ - 'spec/lib/fcrepo_wrapper/instance_spec.rb'
177
+
178
+ # Offense count: 1
179
+ # Cop supports --auto-correct.
180
+ Style/UnneededInterpolation:
181
+ Exclude:
182
+ - 'lib/fcrepo_wrapper/instance.rb'
183
+
184
+ # Offense count: 3
185
+ # Cop supports --auto-correct.
186
+ # Configuration parameters: MaxLineLength.
187
+ Style/WhileUntilModifier:
188
+ Exclude:
189
+ - 'exe/fcrepo_wrapper'
190
+ - 'lib/fcrepo_wrapper/instance.rb'
@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
  sudo: false
3
3
  rvm:
4
- - 2.2.0
5
- - jruby
6
- cache:
7
- directories:
8
- - /tmp/solr-5.1.0
4
+ - 2.3.1
5
+ - jruby-9.1.2.0
6
+
7
+ jdk:
8
+ - oraclejdk8
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
2
 
3
3
  require 'rspec/core/rake_task'
4
4
 
@@ -64,7 +64,10 @@ subcommands = {
64
64
  begin
65
65
  args.order!
66
66
  command = ARGV.shift
67
- subcommands[command].order! if command
67
+ if command
68
+ raise "Bad subcommand: #{command}" unless subcommands[command]
69
+ subcommands[command].order!
70
+ end
68
71
  args.parse!
69
72
  rescue => error
70
73
  $stderr.puts "ERROR: #{error}\n"
@@ -72,9 +75,6 @@ rescue => error
72
75
  exit 1
73
76
  end
74
77
 
75
- # default to verbose
76
- options[:verbose] = true if options[:verbose].nil?
77
-
78
78
  instance = FcrepoWrapper.default_instance(options)
79
79
 
80
80
  if command == 'clean'
@@ -91,6 +91,8 @@ instance.wrap do |conn|
91
91
  sleep 1
92
92
  end
93
93
  rescue Interrupt
94
+ Signal.trap("SIGTERM") { "IGNORE" }
95
+ Signal.trap("SIGINT") { "IGNORE" }
94
96
  $stderr.puts "Fedora is shutting down."
95
97
  end
96
98
  end
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
 
26
26
  spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "rubocop"
27
28
  spec.add_development_dependency "simple_solr_client"
28
29
  spec.add_development_dependency "coveralls"
29
30
  end
@@ -7,7 +7,7 @@ require 'fcrepo_wrapper/instance'
7
7
 
8
8
  module FcrepoWrapper
9
9
  def self.default_fcrepo_version
10
- '4.5.1'
10
+ '4.6.0'
11
11
  end
12
12
 
13
13
  def self.default_fcrepo_port
@@ -6,8 +6,9 @@ module FcrepoWrapper
6
6
  class Configuration
7
7
  attr_reader :options
8
8
  def initialize(options)
9
- @options = read_config(options[:config], options[:verbose])
10
- .merge options
9
+ @config = options[:config]
10
+ @verbose = options[:verbose]
11
+ @options = load_configs(Array(options[:config])).merge(options)
11
12
  end
12
13
 
13
14
  def instance_dir
@@ -63,7 +64,7 @@ module FcrepoWrapper
63
64
  end
64
65
 
65
66
  def verbose?
66
- !!options.fetch(:verbose, false)
67
+ @verbose || (options && !!options.fetch(:verbose, false))
67
68
  end
68
69
 
69
70
  def managed?
@@ -114,28 +115,34 @@ module FcrepoWrapper
114
115
 
115
116
  private
116
117
 
117
- def read_config(config_file, verbose)
118
- default_configuration_paths.each do |p|
118
+ def load_configs(config_files)
119
+ config = {}
120
+
121
+ (default_configuration_paths + config_files.compact).each do |p|
119
122
  path = File.expand_path(p)
120
- config_file ||= path if File.exist? path
123
+ next unless File.exist? path
124
+ config.merge!(read_config(path))
121
125
  end
122
126
 
123
- unless config_file
124
- $stdout.puts "No config specified" if verbose
125
- return {}
126
- end
127
+ config
128
+ end
127
129
 
128
- $stdout.puts "Loading configuration from #{config_file}" if verbose
130
+ def read_config(config_file)
131
+ $stdout.puts "Loading configuration from #{config_file}" if verbose?
129
132
  config = YAML.load(ERB.new(IO.read(config_file)).result(binding))
130
133
  unless config
131
- $stderr.puts "Unable to parse config #{config_file}" if verbose
134
+ $stderr.puts "Unable to parse config #{config_file}" if verbose?
132
135
  return {}
133
136
  end
134
- config.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
137
+ convert_keys(config)
138
+ end
139
+
140
+ def convert_keys(hash)
141
+ hash.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
135
142
  end
136
143
 
137
144
  def default_configuration_paths
138
- ['.fcrepo_wrapper', '~/.fcrepo_wrapper']
145
+ ['~/.fcrepo_wrapper.yml', '~/.fcrepo_wrapper', '.fcrepo_wrapper.yml', '.fcrepo_wrapper']
139
146
  end
140
147
 
141
148
  def default_download_dir
@@ -1,3 +1,3 @@
1
1
  module FcrepoWrapper
2
- VERSION = '0.5.2'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
@@ -0,0 +1,2 @@
1
+ port: 9998
2
+ verbose: true
@@ -40,7 +40,25 @@ describe FcrepoWrapper::Configuration do
40
40
  it "doesn't cast numerics to strings" do
41
41
  expect(config.port).to eq 9999
42
42
  end
43
+ end
43
44
 
45
+ describe "#load_configs" do
46
+ before do
47
+ allow(config).to receive(:default_configuration_paths).and_return([])
48
+ end
49
+ context 'with a single config file' do
50
+ let(:options) { { config: 'spec/fixtures/sample_config.yml' } }
51
+ it "uses values from the config file" do
52
+ expect(config.port).to eq 9999
53
+ end
54
+ end
55
+ context 'with multiple config files' do
56
+ let(:options) { { config: ['spec/fixtures/sample_config.yml', 'spec/fixtures/another_sample_config.yml'] } }
57
+ it "uses values from the config file" do
58
+ expect(config.port).to eq 9998
59
+ expect(config.verbose?).to eq true
60
+ end
61
+ end
44
62
  end
45
63
 
46
64
  describe "#validate" do
@@ -29,8 +29,8 @@ describe FcrepoWrapper::Instance do
29
29
  end
30
30
 
31
31
  describe "#instance_dir" do
32
- subject { File.exists?(wrapper.instance_dir) }
33
- it { is_expected.to be true }
32
+ subject { wrapper.instance_dir }
33
+ it { is_expected.to start_with Dir.tmpdir }
34
34
  end
35
35
 
36
36
  describe "#options" do
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.5.2
4
+ version: 0.6.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-07-06 00:00:00.000000000 Z
11
+ date: 2016-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-progressbar
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: simple_solr_client
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -104,7 +118,6 @@ extra_rdoc_files: []
104
118
  files:
105
119
  - ".gitignore"
106
120
  - ".rubocop.yml"
107
- - ".rubocop_hound.yml"
108
121
  - ".rubocop_todo.yml"
109
122
  - ".travis.yml"
110
123
  - Gemfile
@@ -124,6 +137,7 @@ files:
124
137
  - lib/fcrepo_wrapper/settings.rb
125
138
  - lib/fcrepo_wrapper/tasks/fcrepo_wrapper.rake
126
139
  - lib/fcrepo_wrapper/version.rb
140
+ - spec/fixtures/another_sample_config.yml
127
141
  - spec/fixtures/sample_config.yml
128
142
  - spec/lib/fcrepo_wrapper/configuration_spec.rb
129
143
  - spec/lib/fcrepo_wrapper/instance_spec.rb
@@ -150,11 +164,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
164
  version: '0'
151
165
  requirements: []
152
166
  rubyforge_project:
153
- rubygems_version: 2.6.4
167
+ rubygems_version: 2.5.1
154
168
  signing_key:
155
169
  specification_version: 4
156
170
  summary: Solr 5 service wrapper
157
171
  test_files:
172
+ - spec/fixtures/another_sample_config.yml
158
173
  - spec/fixtures/sample_config.yml
159
174
  - spec/lib/fcrepo_wrapper/configuration_spec.rb
160
175
  - spec/lib/fcrepo_wrapper/instance_spec.rb