gem2rpm 0.8.4 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -55,12 +55,18 @@ gem2rpm over it.
55
55
  Template Details
56
56
  ================
57
57
 
58
- The template is a standard erb file; there are three main variables
59
- available in the template file:
58
+ The template is a standard erb file; there are two main variables available
59
+ in the template file:
60
60
 
61
- format - The Gem::Format for the gem
61
+ package - The Gem::Package for the gem
62
62
  spec - The Gem::Specification for the gem (the same as format.spec)
63
63
 
64
+ Deprecated:
65
+
66
+ format - The Gem::Format for the gem. Please note that this is kept
67
+ just for compatibility reasons, since RubyGems 2.0 removed
68
+ this class.
69
+
64
70
  Conventions
65
71
  ===========
66
72
 
data/bin/gem2rpm CHANGED
@@ -5,7 +5,6 @@ $:.push(File.expand_path(File.dirname(__FILE__) + "/../lib"))
5
5
 
6
6
  require 'gem2rpm'
7
7
  require 'optparse'
8
- require 'rubygems/format'
9
8
  require 'fileutils'
10
9
  require 'open-uri'
11
10
  require 'uri'
@@ -141,7 +140,7 @@ if srpm
141
140
  end
142
141
 
143
142
  if deps
144
- Gem::Format.from_file_by_path(gemfile).spec.dependencies.each do |dep|
143
+ Gem2Rpm::Package.new(gemfile).spec.dependencies.each do |dep|
145
144
  Gem2Rpm::Dependency.new(dep).requirement.each do |r|
146
145
  puts "rubygem(#{dep.name}) #{r}"
147
146
  end
data/lib/gem2rpm.rb CHANGED
@@ -1,43 +1,30 @@
1
1
  require 'erb'
2
2
  require 'socket'
3
- require 'rubygems/format'
3
+ require 'gem2rpm/package'
4
4
  require 'gem2rpm/distro'
5
+ require 'gem2rpm/format'
6
+ require 'gem2rpm/spec_fetcher'
5
7
  require 'gem2rpm/specification'
6
8
 
7
- # Adapt to the differences between rubygems < 1.0.0 and after
8
- # Once we can be reasonably certain that everybody has version >= 1.0.0
9
- # all this logic should be killed
10
- GEM_VERSION = Gem::Version.create(Gem::RubyGemsVersion)
11
- HAS_REMOTE_INSTALLER = GEM_VERSION < Gem::Version.create("1.0.0")
9
+ module Gem2Rpm
10
+ Gem2Rpm::VERSION = "0.9.0"
12
11
 
13
- if HAS_REMOTE_INSTALLER
14
- require 'rubygems/remote_installer'
15
- end
12
+ def self.find_download_url(name, version)
13
+ dep = Gem::Dependency.new(name, "=#{version}")
14
+ fetcher = Gem2Rpm::SpecFetcher.new(Gem::SpecFetcher.fetcher)
15
+ dummy, source = fetcher.spec_for_dependency(dep, false).first.first
16
16
 
17
- module Gem2Rpm
18
- Gem2Rpm::VERSION = "0.8.4"
17
+ download_path = source.uri
19
18
 
20
- if HAS_REMOTE_INSTALLER
21
- def self.find_download_url(name, version)
22
- installer = Gem::RemoteInstaller.new
23
- dummy, download_path = installer.find_gem_to_install(name, "=#{version}")
24
- download_path += "/gems/" if download_path.to_s != ""
25
- return download_path
26
- end
27
- else
28
- def self.find_download_url(name, version)
29
- dep = Gem::Dependency.new(name, "=#{version}")
30
- fetcher = Gem::SpecFetcher.fetcher
31
- dummy, download_path = fetcher.find_matching(dep, false, false).first
32
- download_path += "gems/" if download_path.to_s != ""
33
- return download_path
34
- end
19
+ download_path += "gems/" if download_path.to_s != ""
20
+ return download_path
35
21
  end
36
22
 
37
23
  def Gem2Rpm.convert(fname, template=TEMPLATE, out=$stdout,
38
24
  nongem=true, local=false, doc_subpackage = true)
39
- format = Gem::Format.from_file_by_path(fname)
40
- spec = Gem2Rpm::Specification.new(format.spec)
25
+ package = Gem2Rpm::Package.new(fname)
26
+ format = Gem2Rpm::Format.new(package)
27
+ spec = Gem2Rpm::Specification.new(package.spec)
41
28
  spec.description ||= spec.summary
42
29
  download_path = ""
43
30
  unless local
