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 CHANGED
@@ -37,6 +37,8 @@ $ epub_validator /path/to/sample.epub
37
37
 
38
38
  Checking....FAILED!
39
39
 
40
+ This is not a valid EPUB 3.0 ebook.
41
+
40
42
  ERROR: OPS/toc.ncx(21): 'OPS/': referenced resource exists, but not declared in the OPF file
41
43
  ```
42
44
 
@@ -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.dup
8
- ARGV.clear
9
- command = args.shift.strip rescue 'help'
8
+ args = ARGV
10
9
 
11
- puts "\nChecking...."
12
- validation = EpubValidator.check(command)
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
- puts
15
- puts "Detected as EPUB version #{validation.epub_version}"
16
- puts
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 "...Passed.\n"
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!\n\n"
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
@@ -1,3 +1,3 @@
1
1
  module EpubValidator
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epub_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: