class Epuber::Command

Public Class Methods

new(argv) click to toggle source
Calls superclass method
# File lib/epuber/command.rb, line 35
def initialize(argv)
  super

  UI.logger.verbose = verbose?
end
run(argv = []) click to toggle source
Calls superclass method
# File lib/epuber/command.rb, line 27
def self.run(argv = [])
  super
rescue Interrupt
  UI.error('[!] Cancelled')
rescue StandardError => e
  UI.error!(e)
end

Public Instance Methods

run() click to toggle source
# File lib/epuber/command.rb, line 41
def run; end

Protected Instance Methods

book() click to toggle source

@return [Epuber::Book::Book]

# File lib/epuber/command.rb, line 47
def book
  Config.instance.bookspec
end
pre_build_checks() click to toggle source
# File lib/epuber/command.rb, line 74
def pre_build_checks
  Config.instance.warn_for_outdated_versions!

  # remove build caches if we are using different version of Epuber or Bade
  if !Config.instance.same_version_as_last_run? && File.exist?(Config.instance.working_path)
    UI.warning('Using different version of Epuber or Bade, removing all build caches')
    Config.instance.remove_build_caches
  end

  # ensure we are in the project directory
  if Dir.pwd != Config.instance.project_path
    UI.debug("Changing directory to project directory: #{Config.instance.project_path}")
    Dir.chdir(Config.instance.project_path)
  end
end
verify_one_bookspec_exists!() click to toggle source

@return [void]

@raise PlainInformative if no .bookspec file don’t exists or there are too many

# File lib/epuber/command.rb, line 55
def verify_one_bookspec_exists!
  project_path = Config.instance.project_path
  bookspec_files = Config.find_bookspec_files(project_path)

  if bookspec_files.empty?
    raise PlainInformative, "No `.bookspec' found in the project directory (or in any parent folders)."
  end

  if bookspec_files.count > 1
    raise PlainInformative, "Multiple `.bookspec' found in directory (directory: #{project_path})"
  end
end
write_lockfile() click to toggle source
# File lib/epuber/command.rb, line 68
def write_lockfile
  return if Epuber::Config.test?

  Epuber::Config.instance.save_lockfile
end