Browse files

Merge pull request #74 from tmikoss/master

Make binary installer understand spaces in filename
  • Loading branch information...
2 parents aa8d5c1 + 4fd24d9 commit 37df05108d037b72305a18fa7b51ea3b7e88a96a @crafterm committed Nov 16, 2012
Showing with 28 additions and 16 deletions.
  1. +6 −2 lib/sprinkle/installers/binary.rb
  2. +22 −14 spec/sprinkle/installers/binary_spec.rb
View
8 lib/sprinkle/installers/binary.rb
@@ -24,10 +24,14 @@ def prepare_commands #:nodoc:
def install_commands #:nodoc:
commands = [ "bash -c 'wget -cq --directory-prefix=#{@options[:archives].first} #{@binary_archive}'" ]
- commands << "bash -c 'cd #{@options[:prefix].first} && #{extract_command} #{@options[:archives].first}/#{@binary_archive.split("/").last}'"
+ commands << "bash -c \"cd #{@options[:prefix].first} && #{extract_command} '#{@options[:archives].first}/#{archive_name}'\""
end
- def extract_command(archive_name = @binary_archive.split("/").last)
+ def archive_name
+ @archive_name ||= @binary_archive.split("/").last.gsub('%20', ' ')
+ end
+
+ def extract_command
case archive_name
when /(tar.gz)|(tgz)$/
'tar xzf'
View
36 spec/sprinkle/installers/binary_spec.rb
@@ -3,25 +3,23 @@
describe Sprinkle::Installers::Binary do
include Sprinkle::Deployment
- def create_context
- binary = 'http://www.example.com/archive.tar.gz'
-
+ def create_context(source = 'http://www.example.com/archive.tar.gz')
deployment = deployment do
delivery :capistrano
- binary "http://www.example.com/archive.tar.gz" do
+ binary source do
prefix '/prefix/directory'
archives '/archives/directory'
end
end
- installer = create_binary binary do
+ installer = create_binary source do
prefix '/prefix/directory'
archives '/archives/directory'
end
installer.defaults(@deployment)
-
- [binary, deployment, installer]
+
+ [source, deployment, installer]
end
def create_binary(binary, version = nil, &block)
@@ -33,32 +31,42 @@ def create_binary(binary, version = nil, &block)
before do
@binary, @deployment, @installer = create_context
end
-
+
it "should return mkdir command to create the prefix directory" do
@installer.send(:prepare_commands)[0].should == 'mkdir -p /prefix/directory'
end
it "should return mkdir command to create the archives directory" do
@installer.send(:prepare_commands)[1].should == 'mkdir -p /archives/directory'
end
end
-
-
+
+
describe "binary#install_commands" do
before do
@binary, @deployment, @installer = create_context
end
-
+
it "should return a commands to place the binary in the correct archive directory" do
@installer.send(:install_commands)[0].should =~ /--directory-prefix=\/archives\/directory/
end
-
+
it "should return a command to extract to the correct prefix folder" do
@installer.send(:install_commands)[1].should =~ /cd \/prefix\/directory/
end
it "should return a command to extract the right file in the right directory" do
- @installer.send(:install_commands)[1].should =~ / \/archives\/directory\/archive.tar.gz/
+ @installer.send(:install_commands)[1].should =~ / '\/archives\/directory\/archive.tar.gz'/
end
end
-
+
+ describe "when source contains spaces (%20's) in path" do
+ before do
+ _, _, @installer = create_context('http://c758482.r82.cf2.rackcdn.com/Sublime%20Text%202.0.1%20x64.tar.bz2')
+ end
+
+ it "should correctly interpret the archive filename as it gets extracted downloaded to file system" do
+ @installer.send(:install_commands)[1].should =~ / '\/archives\/directory\/Sublime Text 2.0.1 x64.tar.bz2'/
+ end
+ end
+
end

0 comments on commit 37df051

Please sign in to comment.