class Astromapper::Exporter
Attributes
options[RW]
root_dir[RW]
Public Class Methods
new(root_dir, options)
click to toggle source
# File lib/astromapper/exporter.rb, line 11 def initialize(root_dir, options) @root_dir = root_dir @options = options end
run(root_dir, options)
click to toggle source
# File lib/astromapper/exporter.rb, line 3 def self.run(root_dir, options) exporter = new(root_dir, options) exporter.export! end
Public Instance Methods
config()
click to toggle source
# File lib/astromapper/exporter.rb, line 60 def config Astromapper.config(root_dir) end
export!()
click to toggle source
# File lib/astromapper/exporter.rb, line 20 def export! helper = root_dir.join("config/helper.rb") load(helper) if helper.exist? exported = [] sector = Builder::Sector.constitute(root_dir) sector.to_file # export_pdf = [nil, "pdf"].include?(options[:only]) # export_html = [nil, "html", "mobi", "epub"].include?(options[:only]) # export_epub = [nil, "mobi", "epub"].include?(options[:only]) # export_mobi = [nil, "mobi"].include?(options[:only]) # export_txt = [nil, "txt"].include?(options[:only]) # exported = [] # exported << Parser::PDF.parse(root_dir) if export_pdf && Dependency.xelatex?# && Dependency.prince? # exported << Parser::HTML.parse(root_dir) if export_html # epub_done = Parser::Epub.parse(root_dir) if export_epub # exported << epub_done # exported << Parser::Mobi.parse(root_dir) if export_mobi && epub_done && Dependency.kindlegen? # exported << Parser::Txt.parse(root_dir) if export_txt && Dependency.html2text? if exported.all? color = :green message = options[:auto] ? "exported!" : "** Map has been exported" # Notifier.notify( # # :image => Astromapper::ROOT.join("templates/ebook.png"), # :title => "Astromapper", # :message => "Your \"#{config[:title]}\" map has been exported!" # ) else color = :red message = options[:auto] ? "could not be exported!" : "** e-book couldn't be exported" end ui.say message, color end
ui()
click to toggle source
# File lib/astromapper/exporter.rb, line 16 def ui @ui ||= Thor::Base.shell.new end