class Bookshelf::Cli
Constants
- FORMATS
Public Class Methods
exit_on_failure?()
click to toggle source
# File lib/bookshelf/cli.rb, line 6 def self.exit_on_failure? true end
new(args = [], options = {}, config = {})
click to toggle source
Calls superclass method
# File lib/bookshelf/cli.rb, line 10 def initialize(args = [], options = {}, config = {}) if (config[:current_task] || config[:current_command]).name == "new" && args.empty? raise Error, "The e-Book path is required. For details run: bookshelf help new" end super end
Public Instance Methods
check()
click to toggle source
# File lib/bookshelf/cli.rb, line 47 def check result = [] result << { :description => "Prince XML: Converts HTML files into PDF files.", :installed => Bookshelf::Dependency.prince? } result.each do |result| text = color(result[:name], :blue) text << "\n" << result[:description] text << "\n" << (result[:installed] ? color("Installed.", :green) : color("Not installed.", :red)) text << "\n" say(text) end end
export()
click to toggle source
# File lib/bookshelf/cli.rb, line 29 def export if options[:only] && !FORMATS.include?(options[:only]) raise Error, "The --only option need to be one of: #{FORMATS.join(", ")}" end book_dir = Pathname.new("text") Bookshelf::Exporter.run(book_dir, options) end
new(path)
click to toggle source
# File lib/bookshelf/cli.rb, line 20 def new(path) generator = Generator.new generator.destination_root = path generator.invoke_all end
stats()
click to toggle source
# File lib/bookshelf/cli.rb, line 66 def stats stats = Bookshelf::Stats.new(Bookshelf.root_dir) say [ "Chapters: #{stats.chapters}", "Words: #{stats.words}", "Images: #{stats.images}", "Links: #{stats.links}" ].join("\n") end
version()
click to toggle source
# File lib/bookshelf/cli.rb, line 41 def version say "Bookshelf version #{Version::STRING}" end
Private Instance Methods
color(text, color)
click to toggle source
# File lib/bookshelf/cli.rb, line 79 def color(text, color) color? ? shell.set_color(text, color) : text end
color?()
click to toggle source
# File lib/bookshelf/cli.rb, line 83 def color? shell.instance_of?(Thor::Shell::Color) end