opt_parse_validator 1.9.1 → 1.9.5

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
  SHA256:
3
- metadata.gz: 3ccb947d9079bcc004e16bdfea47a5e5207c26e871da1a1cf0c01f2bbeca5b65
4
- data.tar.gz: 87139c6bbe1664ff3c70374a81d3e6940193b5d46cd0d07c5905cc22ab468cfb
3
+ metadata.gz: 24a508e92f221f7b26c0ca9e539ab3272538215166d58de297fd03a1ee8d6cfe
4
+ data.tar.gz: 4f0541a2877f01224d964c2d259a665c81c91000da1a91229810e2cf98d156d5
5
5
  SHA512:
6
- metadata.gz: dd7dd0aa734ad3ad63bd1644b8ab05213d96a0d3c223de20d2152581c22c04b7f68df65ea52fbe4b189e46d44b32d005b855da92e12c5e336b31eb42553d5c00
7
- data.tar.gz: 50bca2d9e0f17c6c1f9662b3d3e6a9d9b1d8ed5352b6e35c4847ac373ff91b64a50adfe53ffd73f993575e90a9cae67cfe7bcd52fafe702cefb30ec44d718dce
6
+ metadata.gz: 77b216809c7fc8d31fcf37953fba5fefa56e6a290c8844283e34fc2108e3883ae09357f4b3ac46386880a7713749c706ded2733d1e089ac62797ab13f3cfb59a
7
+ data.tar.gz: 6d944517f3b33ac2cffa6a7b31f45d9d53c9db0254638ee8aee074a475e04840572deb2902a289c9bca09e66b1229b7e6bb4448a317e1b2a463eaa5e9ecdd09f
@@ -51,7 +51,7 @@ module OptParseValidator
51
51
 
52
52
  each { |config_file| result.deep_merge!(config_file.parse) }
53
53
 
54
- result = result.dig(result_key) || {} if result_key
54
+ result = result[result_key] || {} if result_key
55
55
 
56
56
  result.deep_symbolize_keys
57
57
  end
@@ -8,10 +8,12 @@ class OptionParser
8
8
  class << self
9
9
  alias original_candidate candidate
10
10
 
11
+ # rubocop:disable Style/OptionalBooleanParameter
11
12
  def candidate(key, icase = false, pat = nil, &block)
12
13
  # Maybe also do this for -v/--version ?
13
14
  key == 'h' ? original_candidate('help', icase, pat, &block) : []
14
15
  end
16
+ # rubocop:enable Style/OptionalBooleanParameter
15
17
  end
16
18
  end
17
19
  end
@@ -43,7 +43,7 @@ module OptParseValidator
43
43
  end
44
44
 
45
45
  def required_unless
46
- @required_unless ||= [*attrs[:required_unless]]
46
+ @required_unless ||= Array(attrs[:required_unless])
47
47
  end
48
48
 
49
49
  # @return [ Mixed ]
@@ -91,7 +91,7 @@ module OptParseValidator
91
91
  #
92
92
  # @return [ Mixed ]
93
93
  def normalize(value)
94
- [*attrs[:normalize]].each do |method|
94
+ Array(attrs[:normalize]).each do |method|
95
95
  next unless method.is_a?(Symbol)
96
96
 
97
97
  value = value.send(method) if value.respond_to?(method)
@@ -34,7 +34,7 @@ module OptParseValidator
34
34
 
35
35
  unless choices.include?(value)
36
36
  raise Error, "'#{value}' is not a valid choice, expected one " \
37
- "of the followings: #{choices.join(',')}"
37
+ "of the followings: #{choices.join(',')}"
38
38
  end
39
39
 
40
40
  value
@@ -26,7 +26,7 @@ module OptParseValidator
26
26
  end
27
27
 
28
28
  def check_extensions(path)
29
- return if [*attrs[:extensions]].include?(path.extname.delete('.'))
29
+ return if Array(attrs[:extensions]).include?(path.extname.delete('.'))
30
30
 
31
31
  raise Error, "The extension of '#{path}' is not allowed"
32
32
  end
@@ -104,7 +104,7 @@ module OptParseValidator
104
104
 
105
105
  # @return [ Array<Array<Symbol>> ]
106
106
  def incompatible
107
- [*attrs[:incompatible]]
107
+ Array(attrs[:incompatible])
108
108
  end
109
109
 
110
110
  # @param [ Hash ] values
@@ -39,22 +39,22 @@ module OptParseValidator
39
39
 
40
40
  # @param [ Pathname ] path
41
41
  def check_file(path)
42
- raise Error, "'#{path}' is not a file" unless path.file? || attrs[:exists] == false
42
+ raise Error, "The path '#{path}' does not exist or is not a file" unless path.file? || attrs[:exists] == false
43
43
  end
44
44
 
45
45
  # @param [ Pathname ] path
46
46
  def check_directory(path)
47
- raise Error, "'#{path}' is not a directory" unless path.directory? || attrs[:exists] == false
47
+ raise Error, "The path '#{path}' does not exist or is not a directory" unless path.directory? || attrs[:exists] == false
48
48
  end
49
49
 
50
50
  # @param [ Pathname ] path
51
51
  def check_executable(path)
52
- raise Error, "'#{path}' is not executable" unless path.executable?
52
+ raise Error, "The path '#{path}' is not executable" unless path.executable?
53
53
  end
54
54
 
55
55
  # @param [ Pathname ] path
56
56
  def check_readable(path)
57
- raise Error, "'#{path}' is not readable" unless path.readable?
57
+ raise Error, "The path '#{path}' is not readable" unless path.readable?
58
58
  end
59
59
 
60
60
  # If the path does not exist, it will check for the parent
