<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -146,7 +146,7 @@ module Capistrano
           # Returns the name of the file that the source code will be
           # compressed to.
           def filename
-            @filename ||= File.join(tmpdir, &quot;#{File.basename(destination)}.#{compression_extension}&quot;)
+            @filename ||= File.join(tmpdir, &quot;#{File.basename(destination)}.#{compression.extension}&quot;)
           end
 
           # The directory to which the copy should be checked out
@@ -166,46 +166,33 @@ module Capistrano
             @remote_filename ||= File.join(remote_dir, File.basename(filename))
           end
 
+          # A struct for representing the specifics of a compression type.
+          # Commands are arrays, where the first element is the utility to be
+          # used to perform the compression or decompression.
+          Compression = Struct.new(:extension, :compress_command, :decompress_command)
+          
           # The compression method to use, defaults to :gzip.
           def compression
-            configuration[:copy_compression] || :gzip
-          end
-
-          # Returns the file extension used for the compression method in
-          # question.
-          def compression_extension
-            case compression
-            when :gzip, :gz   then &quot;tar.gz&quot;
-            when :bzip2, :bz2 then &quot;tar.bz2&quot;
-            when :zip         then &quot;zip&quot;
-            else raise ArgumentError, &quot;invalid compression type #{compression.inspect}&quot;
+            type = configuration[:copy_compression] || :gzip
+            case type
+            when :gzip, :gz   then Compression.new(&quot;tar.gz&quot;,  %w(tar czf), %w(tar xzf))
+            when :bzip2, :bz2 then Compression.new(&quot;tar.bz2&quot;, %w(tar cjf), %w(tar xjf))
+            when :zip         then Compression.new(&quot;zip&quot;,     %w(zip -qr), %w(unzip -q))
+            else raise ArgumentError, &quot;invalid compression type #{type.inspect}&quot;
             end
           end
-
+          
           # Returns the command necessary to compress the given directory
-          # into the given file. The command is returned as an array, where
-          # the first element is the utility to be used to perform the compression.
+          # into the given file.
           def compress(directory, file)
-            case compression
-            when :gzip, :gz   then [&quot;tar&quot;, &quot;czf&quot;, file, directory]
-            when :bzip2, :bz2 then [&quot;tar&quot;, &quot;cjf&quot;, file, directory]
-            when :zip         then [&quot;zip&quot;, &quot;-qr&quot;, file, directory]
-            else raise ArgumentError, &quot;invalid compression type #{compression.inspect}&quot;
-            end
+            compression.compress_command + [file, directory]
           end
 
           # Returns the command necessary to decompress the given file,
           # relative to the current working directory. It must also
-          # preserve the directory structure in the file. The command is returned
-          # as an array, where the first element is the utility to be used to
-          # perform the decompression.
+          # preserve the directory structure in the file.
           def decompress(file)
-            case compression
-            when :gzip, :gz   then [&quot;tar&quot;, &quot;xzf&quot;, file]
-            when :bzip2, :bz2 then [&quot;tar&quot;, &quot;xjf&quot;, file]
-            when :zip         then [&quot;unzip&quot;, &quot;-q&quot;, file]
-            else raise ArgumentError, &quot;invalid compression type #{compression.inspect}&quot;
-            end
+            compression.decompress_command + [file]
           end
       end
 </diff>
      <filename>lib/capistrano/recipes/deploy/strategy/copy.rb</filename>
    </modified>
    <modified>
      <diff>@@ -86,7 +86,17 @@ class DeployStrategyCopyTest &lt; Test::Unit::TestCase
 
     @strategy.deploy!
   end
-
+  
+  def test_deploy_with_unknown_compression_should_error_on_extension
+    @config[:copy_compression] = :bogus
+    Dir.expects(:tmpdir).returns(&quot;/temp/dir&quot;)
+    @source.expects(:checkout).with(&quot;154&quot;, &quot;/temp/dir/1234567890&quot;).returns(:local_checkout)
+    @strategy.stubs(:system)
+    File.stubs(:open)
+    
+    assert_raises(ArgumentError) { @strategy.deploy! }
+  end
+  
   def test_deploy_with_custom_copy_dir_should_use_that_as_tmpdir
     Dir.expects(:tmpdir).never
     Dir.expects(:chdir).with(&quot;/other/path&quot;).yields</diff>
      <filename>test/deploy/strategy/copy_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e3844726613d39659804d9f1a2f3423dd6596106</id>
    </parent>
  </parents>
  <author>
    <name>Ryan McGeary</name>
    <email>ryanongit@mcgeary.org</email>
  </author>
  <url>http://github.com/jamis/capistrano/commit/ebe3d9eecb4724736125845424a2608a6c90e644</url>
  <id>ebe3d9eecb4724736125845424a2608a6c90e644</id>
  <committed-date>2008-05-12T20:36:51-07:00</committed-date>
  <authored-date>2008-05-12T20:36:51-07:00</authored-date>
  <message>Improved test coverage for copy strategy compression.
DRY'd up the compression type lookups and invalid compression type error handling.</message>
  <tree>c133ff50c91591d2cb23215af543422b13b8c8b4</tree>
  <committer>
    <name>Ryan McGeary</name>
    <email>ryanongit@mcgeary.org</email>
  </committer>
</commit>
