class Verku::Cli

Constants

FORMATS

Public Class Methods

exit_on_failure?() click to toggle source
# File lib/verku/cli.rb, line 8
def self.exit_on_failure?
  true
end
new(args = [], options = {}, config = {}) click to toggle source
Calls superclass method
# File lib/verku/cli.rb, line 11
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: verku help new"
  end
  super
end

Public Instance Methods

create(path) click to toggle source
# File lib/verku/cli.rb, line 20
def create(path)
  say "Verku -- A Million Monkeys Writing Your Masterpiece."
  generator = Generator.new
  generator.destination_root = path.squish.gsub(' ','-')
  generator.invoke_all
end
export() click to toggle source
# File lib/verku/cli.rb, line 31
def export
  inside_ebook!
  if options[:only] && !FORMATS.include?(options[:only])
    raise Error, "The --only option need to be one of: #{FORMATS.join(", ")}"
  end
  Verku::Exporter.run(root_dir, options)
end
move(oid,nid) click to toggle source
# File lib/verku/cli.rb, line 67
def move(oid,nid)
  s = Structure.new(root_dir)
  s.move(oid,nid)
end
pdf() click to toggle source
# File lib/verku/cli.rb, line 40
def pdf
  inside_ebook!
  Verku::Exporter.run(root_dir, {:only => 'pdf'})
end
stats() click to toggle source
# File lib/verku/cli.rb, line 52
def stats
  inside_ebook!
  stats = Verku::Stats.new(root_dir)

  say [
    # "Chapters: #{stats.chapters}",
    "Goal:     #{sprintf("%7d", stats.target)}",
    "Words:    #{sprintf("%7d", stats.words)}",
    "          -------",
    "Remain:   #{sprintf("%7d", stats.remaining)}",
    "Progress: #{sprintf("%7d", stats.today)}"
  ].join("\n")
end
trash(scene_id) click to toggle source
# File lib/verku/cli.rb, line 72
def trash(scene_id)
  s = Structure.new(root_dir)
  s.trash(scene_id)
end
version() click to toggle source
# File lib/verku/cli.rb, line 47
def version
  say "Verku version #{Verku::VERSION}"
end

Private Instance Methods

config() click to toggle source
# File lib/verku/cli.rb, line 77
def config
  YAML.load_file(config_path).with_indifferent_access
end
config_path() click to toggle source
# File lib/verku/cli.rb, line 80
def config_path
  root_dir.join("_verku.yml")
end
inside_ebook!() click to toggle source
# File lib/verku/cli.rb, line 86
def inside_ebook!
  unless File.exist?(config_path)
    raise Error, "You have to run this command from inside an e-book directory."
  end
end
root_dir() click to toggle source
# File lib/verku/cli.rb, line 83
def root_dir
  @root ||= Pathname.new(Dir.pwd)
end