Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change fedora template for range of dependencies #95

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/gem2rpm/rpm_dependency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,23 @@ def to_rpm
end
rpm_dependencies.join("\n")
end

def with_range_of_dependencies
dep = __getobj__.dup

rpm_dependencies = requirement.map do |version|
next if version && version.to_s.empty?
[dep.name, version].compact.join(' ')
end
dependencies_string = rpm_dependencies.compact.uniq.join(' with ')
dependencies_string = '(' << dependencies_string << ')' if requirement.size > 1

dep.name = dependencies_string
self.class.new dep
end

def to_string
name.to_s
end
end
end
11 changes: 11 additions & 0 deletions lib/gem2rpm/rpm_dependency_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,16 @@ def to_rpm
s = entries.map(&:to_rpm).join("\n")
s += "\n" unless s.empty?
end

def with_range_of_dependencies
dep_list = self.map(&:with_range_of_dependencies)

self.class.new dep_list
end

def to_string
s = entries.map(&:to_string).join("\n")
s += "\n" unless s.empty?
end
end
end
2 changes: 1 addition & 1 deletion templates/fedora-27-rawhide.spec.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ BuildRequires: gcc
<% end -%>
<%= development_dependencies.reject do |d|
["rdoc", "rake", "bundler"].include? d.name
end.virtualize.with_requires.comment_out.to_rpm -%>
end.virtualize.with_range_of_dependencies.with_requires.comment_out.to_string -%>
<% if spec.extensions.empty? -%>
BuildArch: noarch
<% end -%>
Expand Down
2 changes: 1 addition & 1 deletion test/templates/test_fedora.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_exclude_extension_directory
end

def test_build_requires
assert_match(/^# BuildRequires: rubygem\(test_development\) >= 1\.0\.0$/, @out_string)
assert_match(/^# BuildRequires: \(rubygem\(test_development\) >= 1.0 with rubygem\(test_development\) < 2 with rubygem\(test_development\) >= 1.0.0\)/, @out_string)
end

def test_rubygems_is_not_required
Expand Down