Class: Braavos::Config
- Inherits:
-
Object
- Object
- Braavos::Config
- Defined in:
- lib/braavos/config.rb
Instance Attribute Summary collapse
-
#backup_prefix ⇒ Object
Returns the value of attribute backup_prefix.
-
#bucket_name ⇒ Object
Returns the value of attribute bucket_name.
-
#data_loc ⇒ Object
Returns the value of attribute data_loc.
-
#discovery ⇒ Object
Returns the value of attribute discovery.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parallel_jobs ⇒ Object
Returns the value of attribute parallel_jobs.
-
#service ⇒ Object
Returns the value of attribute service.
-
#settings ⇒ Object
Returns the value of attribute settings.
-
#storage_backing ⇒ Object
Returns the value of attribute storage_backing.
-
#sync_loc ⇒ Object
Returns the value of attribute sync_loc.
-
#temp_loc ⇒ Object
Returns the value of attribute temp_loc.
Instance Method Summary collapse
- #backup_path(reset = false) ⇒ Object
- #get_regex(key) ⇒ Object
-
#initialize(config) ⇒ Config
constructor
A new instance of Config.
- #service_class ⇒ Object
- #storage_class ⇒ Object
Constructor Details
#initialize(config) ⇒ Config
Returns a new instance of Config.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/braavos/config.rb', line 6 def initialize(config) @settings = config config.each do |k,v| send("#{k}=", v) if respond_to?("#{k}=") end self.backup_prefix = nil if backup_prefix && backup_prefix.strip.size == 0 self.storage_backing ||= 's3' self.temp_loc ||= '' FileUtils.mkdir_p temp_loc unless File.directory?(temp_loc) raise "Missing temp location: #{temp_loc}" unless File.directory?(temp_loc) end |
Instance Attribute Details
#backup_prefix ⇒ Object
Returns the value of attribute backup_prefix.
3 4 5 |
# File 'lib/braavos/config.rb', line 3 def backup_prefix @backup_prefix end |
#bucket_name ⇒ Object
Returns the value of attribute bucket_name.
3 4 5 |
# File 'lib/braavos/config.rb', line 3 def bucket_name @bucket_name end |
#data_loc ⇒ Object
Returns the value of attribute data_loc.
3 4 5 |
# File 'lib/braavos/config.rb', line 3 def data_loc @data_loc end |
#discovery ⇒ Object
Returns the value of attribute discovery.
3 4 5 |
# File 'lib/braavos/config.rb', line 3 def discovery @discovery end |
#environment ⇒ Object
Returns the value of attribute environment.
3 4 5 |
# File 'lib/braavos/config.rb', line 3 def environment @environment end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/braavos/config.rb', line 3 def name @name end |
#parallel_jobs ⇒ Object
Returns the value of attribute parallel_jobs.
3 4 5 |
# File 'lib/braavos/config.rb', line 3 def parallel_jobs @parallel_jobs end |
#service ⇒ Object
Returns the value of attribute service.
3 4 5 |
# File 'lib/braavos/config.rb', line 3 def service @service end |
#settings ⇒ Object
Returns the value of attribute settings.
3 4 5 |
# File 'lib/braavos/config.rb', line 3 def settings @settings end |
#storage_backing ⇒ Object
Returns the value of attribute storage_backing.
3 4 5 |
# File 'lib/braavos/config.rb', line 3 def storage_backing @storage_backing end |
#sync_loc ⇒ Object
Returns the value of attribute sync_loc.
3 4 5 |
# File 'lib/braavos/config.rb', line 3 def sync_loc @sync_loc end |
#temp_loc ⇒ Object
Returns the value of attribute temp_loc.
3 4 5 |
# File 'lib/braavos/config.rb', line 3 def temp_loc @temp_loc end |
Instance Method Details
#backup_path(reset = false) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/braavos/config.rb', line 31 def backup_path(reset=false) remove_instance_variable(:@backup_path) if reset @backup_path ||= -> do path = [backup_prefix, name, environment, service].compact File.join(*path) end.call end |
#get_regex(key) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/braavos/config.rb', line 39 def get_regex(key) if (regex = settings[key]) && regex.size > 2 if regex[0] == regex[-1] && regex[0] == '/' regex = regex[1...-1] end /#{regex}/ end end |
#service_class ⇒ Object
19 20 21 22 23 |
# File 'lib/braavos/config.rb', line 19 def service_class @service_class ||= -> do Object.const_get("Braavos::Service::#{service.capitalize}") end.call end |
#storage_class ⇒ Object
25 26 27 28 29 |
# File 'lib/braavos/config.rb', line 25 def storage_class @storage_class ||= -> do Object.const_get("Braavos::Storage::#{storage_backing.capitalize}") end.call end |