epub_validator 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -0
- data/bin/epub_validator +31 -10
- data/lib/epub_validator/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
data/bin/epub_validator
CHANGED
@@ -2,25 +2,46 @@
|
|
2
2
|
|
3
3
|
$LOAD_PATH << File.expand_path(File.dirname(__FILE__) + '/../lib')
|
4
4
|
|
5
|
+
require 'optparse'
|
5
6
|
require 'epub_validator'
|
6
7
|
|
7
|
-
args = ARGV
|
8
|
-
ARGV.clear
|
9
|
-
command = args.shift.strip rescue 'help'
|
8
|
+
args = ARGV
|
10
9
|
|
11
|
-
|
12
|
-
|
10
|
+
options = OptionParser.new do |opts|
|
11
|
+
opts.banner = "Usage: #{opts.program_name} [OPTIONS] /path/to/some.epub"
|
12
|
+
opts.separator ""
|
13
|
+
opts.separator "Common options:"
|
13
14
|
|
14
|
-
|
15
|
-
puts
|
16
|
-
|
15
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
16
|
+
puts opts
|
17
|
+
exit
|
18
|
+
end
|
19
|
+
opts.on_tail("--version", "Show version") do
|
20
|
+
puts EpubValidator::VERSION
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
args = ['-h'] if args.empty?
|
26
|
+
options.parse!(args)
|
27
|
+
|
28
|
+
filename = args.shift.strip
|
29
|
+
unless filename
|
30
|
+
puts "You must provide an EPUB filename"
|
31
|
+
exit
|
32
|
+
end
|
33
|
+
|
34
|
+
print "\nChecking...."
|
35
|
+
validation = EpubValidator.check(filename)
|
17
36
|
|
18
37
|
if validation.valid?
|
19
|
-
puts "
|
38
|
+
puts "Congratulations! This is a valid EPUB #{validation.epub_version} ebook."
|
20
39
|
puts
|
21
40
|
puts validation.messages
|
22
41
|
else
|
23
|
-
puts "FAILED
|
42
|
+
puts "FAILED!"
|
43
|
+
puts
|
44
|
+
puts "This is not a valid EPUB #{validation.epub_version} ebook."
|
24
45
|
puts
|
25
46
|
puts validation.messages
|
26
47
|
end
|