Class: Gem2Rpm::RpmDependency

Inherits:
Dependency
  • Object
show all
Defined in:
lib/gem2rpm/rpm_dependency.rb

Instance Method Summary collapse

Methods inherited from Dependency

#requirement, #type

Constructor Details

#initialize(dependency) ⇒ RpmDependency

Returns a new instance of RpmDependency.



3
4
5
6
7
8
9
# File 'lib/gem2rpm/rpm_dependency.rb', line 3

def initialize(dependency)
  if dependency.respond_to? :__getobj__
    super dependency.__getobj__
  else
    super
  end
end

Instance Method Details

#comment_outObject

Comment out the dependency.



33
34
35
36
37
38
# File 'lib/gem2rpm/rpm_dependency.rb', line 33

def comment_out
  dep = __getobj__.dup
  dep.name = "# #{dep.name}"

  self.class.new dep
end

#to_rpmObject

Returns string with entry suitable for RPM .spec file.



41
42
43
44
45
46
47
# File 'lib/gem2rpm/rpm_dependency.rb', line 41

def to_rpm
  rpm_dependencies = requirement.map do |version|
    version = nil if version && version.to_s.empty?
    [name, version].compact.join(' ')
  end
  rpm_dependencies.join("\n")
end

#virtualizeObject

Convert to rubygem() virtual provide dependency.



12
13
14
15
16
17
# File 'lib/gem2rpm/rpm_dependency.rb', line 12

def virtualize
  dep = __getobj__.dup
  dep.name = "rubygem(#{dep.name})"

  self.class.new dep
end

#with_requiresObject

Output dependency with RPM requires tag.



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gem2rpm/rpm_dependency.rb', line 20

def with_requires
  dep = __getobj__.dup
  dep.name = case dep.type
  when :development
    "BuildRequires: #{dep.name}"
  else
    "Requires: #{dep.name}"
  end

  self.class.new dep
end