Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Ewoud Kohl van Wijngaarden <[email protected]>
  • Loading branch information
dcermak and ekohl authored Jul 7, 2022
1 parent c9eb1ca commit 1595078
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions bin/gem2rpm
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,9 @@ end
rest = options[:args]

template = nil
if template_file.nil?
f = open('/etc/os-release', 'r') if File.exists?('/etc/os-release')
if f
f.read.split('\n').each do |line|
line.match(%r{^ID=(.*)$}) { |m| template_file=m[1] }
end
f.close
f = nil
if template_file.nil? && File.exist?('/etc/os-release')
File.read('/etc/os-release').each_line(chomp: true) do |line|
line.match(%r{^ID=(.*)$}) { |m| template_file=m[1] }
end
if template_file.match? '^"opensuse'
$stderr.puts 'Using template opensuse on openSUSE variant'
Expand All @@ -44,15 +39,13 @@ end
if template_file.nil?
template = Gem2Rpm::TEMPLATE
else
template_file = File.join(Gem2Rpm.template_dir, template_file + '.spec.erb') unless File.exist?(template_file)
begin
f = open(template_file, 'r') if File.exists?(template_file)
f = open(File.join(Gem2Rpm.template_dir, template_file + '.spec.erb'), 'r') unless f
template = File.read(template_file)
rescue Errno::ENOENT
$stderr.puts "Could not open template #{template_file}. Aborting"
exit(1)
end
template = f.read
f.close
end

if options[:print_template_file]
Expand Down

0 comments on commit 1595078

Please sign in to comment.