Files

Class/Module Index [+]

Quicksearch

Gem2Rpm

Constants

TEMPLATE
VERSION

Public Class Methods

convert(fname, template=TEMPLATE, out=$stdout, nongem=true, local=false, doc_subpackage = true) click to toggle source
# File lib/gem2rpm.rb, line 37
def Gem2Rpm.convert(fname, template=TEMPLATE, out=$stdout,
                    nongem=true, local=false, doc_subpackage = true)
  format = Gem::Format.from_file_by_path(fname)
  spec = Gem2Rpm::Specification.new(format.spec)
  spec.description ||= spec.summary
  download_path = ""
  unless local
    begin
      download_path = find_download_url(spec.name, spec.version)
    rescue Gem::Exception => e
      $stderr.puts "Warning: Could not retrieve full URL for #{spec.name}\nWarning: Edit the specfile and enter the full download URL as 'Source0' manually"
      $stderr.puts "#{e.inspect}"
    end
  end
  template = ERB.new(template, 0, '-')
  out.puts template.result(binding)
rescue Gem::Exception => e
  puts e
end
find_download_url(name, version) click to toggle source
# File lib/gem2rpm.rb, line 21
def self.find_download_url(name, version)
  installer = Gem::RemoteInstaller.new
  dummy, download_path = installer.find_gem_to_install(name, "=#{version}")
  download_path += "/gems/" if download_path.to_s != ""
  return download_path
end
packager() click to toggle source

Returns the email address of the packager (i.e., the person running gem2spec). Taken from RPM macros if present, constructed from system username and hostname otherwise.

# File lib/gem2rpm.rb, line 60
def Gem2Rpm.packager()
  packager = `rpmdev-packager`.chomp

  if packager.empty?
    packager = `rpm --eval '%{packager}'`.chomp
  end

  if packager.empty? or packager == '%{packager}'
    packager = "#{Etc::getpwnam(Etc::getlogin).gecos} <#{Etc::getlogin}@#{Socket::gethostname}>"
  end

  packager
end
template_dir() click to toggle source
# File lib/gem2rpm.rb, line 74
def Gem2Rpm.template_dir
  File.join(File.dirname(__FILE__), '..', 'templates')
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.