@@ -62,7 +62,7 @@ module OptParseValidator
62
62
  #
63
63
  # @param [ Pathname ] path
64
64
  def check_writable(path)
65
- raise Error, "'#{path}' is not writable" if path.exist? && !path.writable? || !path.parent.writable?
65
+ raise Error, "The path '#{path}' is not writable" if (path.exist? && !path.writable?) || !path.parent.writable?
66
66
  end
67
67
  end
68
68
  end
@@ -13,7 +13,7 @@ module OptParseValidator
13
13
 
14
14
  # @return [ Array<String> ]
15
15
  def allowed_protocols
16
- @allowed_protocols ||= [*attrs[:protocols]].map(&:downcase)
16
+ @allowed_protocols ||= Array(attrs[:protocols]).map(&:downcase)
17
17
  end
18
18
 
19
19
  # The default protocol (or scheme) to use if none was given
@@ -5,5 +5,5 @@
5
5
  path file_path directory_path array integer_range multi_choices regexp headers
6
6
  smart_list alias
7
7
  ].each do |opt|
8
- require 'opt_parse_validator/opts/' + opt
8
+ require "opt_parse_validator/opts/#{opt}"
9
9
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Gem Version
4
4
  module OptParseValidator
5
- VERSION = '1.9.1'
5
+ VERSION = '1.9.5'
6
6
  end
@@ -109,7 +109,7 @@ module OptParseValidator
109
109
  def register_callback(opt)
110
110
  on(*opt.option) do |arg|
111
111
  if opt.alias?
112
- parse!(opt.alias_for.split(' '))
112
+ parse!(opt.alias_for.split)
113
113
  else
114
114
  @results[opt.to_sym] = opt.normalize(opt.validate(arg))
115
115
  end
@@ -145,11 +145,12 @@ module OptParseValidator
145
145
  # @return [ Void ]
146
146
  def post_processing
147
147
  @opts.each do |opt|
148
- raise NoRequiredOption, "The option --#{opt} is required" if opt.required? && !@results.key?(opt.to_sym)
148
+ raise NoRequiredOption, "The option #{opt.to_long} is required" if opt.required? && !@results.key?(opt.to_sym)
149
149
 
150
150
  next if opt.required_unless.empty? || @results.key?(opt.to_sym)
151
151
 
152
- fail_msg = "One of the following options is required: --#{opt}, --#{opt.required_unless.join(', --')}"
152
+ fail_msg = 'One of the following options is required: ' \
153
+ "#{opt.to_long}, --#{opt.required_unless.join(', --').tr('_', '-')}"
153
154
 
154
155
  raise NoRequiredOption, fail_msg unless opt.required_unless.any? do |sym|
155
156
  @results.key?(sym)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opt_parse_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
4
+ version: 1.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - WPScanTeam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-25 00:00:00.000000000 Z
11
+ date: 2021-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '5.2'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 6.1.0
22
+ version: 6.2.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '5.2'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 6.1.0
32
+ version: 6.2.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: addressable
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '2.5'
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '2.8'
42
+ version: '2.9'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: '2.5'
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '2.8'
52
+ version: '2.9'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: bundler
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -84,14 +84,14 @@ dependencies:
84
84
  requirements:
85
85
  - - "~>"
86
86
  - !ruby/object:Gem::Version
87
- version: 3.9.0
87
+ version: 3.10.0
88
88
  type: :development
89
89
  prerelease: false
90
90
  version_requirements: !ruby/object:Gem::Requirement
91
91
  requirements:
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
- version: 3.9.0
94
+ version: 3.10.0
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: rspec-its
97
97
  requirement: !ruby/object:Gem::Requirement
@@ -112,42 +112,42 @@ dependencies:
112
112
  requirements:
113
113
  - - "~>"
114
114
  - !ruby/object:Gem::Version
115
- version: 0.84.0
115
+ version: 1.21.0
116
116
  type: :development
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - "~>"
121
121
  - !ruby/object:Gem::Version
122
- version: 0.84.0
122
+ version: 1.21.0
123
123
  - !ruby/object:Gem::Dependency
124
124
  name: rubocop-performance
125
125
  requirement: !ruby/object:Gem::Requirement
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: 1.6.0
129
+ version: 1.11.0
130
130
  type: :development
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - "~>"
135
135
  - !ruby/object:Gem::Version
136
- version: 1.6.0
136
+ version: 1.11.0
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: simplecov
139
139
  requirement: !ruby/object:Gem::Requirement
140
140
  requirements:
141
141
  - - "~>"
142
142
  - !ruby/object:Gem::Version
143
- version: 0.18.2
143
+ version: 0.21.0
144
144
  type: :development
145
145
  prerelease: false
146
146
  version_requirements: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - "~>"
149
149
  - !ruby/object:Gem::Version
150
- version: 0.18.2
150
+ version: 0.21.0
151
151
  - !ruby/object:Gem::Dependency
152
152
  name: simplecov-lcov
153
153
  requirement: !ruby/object:Gem::Requirement
@@ -165,7 +165,7 @@ dependencies:
165
165
  description: Implementation of validators for the ruby OptionParser lib. Mainly used
166
166
  in the CMSScanner gem to define the cli options available
167
167
  email:
168
- - team@wpscan.org
168
+ - contact@wpscan.com
169
169
  executables: []
170
170
  extensions: []
171
171
  extra_rdoc_files: []
@@ -220,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
220
  - !ruby/object:Gem::Version
221
221
  version: '0'
222
222
  requirements: []
223
- rubygems_version: 3.0.3
223
+ rubygems_version: 3.0.3.1
224
224
  signing_key:
225
225
  specification_version: 4
226
226
  summary: Ruby OptionParser Validators