<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Akbloom's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 04:17:27 GMT</pubDate>
    <description>DZone Snippets: Akbloom's Code Snippets</description>
    <item>
      <title>rcov rake task for rails project</title>
      <link>http://snippets.dzone.com/posts/show/4525</link>
      <description>This task will create a folder (doc/coverage) then run all of your tests and produce HTML with code coverage information in that folder. If you are on a mac it will even open the index.html file up for you automatically&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# this requires the RCOV gem to be installed on your system&lt;br /&gt;namespace :test do&lt;br /&gt;  desc "Generate code coverage with rcov"&lt;br /&gt;  task :coverage do&lt;br /&gt;    rm_f "doc/coverage/coverage.data"&lt;br /&gt;    rm_f "doc/coverage"&lt;br /&gt;    mkdir "doc/coverage"&lt;br /&gt;    rcov = %(rcov --rails --aggregate doc/coverage/coverage.data --text-summary -Ilib --html -o doc/coverage test/**/*_test.rb)&lt;br /&gt;    system rcov&lt;br /&gt;    system "open doc/coverage/index.html" if PLATFORM['darwin']&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 11 Sep 2007 16:13:45 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4525</guid>
      <author>akbloom (Andrew Bloom)</author>
    </item>
    <item>
      <title>Usefull Additions to the Hash Class</title>
      <link>http://snippets.dzone.com/posts/show/4519</link>
      <description>Rename keys and return a duplicate hash, or perform the method and modify the current hash.&lt;br /&gt;Check each value in the hash and return true if they are all empty, otherwise return false.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class Hash&lt;br /&gt;  def rename_key(old_key, new_key)&lt;br /&gt;    return Hash.rename_key(self.dup, old_key, new_key)&lt;br /&gt;  end&lt;br /&gt;  &lt;br /&gt;  def rename_key!(old_key, new_key)&lt;br /&gt;    return Hash.rename_key(self, old_key, new_key)&lt;br /&gt;  end&lt;br /&gt;  &lt;br /&gt;  def all_values_empty?&lt;br /&gt;    self.each_value do |v|&lt;br /&gt;      return false if v and v != ""&lt;br /&gt;    end&lt;br /&gt;    &lt;br /&gt;    return true&lt;br /&gt;  end&lt;br /&gt;  &lt;br /&gt;  private&lt;br /&gt;    def self.rename_key(hsh, old_key, new_key)&lt;br /&gt;      hsh[new_key.to_s] = hsh.delete(old_key.to_s)&lt;br /&gt;      return hsh&lt;br /&gt;    end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 10 Sep 2007 21:01:10 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4519</guid>
      <author>akbloom (Andrew Bloom)</author>
    </item>
  </channel>
</rss>
