checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
2
SHA256:
3
- metadata.gz: bfcde1ed88a3d3b41836d151c76a25e1f5c6f36e5e62a2910878d9463dc8bddd
4
- data.tar.gz: 6d07487070338fb64622883ed0c7d5cc70cc90e50d0c32ef56e48ebab47bdb07
3
+ metadata.gz: e37a9c3438b53cfe9453653062ef294af7b37c99acfe77937bd9ee1d8bebaca8
4
+ data.tar.gz: 1defdfeb5e06c3f37742fb54f19d38f3f0399d8564fcc2ffbe965ca476ab8bc5
5
5
SHA512:
6
- metadata.gz: efc33f8e0cc1522c8d7b22d1bff81227f26bf67693c3ea14800d34e361bcf0a76d7b04aa656bfc5ce19c10b6a78a37d03b146ff75ac141b1db629ce90e95699d
7
- data.tar.gz: 5dba47501b4d609120a4033e1531ffe7af505e4bbd72aaea5a5725b1d00d61eddde009aa94096656a1fab9346c98e433a74be58dda68d67ea1cbe2ebd1032cf4
6
+ metadata.gz: 7b6297d0b83ca482b02796dea0830b569adc28bdf226822091bd74649712ca08494347cf18fc1ec4f07126eb0819723858418be1d37c7e00b046860f644a9c8b
7
+ data.tar.gz: 61a03033ff7bf52add8ea3886936e79ae188149c9b01dbe24f75706f30a4d577bcc0a61f0e02830be13272c4c35bca09dfe743f5dded863627696353717acebe
data/lib/opt_parse_validator.rb CHANGED
@@ -29,8 +29,8 @@ module OptParseValidator
29
29
end
30
30
31
31
# @return [ OptParseValidator::ConfigFilesLoaderMerger ]
32
- def options_files
33
- @options_files ||= ConfigFilesLoaderMerger.new
32
+ def config_files
33
+ @config_files ||= ConfigFilesLoaderMerger.new
34
34
end
35
35
36
36
# @param [ Array<OptBase> ] options
@@ -56,7 +56,7 @@ module OptParseValidator
56
56
57
57
# @return [ Hash ]
58
58
def results(argv = default_argv)
59
- load_options_files
59
+ load_config_files
60
60
parse!(argv)
61
61
post_processing
62
62
@@ -124,8 +124,8 @@ module OptParseValidator
124
124
end
125
125
126
126
# @return [ Void ]
127
- def load_options_files
128
- files_data = options_files.parse(symbolize_keys: true)
127
+ def load_config_files
128
+ files_data = config_files.parse
129
129
130
130
@opts.each do |opt|
131
131
next unless files_data.key?(opt.to_sym)
data/lib/opt_parse_validator/config_files_loader_merger.rb CHANGED
@@ -6,12 +6,11 @@ require_relative 'config_files_loader_merger/yml'
6
6
7
7
# :nocov:
8
8
# @param [ String ] path The path of the file to load
9
- # @param [ Hash ] opts See https://ruby-doc.org/stdlib-2.6.3/libdoc/psych/rdoc/Psych.html#method-c-safe_load
9
+ def yaml_safe_load(path)
10
- def yaml_safe_load(path, opts = {})
11
10
if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1') # Ruby 2.6
12
- YAML.safe_load(File.read(path), opts) || {}
11
+ YAML.safe_load(File.read(path), permitted_classes: [Regexp]) || {}
13
12
else
14
- YAML.safe_load(File.read(path), opts[:permitted_classes] || [], opts[:permitted_symbols] || [], opts[:aliases]) || {}
13
+ YAML.safe_load(File.read(path), [Regexp]) || {}
15
14
end
16
15
end
17
16
# :nocov:
@@ -29,6 +28,8 @@ module OptParseValidator
29
28
extensions.map { |sym| sym.to_s.downcase }
30
29
end
31
30
31
+ attr_accessor :result_key
32
+
32
33
# @param [ String ] file_path
33
34
#
34
35
# @return [ Self ]
@@ -43,16 +44,16 @@ module OptParseValidator
43
44
end
44
45
45
46
# @params [ Hash ] opts
46
- # @option opts [ Boolean ] :symbolize_keys Whether or not to symbolize keys in the returned hash
47
- # @option opts [ Array ] :yaml_arguments See https://ruby-doc.org/stdlib-2.3.1/libdoc/psych/rdoc/Psych.html#method-c-safe_load
48
47
#
49
48
# @return [ Hash ]
50
- def parse(opts = {})
49
+ def parse
51
50
result = {}
52
51
53
- each { |option_file| result.deep_merge!(option_file.parse(opts)) }
52
+ each { |config_file| result.deep_merge!(config_file.parse) }
53
+
54
+ result = result.dig(result_key) || {} if result_key
54
55
55
- opts[:symbolize_keys] ? result.deep_symbolize_keys : result
56
+ result.deep_symbolize_keys
56
57
end
57
58
end
58
59
end
data/lib/opt_parse_validator/config_files_loader_merger/base.rb CHANGED
@@ -12,9 +12,8 @@ module OptParseValidator
12
12
@path = path
13
13
end
14
14
15
- # @params [ Hash ] opts
16
15
# @return [ Hash ] a { 'key' => value } hash
17
- def parse(_opts = {})
16
+ def parse
18
17
raise NotImplementedError
19
18
end
20
19
data/lib/opt_parse_validator/config_files_loader_merger/json.rb CHANGED
@@ -7,9 +7,8 @@ module OptParseValidator
7
7
module ConfigFile
8
8
# Json Implementation
9
9
class JSON < Base
10
- # @params [ Hash ] opts
11
10
# @return [ Hash ] a { 'key' => value } hash
12
- def parse(_opts = {})
11
+ def parse
13
12
::JSON.parse(File.read(path))
14
13
end
15
14
end
data/lib/opt_parse_validator/config_files_loader_merger/yml.rb CHANGED
@@ -7,12 +7,9 @@ module OptParseValidator
7
7
module ConfigFile
8
8
# Yaml Implementation
9
9
class YML < Base
10
- # @params [ Hash ] opts
11
- # @option opts [ Hash ] :yaml_options See https://ruby-doc.org/stdlib-2.6.3/libdoc/psych/rdoc/Psych.html#method-c-safe_load
12
- #
13
10
# @return [ Hash ] a { 'key' => value } hash
14
- def parse(opts = {})
15
- yaml_safe_load(path, opts[:yaml_options] || {})
11
+ def parse
12
+ yaml_safe_load(path)
16
13
end
17
14
end
18
15
end
data/lib/opt_parse_validator/opts/multi_choices.rb CHANGED
@@ -94,7 +94,7 @@ module OptParseValidator
94
94
# @return [ Array ]
95
95
def value_from_pattern(item)
96
96
choices.each do |key, opt|
97
- next unless item =~ /\A#{key.to_s}(.*)\z/
97
+ next unless item =~ /\A#{key}(.*)\z/
98
98
99
99
return [opt, Regexp.last_match[1]]
100
100
end
data/lib/opt_parse_validator/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
3
3
# Gem Version
4
4
module OptParseValidator
5
- VERSION = '1.7.4'
5
+ VERSION = '1.8.0'
6
6
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: 1.7.4
4
+ version: 1.8.0
5
5
platform: ruby
6
6
authors:
7
7
- WPScanTeam
8
8
autorequire:
9
9
bindir: bin
10
10
cert_chain: []
11
- date: 2019-07-31 00:00:00.000000000 Z
11
+ date: 2019-09-11 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: '4.2'
20
20
- - "<"
21
21
- !ruby/object:Gem::Version
22
- version: 5.3.0
22
+ version: 6.1.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: '4.2'
30
30
- - "<"
31
31
- !ruby/object:Gem::Version
32
- version: 5.3.0
32
+ version: 6.1.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.7'
42
+ version: '2.8'
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.7'
52
+ version: '2.8'
53
53
- !ruby/object:Gem::Dependency
54
54
name: bundler
55
55
requirement: !ruby/object:Gem::Requirement
@@ -126,14 +126,14 @@ dependencies:
126
126
requirements:
127
127
- - "~>"
128
128
- !ruby/object:Gem::Version
129
- version: 0.73.0
129
+ version: 0.74.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: 0.73.0
136
+ version: 0.74.0
137
137
- !ruby/object:Gem::Dependency
138
138
name: rubocop-performance
139
139
requirement: !ruby/object:Gem::Requirement