Class: Gb::GbConfig

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

Defined Under Namespace

Classes: GitlabConfig, ProjectConfig

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_path, node) ⇒ GbConfig

Returns a new instance of GbConfig.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/config/gb_config.rb', line 8

def initialize(config_path, node)
  @config_path = config_path

  gitlab = node['gitlab']
  @gitlab = GitlabConfig.new(gitlab)

  @projects = []
  projects = node['projects']
  if !projects.nil?
    projects.each do |project|
      projectConfig = ProjectConfig.new(project)
      @projects << projectConfig
    end
  end
end

Instance Attribute Details

#config_pathObject (readonly)

Returns the value of attribute config_path.



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

def config_path
  @config_path
end

#gitlabObject (readonly)

Returns the value of attribute gitlab.



5
6
7
# File 'lib/config/gb_config.rb', line 5

def gitlab
  @gitlab
end

#projectsObject (readonly)

Returns the value of attribute projects.



4
5
6
# File 'lib/config/gb_config.rb', line 4

def projects
  @projects
end

Class Method Details

.load_file(config_path) ⇒ Object



24
25
26
27
# File 'lib/config/gb_config.rb', line 24

def self.load_file(config_path)
  node = YAML.load_file(config_path)
  GbConfig.new(config_path, node)
end

.load_yml(yml) ⇒ Object



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

def self.load_yml(yml)
  node = YAML.load(yml)
  GbConfig.new(nil, node)
end

Instance Method Details

#to_dictionaryObject



34
35
36
37
38
39
# File 'lib/config/gb_config.rb', line 34

def to_dictionary
  projects = self.projects.map do |project|
    project.to_dictionary
  end
  {"projects"=>projects, "gitlab"=>self.gitlab.to_dictionary}
end