opt_parse_validator 0.0.13.11 → 0.0.14.0
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/options_file/base.rb +1 -1
- data/lib/opt_parse_validator/options_file/yml.rb +1 -1
- data/lib/opt_parse_validator/options_files.rb +1 -1
- data/lib/opt_parse_validator/opts/base.rb +2 -2
- data/lib/opt_parse_validator/opts/boolean.rb +1 -1
- data/lib/opt_parse_validator/opts/choice.rb +3 -3
- data/lib/opt_parse_validator/opts/credentials.rb +1 -1
- data/lib/opt_parse_validator/opts/file_path.rb +1 -1
- data/lib/opt_parse_validator/opts/headers.rb +1 -1
- data/lib/opt_parse_validator/opts/integer.rb +1 -1
- data/lib/opt_parse_validator/opts/integer_range.rb +2 -2
- data/lib/opt_parse_validator/opts/multi_choices.rb +4 -4
- data/lib/opt_parse_validator/opts/path.rb +5 -5
- data/lib/opt_parse_validator/opts/positive_integer.rb +1 -1
- data/lib/opt_parse_validator/opts/uri.rb +1 -1
- data/lib/opt_parse_validator/version.rb +1 -1
- data/lib/opt_parse_validator.rb +4 -4
- data/opt_parse_validator.gemspec +4 -4
- metadata +29 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a34dacc55d16b62f89bd6f1d2abda599a3876b3
|
4
|
+
data.tar.gz: c23a8feb575ecfead935c4e163dcd95d8ce27d3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 357e580715074b73a6cc639f2f32e1fa52ee9ce116ce82181350c0d08457f76846e1dce9a0d3a567fa4788a2c2730f588050e673b61f43d21e0279d717721161
|
7
|
+
data.tar.gz: 849d98dd225c8a6e17378f8e59ba6f75f9a665e06968636f089747069eda70d2b71e9a7464fd03f3dd7c9cfab4b6d35f6a56d3a6f8585163506c4058db44b186
|
@@ -23,7 +23,7 @@ module OptParseValidator
|
|
23
23
|
|
24
24
|
ext = File.extname(file_path).delete('.')
|
25
25
|
|
26
|
-
|
26
|
+
raise Error, "The option file's extension '#{ext}' is not supported" unless supported_extensions.include?(ext)
|
27
27
|
|
28
28
|
super(OptionsFile.const_get(ext.upcase).new(file_path))
|
29
29
|
end
|
@@ -58,7 +58,7 @@ module OptParseValidator
|
|
58
58
|
# @param [ String ] value
|
59
59
|
def validate(value)
|
60
60
|
if value.nil? || value.to_s.empty?
|
61
|
-
|
61
|
+
raise Error, 'Empty option value supplied' if value_if_empty.nil?
|
62
62
|
return value_if_empty
|
63
63
|
end
|
64
64
|
value
|
@@ -88,7 +88,7 @@ module OptParseValidator
|
|
88
88
|
unless @symbol
|
89
89
|
long_option = to_long
|
90
90
|
|
91
|
-
|
91
|
+
raise Error, "Could not find option symbol for #{option}" unless long_option
|
92
92
|
|
93
93
|
@symbol = long_option.gsub(/^--/, '').tr('-', '_').to_sym
|
94
94
|
end
|
@@ -11,7 +11,7 @@ module OptParseValidator
|
|
11
11
|
return true if value.match(TRUE_PATTERN)
|
12
12
|
return false if value.match(FALSE_PATTERN)
|
13
13
|
|
14
|
-
|
14
|
+
raise Error, 'Invalid boolean value, expected true|t|yes|y|1|false|f|no|n|0'
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -6,8 +6,8 @@ module OptParseValidator
|
|
6
6
|
# :choices [ Array ] The available choices (mandatory)
|
7
7
|
# :case_sensitive [ Boolean ] Default: false
|
8
8
|
def initialize(option, attrs = {})
|
9
|
-
|
10
|
-
|
9
|
+
raise Error, 'The :choices attribute is mandatory' unless attrs.key?(:choices)
|
10
|
+
raise Error, 'The :choices attribute must be an array' unless attrs[:choices].is_a?(Array)
|
11
11
|
|
12
12
|
super(option, attrs)
|
13
13
|
end
|
@@ -31,7 +31,7 @@ module OptParseValidator
|
|
31
31
|
end
|
32
32
|
|
33
33
|
unless choices.include?(value)
|
34
|
-
|
34
|
+
raise Error, "'#{value}' is not a valid choice, expected one " \
|
35
35
|
"of the followings: #{choices.join(',')}"
|
36
36
|
end
|
37
37
|
|
@@ -4,7 +4,7 @@ module OptParseValidator
|
|
4
4
|
# @return [ Hash ] A hash containing the :username and :password
|
5
5
|
def validate(value)
|
6
6
|
unless value.index(':')
|
7
|
-
|
7
|
+
raise Error, 'Incorrect credentials format, username:password expected'
|
8
8
|
end
|
9
9
|
creds = value.split(':', 2)
|
10
10
|
|
@@ -26,7 +26,7 @@ module OptParseValidator
|
|
26
26
|
def check_extensions(path)
|
27
27
|
return if [*attrs[:extensions]].include?(path.extname.delete('.'))
|
28
28
|
|
29
|
-
|
29
|
+
raise Error, "The extension of '#{path}' is not allowed"
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -14,12 +14,12 @@ module OptParseValidator
|
|
14
14
|
def validate(value)
|
15
15
|
a = super(value).split(separator)
|
16
16
|
|
17
|
-
|
17
|
+
raise Error, "Incorrect number of ranges found: #{a.size}, should be 2" unless a.size == 2
|
18
18
|
|
19
19
|
first_integer = a.first.to_i
|
20
20
|
last_integer = a.last.to_i
|
21
21
|
|
22
|
-
|
22
|
+
raise Error, 'Argument is not a valid integer range' unless first_integer.to_s == a.first && last_integer.to_s == a.last
|
23
23
|
|
24
24
|
(first_integer..last_integer)
|
25
25
|
end
|
@@ -7,8 +7,8 @@ module OptParseValidator
|
|
7
7
|
# @option attrs [ Array<Array> ] :incompatible
|
8
8
|
# @options attrs [ String ] :separator See OptArray#new
|
9
9
|
def initialize(option, attrs = {})
|
10
|
-
|
11
|
-
|
10
|
+
raise Error, 'The :choices attribute is mandatory' unless attrs.key?(:choices)
|
11
|
+
raise Error, 'The :choices attribute must be a hash' unless attrs[:choices].is_a?(Hash)
|
12
12
|
|
13
13
|
super(option, attrs)
|
14
14
|
end
|
@@ -82,7 +82,7 @@ module OptParseValidator
|
|
82
82
|
return [opt, Regexp.last_match[1]]
|
83
83
|
end
|
84
84
|
|
85
|
-
|
85
|
+
raise Error, "Unknown choice: #{item}"
|
86
86
|
end
|
87
87
|
|
88
88
|
# @return [ Array<Array<Symbol>> ]
|
@@ -102,7 +102,7 @@ module OptParseValidator
|
|
102
102
|
|
103
103
|
next unless values.key?(sym)
|
104
104
|
|
105
|
-
|
105
|
+
raise Error, "Incompatible choices detected: #{last_match}, #{key}" unless last_match.empty?
|
106
106
|
|
107
107
|
last_match = key
|
108
108
|
end
|
@@ -37,22 +37,22 @@ module OptParseValidator
|
|
37
37
|
|
38
38
|
# @param [ Pathname ] path
|
39
39
|
def check_file(path)
|
40
|
-
|
40
|
+
raise Error, "'#{path}' is not a file" unless path.file? || attrs[:exists] == false
|
41
41
|
end
|
42
42
|
|
43
43
|
# @param [ Pathname ] path
|
44
44
|
def check_directory(path)
|
45
|
-
|
45
|
+
raise Error, "'#{path}' is not a directory" unless path.directory? || attrs[:exists] == false
|
46
46
|
end
|
47
47
|
|
48
48
|
# @param [ Pathname ] path
|
49
49
|
def check_executable(path)
|
50
|
-
|
50
|
+
raise Error, "'#{path}' is not executable" unless path.executable?
|
51
51
|
end
|
52
52
|
|
53
53
|
# @param [ Pathname ] path
|
54
54
|
def check_readable(path)
|
55
|
-
|
55
|
+
raise Error, "'#{path}' is not readable" unless path.readable?
|
56
56
|
end
|
57
57
|
|
58
58
|
# If the path does not exist, it will check for the parent
|
@@ -60,7 +60,7 @@ module OptParseValidator
|
|
60
60
|
#
|
61
61
|
# @param [ Pathname ] path
|
62
62
|
def check_writable(path)
|
63
|
-
|
63
|
+
raise Error, "'#{path}' is not writable" if path.exist? && !path.writable? || !path.parent.writable?
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -32,7 +32,7 @@ module OptParseValidator
|
|
32
32
|
unless allowed_protocols.empty? || allowed_protocols.include?(uri.scheme)
|
33
33
|
# For future refs: will have to check if the uri.scheme exists,
|
34
34
|
# otherwise it means that the value was empty
|
35
|
-
|
35
|
+
raise Addressable::URI::InvalidURIError
|
36
36
|
end
|
37
37
|
|
38
38
|
uri.to_s
|
data/lib/opt_parse_validator.rb
CHANGED
@@ -61,8 +61,8 @@ module OptParseValidator
|
|
61
61
|
#
|
62
62
|
# @return [ void ]
|
63
63
|
def check_option(opt)
|
64
|
-
|
65
|
-
|
64
|
+
raise Error, "The option is not an OptBase, #{opt.class} supplied" unless opt.is_a?(OptBase)
|
65
|
+
raise Error, "The option #{opt.to_sym} is already used !" if @symbols_used.include?(opt.to_sym)
|
66
66
|
end
|
67
67
|
|
68
68
|
# @return [ Hash ]
|
@@ -100,7 +100,7 @@ module OptParseValidator
|
|
100
100
|
def post_processing
|
101
101
|
@opts.each do |opt|
|
102
102
|
if opt.required?
|
103
|
-
|
103
|
+
raise NoRequiredOption, "The option #{opt} is required" unless @results.key?(opt.to_sym)
|
104
104
|
end
|
105
105
|
|
106
106
|
next if opt.required_unless.empty?
|
@@ -108,7 +108,7 @@ module OptParseValidator
|
|
108
108
|
|
109
109
|
fail_msg = "One of the following options is required: #{opt}, #{opt.required_unless.join(', ')}"
|
110
110
|
|
111
|
-
|
111
|
+
raise NoRequiredOption, fail_msg unless opt.required_unless.any? do |sym|
|
112
112
|
@results.key?(sym)
|
113
113
|
end
|
114
114
|
end
|
data/opt_parse_validator.gemspec
CHANGED
@@ -33,14 +33,14 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
34
34
|
s.require_paths = ['lib']
|
35
35
|
|
36
|
-
s.add_dependency 'addressable', '~> 2.5.0'
|
37
36
|
s.add_dependency 'activesupport', '~> 5.1.0'
|
37
|
+
s.add_dependency 'addressable', '~> 2.5.0'
|
38
38
|
|
39
|
+
s.add_development_dependency 'bundler', '~> 1.6'
|
40
|
+
s.add_development_dependency 'coveralls', '~> 0.8.0'
|
39
41
|
s.add_development_dependency 'rake', '~> 12.0'
|
40
42
|
s.add_development_dependency 'rspec', '~> 3.7.0'
|
41
43
|
s.add_development_dependency 'rspec-its', '~> 1.2.0'
|
42
|
-
s.add_development_dependency '
|
43
|
-
s.add_development_dependency 'rubocop', '~> 0.50.0'
|
44
|
+
s.add_development_dependency 'rubocop', '~> 0.51.0'
|
44
45
|
s.add_development_dependency 'simplecov', '~> 0.14.0' # Can't update to 0.15 as it breaks coveralls dep
|
45
|
-
s.add_development_dependency 'coveralls', '~> 0.8.0'
|
46
46
|
end
|
metadata
CHANGED
@@ -1,141 +1,141 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opt_parse_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- WPScanTeam
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 5.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 5.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: addressable
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 5.
|
33
|
+
version: 2.5.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 5.
|
40
|
+
version: 2.5.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '1.6'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '1.6'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: coveralls
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.8.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.8.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: '12.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: '12.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 3.7.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 3.7.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: rspec-its
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 1.2.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 1.2.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: rubocop
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
117
|
+
version: 0.51.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
124
|
+
version: 0.51.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: simplecov
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 0.
|
131
|
+
version: 0.14.0
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 0.
|
138
|
+
version: 0.14.0
|
139
139
|
description: Implementation of validators for the ruby OptionParser lib. Mainly used
|
140
140
|
in the CMSScanner gem to define the cli options available
|
141
141
|
email:
|