Module: Gem2Rpm
- Extended by:
- TemplateHelpers
- Defined in:
- lib/gem2rpm.rb,
lib/gem2rpm/distro.rb,
lib/gem2rpm/helpers.rb,
lib/gem2rpm/rpm_file.rb,
lib/gem2rpm/template.rb,
lib/gem2rpm/gem/format.rb,
lib/gem2rpm/test_suite.rb,
lib/gem2rpm/gem/package.rb,
lib/gem2rpm/configuration.rb,
lib/gem2rpm/rpm_file_list.rb,
lib/gem2rpm/gem/dependency.rb,
lib/gem2rpm/rpm_dependency.rb,
lib/gem2rpm/gem/spec_fetcher.rb,
lib/gem2rpm/template_helpers.rb,
lib/gem2rpm/gem/specification.rb,
lib/gem2rpm/rpm_dependency_list.rb
Defined Under Namespace
Modules: Helpers, TemplateHelpers Classes: Configuration, Dependency, Distro, DownloadUrlError, Exception, Format, Package, RpmDependency, RpmDependencyList, RpmFile, RpmFileList, SpecFetcher, Specification, Template, TestSuite
Constant Summary collapse
- VERSION =
"1.0.2".freeze
- OPEN_MODE =
:nodoc:
if Object.const_defined? :Encoding 'r:UTF-8' else 'r' end
Class Method Summary collapse
- .convert(fname, template, out = $stdout, nongem = true, local = false, doc_subpackage = true) ⇒ Object
- .find_download_url(name, version) ⇒ Object
-
.packager ⇒ Object
Returns the email address of the packager (i.e., the person running gem2spec).
-
.print_dependencies(gemfile, out = $stdout) ⇒ Object
Print gem dependencies to the specified output ($stdout by default).
- .rubygem_template ⇒ Object
- .show_message(message, obj = nil, out = $stderr) ⇒ Object
- .show_templates(out = $stdout) ⇒ Object
- .show_version(out = $stdout) ⇒ Object
- .vagrant_plugin_template ⇒ Object
Methods included from TemplateHelpers
doc_file_entries, main_file_entries, requirement
Class Method Details
.convert(fname, template, out = $stdout, nongem = true, local = false, doc_subpackage = true) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/gem2rpm.rb', line 65 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 = Configuration.instance.reset runtime_dependencies = Gem2Rpm::RpmDependencyList.new(spec.runtime_dependencies) development_dependencies = Gem2Rpm::RpmDependencyList.new(spec.development_dependencies) tests = TestSuite.new(spec) files = RpmFileList.new(spec.files) main_files = files.top_level_entries.main_entries doc_files = files.top_level_entries.doc_entries download_path = "" unless local begin download_path = find_download_url(spec.name, spec.version) rescue DownloadUrlError => 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 erb = ERB.new(template.read, 0, '-') out.puts erb.result(binding) rescue Gem::Exception => e puts e end |
.find_download_url(name, version) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/gem2rpm.rb', line 47 def self.find_download_url(name, version) dep = Gem::Dependency.new(name, "=#{version}") fetcher = Gem2Rpm::SpecFetcher.new(Gem::SpecFetcher.fetcher) spec_and_source, errors = fetcher.spec_for_dependency(dep, false) fail DownloadUrlError, errors.first.error. unless errors.empty? _spec, source = spec_and_source.first if source && source.uri download_path = source.uri.to_s download_path += "gems/" end download_path end |
.packager ⇒ Object
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.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/gem2rpm.rb', line 108 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? || (packager == '%{packager}') passwd_entry = Etc.getpwnam(Etc.getlogin) packager = "#{(passwd_entry && passwd_entry.gecos) || Etc.getlogin} <#{Etc.getlogin}@#{Socket.gethostname}>" end packager end |
.print_dependencies(gemfile, out = $stdout) ⇒ Object
Print gem dependencies to the specified output ($stdout by default).
100 101 102 103 |
# File 'lib/gem2rpm.rb', line 100 def self.print_dependencies(gemfile, out = $stdout) dl = RpmDependencyList.new(Gem2Rpm::Package.new(gemfile).spec.dependencies) out.puts dl.virtualize.to_rpm end |
.rubygem_template ⇒ Object
123 124 125 |
# File 'lib/gem2rpm.rb', line 123 def self.rubygem_template Template.new(File.join(Template.default_location, "#{Distro.nature}.spec.erb")) end |
.show_message(message, obj = nil, out = $stderr) ⇒ Object
29 30 31 32 |
# File 'lib/gem2rpm.rb', line 29 def self.(, obj = nil, out = $stderr) out.puts("#{}\n\n") out.puts obj if obj end |
.show_templates(out = $stdout) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/gem2rpm.rb', line 34 def self.show_templates(out = $stdout) out.puts "Available templates in #{Gem2Rpm::Template.default_location}:\n\n" template_list = Gem2Rpm::Template.list.map do |t| t = t.gsub(/(.*)\.spec.erb/, '\\1') t.gsub(/^/, t == Distro.nature ? '* ' : ' ') end.join("\n") out.puts template_list end |