opt_parse_validator 0.0.13 → 0.0.13.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/opt_parse_validator/hacks.rb +1 -1
- data/lib/opt_parse_validator/options_file/json.rb +2 -2
- data/lib/opt_parse_validator/options_file/yml.rb +2 -2
- data/lib/opt_parse_validator/options_files.rb +4 -5
- data/lib/opt_parse_validator/opts/base.rb +2 -2
- data/lib/opt_parse_validator/opts/boolean.rb +4 -7
- data/lib/opt_parse_validator/opts/multi_choices.rb +4 -4
- data/lib/opt_parse_validator/opts/path.rb +1 -1
- data/lib/opt_parse_validator/version.rb +1 -1
- data/lib/opt_parse_validator.rb +2 -2
- data/opt_parse_validator.gemspec +7 -7
- metadata +16 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5a2531d386b9187b5ca2c26cd56888d10aa4b99
|
4
|
+
data.tar.gz: 3cc67811d22d44505c9ef4028142f30ed4231f68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed3fbe7b90c8cd35f4c185b3cd1883adbde479d78eb7c98a7d6da5e2bb4283add0c3154abb30eb975692ee320e7f6160fc01f4a182751eaaf93bce8ef0d111ab
|
7
|
+
data.tar.gz: 423bbd205f6db1a201d224ce9723e2adc507335d293471fe0c94f5d88ce50cefb45623d687bf6174189fa8ce5367e5d0b94360b77b9a3d00c8c9cd15b5b21b8a
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ class OptionParser
|
|
4
4
|
# See https://github.com/wpscanteam/CMSScanner/issues/2
|
5
5
|
module Completion
|
6
6
|
class << self
|
7
|
-
|
7
|
+
alias original_candidate candidate
|
8
8
|
|
9
9
|
def candidate(key, icase = false, pat = nil, &block)
|
10
10
|
# Maybe also do this for -v/--version ?
|
@@ -4,9 +4,9 @@ module OptParseValidator
|
|
4
4
|
module OptionsFile
|
5
5
|
# Json Implementation
|
6
6
|
class JSON < Base
|
7
|
-
# @return [ Hash ] a { key
|
7
|
+
# @return [ Hash ] a { 'key' => value } hash
|
8
8
|
def parse
|
9
|
-
::JSON.parse(File.read(path)
|
9
|
+
::JSON.parse(File.read(path))
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -4,9 +4,9 @@ module OptParseValidator
|
|
4
4
|
module OptionsFile
|
5
5
|
# Yaml Implementation
|
6
6
|
class YML < Base
|
7
|
-
# @return [ Hash ] a { key
|
7
|
+
# @return [ Hash ] a { 'key' => value } hash
|
8
8
|
def parse
|
9
|
-
|
9
|
+
YAML.load_file(path) || {}
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -32,12 +32,11 @@ module OptParseValidator
|
|
32
32
|
def parse
|
33
33
|
files_data = {}
|
34
34
|
|
35
|
-
each
|
36
|
-
data = option_file.parse
|
37
|
-
files_data.merge!(data) if data
|
38
|
-
end
|
35
|
+
each { |option_file| files_data.merge!(option_file.parse) }
|
39
36
|
|
40
|
-
|
37
|
+
# Convert string-full keys to symbol ones
|
38
|
+
# No need to go deeper than the first level as it's the max depth
|
39
|
+
Hash[files_data.map { |k, v| [k.to_sym, v] }]
|
41
40
|
end
|
42
41
|
end
|
43
42
|
end
|
@@ -85,7 +85,7 @@ module OptParseValidator
|
|
85
85
|
|
86
86
|
fail Error, "Could not find option symbol for #{option}" unless long_option
|
87
87
|
|
88
|
-
@symbol = long_option.gsub(/^--/, '').
|
88
|
+
@symbol = long_option.gsub(/^--/, '').tr('-', '_').to_sym
|
89
89
|
end
|
90
90
|
@symbol
|
91
91
|
end
|
@@ -95,7 +95,7 @@ module OptParseValidator
|
|
95
95
|
option.each do |option_attr|
|
96
96
|
if option_attr =~ /^--/
|
97
97
|
return option_attr.gsub(/ .*$/, '')
|
98
|
-
|
98
|
+
.gsub(/\[[^\]]+\]/, '')
|
99
99
|
end
|
100
100
|
end
|
101
101
|
nil
|
@@ -8,13 +8,10 @@ module OptParseValidator
|
|
8
8
|
def validate(value)
|
9
9
|
value = value.to_s
|
10
10
|
|
11
|
-
if value.match(TRUE_PATTERN)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
else
|
16
|
-
fail Error, 'Invalid boolean value, expected true|t|yes|y|1|false|f|no|n|0'
|
17
|
-
end
|
11
|
+
return true if value.match(TRUE_PATTERN)
|
12
|
+
return false if value.match(FALSE_PATTERN)
|
13
|
+
|
14
|
+
fail Error, 'Invalid boolean value, expected true|t|yes|y|1|false|f|no|n|0'
|
18
15
|
end
|
19
16
|
end
|
20
17
|
end
|
@@ -21,7 +21,7 @@ module OptParseValidator
|
|
21
21
|
option << "Multiple choices can be supplied, use the '#{separator}' char as a separator"
|
22
22
|
option << "If no choice is supplied, '#{value_if_empty}' will be used" if value_if_empty
|
23
23
|
|
24
|
-
|
24
|
+
append_incompatible_help_messages
|
25
25
|
end
|
26
26
|
|
27
27
|
def append_choices_help_messages
|
@@ -32,7 +32,7 @@ module OptParseValidator
|
|
32
32
|
other_lines_prefix = ' ' * first_line_prefix.size
|
33
33
|
|
34
34
|
opt_help_messages(opt).each_with_index do |message, index|
|
35
|
-
option << "#{index
|
35
|
+
option << "#{index.zero? ? first_line_prefix : other_lines_prefix} #{message}"
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -44,7 +44,7 @@ module OptParseValidator
|
|
44
44
|
opt.help_messages.empty? ? [opt.to_s.humanize] : opt.help_messages
|
45
45
|
end
|
46
46
|
|
47
|
-
def
|
47
|
+
def append_incompatible_help_messages
|
48
48
|
return if incompatible.empty?
|
49
49
|
|
50
50
|
option << 'Incompatible choices (only one of each group/s can be used):'
|
@@ -78,7 +78,7 @@ module OptParseValidator
|
|
78
78
|
# @return [ Array ]
|
79
79
|
def value_from_pattern(item)
|
80
80
|
choices.each do |key, opt|
|
81
|
-
next unless item
|
81
|
+
next unless item =~ /\A#{key.to_s}(.*)\z/
|
82
82
|
|
83
83
|
return [opt, Regexp.last_match[1]]
|
84
84
|
end
|
data/lib/opt_parse_validator.rb
CHANGED
@@ -68,7 +68,7 @@ module OptParseValidator
|
|
68
68
|
# @return [ Hash ]
|
69
69
|
def results(argv = default_argv)
|
70
70
|
load_options_files
|
71
|
-
|
71
|
+
parse!(argv)
|
72
72
|
post_processing
|
73
73
|
|
74
74
|
@results
|
@@ -84,7 +84,7 @@ module OptParseValidator
|
|
84
84
|
@opts.each do |opt|
|
85
85
|
next unless files_data.key?(opt.to_sym)
|
86
86
|
|
87
|
-
@results[opt.to_sym] = opt.normalize(opt.validate(files_data[opt.to_sym]))
|
87
|
+
@results[opt.to_sym] = opt.normalize(opt.validate(files_data[opt.to_sym].to_s))
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
data/opt_parse_validator.gemspec
CHANGED
@@ -32,13 +32,13 @@ Gem::Specification.new do |s|
|
|
32
32
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
33
33
|
s.require_paths = ['lib']
|
34
34
|
|
35
|
-
s.add_dependency 'addressable', '~> 2.
|
36
|
-
s.add_dependency 'activesupport', '~>
|
35
|
+
s.add_dependency 'addressable', '~> 2.4.0'
|
36
|
+
s.add_dependency 'activesupport', '~> 5.0.0.0'
|
37
37
|
|
38
|
-
s.add_development_dependency 'rake', '~>
|
39
|
-
s.add_development_dependency 'rspec', '~> 3.
|
40
|
-
s.add_development_dependency 'rspec-its', '~> 1.2'
|
38
|
+
s.add_development_dependency 'rake', '~> 11.3.0'
|
39
|
+
s.add_development_dependency 'rspec', '~> 3.5.0'
|
40
|
+
s.add_development_dependency 'rspec-its', '~> 1.2.0'
|
41
41
|
s.add_development_dependency 'bundler', '~> 1.6'
|
42
|
-
s.add_development_dependency 'rubocop', '~> 0.
|
43
|
-
s.add_development_dependency 'simplecov', '~> 0.
|
42
|
+
s.add_development_dependency 'rubocop', '~> 0.43.0'
|
43
|
+
s.add_development_dependency 'simplecov', '~> 0.12.0'
|
44
44
|
end
|
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: 0.0.13
|
4
|
+
version: 0.0.13.2
|
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: 2016-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -16,70 +16,70 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.4.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: 2.4.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 5.0.0.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:
|
40
|
+
version: 5.0.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 11.3.0
|
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: 11.3.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 3.5.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: 3.5.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec-its
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 1.2.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: 1.2.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,28 +100,28 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 0.43.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: 0.43.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: simplecov
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 0.12.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:
|
124
|
+
version: 0.12.0
|
125
125
|
description: Implementation of validators for the ruby OptionParser lib. Mainly used
|
126
126
|
in the CMSScanner gem to define the cli options available
|
127
127
|
email:
|
@@ -185,4 +185,3 @@ signing_key:
|
|
185
185
|
specification_version: 4
|
186
186
|
summary: Ruby OptionParser Validators
|
187
187
|
test_files: []
|
188
|
-
has_rdoc:
|