@@ -0,0 +1,19 @@
1
+ require 'delegate'
2
+
3
+ module Gem2Rpm
4
+ class Format < SimpleDelegator
5
+ # Returns the value of attribute gem_path
6
+ def gem_path
7
+ super
8
+ rescue
9
+ spec.file_name
10
+ end
11
+
12
+ # Returns the value of attribute file_entries
13
+ def file_entries
14
+ super
15
+ rescue
16
+ spec.files
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ require 'delegate'
2
+ require 'rubygems/package'
3
+ begin
4
+ require 'rubygems/format'
5
+ rescue LoadError
6
+ end
7
+
8
+ module Gem2Rpm
9
+ class Package < SimpleDelegator
10
+ def initialize(gem)
11
+ super(Gem::Package.new(gem)) rescue super(Gem::Format.from_file_by_path(gem))
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ require 'delegate'
2
+ require 'ostruct'
3
+
4
+ module Gem2Rpm
5
+ class SpecFetcher < SimpleDelegator
6
+ # Find and fetch specs that match +dependency+.
7
+ #
8
+ # If +matching_platform+ is false, gems for all platforms are returned.
9
+ def spec_for_dependency(dependency, matching_platform=true)
10
+ super
11
+ rescue
12
+ spec, source = find_matching(dependency, true, matching_platform).first
13
+ source = OpenStruct.new(:uri => source)
14
+ [[[spec, source]]]
15
+ end
16
+ end
17
+ end
@@ -1,4 +1,4 @@
1
- # Generated from <%= format.gem_path %> by gem2rpm -*- rpm-spec -*-
1
+ # Generated from <%= package.spec.file_name %> by gem2rpm -*- rpm-spec -*-
2
2
  %define rbname <%= spec.name %>
3
3
  %define version <%= spec.version %>
4
4
  %define release 1
@@ -56,14 +56,14 @@ rmdir %{gembuilddir}/bin
56
56
  <% for f in spec.executables -%>
57
57
  %{_bindir}/<%= f %>
58
58
  <% end -%>
59
- <% format.file_entries.each do |entry, data| -%>
59
+ <% package.spec.files.each do |entry, data| -%>
60
60
  <% path = entry['path'] -%>
61
61
  <% doc_prefix = spec.extra_rdoc_files.include?(path) ? "%doc " : "" -%>
62
62
  <%= doc_prefix %>%{gemdir}/gems/<%= spec.name %>-<%= spec.version %>/<%= path %>
63
63
  <% end %>
64
64
 
65
65
  %doc %{gemdir}/doc/<%= spec.name %>-<%= spec.version %>
66
- %{gemdir}/cache/<%= format.gem_path %>
67
- %{gemdir}/specifications/<%= format.gem_path %>spec
66
+ %{gemdir}/cache/<%= package.spec.file_name %>
67
+ %{gemdir}/specifications/<%= package.spec.file_name %>spec
68
68
 
69
69
  %changelog
@@ -1,4 +1,4 @@
1
- # Generated from <%= File::basename(format.gem_path) %> by gem2rpm -*- rpm-spec -*-
1
+ # Generated from <%= package.spec.file_name %> by gem2rpm -*- rpm-spec -*-
2
2
  %global gem_name <%= spec.name %>
3
3
  <%# TODO: Try to check against spec.required_ruby_version -%>
4
4
  %global rubyabi 1.9.1
@@ -1,4 +1,4 @@
1
- # Generated from <%= File::basename(format.gem_path) %> by gem2rpm -*- rpm-spec -*-
1
+ # Generated from <%= package.spec.file_name %> by gem2rpm -*- rpm-spec -*-
2
2
  %global gem_name <%= spec.name %>
3
3
 
4
4
  Name: rubygem-%{gem_name}
@@ -1,4 +1,4 @@
1
- # Generated from <%= File::basename(format.gem_path) %> by gem2rpm -*- rpm-spec -*-
1
+ # Generated from <%= package.spec.file_name %> by gem2rpm -*- rpm-spec -*-
2
2
  %global gemname <%= spec.name %>
3
3
 
4
4
  <% if nongem -%>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem2rpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.9.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-03-08 00:00:00.000000000 Z
13
+ date: 2013-04-22 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: ! " Generate source rpms and rpm spec files from a Ruby Gem. \n The
16
16
  spec file tries to follow the gem as closely as possible\n"
@@ -27,7 +27,10 @@ files:
27
27
  - lib/gem2rpm.rb
28
28
  - lib/gem2rpm/dependency.rb
29
29
  - lib/gem2rpm/distro.rb
30
+ - lib/gem2rpm/format.rb
30
31
  - lib/gem2rpm/helpers.rb
32
+ - lib/gem2rpm/package.rb
33
+ - lib/gem2rpm/spec_fetcher.rb
31
34
  - lib/gem2rpm/specification.rb
32
35
  - templates/default.spec.erb
33
36
  - templates/fedora-17-18.spec.erb