Class: DevMetrics::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



15
16
17
18
19
20
# File 'lib/dev_metrics.rb', line 15

def initialize
  @access_token = nil
  @repo_name = nil
  @excluded_accounts = []
  @rollback_branch_prefixes = []
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



13
14
15
# File 'lib/dev_metrics.rb', line 13

def access_token
  @access_token
end

#excluded_accountsObject

Returns the value of attribute excluded_accounts.



13
14
15
# File 'lib/dev_metrics.rb', line 13

def excluded_accounts
  @excluded_accounts
end

#repo_nameObject

Returns the value of attribute repo_name.



13
14
15
# File 'lib/dev_metrics.rb', line 13

def repo_name
  @repo_name
end

#rollback_branch_prefixesObject

Returns the value of attribute rollback_branch_prefixes.



13
14
15
# File 'lib/dev_metrics.rb', line 13

def rollback_branch_prefixes
  @rollback_branch_prefixes
end

Instance Method Details

#load_from_yaml(path = "dev_metrics_config.yml") ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dev_metrics.rb', line 22

def load_from_yaml(path = "dev_metrics_config.yml")
  unless File.exist?(path)
    warn "Config file '#{path}' not found. Please create it before running this tool."
    exit 1
  end

  config = YAML.load_file(path)
  if config["access_token"].nil? || config["repo_name"].nil?
    warn "Config file must include 'access_token' and 'repo_name'."
    exit 1
  end

  @access_token = config["access_token"]
  @repo_name = config["repo_name"]
  @excluded_accounts = config["excluded_accounts"] || []
  @rollback_branch_prefixes = config["rollback_branch_prefixes"] || []
end