class RubyTapasDownloader::Config
Retrieve configurations.
Constants
- CONFIG_KEYS
Public Class Methods
default_download_path()
click to toggle source
Default Download path
# File lib/ruby_tapas_downloader/config.rb, line 29 def default_download_path user_configurations[DOWNLOAD_PATH] end
default_email()
click to toggle source
Default Email
# File lib/ruby_tapas_downloader/config.rb, line 19 def default_email user_configurations[EMAIL] end
default_password()
click to toggle source
Default Password
# File lib/ruby_tapas_downloader/config.rb, line 24 def default_password user_configurations[PASSWORD] end
update(email: nil, password: nil, download_path: nil)
click to toggle source
Updates user preferences
# File lib/ruby_tapas_downloader/config.rb, line 34 def update(email: nil, password: nil, download_path: nil) download_path = absolute_path(download_path) new_configs = { EMAIL => email, PASSWORD => password, DOWNLOAD_PATH => download_path } user_configurations[EMAIL] = email user_configurations[PASSWORD] = password user_configurations[DOWNLOAD_PATH] = download_path user_configurations.store new_configs end
urls()
click to toggle source
Retrieve urls stored in ‘urls.yml`. @return [Hash] the urls stored in `urls.yml`.
# File lib/ruby_tapas_downloader/config.rb, line 14 def urls @urls ||= YAML.load_file urls_config_path end
Private Class Methods
absolute_path(path)
click to toggle source
# File lib/ruby_tapas_downloader/config.rb, line 56 def absolute_path(path) return path if (Pathname.new path).absolute? File.expand_path(Dir.pwd, path) end
urls_config_path()
click to toggle source
# File lib/ruby_tapas_downloader/config.rb, line 62 def urls_config_path Pathname File.expand_path('../../../config/urls.yml', __FILE__) end
user_configurations()
click to toggle source
# File lib/ruby_tapas_downloader/config.rb, line 50 def user_configurations @configs ||= UserConfigurations::Configuration.new( 'ruby-tapas-downloader' ) end