Class: Bookshelf::Cli
- Inherits:
-
Thor
- Object
- Thor
- Bookshelf::Cli
- Defined in:
- lib/bookshelf/cli.rb
Constant Summary collapse
- FORMATS =
%w[pdf html epub]
Class Method Summary collapse
Instance Method Summary collapse
- #check ⇒ Object
- #export ⇒ Object
-
#initialize(args = [], options = {}, config = {}) ⇒ Cli
constructor
A new instance of Cli.
- #new(path) ⇒ Object
- #stats ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(args = [], options = {}, config = {}) ⇒ Cli
Returns a new instance of Cli.
11 12 13 14 15 16 17 |
# File 'lib/bookshelf/cli.rb', line 11 def initialize(args = [], = {}, 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 |
Class Method Details
.exit_on_failure? ⇒ Boolean
7 8 9 |
# File 'lib/bookshelf/cli.rb', line 7 def self.exit_on_failure? true end |
Instance Method Details
#check ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/bookshelf/cli.rb', line 48 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 ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/bookshelf/cli.rb', line 30 def export if [:only] && !FORMATS.include?([:only]) raise Error, "The --only option need to be one of: #{FORMATS.join(", ")}" end book_dir = Pathname.new("text") Bookshelf::Exporter.run(book_dir, ) end |
#new(path) ⇒ Object
21 22 23 24 25 |
# File 'lib/bookshelf/cli.rb', line 21 def new(path) generator = Generator.new generator.destination_root = path generator.invoke_all end |