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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a90744747bab0639f4bcbb7f50f7303f1d1bd06
4
- data.tar.gz: 968a77bee71151631058bf5028a22dfe984a06ec
3
+ metadata.gz: 9a34dacc55d16b62f89bd6f1d2abda599a3876b3
4
+ data.tar.gz: c23a8feb575ecfead935c4e163dcd95d8ce27d3d
5
5
  SHA512:
6
- metadata.gz: 71e52af14ca0a516aa77163ba216ac1491a321b0c5e3d076f76669a564b77e88afad004efb0d08193d8c9d4734ce06a7ff683c8f179883222cf64e5a502b6977
7
- data.tar.gz: ce2da38c2d6b20869a702d91b7aecc6783baaca9b5951444852b1a0bdcd090717c0a8d372bf35dc4f32fe3e2cbb1afbd6c799bf58eb091cfc73d77d3dafd60d4
6
+ metadata.gz: 357e580715074b73a6cc639f2f32e1fa52ee9ce116ce82181350c0d08457f76846e1dce9a0d3a567fa4788a2c2730f588050e673b61f43d21e0279d717721161
7
+ data.tar.gz: 849d98dd225c8a6e17378f8e59ba6f75f9a665e06968636f089747069eda70d2b71e9a7464fd03f3dd7c9cfab4b6d35f6a56d3a6f8585163506c4058db44b186
@@ -11,7 +11,7 @@ module OptParseValidator
11
11
 
12
12
  # @return [ Hash ] a { key: value } hash
13
13
  def parse
14
- fail NotImplementedError
14
+ raise NotImplementedError
15
15
  end
16
16
 
17
17
  def ==(other)
@@ -6,7 +6,7 @@ module OptParseValidator
6
6
  class YML < Base
7
7
  # @return [ Hash ] a { 'key' => value } hash
8
8
  def parse
9
- YAML.load_file(path) || {}
9
+ YAML.safe_load(File.read(path)) || {}
10
10
  end
11
11
  end
12
12
  end
@@ -23,7 +23,7 @@ module OptParseValidator
23
23
 
24
24
  ext = File.extname(file_path).delete('.')
25
25
 
26
- fail Error, "The option file's extension '#{ext}' is not supported" unless supported_extensions.include?(ext)
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
- fail Error, 'Empty option value supplied' if value_if_empty.nil?
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
- fail Error, "Could not find option symbol for #{option}" unless long_option
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
- fail Error, 'Invalid boolean value, expected true|t|yes|y|1|false|f|no|n|0'
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
- fail Error, 'The :choices attribute is mandatory' unless attrs.key?(:choices)
10
- fail Error, 'The :choices attribute must be an array' unless attrs[:choices].is_a?(Array)
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
- fail Error, "'#{value}' is not a valid choice, expected one " \
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
- fail Error, 'Incorrect credentials format, username:password expected'
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
- fail Error, "The extension of '#{path}' is not allowed"
29
+ raise Error, "The extension of '#{path}' is not allowed"
30
30
  end
31
31
  end
32
32
  end
@@ -18,7 +18,7 @@ module OptParseValidator
18
18
  headers = {}
19
19
 
20
20
  values.each do |header|
21
- fail Error, "Malformed header: '#{header}'" unless header.index(':')
21
+ raise Error, "Malformed header: '#{header}'" unless header.index(':')
22
22
 
23
23
  val = header.split(':', 2)
24
24
 
@@ -5,7 +5,7 @@ module OptParseValidator
5
5
  #
6
6
  # @return [ Integer ]
7
7
  def validate(value)
8
- fail Error, "#{value} is not an integer" if value.to_i.to_s != value
8
+ raise Error, "#{value} is not an integer" if value.to_i.to_s != value
9
9
  value.to_i
10
10
  end
11
11
  end
@@ -14,12 +14,12 @@ module OptParseValidator
14
14
  def validate(value)
15
15
  a = super(value).split(separator)
16
16
 
