<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Ruby: Unzipping a file using rubyzip</title>
	<atom:link href="http://www.markhneedham.com/blog/2008/10/02/ruby-unzipping-a-file-using-rubyzip/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markhneedham.com/blog/2008/10/02/ruby-unzipping-a-file-using-rubyzip/</link>
	<description>Thoughts on Software Development</description>
	<lastBuildDate>Sat, 11 Feb 2012 23:17:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Aninda</title>
		<link>http://www.markhneedham.com/blog/2008/10/02/ruby-unzipping-a-file-using-rubyzip/comment-page-1/#comment-39780</link>
		<dc:creator>Aninda</dc:creator>
		<pubDate>Sun, 20 Jun 2010 18:05:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=407#comment-39780</guid>
		<description>Hi Mark,
Thanks for your example. I was wondering how you would deal with the scenario that you have a zip file within a zip file?</description>
		<content:encoded><![CDATA[<p>Hi Mark,<br />
Thanks for your example. I was wondering how you would deal with the scenario that you have a zip file within a zip file?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Larkin</title>
		<link>http://www.markhneedham.com/blog/2008/10/02/ruby-unzipping-a-file-using-rubyzip/comment-page-1/#comment-19837</link>
		<dc:creator>Michael Larkin</dc:creator>
		<pubDate>Thu, 09 Jul 2009 03:55:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=407#comment-19837</guid>
		<description>Thanks!  This was a great example.

I added a next unless f.file? to skip directories (they&#039;re created automatically by the mkdir_p call) as well as filtering out the junk files like .DS_STORE, Thumbs.db, __MAC_OSX and such.</description>
		<content:encoded><![CDATA[<p>Thanks!  This was a great example.</p>
<p>I added a next unless f.file? to skip directories (they&#8217;re created automatically by the mkdir_p call) as well as filtering out the junk files like .DS_STORE, Thumbs.db, __MAC_OSX and such.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: grosser</title>
		<link>http://www.markhneedham.com/blog/2008/10/02/ruby-unzipping-a-file-using-rubyzip/comment-page-1/#comment-7937</link>
		<dc:creator>grosser</dc:creator>
		<pubDate>Wed, 04 Feb 2009 06:59:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=407#comment-7937</guid>
		<description>here comes the reverse example: 
packing a folder to a zip file

http://pragmatig.wordpress.com/2009/02/04/compressing-a-folder-to-a-zip-archive-with-ruby/</description>
		<content:encoded><![CDATA[<p>here comes the reverse example:<br />
packing a folder to a zip file</p>
<p><a href="http://pragmatig.wordpress.com/2009/02/04/compressing-a-folder-to-a-zip-archive-with-ruby/" rel="nofollow">http://pragmatig.wordpress.com/2009/02/04/compressing-a-folder-to-a-zip-archive-with-ruby/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://www.markhneedham.com/blog/2008/10/02/ruby-unzipping-a-file-using-rubyzip/comment-page-1/#comment-628</link>
		<dc:creator>John</dc:creator>
		<pubDate>Mon, 06 Oct 2008 17:00:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=407#comment-628</guid>
		<description>Mark, another problem is when you want to make a ZIP on, say, a Windows system that doesn&#039;t have Cygwin. In other words, no native ZIP. Without a native ZIP (that understand -r) you also can&#039;t do rake package (unless things have changed recently). Here&#039;s a hack at making a ZIP from Ruby. I would love to have a more robust version of this.

# Drop-in for zip for those who don&#039;t have one on their systems.
# For this, you will first need to
#   gem install rubyzip
#

require &#039;rubygems&#039;
require &#039;zip/zip&#039;

recursive = false
if ARGV[0] == &#039;-r&#039;
  recursive = true
  ARGV.shift
end

archive = ARGV.shift
ARGV.each do &#124;arg&#124;
  files = recursive ? Dir[ arg + &#039;/**/*.*&#039; ] : [arg]
  files.each do &#124;f&#124;
    Zip::ZipFile.open(archive, Zip::ZipFile::CREATE) do &#124;z&#124;
      begin
        z.remove(f)
      rescue
      end
      entry = f.dup
      # blech
      if (entry[0..1] == &#039;./&#039;)
        entry = entry[2..-1]
      end
      z.add(entry, f)
      puts &quot;  adding #{f}&quot;
    end
  end
end</description>
		<content:encoded><![CDATA[<p>Mark, another problem is when you want to make a ZIP on, say, a Windows system that doesn&#8217;t have Cygwin. In other words, no native ZIP. Without a native ZIP (that understand -r) you also can&#8217;t do rake package (unless things have changed recently). Here&#8217;s a hack at making a ZIP from Ruby. I would love to have a more robust version of this.</p>
<p># Drop-in for zip for those who don&#8217;t have one on their systems.<br />
# For this, you will first need to<br />
#   gem install rubyzip<br />
#</p>
<p>require &#8216;rubygems&#8217;<br />
require &#8216;zip/zip&#8217;</p>
<p>recursive = false<br />
if ARGV[0] == &#8216;-r&#8217;<br />
  recursive = true<br />
  ARGV.shift<br />
end</p>
<p>archive = ARGV.shift<br />
ARGV.each do |arg|<br />
  files = recursive ? Dir[ arg + '/**/*.*' ] : [arg]<br />
  files.each do |f|<br />
    Zip::ZipFile.open(archive, Zip::ZipFile::CREATE) do |z|<br />
      begin<br />
        z.remove(f)<br />
      rescue<br />
      end<br />
      entry = f.dup<br />
      # blech<br />
      if (entry[0..1] == &#8216;./&#8217;)<br />
        entry = entry[2..-1]<br />
      end<br />
      z.add(entry, f)<br />
      puts &#8221;  adding #{f}&#8221;<br />
    end<br />
  end<br />
end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg</title>
		<link>http://www.markhneedham.com/blog/2008/10/02/ruby-unzipping-a-file-using-rubyzip/comment-page-1/#comment-574</link>
		<dc:creator>Greg</dc:creator>
		<pubDate>Thu, 02 Oct 2008 22:36:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=407#comment-574</guid>
		<description>http://blog.thoughtfolder.com/code/e.rb

unzips any file on linux</description>
		<content:encoded><![CDATA[<p><a href="http://blog.thoughtfolder.com/code/e.rb" rel="nofollow">http://blog.thoughtfolder.com/code/e.rb</a></p>
<p>unzips any file on linux</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://www.markhneedham.com/blog/2008/10/02/ruby-unzipping-a-file-using-rubyzip/comment-page-1/#comment-563</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Thu, 02 Oct 2008 05:24:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=407#comment-563</guid>
		<description>&quot;calling a binary from ruby isn&#039;t exactly kosher&quot;.  Sure it is, just make sure to properly check stdout and stderr as needed to make sure everything went as planned.</description>
		<content:encoded><![CDATA[<p>&#8220;calling a binary from ruby isn&#8217;t exactly kosher&#8221;.  Sure it is, just make sure to properly check stdout and stderr as needed to make sure everything went as planned.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lisa Seelye</title>
		<link>http://www.markhneedham.com/blog/2008/10/02/ruby-unzipping-a-file-using-rubyzip/comment-page-1/#comment-560</link>
		<dc:creator>Lisa Seelye</dc:creator>
		<pubDate>Wed, 01 Oct 2008 20:36:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=407#comment-560</guid>
		<description>You&#039;re better off just piping to your local unzip binary. The rubyzip library isn&#039;t very well made (even though it seems like the only thing we have) and the native unzip binary is just so powerful that it makes sense to harness it, even though calling a binary from ruby isn&#039;t exactly kosher.</description>
		<content:encoded><![CDATA[<p>You&#8217;re better off just piping to your local unzip binary. The rubyzip library isn&#8217;t very well made (even though it seems like the only thing we have) and the native unzip binary is just so powerful that it makes sense to harness it, even though calling a binary from ruby isn&#8217;t exactly kosher.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

