Class: Bubbles::Config
- Inherits:
-
Object
- Object
- Bubbles::Config
- Defined in:
- lib/bubbles/config.rb
Instance Attribute Summary collapse
- #config_path ⇒ Object
- #local_dir_metadata_file_path ⇒ Object
- #local_dir_uploader_path ⇒ Object
- #log_level ⇒ Object
- #log_path ⇒ Object
- #logger ⇒ Object
-
#num_of_files_to_schedule ⇒ Object
how many files should DirWatcher schedule for upload, defaults to 1.
- #processing_dir ⇒ Object
-
#s3_access_key_id ⇒ Object
writeonly
Sets the attribute s3_access_key_id.
- #s3_bucket ⇒ Object
- #s3_path ⇒ Object
- #s3_region ⇒ Object
-
#s3_secret_access_key ⇒ Object
writeonly
Sets the attribute s3_secret_access_key.
-
#sleep_interval ⇒ Object
number of seconds between every command execution in queue seconds, defaults to 1.
- #source_dir ⇒ Object
- #uniq_filename_randomizer ⇒ Object
- #uploader_classes ⇒ Object
-
#use_default_config_locations ⇒ Object
writeonly
Sets the attribute use_default_config_locations.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#config_path ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# 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 ⇒ Object
47 48 49 50 |
# File 'lib/bubbles/config.rb', line 47 def 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 ⇒ Object
52 53 54 55 56 57 58 |
# 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 ⇒ Object
20 21 22 |
# File 'lib/bubbles/config.rb', line 20 def log_level @log_level || config_yml['log_level'] || 0 end |
#log_path ⇒ Object
16 17 18 |
# File 'lib/bubbles/config.rb', line 16 def log_path @log_path || config_yml['log_path'] || STDOUT end |
#logger ⇒ Object
24 25 26 |
# 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 ⇒ Object
how many files should DirWatcher schedule for upload, defaults to 1
68 69 70 |
# File 'lib/bubbles/config.rb', line 68 def num_of_files_to_schedule @num_of_files_to_schedule || 1 end |
#processing_dir ⇒ Object
33 34 35 36 |
# 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_access_key_id=(value) ⇒ Object
Sets the attribute s3_access_key_id
11 12 13 |
# File 'lib/bubbles/config.rb', line 11 def s3_access_key_id=(value) @s3_access_key_id = value end |
#s3_bucket ⇒ Object
109 110 111 112 113 |
# 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_path ⇒ Object
97 98 99 100 101 |
# File 'lib/bubbles/config.rb', line 97 def s3_path @s3_path \ || config_yml['s3_path'] \ || '' end |
#s3_region ⇒ Object
91 92 93 94 95 |
# 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 |
#s3_secret_access_key=(value) ⇒ Object
Sets the attribute s3_secret_access_key
11 12 13 |
# File 'lib/bubbles/config.rb', line 11 def s3_secret_access_key=(value) @s3_secret_access_key = value end |
#sleep_interval ⇒ Object
number of seconds between every command execution in queue seconds, defaults to 1
61 62 63 64 65 |
# File 'lib/bubbles/config.rb', line 61 def sleep_interval @sleep_interval \ || config_yml['sleep_interval'] \ || 1 end |
#source_dir ⇒ Object
28 29 30 31 |
# 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 ⇒ Object
83 84 85 |
# File 'lib/bubbles/config.rb', line 83 def uniq_filename_randomizer @uniq_filename_randomizer ||= ->() { SecureRandom.uuid } end |
#uploader_classes ⇒ Object
38 39 40 41 42 43 44 45 |
# 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 |
#use_default_config_locations=(value) ⇒ Object
Sets the attribute use_default_config_locations
11 12 13 |
# File 'lib/bubbles/config.rb', line 11 def use_default_config_locations=(value) @use_default_config_locations = value end |
Class Method Details
.home_config ⇒ Object
3 4 5 |
# File 'lib/bubbles/config.rb', line 3 def self.home_config Pathname.new(Dir.home).join('.bubbles/config.yml').to_s end |
.var_config ⇒ Object
7 8 9 |
# File 'lib/bubbles/config.rb', line 7 def self.var_config '/var/lib/bubbles/config.yml' end |
Instance Method Details
#s3_acl ⇒ Object
103 104 105 106 107 |
# File 'lib/bubbles/config.rb', line 103 def s3_acl @s3_acl \ || config_yml['s3_acl'] \ || 'private' end |
#s3_credentials ⇒ Object
87 88 89 |
# File 'lib/bubbles/config.rb', line 87 def s3_credentials @aws_credentials ||= Aws::Credentials.new(s3_access_key_id, s3_secret_access_key) end |