Class: Discharger::SetupRunner::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/discharger/setup_runner/configuration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



10
11
12
13
14
15
16
17
18
# File 'lib/discharger/setup_runner/configuration.rb', line 10

def initialize
  @app_name = "Application"
  @database = DatabaseConfig.new
  @redis = nil
  @services = []
  @steps = []
  @custom_steps = []
  @pre_steps = []
end

Instance Attribute Details

#app_nameObject

Returns the value of attribute app_name.



8
9
10
# File 'lib/discharger/setup_runner/configuration.rb', line 8

def app_name
  @app_name
end

#custom_stepsObject

Returns the value of attribute custom_steps.



8
9
10
# File 'lib/discharger/setup_runner/configuration.rb', line 8

def custom_steps
  @custom_steps
end

#databaseObject

Returns the value of attribute database.



8
9
10
# File 'lib/discharger/setup_runner/configuration.rb', line 8

def database
  @database
end

#pre_stepsObject

Returns the value of attribute pre_steps.



8
9
10
# File 'lib/discharger/setup_runner/configuration.rb', line 8

def pre_steps
  @pre_steps
end

#redisObject

Returns the value of attribute redis.



8
9
10
# File 'lib/discharger/setup_runner/configuration.rb', line 8

def redis
  @redis
end

#servicesObject

Returns the value of attribute services.



8
9
10
# File 'lib/discharger/setup_runner/configuration.rb', line 8

def services
  @services
end

#stepsObject

Returns the value of attribute steps.



8
9
10
# File 'lib/discharger/setup_runner/configuration.rb', line 8

def steps
  @steps
end

Class Method Details

.from_file(path) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/discharger/setup_runner/configuration.rb', line 20

def self.from_file(path)
  config = new
  yaml = YAML.load_file(path)

  # Handle empty YAML files
  return config if yaml.nil? || yaml == false

  config.app_name = yaml["app_name"] if yaml["app_name"]
  config.database.from_hash(yaml["database"]) if yaml["database"]
  config.redis = RedisConfig.new.tap { |r| r.from_hash(yaml["redis"]) } if yaml["redis"]
  config.services = yaml["services"] || []
  config.steps = yaml["steps"] || []
  config.custom_steps = yaml["custom_steps"] || []
  config.pre_steps = yaml["pre_steps"] || []

  config
end