Class: Skiptorium::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/skiptorium/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, destinations) ⇒ Config

Returns a new instance of Config.



5
6
7
8
# File 'lib/skiptorium/config.rb', line 5

def initialize(source, destinations)
  @source = source
  @destinations = destinations
end

Instance Attribute Details

#destinationsObject (readonly)

Returns the value of attribute destinations.



3
4
5
# File 'lib/skiptorium/config.rb', line 3

def destinations
  @destinations
end

#sourceObject (readonly)

Returns the value of attribute source.



3
4
5
# File 'lib/skiptorium/config.rb', line 3

def source
  @source
end

Class Method Details

.load(path) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/skiptorium/config.rb', line 10

def self.load(path)
  content = File.read(path)
  content = content.gsub(/\$\{(\w+)\}/) { ENV[$1] || raise("Environment variable #{$1} not set") }
  data = YAML.safe_load(content, permitted_classes: [Date, DateTime, Time, Symbol])

  new(data['source'], data['destinations'])
end