class Bubbles::Config
Attributes
config_path[W]
local_dir_metadata_file_path[W]
local_dir_uploader_path[W]
log_level[W]
log_path[W]
logger[W]
num_of_files_to_schedule[W]
processing_dir[W]
s3_access_key_id[W]
s3_bucket[W]
s3_path[W]
s3_region[W]
s3_secret_access_key[W]
sleep_interval[W]
source_dir[W]
uniq_filename_randomizer[W]
uploader_classes[W]
use_default_config_locations[W]
Public Class Methods
home_config()
click to toggle source
# File lib/bubbles/config.rb, line 3 def self.home_config Pathname.new(Dir.home).join('.bubbles/config.yml').to_s end
var_config()
click to toggle source
# File lib/bubbles/config.rb, line 7 def self.var_config '/var/lib/bubbles/config.yml' end
Public Instance Methods
config_path()
click to toggle source
# File lib/bubbles/config.rb, line 72 def config_path if @config_path raise "Config file #{@config_path} does not exist" unless File.exist?(@config_path) @config_path elsif File.exist?(self.class.var_config) && use_default_config_locations self.class.var_config elsif File.exist?(self.class.home_config) && use_default_config_locations self.class.home_config end end
local_dir_metadata_file_path()
click to toggle source
# File lib/bubbles/config.rb, line 47 def local_dir_metadata_file_path err_msg = 'You need to set `local_dir_metadata_file_path`' @local_dir_metadata_file_path ||= config_yml.fetch('local_dir_metadata_file_path') { raise err_msg } end
local_dir_uploader_path()
click to toggle source
# File lib/bubbles/config.rb, line 52 def local_dir_uploader_path err_msg = 'As you are using LocalDir uploader,' + ' you need to specify `local_dir_uploader_path` in your config' + ' so the uploader knows where to upload' @local_dir_uploader_path ||= config_yml.fetch('local_dir_uploader_path') { raise err_msg } pathnamed(@local_dir_uploader_path) end
log_level()
click to toggle source
# File lib/bubbles/config.rb, line 20 def log_level @log_level || config_yml['log_level'] || 0 end
log_path()
click to toggle source
# File lib/bubbles/config.rb, line 16 def log_path @log_path || config_yml['log_path'] || STDOUT end
logger()
click to toggle source
# File lib/bubbles/config.rb, line 24 def logger @logger ||= Logger.new(log_path).tap { |l| l.level = log_level } end
num_of_files_to_schedule()
click to toggle source
how many files should DirWatcher
schedule for upload, defaults to 1
# File lib/bubbles/config.rb, line 68 def num_of_files_to_schedule @num_of_files_to_schedule || 1 end
processing_dir()
click to toggle source
# File lib/bubbles/config.rb, line 33 def processing_dir @processing_dir ||= config_yml.fetch('processing_dir') { raise_config_required } pathnamed(@processing_dir) end
s3_acl()
click to toggle source
# File lib/bubbles/config.rb, line 103 def s3_acl @s3_acl \ || config_yml['s3_acl'] \ || 'private' end
s3_bucket()
click to toggle source
# File lib/bubbles/config.rb, line 109 def s3_bucket @s3_bucket \ || config_yml['s3_bucket'] \ || raise('Please provide s3_bucket in your config file') end
s3_credentials()
click to toggle source
# File lib/bubbles/config.rb, line 87 def s3_credentials @aws_credentials ||= Aws::Credentials.new(s3_access_key_id, s3_secret_access_key) end
s3_path()
click to toggle source
# File lib/bubbles/config.rb, line 97 def s3_path @s3_path \ || config_yml['s3_path'] \ || '' end
s3_region()
click to toggle source
# File lib/bubbles/config.rb, line 91 def s3_region @s3_region \ || config_yml['s3_region'] \ || raise('Please provide s3_region in your config file') end
sleep_interval()
click to toggle source
number of seconds between every command execution in queue seconds, defaults to 1
# File lib/bubbles/config.rb, line 61 def sleep_interval @sleep_interval \ || config_yml['sleep_interval'] \ || 1 end
source_dir()
click to toggle source
# File lib/bubbles/config.rb, line 28 def source_dir @source_dir ||= config_yml.fetch('source_dir') { raise_config_required } pathnamed(@source_dir) end
uniq_filename_randomizer()
click to toggle source
# File lib/bubbles/config.rb, line 83 def uniq_filename_randomizer @uniq_filename_randomizer ||= ->() { SecureRandom.uuid } end
uploader_classes()
click to toggle source
# File lib/bubbles/config.rb, line 38 def uploader_classes return @uploader_classes if @uploader_classes if uploaders = config_yml['uploaders'] uploaders.map { |u| Object.const_get(u) } else [Bubbles::Uploaders::S3] end end
Private Instance Methods
config_yml()
click to toggle source
# File lib/bubbles/config.rb, line 133 def config_yml if config_path @config_yml ||= YAML.load_file(config_path) else {} end end
pathnamed(location_obj)
click to toggle source
# File lib/bubbles/config.rb, line 145 def pathnamed(location_obj) location_obj.respond_to?(:basename) ? location_obj : Pathname.new(location_obj) end
raise_config_required()
click to toggle source
# File lib/bubbles/config.rb, line 141 def raise_config_required raise "Please provide configuration file. You can do this by creating #{self.class.home_config} or check project github README.md" end
s3_access_key_id()
click to toggle source
# File lib/bubbles/config.rb, line 121 def s3_access_key_id @s3_access_key_id \ || config_yml['s3_access_key_id'] \ || raise('Please provide s3_access_key_id in your config file') end
s3_secret_access_key()
click to toggle source
# File lib/bubbles/config.rb, line 127 def s3_secret_access_key @s3_secret_access_key \ || config_yml['s3_secret_access_key'] \ || raise('Please provide s3_secret_access_key in your config file') end
use_default_config_locations()
click to toggle source
# File lib/bubbles/config.rb, line 116 def use_default_config_locations return @use_default_config_locations unless @use_default_config_locations.nil? true end