gem2rpm 0.11.2 → 0.11.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05c2d7ff2784e6acf91598c7eb14826f9b6e131c
4
- data.tar.gz: dd82ef52cba6f90b6f27659345b4a5aa40c92b8f
3
+ metadata.gz: 911d15cecd229ed97a9a901cfdac408ef08796cb
4
+ data.tar.gz: 211b7ad4686015ac6eb03729f61a31f85894c581
5
5
  SHA512:
6
- metadata.gz: 233cfde605cf890876d4fba199ff1c1d23ffd34d683af16146406594dbf443f683961a7294310787924685c687650f7fd0aaaf7f82faa5d25602f5e4c2f25125
7
- data.tar.gz: 52cd2e8b0fcece311b18f79b61c928829adc88b95144cbbd61ea45f17fc77835305c1556d0a82d89065f6e4f045a22bc5ec119f19e8ec67923929138a58b2b3e
6
+ metadata.gz: f4cb61a3ab8618afda9f3530bafb8712e76ebc21eb7f00ff97678704584342a3f1af230d4b4d150457db1f33feec7c5756ff0dcc92b7985921e3c3d7f5f2505c
7
+ data.tar.gz: bf4a5b88e63300b0f0db6bd0f64685250c182a638a2b6e0e41588bd588f65e5ade8187fe438d7ae05e951d09ad907cb7e3284620488f681341bdad6661c83172
data/AUTHORS CHANGED
@@ -25,3 +25,4 @@ Patches from:
25
25
  Bohuslav Kabrda bkabrda@redhat.com
26
26
  Saleem Ansari tuxdna@gmail.com
27
27
  Sergio Rubio rubiojr@frameos.org
28
+ Oleg Girko ol@infoserver.lv
data/README.md CHANGED
@@ -58,7 +58,7 @@ $ gem2rpm -T > rubygem-GEM.spec.template
58
58
  Now you can edit the template and then run gem2rpm to generate the spec file using the edited template:
59
59
 
60
60
  ```
61
- $ gem2rpm -t rubygem-GEM.spec.template > rubygem-GEM.spec
61
+ $ gem2rpm -t rubygem-GEM.spec.template GEM-1.2.3.gem > rubygem-GEM.spec
62
62
  ```
63
63
 
64
64
  With this new template you can now build your RPM as usual and when a new version of the gem becomes available, you just edit the saved template and rerun gem2rpm over it.
@@ -115,7 +115,7 @@ where GEM is the name of the packaged gem. The default template also makes
115
115
  sure that the resulting package provides 'ruby($GEM)', according to general
116
116
  packaging conventions for scripting languages.
117
117
 
118
- ## Limitiations
118
+ ## Limitations
119
119
 
120
120
  Because of the differences between the two packaging schemes, it is impossible to come up with a completely automated way of doing the conversion, but the spec files produced by this package should be good enough for most pure-ruby gems.
121
121
 
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- ruby -*-
3
3
 
4
- $:.push(File.expand_path(File.dirname(__FILE__) + "/../lib"))
4
+ $LOAD_PATH.push(File.expand_path(File.dirname(__FILE__) + "/../lib"))
5
5
 
6
6
  require 'gem2rpm'
7
7
  require 'optparse'
@@ -9,98 +9,31 @@ require 'fileutils'
9
9
  require 'open-uri'
10
10
  require 'uri'
11
11
 
