Sha256: f962f613534d0f59b99cdb9f29251a9dfe91a1f7bb8551c75b587657c2d8ff87

Contents?: true

Size: 962 Bytes

Versions: 24

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://github.com/IDPF/epubcheck/releases/download/v3.0/epubcheck-3.0.zip'
          message = "Download EpubCheck 3.0 (#{url}) and unzip it in your home directory"
          @epubcheck ||= executable(filename, message).inspect
        end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
softcover-0.8.9 lib/softcover/commands/epub_validator.rb
softcover-0.8.8 lib/softcover/commands/epub_validator.rb
softcover-0.8.7 lib/softcover/commands/epub_validator.rb
softcover-0.8.6 lib/softcover/commands/epub_validator.rb
softcover-0.8.5 lib/softcover/commands/epub_validator.rb
softcover-0.8.4 lib/softcover/commands/epub_validator.rb
softcover-0.8.3 lib/softcover/commands/epub_validator.rb
softcover-0.8.2 lib/softcover/commands/epub_validator.rb
softcover-0.8.1 lib/softcover/commands/epub_validator.rb
softcover-0.8.0 lib/softcover/commands/epub_validator.rb
softcover-0.7.11 lib/softcover/commands/epub_validator.rb
softcover-0.7.10 lib/softcover/commands/epub_validator.rb
softcover-0.7.9 lib/softcover/commands/epub_validator.rb
softcover-0.7.8 lib/softcover/commands/epub_validator.rb
softcover-0.7.7 lib/softcover/commands/epub_validator.rb
softcover-0.7.6 lib/softcover/commands/epub_validator.rb
softcover-0.7.5 lib/softcover/commands/epub_validator.rb
softcover-0.7.4 lib/softcover/commands/epub_validator.rb
softcover-0.7.3 lib/softcover/commands/epub_validator.rb
softcover-0.7.2 lib/softcover/commands/epub_validator.rb