Sha256: 5454ae20079621fd1edac9177dc587fda549c71bc8502c5bdd894d01d468effb

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

require 'pathname'
require 'gem2rpm/helpers'

module Gem2Rpm
  class RpmFile < String
    # Returns string with entry suitable for RPM .spec file. This typically
    # includes all necessary macros depending on file categorization.
    def to_rpm
      config = Gem2Rpm::Configuration.instance

      case
      when license?
        "#{config.macro_for(:license)} #{config.macro_for(:instdir)}/#{self}".strip
      when doc?
        "#{config.macro_for(:doc)} #{config.macro_for(:instdir)}/#{self}".strip
      when ignore?
        "#{config.macro_for(:ignore)} #{config.macro_for(:instdir)}/#{self}".strip
      # /lib should have its own macro
      when self == 'lib'
        "#{config.macro_for(:libdir)}"
      else
        "#{config.macro_for(:instdir)}/#{self}"
      end
    end

    # Returs true for documentation files.
    def doc?
      Helpers.check_str_on_conditions(self, Gem2Rpm::Configuration.instance.rule_for(:doc))
    end

    # Returns true for license files.
    def license?
      Helpers.check_str_on_conditions(self, Gem2Rpm::Configuration.instance.rule_for(:license))
    end

    # Returns true for files which should be ommited from the package.
    def ignore?
      Helpers.check_str_on_conditions(self, Gem2Rpm::Configuration.instance.rule_for(:ignore))
    end

    # Returns true for files which are part of package test suite.
    def test?
      Helpers.check_str_on_conditions(self, Gem2Rpm::Configuration.instance.rule_for(:test))
    end

    # Returns true for other known miscellaneous files.
    def misc?
      Helpers.check_str_on_conditions(self, Gem2Rpm::Configuration.instance.rule_for(:misc))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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