Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #97 from edmundoa/multi-platform

Fix support for platform dependent gems
  • Loading branch information...
commit c5c369a8a31e5b4b498be58de43956518c887d13 2 parents bf31d46 + 02fc7bd
@cwninja cwninja authored
View
7 lib/geminabox/incoming_gem.rb
@@ -42,7 +42,12 @@ def spec
end
def name
- "#{spec.name}-#{spec.version}.gem"
+ unless @name
+ filename = %W[#{spec.name} #{spec.version}]
+ filename.push(spec.platform) if spec.platform && spec.platform != "ruby"
+ @name = filename.join("-") + ".gem"
+ end
+ @name
end
def dest_filename
View
12 test/test_support/gem_factory.rb
@@ -8,9 +8,10 @@ def initialize(path)
end
def gem(name, options = {})
- version = options[:version] || "1.0.0"
+ version = options[:version] || "1.0.0"
+ platform = options[:platform] || "ruby"
- dependincies = options.fetch(:deps, {}).collect do |dep, requirement|
+ dependencies = options.fetch(:deps, {}).collect do |dep, requirement|
dep = [*dep]
gem(*dep)
if requirement
@@ -21,7 +22,9 @@ def gem(name, options = {})
end.join("\n")
name = name.to_s
- path = @path.join("#{name}-#{version}.gem")
+ filename = %W[#{name} #{version}]
+ filename.push(platform) if platform != "ruby"
+ path = @path.join("#{filename.join("-")}.gem")
FileUtils.mkdir_p File.dirname(path)
unless File.exists? path
@@ -29,11 +32,12 @@ def gem(name, options = {})
Gem::Specification.new do |s|
s.name = #{name.inspect}
s.version = #{version.inspect}
+ s.platform = #{platform.inspect}
s.summary = #{name.inspect}
s.description = s.summary + " description"
s.author = 'Test'
s.files = []
- #{dependincies}
+ #{dependencies}
end
}
View
5 test/units/gem_version_collection_test.rb
@@ -13,12 +13,13 @@ def test_it_groups_by_name
subject = GIB::GemVersionCollection.new([
['foo', '1.2.3', 'ruby'],
['foo', '1.2.4', 'ruby'],
- ['bar', '1.2.4', 'ruby']
+ ['bar', '1.2.4', 'ruby'],
+ ['foo', '1.2.4', 'x86_amd64-linux'],
])
actual = Hash[subject.by_name]
assert_equal GIB::GemVersionCollection, actual['foo'].class
- assert_equal 2, actual['foo'].size
+ assert_equal 3, actual['foo'].size
assert_equal 1, actual['bar'].size
end
View
7 test/units/incoming_gem_test.rb
@@ -31,6 +31,13 @@ class IncomingGemTest < MiniTest::Unit::TestCase
assert_equal "example-1.0.0.gem", subject.name
end
+ test "#name for platform dependent gem" do
+ file = File.open(GemFactory.gem_file(:example, :platform => "x86_64-linux"))
+ subject = Geminabox::IncomingGem.new(file)
+
+ assert_equal "example-1.0.0-x86_64-linux.gem", subject.name
+ end
+
test "#dest_filename" do
file = File.open(GemFactory.gem_file(:example))
subject = Geminabox::IncomingGem.new(file, "/root/path")
Please sign in to comment.
Something went wrong with that request. Please try again.