Class: Chef::Provider::Package::Yum::RPMPackage
- Inherits:
-
Object
- Object
- Chef::Provider::Package::Yum::RPMPackage
- Includes:
- Comparable
- Defined in:
- lib/chef/provider/package/yum/rpm_utils.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#a ⇒ Object
(also: #arch)
readonly
Returns the value of attribute a.
-
#n ⇒ Object
(also: #name)
readonly
Returns the value of attribute n.
-
#provides ⇒ Object
readonly
Returns the value of attribute provides.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #<=>(y) ⇒ Object
- #compare(y) ⇒ Object
-
#initialize(*args) ⇒ RPMPackage
constructor
A new instance of RPMPackage.
- #nevra ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(*args) ⇒ RPMPackage
Returns a new instance of RPMPackage.
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
# File 'lib/chef/provider/package/yum/rpm_utils.rb', line 327 def initialize(*args) if args.size == 4 @n = args[0] @version = RPMVersion.new(args[1]) @a = args[2] @provides = args[3] elsif args.size == 6 @n = args[0] e = args[1].to_i v = args[2] r = args[3] @version = RPMVersion.new(e, v, r) @a = args[4] @provides = args[5] else raise ArgumentError, "Expecting either 'name, epoch-version-release, arch, provides' " + "or 'name, epoch, version, release, arch, provides'" end # We always have one, ourselves! if @provides.empty? @provides = [ RPMProvide.new(@n, @version.evr, :==) ] end end |
Instance Attribute Details
#a ⇒ Object (readonly) Also known as: arch
Returns the value of attribute a.
351 352 353 |
# File 'lib/chef/provider/package/yum/rpm_utils.rb', line 351 def a @a end |
#n ⇒ Object (readonly) Also known as: name
Returns the value of attribute n.
351 352 353 |
# File 'lib/chef/provider/package/yum/rpm_utils.rb', line 351 def n @n end |
#provides ⇒ Object (readonly)
Returns the value of attribute provides.
351 352 353 |
# File 'lib/chef/provider/package/yum/rpm_utils.rb', line 351 def provides @provides end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
351 352 353 |
# File 'lib/chef/provider/package/yum/rpm_utils.rb', line 351 def version @version end |
Instance Method Details
#<=>(y) ⇒ Object
355 356 357 |
# File 'lib/chef/provider/package/yum/rpm_utils.rb', line 355 def <=>(y) compare(y) end |
#compare(y) ⇒ Object
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/chef/provider/package/yum/rpm_utils.rb', line 359 def compare(y) x = self # easy! :) return 0 if x.nevra == y.nevra # compare name if x.n.nil? == false && y.n.nil? return 1 elsif x.n.nil? && y.n.nil? == false return -1 elsif x.n.nil? == false && y.n.nil? == false if x.n < y.n return -1 elsif x.n > y.n return 1 end end # compare version if x.version > y.version return 1 elsif x.version < y.version return -1 end # compare arch if x.a.nil? == false && y.a.nil? return 1 elsif x.a.nil? && y.a.nil? == false return -1 elsif x.a.nil? == false && y.a.nil? == false if x.a < y.a return -1 elsif x.a > y.a return 1 end end return 0 end |
#nevra ⇒ Object
405 406 407 |
# File 'lib/chef/provider/package/yum/rpm_utils.rb', line 405 def nevra "#{@n}-#{@version.evr}.#{@a}" end |
#to_s ⇒ Object
401 402 403 |
# File 'lib/chef/provider/package/yum/rpm_utils.rb', line 401 def to_s nevra end |