Class: Repub::App

Inherits:
Object show all
Includes:
Builder, Fetcher, Logger, Options, Parser, Profile, Singleton
Defined in:
lib/repub/app.rb,
lib/repub/app/filter.rb,
lib/repub/app/logger.rb,
lib/repub/app/parser.rb,
lib/repub/app/builder.rb,
lib/repub/app/fetcher.rb,
lib/repub/app/options.rb,
lib/repub/app/profile.rb,
lib/repub/app/pre_filters.rb,
lib/repub/app/post_filters.rb

Defined Under Namespace

Modules: Builder, Fetcher, Filter, Logger, Options, Parser, Profile Classes: PostFilters, PreFilters

Constant Summary

Constants included from Logger

Logger::LOGGER_NORMAL, Logger::LOGGER_QUIET, Logger::LOGGER_VERBOSE

Constants included from Profile

Profile::PROFILE_KEYS

Constants included from Fetcher

Fetcher::AssetTypes

Constants included from Parser

Parser::Selectors

Instance Attribute Summary

Attributes included from Options

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Options

#help, #parse_options

Methods included from Logger

#log

Methods included from Profile

#dump_profile, #list_profiles, #load_profile, #write_profile

Methods included from Fetcher

#fetch

Methods included from Parser

#parse

Methods included from Builder

#build

Class Method Details

.data_pathObject



26
27
28
29
30
# File 'lib/repub/app.rb', line 26

def self.data_path
  data_path = File.join(File.expand_path('~'), '.repub')
  FileUtils.mkdir_p(data_path) unless File.exist?(data_path)
  data_path
end

.nameObject



22
23
24
# File 'lib/repub/app.rb', line 22

def self.name
  File.basename($0)
end

Instance Method Details

#run(args) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/repub/app.rb', line 32

def run(args)
  parse_options(args)
  
  log.level = options[:verbosity]
  log.info "Making ePub from #{options[:url]}"
  builder = build(parse(fetch))
  log.info "Saved #{builder.output_path}"
  
  Launchy::Browser.run(builder.document_path) if options[:browser]

rescue RuntimeError => ex
  log.fatal "** ERROR: #{ex.to_s}"
rescue Exception => ex
  log.fatal "** ERROR: #{ex.to_s}" unless ex.is_a? SystemExit
end