Class: GerritEventRouter::Config

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

Defined Under Namespace

Classes: Array, Base

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



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

def initialize
  @gerrits = Array.new
  @brokers = Array.new
end

Instance Attribute Details

#brokersObject

Returns the value of attribute brokers.



57
58
59
# File 'lib/ger/config.rb', line 57

def brokers
  @brokers
end

#gerritsObject

Returns the value of attribute gerrits.



57
58
59
# File 'lib/ger/config.rb', line 57

def gerrits
  @gerrits
end

Instance Method Details

#load(path) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ger/config.rb', line 33

def load(path)
  open(path) do |stream|
    YAML.load_stream(stream, path) do |obj|
      if obj.instance_of?(GER::Gerrit::Config)
        @gerrits << obj
      elsif obj.kind_of?(GER::Broker::Config::Base)
        @brokers << obj
      end
    end
  end
  self
end

#names(to_yaml = true) ⇒ Object



46
47
48
49
50
51
52
53
54
55
# File 'lib/ger/config.rb', line 46

def names(to_yaml = true)
  h = Hash.new
  h[:gerrit] = @gerrits.map {|item| item.name}
  h[:broker] = @brokers.map {|item| item.name}
  if to_yaml then
    YAML.dump(h)
  else
    h
  end
end