opt_parse_validator 1.9.0 → 1.9.1

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: 89b8da406e7e4e0e9867e361779d2e9a3f0b4be2a76dc84e3075dfb118026f48
4
- data.tar.gz: 4f2f06a234e3d0e1ca4d00888be600d941d0cf9f53ff51daf2d2c1880c91cd1c
3
+ metadata.gz: 3ccb947d9079bcc004e16bdfea47a5e5207c26e871da1a1cf0c01f2bbeca5b65
4
+ data.tar.gz: 87139c6bbe1664ff3c70374a81d3e6940193b5d46cd0d07c5905cc22ab468cfb
5
5
  SHA512:
6
- metadata.gz: d469dc14d2cbab0c3a16a11ad5f54d8e935c8262345b700d69b48411a8f35d7058bd8f65f48470f3650e5d72e81d917fe84226079565346c33c26169df84c49e
7
- data.tar.gz: a602fc39ae87a54aed14a01e663b195dfa50f1e2f619dca25bd3d2727c93adac7247cb56d1c5ac9008b75ed19dccb3696f188873ebc4c2c731be6c597b3f5498
6
+ metadata.gz: dd7dd0aa734ad3ad63bd1644b8ab05213d96a0d3c223de20d2152581c22c04b7f68df65ea52fbe4b189e46d44b32d005b855da92e12c5e336b31eb42553d5c00
7
+ data.tar.gz: 50bca2d9e0f17c6c1f9662b3d3e6a9d9b1d8ed5352b6e35c4847ac373ff91b64a50adfe53ffd73f993575e90a9cae67cfe7bcd52fafe702cefb30ec44d718dce
@@ -108,18 +108,16 @@ module OptParseValidator
108
108
  # @return [ void ]
109
109
  def register_callback(opt)
110
110
  on(*opt.option) do |arg|
111
- begin
112
- if opt.alias?
113
- parse!(opt.alias_for.split(' '))
114
- else
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,11 @@ 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} 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 = "One of the following options is required: #{opt}, #{opt.required_unless.join(', ')}"
152
+ fail_msg = "One of the following options is required: --#{opt}, --#{opt.required_unless.join(', --')}"
155
153
 
156
154
  raise NoRequiredOption, fail_msg unless opt.required_unless.any? do |sym|
157
155
  @results.key?(sym)
@@ -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.gsub(/^--/, '').tr('-', '_').to_sym
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 /^--/.match?(option_attr)
118
+ if option_attr.start_with?('--')
119
119
  return option_attr.gsub(/ .*$/, '')
120
120
  .gsub(/\[[^\]]+\]/, '')
121
121
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Gem Version
4
4
  module OptParseValidator
5
- VERSION = '1.9.0'
5
+ VERSION = '1.9.1'
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.9.0
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - WPScanTeam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-12 00:00:00.000000000 Z
11
+ date: 2020-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -112,28 +112,28 @@ dependencies:
112
112
  requirements:
113
113
  - - "~>"
114
114
  - !ruby/object:Gem::Version
115
- version: 0.81.0
115
+ version: 0.84.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.81.0
122
+ version: 0.84.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.5.0
129
+ version: 1.6.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.5.0
136
+ version: 1.6.0
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: simplecov
139
139
  requirement: !ruby/object:Gem::Requirement