[DRE-commits] [gem2deb] 02/06: gem2tgz: fix full path handling when generating tarball name
Antonio Terceiro
terceiro at moszumanska.debian.org
Mon Dec 2 13:03:21 UTC 2013
This is an automated email from the git hooks/post-receive script.
terceiro pushed a commit to branch master
in repository gem2deb.
commit c4b3bcdce224d1c587745b96d9f7b7dc692d0be2
Author: Antonio Terceiro <terceiro at debian.org>
Date: Mon Dec 2 09:18:35 2013 -0300
gem2tgz: fix full path handling when generating tarball name
Closes: #730854
---
lib/gem2deb/gem2tgz.rb | 7 ++++++-
test/unit/gem2tgz_test.rb | 11 +++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/lib/gem2deb/gem2tgz.rb b/lib/gem2deb/gem2tgz.rb
index f40cd8c..53092a6 100644
--- a/lib/gem2deb/gem2tgz.rb
+++ b/lib/gem2deb/gem2tgz.rb
@@ -41,10 +41,15 @@ module Gem2Deb
@gem_full_path = File.expand_path(gem)
@tarball = tarball
if @tarball.nil?
+ path = File.dirname(@gem)
+ filename = File.basename(@gem)
+
# the _ -> - substitution is required because '_' is invalid
# in Debian packages names
# same for downcase
- @tarball = @gem.gsub(@ext, '.tar.gz').gsub(/_/,'-').downcase
+ filename = filename.gsub(@ext, '.tar.gz').gsub(/_/,'-').downcase
+
+ @tarball = File.join(path, filename)
end
@tarball_full_path = File.expand_path(@tarball)
@target_dirname = File::basename(@tarball).gsub('.tar.gz', '')
diff --git a/test/unit/gem2tgz_test.rb b/test/unit/gem2tgz_test.rb
index c974ac0..1aaddbc 100644
--- a/test/unit/gem2tgz_test.rb
+++ b/test/unit/gem2tgz_test.rb
@@ -78,4 +78,15 @@ class Gem2TgzTest < Gem2DebTestCase
end
end
+ should 'not mess with the full path' do
+ testdir = File.join(tmpdir, 'Downloads') # uppercase
+ FileUtils.mkdir_p(testdir)
+ FileUtils.cp(SIMPLE_GEM, testdir)
+ gem = File.join(testdir, File.basename(SIMPLE_GEM))
+ tarball = gem.gsub('.gem', '.tar.gz')
+
+ Gem2Deb::Gem2Tgz.new(gem).convert!
+ assert File.exists?(tarball)
+ end
+
end
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/gem2deb.git
More information about the Pkg-ruby-extras-commits
mailing list