Class: AsciiBinderGabrielRH::DistroMap

Inherits:
Object
  • Object
show all
Defined in:
lib/ascii_binder_gabriel_rh/distro_map.rb

Instance Method Summary collapse

Constructor Details

#initialize(distro_map_filepath) ⇒ DistroMap

Returns a new instance of DistroMap.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/ascii_binder_gabriel_rh/distro_map.rb', line 7

def initialize(distro_map_filepath)
  @distro_yaml = YAML.load_file(distro_map_filepath)
  @distro_map  = {}
  @distro_yaml.each do |distro_key,distro_config|
    if @distro_map.has_key?(distro_key)
      Trollop::die "Error parsing '#{distro_map_filepath}': distro key '#{distro_key}' is used more than once."
    end
    distro = AsciiBinderGabrielRH::Distro.new(distro_map_filepath,distro_key,distro_config)
    @distro_map[distro_key] = distro
  end
end

Instance Method Details

#distro_branches(distro_key = '') ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ascii_binder_gabriel_rh/distro_map.rb', line 38

def distro_branches(distro_key='')
  if distro_key == ''
    branch_list = []
    distros.each do |distro|
      branch_list.concat(distro.branch_ids)
    end
    return branch_list.uniq
  else
    return get_distro(distro_key).branch_ids
  end
end

#distro_keysObject



30
31
32
# File 'lib/ascii_binder_gabriel_rh/distro_map.rb', line 30

def distro_keys
  @distro_map.keys
end

#distrosObject



34
35
36
# File 'lib/ascii_binder_gabriel_rh/distro_map.rb', line 34

def distros
  @distro_map.values
end

#errorsObject



58
59
60
61
62
63
64
65
# File 'lib/ascii_binder_gabriel_rh/distro_map.rb', line 58

def errors
  errors = []
  @distro_map.values.each do |distro|
    next if distro.is_valid?
    errors << distro.errors
  end
  return errors
end

#get_distro(distro_key) ⇒ Object



19
20
21
22
23
24
# File 'lib/ascii_binder_gabriel_rh/distro_map.rb', line 19

def get_distro(distro_key)
  unless @distro_map.has_key?(distro_key)
    Trollop::die "Distro key '#{distro_key}' does not exist"
  end
  @distro_map[distro_key]
end

#include_distro_key?(distro_key) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/ascii_binder_gabriel_rh/distro_map.rb', line 26

def include_distro_key?(distro_key)
  @distro_map.has_key?(distro_key)
end

#is_valid?Boolean

Returns:

  • (Boolean)


50
51
52
53
54
55
56
# File 'lib/ascii_binder_gabriel_rh/distro_map.rb', line 50

def is_valid?
  @distro_map.values.each do |distro|
    next if distro.is_valid?
    return false
  end
  return true
end