dir_validator 0.13.2 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +4 -0
- data/lib/dir_validator.rb +26 -4
- metadata +5 -5
data/CHANGELOG.rdoc
CHANGED
data/lib/dir_validator.rb
CHANGED
@@ -14,6 +14,8 @@ module DirValidator
|
|
14
14
|
# module DirValidator
|
15
15
|
# def initialize_validator
|
16
16
|
# # Should return the arguments to DirValidator.new().
|
17
|
+
# # Alternatively, the user can supply those arguments on
|
18
|
+
# # the command line; in that case, this method is unneeded.
|
17
19
|
# end
|
18
20
|
#
|
19
21
|
# def run_validator(dv)
|
@@ -28,19 +30,37 @@ module DirValidator
|
|
28
30
|
# wanting to offer the functionality of the dir_validator gem and
|
29
31
|
# to receive the validation code as an input.
|
30
32
|
def self.run_script(args)
|
33
|
+
# Usage message, and a copy of the args (typically from ARGV).
|
34
|
+
usage = lambda { abort "Usage: #{$PROGRAM_NAME} SCRIPT [DIRECTORY]" }
|
35
|
+
args = args.dup
|
31
36
|
# Require the script, and add its functions to the module.
|
32
|
-
script = args.
|
33
|
-
|
37
|
+
script = args.shift
|
38
|
+
usage.call unless File.file?(script.to_s)
|
34
39
|
require File.expand_path(script)
|
35
40
|
module_function(:initialize_validator, :run_validator)
|
36
|
-
#
|
37
|
-
|
41
|
+
# Get the initialization parameters for the validator.
|
42
|
+
# If the user did not implement the initialize_validator() method,
|
43
|
+
# we will get the params from from args (the command line).
|
44
|
+
init_params = initialize_validator()
|
45
|
+
init_params = args unless init_params.first
|
46
|
+
usage.call unless File.directory?(init_params.first.to_s)
|
47
|
+
# Create validator and run the validation code supplied by user.
|
48
|
+
dv = DirValidator.new(*init_params)
|
38
49
|
run_validator(dv)
|
39
50
|
dv.validate()
|
40
51
|
# Return the validator.
|
41
52
|
return dv
|
42
53
|
end
|
43
54
|
|
55
|
+
# Users depending on run_script() can implement this method if they
|
56
|
+
# prefer to pass arguments to the initializer in Ruby code
|
57
|
+
# rather than on the command line.
|
58
|
+
#
|
59
|
+
# @!visibility private
|
60
|
+
def initialize_validator
|
61
|
+
return []
|
62
|
+
end
|
63
|
+
|
44
64
|
end
|
45
65
|
|
46
66
|
require 'dir_validator/catalog'
|
@@ -48,3 +68,5 @@ require 'dir_validator/item'
|
|
48
68
|
require 'dir_validator/quantity'
|
49
69
|
require 'dir_validator/validator'
|
50
70
|
require 'dir_validator/warning'
|
71
|
+
|
72
|
+
require 'awesome_print'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dir_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 39
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 14
|
9
|
+
- 0
|
10
|
+
version: 0.14.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Monty Hindman
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-08-
|
18
|
+
date: 2012-08-03 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|