17
- fail Error, "Incorrect number of ranges found: #{a.size}, should be 2" unless a.size == 2
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
- fail Error, 'Argument is not a valid integer range' unless first_integer.to_s == a.first && last_integer.to_s == a.last
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
- fail Error, 'The :choices attribute is mandatory' unless attrs.key?(:choices)
11
- fail Error, 'The :choices attribute must be a hash' unless attrs[:choices].is_a?(Hash)
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
- fail Error, "Unknown choice: #{item}"
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
- fail Error, "Incompatible choices detected: #{last_match}, #{key}" unless last_match.empty?
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
- fail Error, "'#{path}' is not a file" unless path.file? || attrs[:exists] == false
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
- fail Error, "'#{path}' is not a directory" unless path.directory? || attrs[:exists] == false
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
- fail Error, "'#{path}' is not executable" unless path.executable?
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
- fail Error, "'#{path}' is not readable" unless path.readable?
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
- fail Error, "'#{path}' is not writable" if path.exist? && !path.writable? || !path.parent.writable?
63
+ raise Error, "'#{path}' is not writable" if path.exist? && !path.writable? || !path.parent.writable?
64
64
  end
65
65
  end
66
66
  end
@@ -6,7 +6,7 @@ module OptParseValidator
6
6
  # @return [ Integer ]
7
7
  def validate(value)
8
8
  i = super(value)
9
- fail Error, "#{i} is not > 0" unless i > 0
9
+ raise Error, "#{i} is not > 0" unless i.positive?
10
10
  i
11
11
  end
12
12
  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
- fail Addressable::URI::InvalidURIError
35
+ raise Addressable::URI::InvalidURIError
36
36
  end
37
37
 
38
38
  uri.to_s
@@ -1,4 +1,4 @@
1
1
  # Gem Version
2
2
  module OptParseValidator
3
- VERSION = '0.0.13.11'.freeze
3
+ VERSION = '0.0.14.0'.freeze
4
4
  end
@@ -61,8 +61,8 @@ module OptParseValidator
61
61
  #
62
62
  # @return [ void ]
63
63
  def check_option(opt)
64
- fail Error, "The option is not an OptBase, #{opt.class} supplied" unless opt.is_a?(OptBase)
65
- fail Error, "The option #{opt.to_sym} is already used !" if @symbols_used.include?(opt.to_sym)
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
- fail NoRequiredOption, "The option #{opt} is required" unless @results.key?(opt.to_sym)
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
- fail NoRequiredOption, fail_msg unless opt.required_unless.any? do |sym|
111
+ raise NoRequiredOption, fail_msg unless opt.required_unless.any? do |sym|
112
112
  @results.key?(sym)
113
113
  end
114
114
  end
@@ -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 'bundler', '~> 1.6'
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.13.11
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-10-28 00:00:00.000000000 Z
11
+ date: 2017-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: addressable
14
+ name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.5.0
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: 2.5.0
26
+ version: 5.1.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: activesupport
28
+ name: addressable
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 5.1.0
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.1.0
40
+ version: 2.5.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '12.0'
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: '12.0'
54
+ version: '1.6'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
56
+ name: coveralls
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.7.0
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: 3.7.0
68
+ version: 0.8.0
69
69
  - !ruby/object:Gem::Dependency
70
- name: rspec-its
70
+ name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.2.0
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: 1.2.0
82
+ version: '12.0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: bundler
84
+ name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.6'
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: '1.6'
96
+ version: 3.7.0
97
97
  - !ruby/object:Gem::Dependency
98
- name: rubocop
98
+ name: rspec-its
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.50.0
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: 0.50.0
110
+ version: 1.2.0
111
111
  - !ruby/object:Gem::Dependency
112
- name: simplecov
112
+ name: rubocop
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.14.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.14.0
124
+ version: 0.51.0
125
125
  - !ruby/object:Gem::Dependency
126
- name: coveralls
126
+ name: simplecov
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 0.8.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.8.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: