Class: RPM::Dependency

Inherits:
Object
  • Object
show all
Defined in:
lib/rpm/dependency.rb

Direct Known Subclasses

Conflict, Provide, Require

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, version, flags, owner) ⇒ Dependency

Returns a new instance of Dependency



20
21
22
23
24
25
26
27
28
# File 'lib/rpm/dependency.rb', line 20

def initialize(name, version, flags, owner)

  RPM::Utils.check_type(version, RPM::Version)
  
  @name = name
  @version = version
  @flags = flags
  @owner = owner
end

Instance Attribute Details

#flagsString

Returns dependency flags

Returns:

  • (String)

    dependency flags



12
13
14
# File 'lib/rpm/dependency.rb', line 12

def flags
  @flags
end

#flagstagObject

Returns the value of attribute flagstag



18
19
20
# File 'lib/rpm/dependency.rb', line 18

def flagstag
  @flagstag
end

#nameString

Returns dependency name

Returns:

  • (String)

    dependency name



8
9
10
# File 'lib/rpm/dependency.rb', line 8

def name
  @name
end

#nametagObject

Returns the value of attribute nametag



16
17
18
# File 'lib/rpm/dependency.rb', line 16

def nametag
  @nametag
end

#ownerPackage

Returns package this dependency belongs to

Returns:

  • (Package)

    package this dependency belongs to



14
15
16
# File 'lib/rpm/dependency.rb', line 14

def owner
  @owner
end

#versionString

Returns dependency version

Returns:

  • (String)

    dependency version



10
11
12
# File 'lib/rpm/dependency.rb', line 10

def version
  @version
end

#versiontagObject

Returns the value of attribute versiontag



17
18
19
# File 'lib/rpm/dependency.rb', line 17

def versiontag
  @versiontag
end

Instance Method Details

#eq?Boolean

Returns true if '=', '=<' or '>=' are used to compare the version

Returns:

  • (Boolean)

    true if '=', '=<' or '>=' are used to compare the version



67
68
69
# File 'lib/rpm/dependency.rb', line 67

def eq?
  flags & RPM::SENSE[:equal] 
end

#ge?Boolean

Returns true if '>=' is used to compare the version

Returns:

  • (Boolean)

    true if '>=' is used to compare the version



77
78
79
# File 'lib/rpm/dependency.rb', line 77

def ge?
  (flags & RPM::SENSE[:greater]) && (flags & RPMSENSE[:equal])
end

#gt?Boolean

Returns true if '>' or '>=' are used to compare the version

Returns:

  • (Boolean)

    true if '>' or '>=' are used to compare the version



62
63
64
# File 'lib/rpm/dependency.rb', line 62

def gt?
  flags & RPM::SENSE[:greater]
end

#le?Boolean

Returns true if '=<' is used to compare the version

Returns:

  • (Boolean)

    true if '=<' is used to compare the version



72
73
74
# File 'lib/rpm/dependency.rb', line 72

def le?
  (flags & RPM::SENSE[:less]) && (flags & RPMSENSE[:equal])
end

#lt?Boolean

Returns true if '<' or '=<' are used to compare the version

Returns:

  • (Boolean)

    true if '<' or '=<' are used to compare the version



57
58
59
# File 'lib/rpm/dependency.rb', line 57

def lt?
  flags & RPM::SENSE[:less]
end

#pre?Boolean

Returns true if this is a pre-requires

Returns:

  • (Boolean)

    true if this is a pre-requires



82
83
84
# File 'lib/rpm/dependency.rb', line 82

def pre?
  flags & RPM::SENSE[:prereq] 
end

#satisfy?(other) ⇒ Boolean

Returns true if other satisfies this dependency

Parameters:

Returns:

  • (Boolean)

    true if other satisfies this dependency



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rpm/dependency.rb', line 32

def satisfy?(other)
  case other
    when RPM::Package then
      other.provides.each do |prov|
        return true if self.satisfy?(prov)
      end
      return false
    when RPM::Dependency then
      RPM::FFI.rpmdsCompare(
        RPM::FFI.rpmdsSingle(:providename, other.name,
          other.version.to_vre, other.flags),
        RPM::FFI.rpmdsSingle(:providename, name,
          version.to_vre, flags)) != 0
    when RPM::Version then
      RPM::FFI.rpmdsCompare(
        RPM::FFI.rpmdsSingle(:providename, name,
          other.to_vre, other.to_vre.empty? ? 0 : :equal),
        RPM::FFI.rpmdsSingle(:providename, name,
          version.to_vre, flags)) != 0
    else
      raise(TypeError, "#{other} is not a Version or Dependency")
    end
end