Class: EnhanceRepo::RpmMd::Update

Inherits:
Object
  • Object
show all
Includes:
UpdateSmartFields
Defined in:
lib/enhance_repo/rpm_md/update.rb

Overview

represents one update, which can consist of various packages and references

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from UpdateSmartFields

#each_detected_reference, #each_reference_for, #smart_fill_blank_fields

Constructor Details

#initializeUpdate

Returns a new instance of Update.



124
# File 'lib/enhance_repo/rpm_md/update.rb', line 124

def initialize; end

Instance Attribute Details

#descriptionObject



112
113
114
# File 'lib/enhance_repo/rpm_md/update.rb', line 112

def description
  @description ||= ''
end

#fromObject



88
89
90
# File 'lib/enhance_repo/rpm_md/update.rb', line 88

def from
  @from ||= "#{ENV['USER']}@#{ENV['HOST']}"
end

#issuedObject



104
105
106
# File 'lib/enhance_repo/rpm_md/update.rb', line 104

def issued
  @issued ||= Time.now.to_i
end

#packagesObject



120
121
122
# File 'lib/enhance_repo/rpm_md/update.rb', line 120

def packages
  @packages ||= []
end

#referencesObject



108
109
110
# File 'lib/enhance_repo/rpm_md/update.rb', line 108

def references
  @references ||= []
end

#releaseObject



100
101
102
# File 'lib/enhance_repo/rpm_md/update.rb', line 100

def release
  @release ||= 'unknown'
end

#statusObject



84
85
86
# File 'lib/enhance_repo/rpm_md/update.rb', line 84

def status
  @status ||= 'stable'
end

#titleObject



116
117
118
# File 'lib/enhance_repo/rpm_md/update.rb', line 116

def title
  @title ||= 'untitled update'
end

#typeObject



92
93
94
# File 'lib/enhance_repo/rpm_md/update.rb', line 92

def type
  @type ||= 'optional'
end

#updateidObject



80
81
82
# File 'lib/enhance_repo/rpm_md/update.rb', line 80

def updateid
  @updateid ||= 'unknown'
end

#versionObject



96
97
98
# File 'lib/enhance_repo/rpm_md/update.rb', line 96

def version
  @version ||= 1
end

Instance Method Details

#append_to_builder(builder) ⇒ Object



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/enhance_repo/rpm_md/update.rb', line 142

def append_to_builder(builder)
  builder.update('status' => 'stable', 'from' => from, 'version' => version, 'type' => type) do |b|
    b.title(title)
    b.id(updateid)
    b.issued(issued)
    b.release(release)
    b.description(description)
    # serialize attr_reader :eferences
    b.references do
      references.each do |r|
        b.reference('href' => r.href, 'id' => r.referenceid, 'title' => r.title, 'type' => r.type)
      end
    end
    # done with references
    b.pkglist do
      b.collection do
        packages.each do |pkg|
          b.package('name' => pkg.name, 'arch' => pkg.arch, 'version' => pkg.version.v, 'release' => pkg.version.r) do
            b.filename(File.basename(pkg.path))
          end
        end
      end # </collection>
    end # </pkglist>
    # done with the packagelist
  end
end

#empty?Boolean

an update is not empty if it updates something

Returns:

  • (Boolean)


128
129
130
# File 'lib/enhance_repo/rpm_md/update.rb', line 128

def empty?
  packages.empty?
end

#suggested_filenameObject



132
133
134
# File 'lib/enhance_repo/rpm_md/update.rb', line 132

def suggested_filename
  "update-#{updateid}-#{version}"
end

#write(file) ⇒ Object

write a update out



137
138
139
140
# File 'lib/enhance_repo/rpm_md/update.rb', line 137

def write(file)
  builder = Builder::XmlMarkup.new(target: file, indent: 2)
  append_to_builder(builder)
end