Class: EnhanceRepo::PackageId
- Inherits:
-
Object
- Object
- EnhanceRepo::PackageId
- Includes:
- Logger
- Defined in:
- lib/enhance_repo/package_id.rb
Overview
thin wrapper over rpm package
Direct Known Subclasses
Instance Attribute Summary collapse
-
#checksum ⇒ Object
Returns the value of attribute checksum.
-
#path ⇒ Object
Returns the value of attribute path.
-
#rpm ⇒ Object
Returns the value of attribute rpm.
Instance Method Summary collapse
- #arch ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
- #ident ⇒ Object
-
#initialize(rpmfile) ⇒ PackageId
constructor
A new instance of PackageId.
-
#matches(ident) ⇒ Object
match function at name and nvr level.
-
#method_missing(sym, *args) ⇒ Object
Forward other methods.
- #to_s ⇒ Object
Methods included from Logger
Constructor Details
#initialize(rpmfile) ⇒ PackageId
Returns a new instance of PackageId.
39 40 41 42 43 |
# File 'lib/enhance_repo/package_id.rb', line 39 def initialize(rpmfile) @path = rpmfile @rpm = RPM::Package.open(rpmfile) @checksum = EnhanceRepo::ConfigOpts.instance.digest_class.hexdigest(File.new(rpmfile).read) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
Forward other methods
46 47 48 |
# File 'lib/enhance_repo/package_id.rb', line 46 def method_missing(sym, *args) @rpm.send(sym, *args) end |
Instance Attribute Details
#checksum ⇒ Object
Returns the value of attribute checksum.
33 34 35 |
# File 'lib/enhance_repo/package_id.rb', line 33 def checksum @checksum end |
#path ⇒ Object
Returns the value of attribute path.
34 35 36 |
# File 'lib/enhance_repo/package_id.rb', line 34 def path @path end |
#rpm ⇒ Object
Returns the value of attribute rpm.
35 36 37 |
# File 'lib/enhance_repo/package_id.rb', line 35 def rpm @rpm end |
Instance Method Details
#arch ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/enhance_repo/package_id.rb', line 58 def arch s = self[RPM::TAG_SOURCERPM] if s.nil? return 'src' else return @rpm.arch end end |
#eql?(other) ⇒ Boolean
54 55 56 |
# File 'lib/enhance_repo/package_id.rb', line 54 def eql?(other) @checksum == other.checksum end |
#hash ⇒ Object
50 51 52 |
# File 'lib/enhance_repo/package_id.rb', line 50 def hash @checksum.hash end |
#ident ⇒ Object
86 87 88 |
# File 'lib/enhance_repo/package_id.rb', line 86 def ident "#{@rpm}.#{@rpm.arch}" end |
#matches(ident) ⇒ Object
match function at name and nvr level
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/enhance_repo/package_id.rb', line 68 def matches(ident) # if the name matches, then it is sufficient return true if ident == @rpm.name # if not, compare the edition without release return true if ident == "#{@rpm.name}-#{@rpm.version.v}" # if not, compare the edition with release return true if ident == "#{@rpm.name}-#{@rpm.version.v}-#{@rpm.version.r}" # if not, also the architecture return true if ident == "#{@rpm.name}-#{@rpm.version.v}-#{@rpm.version.r}" # and finally arch return true if ident == "#{@rpm.name}-#{@rpm.version.v}-#{@rpm.version.r}.#{@rpm.arch}" false end |
#to_s ⇒ Object
82 83 84 |
# File 'lib/enhance_repo/package_id.rb', line 82 def to_s @rpm.to_s end |