12
- opts = OptionParser.new("Usage: #{$0} [OPTIONS] GEM")
13
- opts.separator(" Convert Ruby gems to source RPMs and specfiles.")
14
- opts.separator(" Uses a template to generate the RPM specfile")
15
- opts.separator(" from the gem specification.")
16
-
17
- print_template_file = nil
18
- template_file = nil
19
- output_file = nil
20
- local = false
21
- srpm = false
22
- deps = false
23
- nongem = false
24
- doc_subpackage = true
25
- fetch = false
26
-
27
- opts.separator("")
28
- opts.separator(" Options:")
29
- opts.on("-T", "--current-template", "Print the current template") do |val|
30
- print_template_file = true
31
- end
32
- opts.on("-t", "--template TEMPLATE", "Use TEMPLATE for the specfile") do |val|
33
- template_file = val
34
- end
35
- opts.on("--templates", "List all available templates") do
36
- puts "Available templates in #{Gem2Rpm::Template.default_location}:\n\n"
37
- puts Gem2Rpm::Template.list.map{
38
- |t| t.gsub(/(.*)\.spec.erb/, '\\1')
39
- }.join("\n")
40
- exit 0
41
- end
42
- opts.on("-v", "--version", "Print gem2rpm's version and exit") do
43
- puts Gem2Rpm::VERSION
44
- exit 0
45
- end
46
- opts.on("-o", "--output FILE", "Send the specfile to FILE") do |val|
47
- output_file = val
48
- end
49
- opts.on("-s", "--srpm", "Create a source RPM") do |val|
50
- srpm = true
51
- end
52
- opts.on("-l", "--local", "Do not retrieve Gem information over
53
- #{' '*36} the network. Use on disconnected machines") do |val|
54
- local = true
55
- end
56
- opts.on("-d", "--dependencies", "Print the dependencies of the gem") do |val|
57
- deps = true
58
- end
59
- opts.on("-n", "--nongem", "Generate a subpackage for non-gem use") do |val|
60
- nongem = true
61
- end
62
- opts.on("--no-doc", "Disable document subpackage") do |val|
63
- doc_subpackage = false
64
- end
65
- opts.on("--fetch", "Fetch the gem from rubygems.org") do |val|
66
- fetch = true
67
- end
68
- opts.separator("")
69
- opts.separator(" Arguments:")
70
- opts.separator(" GEM The path to the locally stored gem package file or the name")
71
- opts.separator(" of the gem when using --fetch.")
72
- opts.separator("")
73
-
74
- begin
75
- rest = opts.permute(ARGV)
76
- rescue OptionParser::InvalidOption => e
77
- $stderr.puts "#{e}\n\n"
78
- $stderr.puts opts
79
- exit(1)
80
- end
12
+ options = Gem2Rpm::Configuration.instance.options
13
+ rest = options[:args]
81
14
 
82
15
  template = begin
83
- Gem2Rpm::Template.find template_file, :gem_file => rest[0]
16
+ Gem2Rpm::Template.find options[:template_file], :gem_file => rest[0]
84
17
  rescue Gem2Rpm::Template::TemplateError => e
85
18
  $stderr.puts e
86
19
  exit(1)
87
20
  end
88
21
 
89
- if print_template_file
22
+ if options[:print_template_file]
90
23
  puts template.read
91
24
  exit 0
92
25
  end
93
26
 
94
27
  if rest.size != 1
95
- $stderr.puts "Missing GEMFILE\n\n"
96
- $stderr.puts opts
97
- exit(1)
28
+ $stderr.puts "Missing GEMFILE\n\n"
29
+ $stderr.puts opts
30
+ exit(1)
98
31
  end
99
32
  gemfile = rest[0]
100
33
 
101
- if fetch
34
+ if options[:fetch]
102
35
  gem_uri = ''
103
- open("http://rubygems.org/api/v1/gems/#{gemfile}.json") do |f|
36
+ open("https://rubygems.org/api/v1/gems/#{gemfile}.json") do |f|
104
37
  gem_uri = f.read.match(/"gem_uri":\s*"(.*?)",/m)[1]
105
38
  gemfile = URI.parse(gem_uri).path.split('/').last
106
39
  open(gemfile, 'w') do |gf|
@@ -109,45 +42,33 @@ if fetch
109
42
  end
110
43
  end
111
44
 
112
- srpmdir = nil
113
- gemname = nil
114
45
  srpmdir = nil
115
46
  specfile = nil
116
- if srpm
117
- gemname = Gem2Rpm::Package.new(gemfile).spec.name
118
- srpmdir = `/bin/mktemp -t -d gem2rpm-#{gemname}.XXXXXX`.chomp
119
- specfile = File::join(srpmdir, "rubygem-#{gemname}.spec")
120
- if output_file.nil?
121
- output_file = specfile
122
- end
47
+ if options[:srpm]
48
+ gemname = Gem2Rpm::Package.new(gemfile).spec.name
49
+ srpmdir = `/bin/mktemp -t -d gem2rpm-#{gemname}.XXXXXX`.chomp
50
+ specfile = File.join(srpmdir, "rubygem-#{gemname}.spec")
51
+ options[:output_file] ||= specfile
123
52
  end
124
53
 
125
54
  # Produce a specfile
126
- if output_file.nil?
127
- Gem2Rpm::convert(gemfile, template, $stdout, nongem, local, doc_subpackage) unless deps
55
+ if options[:output_file].nil?
56
+ Gem2Rpm.convert(gemfile, template, $stdout, options[:nongem], options[:local], options[:doc_subpackage]) unless options[:deps]
128
57
  else
129
- begin
130
- out = open(output_file, "w")
131
- Gem2Rpm::convert(gemfile, template, out, nongem, local, doc_subpackage)
132
- ensure
133
- out.close()
134
- end
58
+ begin
59
+ out = open(options[:output_file], "w")
60
+ Gem2Rpm.convert(gemfile, template, out, options[:nongem], options[:local], options[:doc_subpackage])
61
+ ensure
62
+ out.close
63
+ end
135
64
  end
136
65
 
137
66
  # Create a source RPM
138
- if srpm
139
- unless File::exist?(specfile)
140
- FileUtils::copy(output_file, specfile)
141
- end
142
- FileUtils::copy(gemfile, srpmdir)
67
+ if options[:srpm]
68
+ FileUtils.copy(options[:output_file], specfile) unless File.exist?(specfile)
69
+ FileUtils.copy(gemfile, srpmdir)
143
70
 
144
- system("rpmbuild -bs --nodeps --define '_sourcedir #{srpmdir}' --define '_srcrpmdir #{Dir::pwd}' #{specfile}")
71
+ system("rpmbuild -bs --nodeps --define '_sourcedir #{srpmdir}' --define '_srcrpmdir #{Dir.pwd}' #{specfile}")
145
72
  end
146
73
 
147
- if deps
148
- Gem2Rpm::Package.new(gemfile).spec.dependencies.each do |dep|
149
- Gem2Rpm::Dependency.new(dep).requirement.each do |r|
150
- puts "rubygem(#{dep.name}) #{r}"
151
- end
152
- end
153
- end
74
+ Gem2Rpm.print_dependencies(gemfile) if options[:deps]
@@ -11,7 +11,7 @@ require 'gem2rpm/template'
11
11
  module Gem2Rpm
12
12
  extend Gem2Rpm::TemplateHelpers
13
13
 
14
- Gem2Rpm::VERSION = "0.11.2"
14
+ Gem2Rpm::VERSION = "0.11.3"
15
15
 
16
16
  class Exception < RuntimeError; end
17
17
  class DownloadUrlError < Exception; end
@@ -29,9 +29,9 @@ module Gem2Rpm
29
29
 
30
30
  spec_and_source, errors = fetcher.spec_for_dependency(dep, false)
31
31
 
32
- raise DownloadUrlError.new(errors.first.error.message) unless errors.empty?
32
+ fail DownloadUrlError, errors.first.error.message unless errors.empty?
33
33
 
34
- spec, source = spec_and_source.first
34
+ _spec, source = spec_and_source.first
35
35
 
36
36
  if source && source.uri
37
37
  download_path = source.uri.to_s
@@ -41,13 +41,13 @@ module Gem2Rpm
41
41
  download_path
42
42
  end
43
43
 
44
- def Gem2Rpm.convert(fname, template, out=$stdout, nongem=true, local=false,
44
+ def self.convert(fname, template, out = $stdout, nongem = true, local = false,
45
45
  doc_subpackage = true)
46
46
  package = Gem2Rpm::Package.new(fname)
47
47
  # Deprecate, kept just for backward compatibility.
48
48
  format = Gem2Rpm::Format.new(package)
49
49
  spec = Gem2Rpm::Specification.new(package.spec)
50
- config = Gem2Rpm::Configuration.instance.to_default
50
+ config = Gem2Rpm::Configuration.instance.reset
51
51
  download_path = ""
52
52
  unless local
53
53
  begin
@@ -64,33 +64,41 @@ module Gem2Rpm
64
64
  puts e
65
65
  end
66
66
 
67
+ # Print gem dependencies to the specified output ($stdout by default).
68
+ def self.print_dependencies(gemfile, out = $stdout)
69
+ Gem2Rpm::Package.new(gemfile).spec.dependencies.each do |dep|
70
+ Gem2Rpm::Dependency.new(dep).requirement.each do |r|
71
+ out.puts "rubygem(#{dep.name}) #{r}"
72
+ end
73
+ end
74
+ end
75
+
67
76
  # Returns the email address of the packager (i.e., the person running
68
77
  # gem2spec). Taken from RPM macros if present, constructed from system
69
78
  # username and hostname otherwise.
70
- def Gem2Rpm.packager()
79
+ def self.packager
71
80
  packager = `rpmdev-packager 2> /dev/null`.chomp rescue ''
72
81
 
73
82
  if packager.empty?
74
83
  packager = `rpm --eval '%{packager}' 2> /dev/null`.chomp rescue ''
75
84
  end
76
85
 
77
- if packager.empty? or packager == '%{packager}'
78
- passwd_entry = Etc::getpwnam(Etc::getlogin)
79
- packager = "#{(passwd_entry && passwd_entry.gecos) || Etc::getlogin } <#{Etc::getlogin}@#{Socket::gethostname}>"
86
+ if packager.empty? || (packager == '%{packager}')
87
+ passwd_entry = Etc.getpwnam(Etc.getlogin)
88
+ packager = "#{(passwd_entry && passwd_entry.gecos) || Etc.getlogin} <#{Etc.getlogin}@#{Socket.gethostname}>"
80
89
  end
81
90
 
82
91
  packager
83
92
  end
84
93
 
85
94
  def self.rubygem_template
86
- Template.new(File.join(Template::default_location, "#{Distro.nature.to_s}.spec.erb"))
95
+ Template.new(File.join(Template.default_location, "#{Distro.nature}.spec.erb"))
87
96
  end
88
97
 
89
98
  def self.vagrant_plugin_template
90
- file = File.join(Template::default_location, "#{Distro.nature.to_s}-vagrant-plugin.spec.erb")
99
+ file = File.join(Template.default_location, "#{Distro.nature}-vagrant-plugin.spec.erb")
91
100
  Template.new(file)
92
101
  end
93
-
94
102
  end
95
103
 
96
104
  # Local Variables:
@@ -4,6 +4,18 @@ module Gem2Rpm
4
4
  class Configuration
5
5
  include Singleton
6
6
 
7
+ DEFAULT_OPTIONS = {
8
+ :print_template_file => nil,
9
+ :template_file => nil,
10
+ :output_file => nil,
11
+ :local => false,
12
+ :srpm => false,
13
+ :deps => false,
14
+ :nongem => false,
15
+ :doc_subpackage => true,
16
+ :fetch => false,
17
+ }
18
+
7
19
  # The defaults should mostly work
8
20
  DEFAULT_MACROS = {
9
21
  :instdir => '%{gem_instdir}',
@@ -14,20 +26,54 @@ module Gem2Rpm
14
26
  }
15
27
 
16
28
  DEFAULT_RULES = {
17
- :doc => [/\/?CHANGELOG.*/i, /\/?CONTRIBUTING.*/i, /\/?CONTRIBUTORS.*/i,
18
- /\/?AUTHORS.*/i,/\/?README.*/i, /\/?History.*/i, /\/?Release.*/i,
19
- /\/?doc(\/.*)?/, 'NEWS'],
20
- :license => [/\/?MIT/, /\/?GPLv[0-9]+/, /\/?.*LICEN(C|S)E/, /\/?COPYING/],
21
- :ignore => ['.gemtest', '.gitignore', '.travis.yml', '.yardopts', '.rvmrc',
22
- '.rubocop.yml', /^\..*rc$/i],
29
+ :doc => [
30
+ /\/?CHANGELOG.*/i,
31
+ /\/?CONTRIBUTING.*/i,
32
+ /\/?CONTRIBUTORS.*/i,
33
+ /\/?AUTHORS.*/i,
34
+ /\/?README.*/i,
35
+ /\/?History.*/i,
36
+ /\/?Release.*/i,
37
+ /\/?doc(\/.*)?/,
38
+ 'NEWS',
39
+ ],
40
+ :license => [
41
+ /\/?MIT/,
42
+ /\/?GPLv[0-9]+/,
43
+ /\/?.*LICEN(C|S)E/,
44
+ /\/?COPYING/,
45
+ ],
46
+ :ignore => [
47
+ '.gemtest',
48
+ '.gitignore',
49
+ '.travis.yml',
50
+ '.yardopts',
51
+ '.rvmrc',
52
+ '.rubocop.yml',
53
+ /^\..*rc$/i,
54
+ ],
23
55
  # Other files including test files that are not required for
24
56
  # runtime and therefore currently included in -doc
25
- :misc => [/.*.gemspec/, /Gemfile.*/, 'Rakefile', 'rakefile.rb', 'Vagrantfile',
26
- /^spec.*/, /^rspec.*/, /^test(s|)/, /^examples.*/]
57
+ :misc => [
58
+ /.*.gemspec/,
59
+ /Gemfile.*/,
60
+ 'Rakefile',
61
+ 'rakefile.rb',
62
+ 'Vagrantfile',
63
+ /^spec.*/,
64
+ /^rspec.*/,
65
+ /^test(s|)/,
66
+ /^examples.*/,
67
+ ]
27
68
  }
28
69
 
29
- # Set the configuration back to default
30
- def to_default
70
+ def initialize
71
+ @options = nil
72
+ @parser = nil
73
+ end
74
+
75
+ # Set the configuration back to default values
76
+ def reset
31
77
  @_macros = nil
32
78
  @_rules = nil
33
79
  self
@@ -51,5 +97,108 @@ module Gem2Rpm
51
97
  rules[category] ||= ''
52
98
  end
53
99
 
100
+ # Get options.
101
+ def options
102
+ handle_options unless @options
103
+ @options
104
+ end
105
+
106
+ private
107
+
108
+ # Handles list of given options. Use ARGV by default.
109
+ def handle_options(args = ARGV)
110
+ @options = Marshal.load Marshal.dump DEFAULT_OPTIONS # deep copy
111
+ parser.parse!(args)
112
+ @options[:args] = args
113
+ # TODO: Refactor, this is probably not the best palce.
114
+ rescue OptionParser::InvalidOption => e
115
+ $stderr.puts "#{e}\n\n"
116
+ $stderr.puts parser
117
+ exit(1)
118
+ end
119
+
120
+ # Creates an option parser.
121
+ def create_option_parser
122
+ @parser = OptionParser.new
123
+ setup_parser_options
124
+ end
125
+
126
+ # Get parser instance.
127
+ def parser
128
+ create_option_parser unless @parser
129
+ @parser
130
+ end
131
+
132
+ def setup_parser_options
133
+ parser.banner = "Usage: #{$PROGRAM_NAME} [OPTIONS] GEM"
134
+
135
+ parser.separator(' Convert Ruby gems to source RPMs and specfiles.')
136
+ parser.separator(' Uses a template to generate the RPM specfile')
137
+ parser.separator(' from the gem specification.')
138
+
139
+ parser.separator('')
140
+
141
+ parser.separator(' Options:')
142
+
143
+ parser.on('-T', '--current-template', 'Print the current template') do
144
+ options[:print_template_file] = true
145
+ end
146
+
147
+ parser.on('-t', '--template TEMPLATE', 'Use TEMPLATE for the specfile') do |val|
148
+ options[:template_file] = val
149
+ end
150
+
151
+ # TODO: This does not belong here.
152
+ parser.on('--templates', 'List all available templates') do
153
+ puts 'Available templates in #{Gem2Rpm::Template.default_location}:\n\n'
154
+ puts Gem2Rpm::Template.list.map do |t|
155
+ t.gsub(/(.*)\.spec.erb/, '\\1')
156
+ end.join("\n")
157
+ exit 0
158
+ end
159
+
160
+ # TODO: This does not belong here.
161
+ parser.on('-v', '--version', 'Print gem2rpm\'s version and exit') do
162
+ puts Gem2Rpm::VERSION
163
+ exit 0
164
+ end
165
+
166
+ parser.on('-o', '--output FILE', 'Send the specfile to FILE') do |val|
167
+ options[:output_file] = val
168
+ end
169
+
170
+ parser.on('-s', '--srpm', 'Create a source RPM') do
171
+ options[:srpm] = true
172
+ end
173
+
174
+ parser.on('-l', '--local', "Do not retrieve Gem information over
175
+ #{' ' * 22} the network. Use on disconnected machines") do
176
+ options[:local] = true
177
+ end
178
+
179
+ parser.on('-d', '--dependencies', 'Print the dependencies of the gem') do
180
+ options[:deps] = true
181
+ end
182
+
183
+ parser.on('-n', '--nongem', 'Generate a subpackage for non-gem use') do
184
+ options[:nongem] = true
185
+ end
186
+
187
+ parser.on('--no-doc', 'Disable document subpackage') do
188
+ options[:doc_subpackage] = false
189
+ end
190
+
191
+ parser.on('--fetch', 'Fetch the gem from rubygems.org') do
192
+ options[:fetch] = true
193
+ end
194
+
195
+ parser.separator('')
196
+
197
+ parser.separator(' Arguments:')
198
+ parser.separator(' GEM The path to the locally stored gem package file or the name')
199
+ parser.separator(' of the gem when using --fetch.')
200
+
201
+ parser.separator('')
202
+ end
54
203
  end
55
204
  end
@@ -11,7 +11,7 @@ module Gem2Rpm
11
11
  version_requirements # For RubyGems < 1.3.6
12
12
  end
13
13
 
14
- Helpers::requirement_versions_to_rpm r
14
+ Helpers.requirement_versions_to_rpm r
15
15
  end
16
16
 
17
17
  # Dependency type. Needs to be explicitly reimplemented.
@@ -25,10 +25,8 @@ module Gem2Rpm
25
25
  end
26
26
 
27
27
  # Try os-release first.
28
- if os_release_files = grouped_release_files['os-release']
29
- content = File.open(os_release_files.first, Gem2Rpm::OPEN_MODE) do |f|
30
- f.read
31
- end
28
+ if (os_release_files = grouped_release_files['os-release'])
29
+ content = File.open(os_release_files.first, Gem2Rpm::OPEN_MODE, &:read)
32
30
 
33
31
  begin
34
32
  os_release.os = content[/^ID=(.*)$/, 1].to_sym
@@ -40,7 +38,7 @@ module Gem2Rpm
40
38
  # If os-release failed (it is empty or has not enough information),
41
39
  # try some other release files.
42
40
  if os_release.os == DEFAULT
43
- if fedora_release_files = grouped_release_files['fedora']
41
+ if (fedora_release_files = grouped_release_files['fedora'])
44
42
  os_release.os = FEDORA
45
43
  versions = []
46
44
 
@@ -73,7 +71,7 @@ module Gem2Rpm
73
71
  # Provides list of release files found on the system.
74
72
  def self.release_files
75
73
  @release_files ||=
76
- Dir.glob('/etc/{os-release,*{_version,-release}}*').uniq.select {|e| File.file? e}
74
+ Dir.glob('/etc/{os-release,*{_version,-release}}*').uniq.select { |e| File.file? e }
77
75
  end
78
76
 
79
77
  # Allows to override release files list.
@@ -84,13 +82,13 @@ module Gem2Rpm
84
82
 
85
83
  # Tries to find best suitable template for specified os and version.
86
84
  def self.template_by_os_version(os, version)
87
- os_templates = Template.list.grep /#{os}.*\.spec\.erb/
85
+ os_templates = Template.list.grep(/#{os}.*\.spec\.erb/)
88
86
 
89
87
  os_templates.each do |file|
90
88
  # We want only distro RubyGems templates to get the right versions
91
89
  next unless file =~ /^#{os}((-([0-9]+\.{0,1}[0-9]+){0,}){0,}(-(#{ROLLING_RELEASES.join('|')})){0,1}).spec.erb/
92
90
 
93
- if match = Regexp.last_match
91
+ if (match = Regexp.last_match)
94
92
  return file.gsub('.spec.erb', '') if in_range?(version, match[1].to_s.split('-').drop(1)) || match[1].empty?
95
93
  end
96
94
  end
@@ -105,7 +103,7 @@ module Gem2Rpm
105
103
  return true if range.first.to_s == version.to_s
106
104
  else # range: [xx, yy]
107
105
  if range[0].to_s <= version.to_s
108
- return true if ROLLING_RELEASES.include? range[1] or version.to_s <= range[1].to_s
106
+ return true if ROLLING_RELEASES.include?(range[1]) || (version.to_s <= range[1].to_s)
109
107
  end
110
108
  end
111
109
 
@@ -36,13 +36,13 @@ module Gem2Rpm
36
36
  # Converts Gem::Requirement into array of requirements strings compatible
37
37
  # with RPM .spec file.
38
38
  def self.requirement_versions_to_rpm(requirement)
39
- self.expand_requirement(requirement.requirements).map do |op, version|
39
+ expand_requirement(requirement.requirements).map do |op, version|
40
40
  version == Gem::Version.new(0) ? "" : "#{op} #{version}"
41
41
  end
42
42
  end
43
43
 
44
44
  def self.file_entries_to_rpm(entries)
45
- rpm_file_list = entries.map{ |e| self.file_entry_to_rpm(e) }
45
+ rpm_file_list = entries.map { |e| file_entry_to_rpm(e) }
46
46
  rpm_file_list.join("\n")
47
47
  end
48
48
 
@@ -64,7 +64,7 @@ module Gem2Rpm
64
64
 
65
65
  def self.file_entry_to_rpm(entry)
66
66
  config = Gem2Rpm::Configuration.instance
67
- case true
67
+ case
68
68
  when doc_file?(entry)
69
69
  "#{config.macro_for(:doc)} #{config.macro_for(:instdir)}/#{entry}".strip
70
70
  when license_file?(entry)
@@ -82,7 +82,7 @@ module Gem2Rpm
82
82
  # Returns a list of top level directories and files
83
83
  # out of an array of file_list
84
84
  def self.top_level_from_file_list(file_list)
85
- file_list.map{ |f| f.gsub!(/([^\/]*).*/,"\\1") }.uniq
85
+ file_list.map { |f| f.gsub!(/([^\/]*).*/, '\1') }.uniq
86
86
  end
87
87
 
88
88
  # Compares string to the given regexp conditions
@@ -6,7 +6,7 @@ module Gem2Rpm
6
6
  # Find and fetch specs that match +dependency+.
7
7
  #
8
8
  # If +matching_platform+ is false, gems for all platforms are returned.
9
- def spec_for_dependency(dependency, matching_platform=true)
9
+ def spec_for_dependency(dependency, matching_platform = true)
10
10
  super
11
11
  rescue
12
12
  errors = []
@@ -5,24 +5,23 @@ require 'gem2rpm/helpers'
5
5
 
6
6
  module Gem2Rpm
7
7
  class Specification < SimpleDelegator
8
-
9
8
  # A long description of gem wrapped to 78 characters.
10
9
  def description
11
10
  d = super.to_s.chomp
12
11
  d = summary.to_s.chomp if d.empty?
13
12
  d.gsub!(/([^.!?])\Z/, "\\1.")
14
- Helpers::word_wrap(d, 78) + "\n"
13
+ Helpers.word_wrap(d, 78) + "\n"
15
14
  end
16
15
 
17
16
  # A list of Gem::Dependency objects this gem depends on (includes every
18
17
  # runtime or development dependency).
19
18
  def dependencies
20
- super.map {|d| Gem2Rpm::Dependency.new d}
19
+ super.map { |d| Gem2Rpm::Dependency.new d }
21
20
  end
22
21
 
23
22
  # List of dependencies that are used for development.
24
23
  def development_dependencies
25
- super.map {|d| Gem2Rpm::Dependency.new d}
24
+ super.map { |d| Gem2Rpm::Dependency.new d }
26
25
  end
27
26
 
28
27
  # The license(s) for the library. Each license must be a short name,
@@ -36,7 +35,7 @@ module Gem2Rpm
36
35
 
37
36
  # List of dependencies that will automatically be activated at runtime.
38
37
  def runtime_dependencies
39
- super.map {|d| Gem2Rpm::Dependency.new d}
38
+ super.map { |d| Gem2Rpm::Dependency.new d }
40
39
  end
41
40
 
42
41
  # The version of Ruby required by the gem. Returns array with
@@ -53,7 +52,7 @@ module Gem2Rpm
53
52
  # array with empty string. However, this should happen only in rare cases.
54
53
  def required_rubygems_version
55
54
  @required_rubygems_version ||= begin
56
- Helpers::requirement_versions_to_rpm(super)
55
+ Helpers.requirement_versions_to_rpm(super)
57
56
  rescue
58
57
  ['']
59
58
  end
@@ -34,10 +34,10 @@ module Gem2Rpm
34
34
  end
35
35
  else
36
36
  begin
37
- if File.exists?(name)
37
+ if File.exist?(name)
38
38
  Gem2Rpm::Template.new(name)
39
39
  else
40
- Gem2Rpm::Template.new(File.join(Gem2Rpm::Template::default_location, name + '.spec.erb'))
40
+ Gem2Rpm::Template.new(File.join(Gem2Rpm::Template.default_location, name + '.spec.erb'))
41
41
  end
42
42
  rescue TemplateError
43
43
  raise TemplateError, "Could not locate template #{name}"
@@ -48,17 +48,17 @@ module Gem2Rpm
48
48
  # Create instance of Template class of specified template filename.
49
49
  # TemplateError is raised when the template file does not exists.
50
50
  def initialize(filename)
51
- if File.exists? filename
51
+ if File.exist? filename
52
52
  @filename = filename
53
53
  else
54
- raise TemplateError, "Could not locate template #{filename}"
54
+ fail TemplateError, "Could not locate template #{filename}"
55
55
  end
56
56
  end
57
57
 
58
58
  # Read the content of the template file.
59
59
  def read
60
60
  @content ||= begin
61
- File.open(@filename, OPEN_MODE) {|f| f.read }
61
+ File.open(@filename, OPEN_MODE, &:read)
62
62
  end
63
63
  end
64
64
  end
@@ -3,14 +3,14 @@ module Gem2Rpm
3
3
  # File list block for the main package
4
4
  def main_file_entries(spec)
5
5
  entries = Helpers.top_level_from_file_list(spec.files)
6
- entries.delete_if{ |f| Helpers.doc_file?(f) || Helpers.misc_file?(f) }
6
+ entries.delete_if { |f| Helpers.doc_file?(f) || Helpers.misc_file?(f) }
7
7
  Helpers.file_entries_to_rpm(entries)
8
8
  end
9
9
 
10
10
  # File list block for the doc sub-package
11
11
  def doc_file_entries(spec)
12
12
  entries = Helpers.top_level_from_file_list(spec.files)
13
- entries.delete_if{ |f| !(Helpers.doc_file?(f) || Helpers.misc_file?(f)) }
13
+ entries.delete_if { |f| !(Helpers.doc_file?(f) || Helpers.misc_file?(f)) }
14
14
  Helpers.file_entries_to_rpm(entries)
15
15
  end
16
16
 
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.11.2
4
+ version: 0.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Lutterkort
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-08-14 00:00:00.000000000 Z
12
+ date: 2016-04-26 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: |2
15
15
  Generate source rpms and rpm spec files from a Ruby Gem.
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  version: '0'
67
67
  requirements: []
68
68
  rubyforge_project:
69
- rubygems_version: 2.4.8
69
+ rubygems_version: 2.5.1
70
70
  signing_key:
71
71
  specification_version: 4
72
72
  summary: Generate rpm specfiles from gems