class RubyTapasDownloader::CLI

The Command Line Interface for Ruby Tapas Downloader.

Attributes

agent[RW]
feed[RW]

Public Class Methods

download_long_description() click to toggle source

Long description for download action

# File lib/ruby_tapas_downloader/cli.rb, line 9
  def self.download_long_description
    env_vars = RubyTapasDownloader::Config::CONFIG_KEYS.join(',')
    <<-LONG_DESC
To download you need to be authenticated, you have tree options:

- Pass the params described before

- Use `ruby-tapas-downloader configure`

- Pass/export env vars: #{ env_vars }
    LONG_DESC
  end

Public Instance Methods

configure() click to toggle source
# File lib/ruby_tapas_downloader/cli.rb, line 53
def configure
  RubyTapasDownloader::Config.update(
    email: email, password: password, download_path: download_path
  )
end
download() click to toggle source
# File lib/ruby_tapas_downloader/cli.rb, line 40
def download
  create_agent
  login
  fetch_feed
  create_catalog
  download_catalog
end

Private Instance Methods

create_agent() click to toggle source
# File lib/ruby_tapas_downloader/cli.rb, line 73
def create_agent
  @agent = Mechanize.new
end
create_catalog() click to toggle source
# File lib/ruby_tapas_downloader/cli.rb, line 85
def create_catalog
  @catalog = RubyTapasDownloader::Extractors::Catalog.new.extract feed
end
download_catalog() click to toggle source
# File lib/ruby_tapas_downloader/cli.rb, line 89
def download_catalog
  @catalog.download download_path, agent
end
download_path() click to toggle source
# File lib/ruby_tapas_downloader/cli.rb, line 69
def download_path
  options[:download_path]
end
email() click to toggle source
# File lib/ruby_tapas_downloader/cli.rb, line 61
def email
  options[:email]
end
fetch_feed() click to toggle source
# File lib/ruby_tapas_downloader/cli.rb, line 81
def fetch_feed
  @feed = RubyTapasDownloader::FeedFetcher.new(agent, email, password).fetch
end
login() click to toggle source
# File lib/ruby_tapas_downloader/cli.rb, line 77
def login
  RubyTapasDownloader::Login.new(agent, email, password).login
end
password() click to toggle source
# File lib/ruby_tapas_downloader/cli.rb, line 65
def password
  options[:password]
end