Class: Gurney::Config

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(branches: nil, api_url: nil, api_token: nil, project_id: nil) ⇒ Config

Returns a new instance of Config.



8
9
10
11
12
13
# File 'lib/gurney/config.rb', line 8

def initialize(branches: nil, api_url: nil, api_token: nil, project_id: nil)
  @branches = branches
  @api_url = api_url
  @api_token = api_token&.to_s
  @project_id = project_id&.to_s
end

Instance Attribute Details

#api_tokenObject

Returns the value of attribute api_token.



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

def api_token
  @api_token
end

#api_urlObject

Returns the value of attribute api_url.



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

def api_url
  @api_url
end

#branchesObject

Returns the value of attribute branches.



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

def branches
  @branches
end

#project_idObject

Returns the value of attribute project_id.



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

def project_id
  @project_id
end

Class Method Details

.from_yaml(yaml) ⇒ Object



15
16
17
18
# File 'lib/gurney/config.rb', line 15

def self.from_yaml(yaml)
    config = YAML.load(yaml)&.map{|(k,v)| [k.to_sym,v]}.to_h
    new(**config)
end