Class: Status::Config

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

Constant Summary collapse

FILE =
".status.yml"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



9
10
11
12
# File 'lib/status/config.rb', line 9

def initialize
  bootstrap
  validate
end

Instance Attribute Details

#parsedObject (readonly)

Returns the value of attribute parsed.



8
9
10
# File 'lib/status/config.rb', line 8

def parsed
  @parsed
end

Instance Method Details

#bootstrapObject



23
24
25
26
27
28
29
30
31
# File 'lib/status/config.rb', line 23

def bootstrap
  @parsed = begin
    YAML.load(File.open(FILE))
  rescue Exception => e
    create_file
    puts "Could not parse YAML file #{FILE}: #{e.message}"
    abort("exit")
  end
end

#validateObject



14
15
16
17
18
19
20
21
# File 'lib/status/config.rb', line 14

def validate
  validate_presence_of :owner
  validate_presence_of :repo
  validate_presence_of :token
  validate_presence_of :ci_url, "ci"
  validate_presence_of :username, "ci"
  validate_presence_of :password, "ci"
end