Class: Giternal::YamlConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/giternal/yaml_config.rb

Instance Method Summary collapse

Constructor Details

#initialize(base_dir, yaml_string) ⇒ YamlConfig

Returns a new instance of YamlConfig.



5
6
7
8
# File 'lib/giternal/yaml_config.rb', line 5

def initialize(base_dir, yaml_string)
  @base_dir = base_dir
  @config_hash = YAML.load yaml_string
end

Instance Method Details

#each_repoObject



10
11
12
# File 'lib/giternal/yaml_config.rb', line 10

def each_repo
  repositories.each { |r| yield(r) if block_given? }
end

#find_repo(path) ⇒ Object



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

def find_repo(path)
  @config_hash.each do |name, attributes|
    if path == File.join(attributes["path"], name)
      return Repository.new(@base_dir, name, attributes["repo"], attributes["path"])
    end
  end
  return nil
end