Class: Codeland::Starter::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/codeland/starter/configuration.rb

Constant Summary collapse

DEFAULT_FILENAME =
'codeland-starter.yml'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(yaml_file = nil) ⇒ Configuration

Returns a new instance of Configuration.



11
12
13
14
15
16
17
18
19
20
# File 'lib/codeland/starter/configuration.rb', line 11

def initialize(yaml_file = nil)
  @yaml = if yaml_file && File.exists?(yaml_file)
            YAML.load_file(File.open(yaml_file))
          elsif File.exists?(default_yaml_file)
            YAML.load_file(File.open(default_yaml_file))
          else
            message = 'Please install with `codeland-starter install`'
            raise MissingYAML, message
          end
end

Instance Attribute Details

#yamlObject (readonly)

Returns the value of attribute yaml.



7
8
9
# File 'lib/codeland/starter/configuration.rb', line 7

def yaml
  @yaml
end

Class Method Details

.[](key) ⇒ Object



30
31
32
# File 'lib/codeland/starter/configuration.rb', line 30

def self.[](key)
  Starter.config.yaml[key] if Starter.config
end

Instance Method Details

#default_yaml_fileObject



22
23
24
# File 'lib/codeland/starter/configuration.rb', line 22

def default_yaml_file
  File.join(Dir.home, DEFAULT_FILENAME)
end

#integrationsObject



26
27
28
# File 'lib/codeland/starter/configuration.rb', line 26

def integrations
  yaml['integrations']
end