opt_parse_validator 1.8.2 → 1.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/opt_parse_validator.rb +12 -13
- data/lib/opt_parse_validator/config_files_loader_merger.rb +1 -1
- data/lib/opt_parse_validator/hacks.rb +2 -0
- data/lib/opt_parse_validator/opts.rb +1 -1
- data/lib/opt_parse_validator/opts/base.rb +4 -4
- data/lib/opt_parse_validator/opts/file_path.rb +1 -1
- data/lib/opt_parse_validator/opts/multi_choices.rb +1 -1
- data/lib/opt_parse_validator/opts/path.rb +5 -5
- data/lib/opt_parse_validator/opts/uri.rb +1 -1
- data/lib/opt_parse_validator/version.rb +1 -1
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9286b871685cbc3d1053587dc31ccf2d01d35cc6efc138607be2fbf04416de8
|
4
|
+
data.tar.gz: b562e1c8e5faadf362f2d14997ebb7237604afd5dc53d6584a83697139c7b696
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33eed0e8bdd867b45e2b7276cf7d47061f47b1bbcce72cc29abfc61530713a413d2bd10663d9bc9130f5666a386b3718c4e1a0ada33eb366a744eb84952bb346
|
7
|
+
data.tar.gz: 83511499d313425a027a6c444e347a6342040419420076ff0d6b5523c039e21841d135ecda353c727a59ff67f25a8ea8c8f6c73ae633384325116905f98e30c0
|
data/lib/opt_parse_validator.rb
CHANGED
@@ -108,18 +108,16 @@ module OptParseValidator
|
|
108
108
|
# @return [ void ]
|
109
109
|
def register_callback(opt)
|
110
110
|
on(*opt.option) do |arg|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
@results[opt.to_sym] = opt.normalize(opt.validate(arg))
|
116
|
-
end
|
117
|
-
rescue StandardError => e
|
118
|
-
# Adds the long option name to the message
|
119
|
-
# And raises it as an OptParseValidator::Error if not already one
|
120
|
-
# e.g --proxy Invalid Scheme format.
|
121
|
-
raise e.is_a?(Error) ? e.class : Error, "#{opt.to_long} #{e}"
|
111
|
+
if opt.alias?
|
112
|
+
parse!(opt.alias_for.split)
|
113
|
+
else
|
114
|
+
@results[opt.to_sym] = opt.normalize(opt.validate(arg))
|
122
115
|
end
|
116
|
+
rescue StandardError => e
|
117
|
+
# Adds the long option name to the message
|
118
|
+
# And raises it as an OptParseValidator::Error if not already one
|
119
|
+
# e.g --proxy Invalid Scheme format.
|
120
|
+
raise e.is_a?(Error) ? e.class : Error, "#{opt.to_long} #{e}"
|
123
121
|
end
|
124
122
|
end
|
125
123
|
|
@@ -147,11 +145,12 @@ module OptParseValidator
|
|
147
145
|
# @return [ Void ]
|
148
146
|
def post_processing
|
149
147
|
@opts.each do |opt|
|
150
|
-
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)
|
151
149
|
|
152
150
|
next if opt.required_unless.empty? || @results.key?(opt.to_sym)
|
153
151
|
|
154
|
-
fail_msg =
|
152
|
+
fail_msg = 'One of the following options is required: ' \
|
153
|
+
"#{opt.to_long}, --#{opt.required_unless.join(', --').tr('_', '-')}"
|
155
154
|
|
156
155
|
raise NoRequiredOption, fail_msg unless opt.required_unless.any? do |sym|
|
157
156
|
@results.key?(sym)
|
@@ -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 ||=
|
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
|
-
|
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)
|
@@ -107,7 +107,7 @@ module OptParseValidator
|
|
107
107
|
|
108
108
|
raise Error, "Could not find option symbol for #{option}" unless long_option
|
109
109
|
|
110
|
-
@symbol = long_option.
|
110
|
+
@symbol = long_option.delete_prefix('--').tr('-', '_').to_sym
|
111
111
|
end
|
112
112
|
@symbol
|
113
113
|
end
|
@@ -115,7 +115,7 @@ module OptParseValidator
|
|
115
115
|
# @return [ String ] The raw long option (e.g: --proxy)
|
116
116
|
def to_long
|
117
117
|
option.each do |option_attr|
|
118
|
-
if
|
118
|
+
if option_attr.start_with?('--')
|
119
119
|
return option_attr.gsub(/ .*$/, '')
|
120
120
|
.gsub(/\[[^\]]+\]/, '')
|
121
121
|
end
|
@@ -26,7 +26,7 @@ module OptParseValidator
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def check_extensions(path)
|
29
|
-
return if
|
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
|
@@ -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 ||=
|
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
|
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.
|
4
|
+
version: 1.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- WPScanTeam
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-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.
|
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.
|
32
|
+
version: 6.2.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: addressable
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,14 +84,14 @@ dependencies:
|
|
84
84
|
requirements:
|
85
85
|
- - "~>"
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version: 3.
|
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.
|
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:
|
115
|
+
version: 1.11.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:
|
122
|
+
version: 1.11.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.
|
129
|
+
version: 1.10.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.
|
136
|
+
version: 1.10.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.
|
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.
|
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
|
-
-
|
168
|
+
- contact@wpscan.com
|
169
169
|
executables: []
|
170
170
|
extensions: []
|
171
171
|
extra_rdoc_files: []
|
@@ -213,7 +213,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
213
213
|
requirements:
|
214
214
|
- - ">="
|
215
215
|
- !ruby/object:Gem::Version
|
216
|
-
version: '2.
|
216
|
+
version: '2.5'
|
217
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
218
218
|
requirements:
|
219
219
|
- - ">="
|