lib/gem2rpm.rb in gem2rpm-0.11.2 vs lib/gem2rpm.rb in gem2rpm-0.11.3
- old
+ new
@@ -9,11 +9,11 @@
require 'gem2rpm/template'
module Gem2Rpm
extend Gem2Rpm::TemplateHelpers
- Gem2Rpm::VERSION = "0.11.2"
+ Gem2Rpm::VERSION = "0.11.3"
class Exception < RuntimeError; end
class DownloadUrlError < Exception; end
OPEN_MODE = # :nodoc:
@@ -27,29 +27,29 @@
dep = Gem::Dependency.new(name, "=#{version}")
fetcher = Gem2Rpm::SpecFetcher.new(Gem::SpecFetcher.fetcher)
spec_and_source, errors = fetcher.spec_for_dependency(dep, false)
- raise DownloadUrlError.new(errors.first.error.message) unless errors.empty?
+ fail DownloadUrlError, errors.first.error.message unless errors.empty?
- spec, source = spec_and_source.first
+ _spec, source = spec_and_source.first
if source && source.uri
download_path = source.uri.to_s
download_path += "gems/"
end
download_path
end
- def Gem2Rpm.convert(fname, template, out=$stdout, nongem=true, local=false,
+ def self.convert(fname, template, out = $stdout, nongem = true, local = false,
doc_subpackage = true)
package = Gem2Rpm::Package.new(fname)
# Deprecate, kept just for backward compatibility.
format = Gem2Rpm::Format.new(package)
spec = Gem2Rpm::Specification.new(package.spec)
- config = Gem2Rpm::Configuration.instance.to_default
+ config = Gem2Rpm::Configuration.instance.reset
download_path = ""
unless local
begin
download_path = find_download_url(spec.name, spec.version)
rescue DownloadUrlError => e
@@ -62,36 +62,44 @@
out.puts erb.result(binding)
rescue Gem::Exception => e
puts e
end
+ # Print gem dependencies to the specified output ($stdout by default).
+ def self.print_dependencies(gemfile, out = $stdout)
+ Gem2Rpm::Package.new(gemfile).spec.dependencies.each do |dep|
+ Gem2Rpm::Dependency.new(dep).requirement.each do |r|
+ out.puts "rubygem(#{dep.name}) #{r}"
+ end
+ end
+ end
+
# 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.
- def Gem2Rpm.packager()
+ def self.packager
packager = `rpmdev-packager 2> /dev/null`.chomp rescue ''
if packager.empty?
packager = `rpm --eval '%{packager}' 2> /dev/null`.chomp rescue ''
end
- if packager.empty? or packager == '%{packager}'
- passwd_entry = Etc::getpwnam(Etc::getlogin)
- packager = "#{(passwd_entry && passwd_entry.gecos) || Etc::getlogin } <#{Etc::getlogin}@#{Socket::gethostname}>"
+ if packager.empty? || (packager == '%{packager}')
+ passwd_entry = Etc.getpwnam(Etc.getlogin)
+ packager = "#{(passwd_entry && passwd_entry.gecos) || Etc.getlogin} <#{Etc.getlogin}@#{Socket.gethostname}>"
end
packager
end
def self.rubygem_template
- Template.new(File.join(Template::default_location, "#{Distro.nature.to_s}.spec.erb"))
+ Template.new(File.join(Template.default_location, "#{Distro.nature}.spec.erb"))
end
def self.vagrant_plugin_template
- file = File.join(Template::default_location, "#{Distro.nature.to_s}-vagrant-plugin.spec.erb")
+ file = File.join(Template.default_location, "#{Distro.nature}-vagrant-plugin.spec.erb")
Template.new(file)
end
-
end
# Local Variables:
# ruby-indent-level: 2
# End: