opt_parse_validator 0.0.13.10 → 0.0.13.11

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
  SHA1:
3
- metadata.gz: eabff19a148cc02589422cf69471913c9a6a9cf4
4
- data.tar.gz: 3a85f042127a44563b192e3694f5768b0fcafd5b
3
+ metadata.gz: 3a90744747bab0639f4bcbb7f50f7303f1d1bd06
4
+ data.tar.gz: 968a77bee71151631058bf5028a22dfe984a06ec
5
5
  SHA512:
6
- metadata.gz: 9709ed1f23736346e3d4dab86032a61fc07cd73e8ae593c04bec00721df16e52ed77e81d41a910df45ec96a4362ea61f2a70247e0f381562c0c036d5625cbac0
7
- data.tar.gz: 5a9537267567f9e8c536885fc22cda5346b6dc3dbd9107b29ff2f7f0d69907004b34328ef4a2e8a518c7c6a951039d7675c6c929136256fb58752e464ad2c7b3
6
+ metadata.gz: 71e52af14ca0a516aa77163ba216ac1491a321b0c5e3d076f76669a564b77e88afad004efb0d08193d8c9d4734ce06a7ff683c8f179883222cf64e5a502b6977
7
+ data.tar.gz: ce2da38c2d6b20869a702d91b7aecc6783baaca9b5951444852b1a0bdcd090717c0a8d372bf35dc4f32fe3e2cbb1afbd6c799bf58eb091cfc73d77d3dafd60d4
data/README.md CHANGED
@@ -64,11 +64,13 @@ Some attributes are available for all Validators:
64
64
  - :case_sensitive
65
65
  - Credentials
66
66
  - Directory Path
67
+ - :create
67
68
  - :exists
68
69
  - :executable
69
70
  - :readable
70
71
  - :writable
71
72
  - File Path
73
+ - :create
72
74
  - :exists
73
75
  - :executable
74
76
  - :readable
@@ -83,6 +85,7 @@ Some attributes are available for all Validators:
83
85
  - incompatible
84
86
  - Positive Integer
85
87
  - Path
88
+ - :create
86
89
  - :file
87
90
  - :directory
88
91
  - :exists
@@ -6,5 +6,10 @@ module OptParseValidator
6
6
 
7
7
  @attrs.merge!(directory: true)
8
8
  end
9
+
10
+ # @param [ Pathname ] path
11
+ def check_create(path)
12
+ FileUtils.mkdir_p(path.to_s) unless Dir.exist?(path.to_s)
13
+ end
9
14
  end
10
15
  end
@@ -10,6 +10,14 @@ module OptParseValidator
10
10
  @attrs.merge!(file: true)
11
11
  end
12
12
 
13
+ # @param [ Pathname ] path
14
+ def check_create(path)
15
+ return if File.exist?(path.to_s)
16
+
17
+ FileUtils.mkdir_p(path.parent.to_s) unless Dir.exist?(path.parent.to_s)
18
+ FileUtils.touch(path.to_s)
19
+ end
20
+
13
21
  def allowed_attrs
14
22
  # :extensions is put at the first place
15
23
  [:extensions] + super
@@ -3,6 +3,8 @@ module OptParseValidator
3
3
  class OptPath < OptBase
4
4
  # Initialize attrs:
5
5
  #
6
+ # :create if set to true, will create the path
7
+ #
6
8
  # :exists if set to false, will ignore the file? and directory? checks
7
9
  #
8
10
  # :file Check if the path is a file
@@ -18,6 +20,7 @@ module OptParseValidator
18
20
  # @return [ String ]
19
21
  def validate(value)
20
22
  path = Pathname.new(value)
23
+
21
24
  allowed_attrs.each do |key|
22
25
  method = "check_#{key}"
23
26
  send(method, path) if respond_to?(method) && attrs[key]
@@ -27,9 +30,11 @@ module OptParseValidator
27
30
  end
28
31
 
29
32
  def allowed_attrs
30
- %i[file directory executable readable writable]
33
+ %i[create file directory executable readable writable]
31
34
  end
32
35
 
36
+ # check_create is implemented in the file_path and directory_path opts
37
+
33
38
  # @param [ Pathname ] path
34
39
  def check_file(path)
35
40
  fail Error, "'#{path}' is not a file" unless path.file? || attrs[:exists] == false
@@ -1,4 +1,4 @@
1
1
  # Gem Version
2
2
  module OptParseValidator
3
- VERSION = '0.0.13.10'.freeze
3
+ VERSION = '0.0.13.11'.freeze
4
4
  end
@@ -37,7 +37,7 @@ Gem::Specification.new do |s|
37
37
  s.add_dependency 'activesupport', '~> 5.1.0'
38
38
 
39
39
  s.add_development_dependency 'rake', '~> 12.0'
40
- s.add_development_dependency 'rspec', '~> 3.6.0'
40
+ s.add_development_dependency 'rspec', '~> 3.7.0'
41
41
  s.add_development_dependency 'rspec-its', '~> 1.2.0'
42
42
  s.add_development_dependency 'bundler', '~> 1.6'
43
43
  s.add_development_dependency 'rubocop', '~> 0.50.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opt_parse_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13.10
4
+ version: 0.0.13.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - WPScanTeam
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.6.0
61
+ version: 3.7.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.6.0
68
+ version: 3.7.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec-its
71
71
  requirement: !ruby/object:Gem::Requirement