Class: TinyCI::Config

Inherits:
Object
  • Object
show all
Includes:
Symbolize
Defined in:
lib/tinyci/config.rb

Overview

Represents the Configuration for a repo, parsed from the .tinyci.yml file in the repo root. Mainly a wrapper around a the hash object parsed from the yaml in the config file. The keys of the hash are recursively symbolized.

Instance Method Summary collapse

Methods included from Symbolize

#map_value, #symbolize

Constructor Details

#initialize(working_dir: '.', config_path: nil, config: nil) ⇒ Config

Constructor

Parameters:

  • working_dir (String) (defaults to: '.')

    The working directory in which to find the config file

  • config_path (String) (defaults to: nil)

    Override the path to the config file

  • config (String) (defaults to: nil)

    Override the config content

Raises:



18
19
20
21
22
23
24
# File 'lib/tinyci/config.rb', line 18

def initialize(working_dir: '.', config_path: nil, config: nil)
  @working_dir = working_dir
  @config_pathname = config_path
  @config_content = config
  
  raise ConfigMissingError, "config file #{config_pathname} not found" unless config_file_exists?
end

Instance Method Details

#[](key) ⇒ Object

Address into the config object

Parameters:

  • key (Symbol)

    The key to address



29
30
31
# File 'lib/tinyci/config.rb', line 29

def [](key)
  config_content[key]
end

#to_hashObject

Return the raw hash representation



34
35
36
# File 'lib/tinyci/config.rb', line 34

def to_hash
  config_content
end