Class: Simp::Metadata::Buildinfo

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/simp/metadata/buildinfo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(component, type) ⇒ Buildinfo

Returns a new instance of Buildinfo.



8
9
10
11
# File 'lib/simp/metadata/buildinfo.rb', line 8

def initialize(component, type)
  @type = type
  @component = component
end

Instance Attribute Details

#componentObject

Returns the value of attribute component.



6
7
8
# File 'lib/simp/metadata/buildinfo.rb', line 6

def component
  @component
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/simp/metadata/buildinfo.rb', line 5

def type
  @type
end

Instance Method Details

#[](index) ⇒ Object



17
18
19
# File 'lib/simp/metadata/buildinfo.rb', line 17

def [](index)
  send index.to_sym
end

#build_methodObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/simp/metadata/buildinfo.rb', line 39

def build_method
  buildinfo = fetch_data
  if buildinfo.nil?
    retval = method_defaults[type]['build_method']
  else
    if buildinfo.key?(type)
      retval = if buildinfo[type].key?('build_method')
                 buildinfo[type]['build_method']
               else
                 method_defaults[type]['build_method']
               end
    else
      retval = method_defaults[type]['build_method']
    end
  end
  retval
end

#eachObject



21
22
23
24
25
# File 'lib/simp/metadata/buildinfo.rb', line 21

def each
  keys.each do |key|
    yield key, self[key]
  end
end

#fetch_dataObject



27
28
29
# File 'lib/simp/metadata/buildinfo.rb', line 27

def fetch_data
  component.fetch_data('buildinfo')
end

#keysObject



13
14
15
# File 'lib/simp/metadata/buildinfo.rb', line 13

def keys
  %w(type build_method)
end

#method_defaultsObject



31
32
33
34
35
36
37
# File 'lib/simp/metadata/buildinfo.rb', line 31

def method_defaults
  {
    'rpm' => {
      'build_method' => 'simp-core'
    }
  }
end