Sha256: d2e263416f7215338e1cd82839da6f9cd36578a78e6ac8f0011b622d11a47284

Contents?: true

Size: 962 Bytes

Versions: 9

Compression:

Stored size: 962 Bytes

Contents

module Softcover
  module Commands
    module EpubValidator
      extend Softcover::Utils
      extend self

      # Validates a book according to the EPUB standard.
      def validate!
        epub = Dir.glob('ebooks/*.epub').first
        puts "Validating EPUB..."
        system("#{java} -jar #{epubcheck} #{epub}")
      end

      private

        def java
          filename = `which java`.chomp
          url = 'http://www.java.com/en/download/help/index_installing.xml'
          message = "Install Java (#{url})"
          @java ||= executable(filename, message)
        end

        def epubcheck
          filename = File.join(Dir.home, 'epubcheck-3.0', 'epubcheck-3.0.jar')
          url = 'https://code.google.com/p/epubcheck/downloads/' +
                'detail?name=epubcheck-3.0.zip'
          message = "Put EpubCheck (#{url}) in your home directory"
          @epubcheck ||= executable(filename, message).inspect
        end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
softcover-0.6.7 lib/softcover/commands/epub_validator.rb
softcover-0.6.6 lib/softcover/commands/epub_validator.rb
softcover-0.6.5 lib/softcover/commands/epub_validator.rb
softcover-0.6.4 lib/softcover/commands/epub_validator.rb
softcover-0.6.3 lib/softcover/commands/epub_validator.rb
softcover-0.6.2 lib/softcover/commands/epub_validator.rb
softcover-0.6.1 lib/softcover/commands/epub_validator.rb
softcover-0.6.0 lib/softcover/commands/epub_validator.rb
softcover-0.5.0 lib/softcover/commands/epub_validator.rb