Class: Konzertmeister::MetaVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/konzertmeister/meta_version.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ MetaVersion



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/konzertmeister/meta_version.rb', line 18

def initialize(data = {})
  @data = data
  data.each do |k,value|
    next if %w[
      infrastructure_version
      tapp_version
      legato_version
      forte_version
      backends
    ].include?(k)

    if m = k.match(/^meta_version_(.*)$/)
      key = m[1]
    else
      key = k
    end

    instance_variable_set("@#{key}", value)
  end
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



3
4
5
# File 'lib/konzertmeister/meta_version.rb', line 3

def created_at
  @created_at
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/konzertmeister/meta_version.rb', line 3

def id
  @id
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



3
4
5
# File 'lib/konzertmeister/meta_version.rb', line 3

def updated_at
  @updated_at
end

Class Method Details

.allObject



5
6
7
8
9
10
11
12
# File 'lib/konzertmeister/meta_version.rb', line 5

def self.all
  response = Konzertmeister.session.get('/meta_versions')
  if response
    response.map do |data|
      Konzertmeister::MetaVersion.new(data)
    end
  end
end

.find_by(attr, value) ⇒ Object



14
15
16
# File 'lib/konzertmeister/meta_version.rb', line 14

def self.find_by(attr, value)
  MetaVersion.new(Konzertmeister.session.get("/meta_versions/#{attr}/#{value}"))
end

Instance Method Details

#forte_versionObject



78
79
80
# File 'lib/konzertmeister/meta_version.rb', line 78

def forte_version
  @forte_version ||= Konzertmeister::ProductVersion.new("forte", @data.fetch("forte_version"))
end

#forte_version=(input_fv) ⇒ Object



82
83
84
# File 'lib/konzertmeister/meta_version.rb', line 82

def forte_version=(input_fv)
  @forte_version = input_fv
end

#infrastructure_versionObject



54
55
56
# File 'lib/konzertmeister/meta_version.rb', line 54

def infrastructure_version
  @infrastructure_version ||= Konzertmeister::InfrastructureVersion.new(@data.fetch("infrastructure_version"))
end

#infrastructure_version=(input_iv) ⇒ Object



58
59
60
# File 'lib/konzertmeister/meta_version.rb', line 58

def infrastructure_version=(input_iv)
  @infrastructure_version = input_iv
end

#legato_versionObject



70
71
72
# File 'lib/konzertmeister/meta_version.rb', line 70

def legato_version
  @legato_version ||= Konzertmeister::ProductVersion.new("legato", @data.fetch("legato_version"))
end

#legato_version=(input_lv) ⇒ Object



74
75
76
# File 'lib/konzertmeister/meta_version.rb', line 74

def legato_version=(input_lv)
  @legato_version = input_lv
end

#saveObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/konzertmeister/meta_version.rb', line 39

def save
  params = {
    'infrastructure_version' => {'infrastructure_version_id' => infrastructure_version.id},
    'tapp_version' => {'tapp_version_id' => tapp_version.id},
    'legato_version' => {'legato_version_id' => legato_version.id},
    'forte_version' => {'forte_version_id' => forte_version.id}
  }
  response = Konzertmeister.session.post('/meta_versions', params)
  if response
    response_object = Konzertmeister::MetaVersion.new(response)
    @id = response_object.id
    response_object
  end
end

#tapp_versionObject



62
63
64
# File 'lib/konzertmeister/meta_version.rb', line 62

def tapp_version
  @tapp_version ||= Konzertmeister::ProductVersion.new("tapp", @data.fetch("tapp_version"))
end

#tapp_version=(input_tv) ⇒ Object



66
67
68
# File 'lib/konzertmeister/meta_version.rb', line 66

def tapp_version=(input_tv)
  @tapp_version = input_tv
end

#to_s(format = :short) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/konzertmeister/meta_version.rb', line 86

def to_s(format = :short)
  fields = [
    id,
    infrastructure_version,
    tapp_version,
    legato_version,
    forte_version
  ]
  table_widths = "%-3s %-25s %-20s %-25s %-25s"

  if @data.has_key?("backends")
    fields << "Backends: #{@data.fetch("backends").size}"
    table_widths += " %-11s"
  end

  case format
  when :short
    fields.join(" ")
  when :table
    table_widths % fields
  end
end