Sha256: 416eddf4b0e5fc150611151062ca45c1fabdfbd6bb0dc1071e0271f23ce7690e

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

module Gem2Rpm
  class RpmDependency < Gem2Rpm::Dependency
    def initialize(dependency)
      if dependency.respond_to? :__getobj__
        super dependency.__getobj__
      else
        super
      end
    end

    # Convert to rubygem() virtual provide dependency.
    def virtualize
      dep = __getobj__.dup
      dep.name = "rubygem(#{dep.name})"

      self.class.new dep
    end

    # Output dependency with RPM requires tag.
    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

    # Comment out the dependency.
    def comment_out
      dep = __getobj__.dup
      dep.name = "# #{dep.name}"

      self.class.new dep
    end

    # Returns string with entry suitable for RPM .spec file.
    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gem2rpm-1.0.2 lib/gem2rpm/rpm_dependency.rb
gem2rpm-1.0.1 lib/gem2rpm/rpm_dependency.rb
gem2rpm-1.0.0 lib/gem2rpm/rpm_dependency.rb