module Polisher::GemFiles

Constants

DOC_FILES

Common files shipped in gems considered doc

IGNORE_FILES

Common files shipped in gems that we should ignore

LICENSE_FILES

License files

RUNTIME_FILES

Critical runtime files that are necessary for the gem to run

Public Class Methods

included(base) click to toggle source
# File lib/polisher/gem/files.rb, line 27
def self.included(base)
  base.extend(ClassMethods)
end

Public Instance Methods

each_file(&bl) click to toggle source

Iterate over each file in gem invoking block with path

# File lib/polisher/gem/files.rb, line 88
def each_file(&bl)
  unpack do |dir|
    Pathname.new(dir).find do |path|
      next if path.to_s == dir.to_s
      pathstr = path.to_s.gsub("#{dir}/", '')
      bl.call pathstr unless pathstr.blank?
    end
  end
end
file_paths() click to toggle source

Retrieve the list of paths to files in the gem

@return [Array<String>] list of files in the gem

# File lib/polisher/gem/files.rb, line 101
def file_paths
  @file_paths ||= begin
    files = []
    each_file do |path|
      files << path
    end
    files
  end
end
has_file_satisfied_by?(spec_file) click to toggle source

Return bool indicating if spec file satisfies any file in gem

# File lib/polisher/gem/files.rb, line 62
def has_file_satisfied_by?(spec_file)
  file_paths.any? { |gem_file| RPM::Spec.file_satisfies?(spec_file, gem_file) }
end
unpack(&bl) click to toggle source

Unpack files & return unpacked directory

If block is specified, it will be invoked with directory after which directory will be removed

# File lib/polisher/gem/files.rb, line 70
def unpack(&bl)
  dir = nil
  pkg = ::Gem::Installer.new gem_path, :unpack => true

  if bl
    Dir.mktmpdir do |tmpdir|
      pkg.unpack tmpdir
      bl.call tmpdir
    end
  else
    dir = Dir.mktmpdir
    pkg.unpack dir
  end

  dir
end