Class: EnhanceRepo::RpmMd::Update
- Inherits:
-
Object
- Object
- EnhanceRepo::RpmMd::Update
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
#each_detected_reference, #each_reference_for, #smart_fill_blank_fields
Constructor Details
#initialize ⇒ Update
Returns a new instance of Update.
124
|
# File 'lib/enhance_repo/rpm_md/update.rb', line 124
def initialize; end
|
Instance Attribute Details
#description ⇒ Object
112
113
114
|
# File 'lib/enhance_repo/rpm_md/update.rb', line 112
def description
@description ||= ''
end
|
#from ⇒ Object
88
89
90
|
# File 'lib/enhance_repo/rpm_md/update.rb', line 88
def from
@from ||= "#{ENV['USER']}@#{ENV['HOST']}"
end
|
#issued ⇒ Object
104
105
106
|
# File 'lib/enhance_repo/rpm_md/update.rb', line 104
def issued
@issued ||= Time.now.to_i
end
|
#packages ⇒ Object
120
121
122
|
# File 'lib/enhance_repo/rpm_md/update.rb', line 120
def packages
@packages ||= []
end
|
#references ⇒ Object
108
109
110
|
# File 'lib/enhance_repo/rpm_md/update.rb', line 108
def references
@references ||= []
end
|
#release ⇒ Object
100
101
102
|
# File 'lib/enhance_repo/rpm_md/update.rb', line 100
def release
@release ||= 'unknown'
end
|
#status ⇒ Object
84
85
86
|
# File 'lib/enhance_repo/rpm_md/update.rb', line 84
def status
@status ||= 'stable'
end
|
#title ⇒ Object
116
117
118
|
# File 'lib/enhance_repo/rpm_md/update.rb', line 116
def title
@title ||= 'untitled update'
end
|
#type ⇒ Object
92
93
94
|
# File 'lib/enhance_repo/rpm_md/update.rb', line 92
def type
@type ||= 'optional'
end
|
#updateid ⇒ Object
80
81
82
|
# File 'lib/enhance_repo/rpm_md/update.rb', line 80
def updateid
@updateid ||= 'unknown'
end
|
#version ⇒ Object
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)
b.references do
references.each do |r|
b.reference('href' => r.href, 'id' => r.referenceid, 'title' => r.title, 'type' => r.type)
end
end
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 end end
end
|
#empty? ⇒ Boolean
an update is not empty if it updates something
128
129
130
|
# File 'lib/enhance_repo/rpm_md/update.rb', line 128
def empty?
packages.empty?
end
|
#suggested_filename ⇒ Object
132
133
134
|
# File 'lib/enhance_repo/rpm_md/update.rb', line 132
def suggested_filename
"update-#{updateid}-#{version}"
end
|
#write(file) ⇒ Object
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
|