Class: Gitl::GitlConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/config/gitl_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) ⇒ GitlConfig

Returns a new instance of GitlConfig.



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

def initialize(config_path, node)
  @config_path = config_path

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

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

Instance Attribute Details

#config_pathObject (readonly)

Returns the value of attribute config_path.



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

def config_path
  @config_path
end

#gitlabObject (readonly)

Returns the value of attribute gitlab.



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

def gitlab
  @gitlab
end

#projectsObject (readonly)

Returns the value of attribute projects.



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

def projects
  @projects
end

Class Method Details

.load_file(config_path) ⇒ Object



22
23
24
25
# File 'lib/config/gitl_config.rb', line 22

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

.load_yml(yml) ⇒ Object



27
28
29
30
# File 'lib/config/gitl_config.rb', line 27

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

Instance Method Details

#to_dictionaryObject



32
33
34
35
36
37
# File 'lib/config/gitl_config.rb', line 32

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