<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Postmodern's Blog</title>
  <link href="http://postmodern.github.io/atom.xml" rel="self" />
  <link href="http://postmodern.github.io/" />
  <updated>2013-04-17T22:24:54-07:00</updated>
  <id>http://postmodern.github.io/</id>
  
  <entry>
    <title>It's simple, we kill eval</title>
    <link href="http://postmodern.github.io/2013/03/07/its-simple-we-kill-eval.html" />
    <updated>2013-03-07T00:00:00-08:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2013/03/07/its-simple-we-kill-eval.html</id>
    <content type="html">&lt;p&gt;&lt;img class=&quot;span-18&quot; src=&quot;/images/2013/03/07/its-simple-we-kill-eval/joker.jpg&quot; alt=&quot;It's simple, we kill eval()&quot;/&gt;&lt;/p&gt;

&lt;h2&gt;... with define_method&lt;/h2&gt;

&lt;p&gt;In &lt;a href=&quot;https://twitter.com/tenderlove&quot;&gt;@tenderlove&lt;/a&gt;'s blog post on &lt;a href=&quot;http://tenderlovemaking.com/2013/03/03/dynamic_method_definitions.html&quot;&gt;dynamic method definitions&lt;/a&gt;, he dispels the
old myth that &lt;code&gt;define_method&lt;/code&gt; is slower than &lt;code&gt;module_eval&lt;/code&gt;/&lt;code&gt;class_eval&lt;/code&gt;.
This myth has caused Ruby developers to prefer using &lt;code&gt;module_eval&lt;/code&gt;/&lt;code&gt;class_eval&lt;/code&gt;
with String substitution to dynamically define methods:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def define_custom_reader(name)
  module_eval %{
    def #{name}
      get_data(&quot;#{name}&quot;)
    end
  }
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The problem with the above code is that if user-input is passed to
&lt;code&gt;define_custom_reader&lt;/code&gt;, it allows an attacker to inject arbitrary Ruby code.
If we rewrite the above code using &lt;code&gt;define_method&lt;/code&gt;, we prevent code injection:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def define_custom_reader(name)
  define_method name do
    get_data(name)
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now &lt;code&gt;define_custom_reader&lt;/code&gt; will define a method using &lt;code&gt;name&lt;/code&gt;, and when the
method is called it will call &lt;code&gt;get_data&lt;/code&gt; with &lt;code&gt;name&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Why doesn't every Rubyist use &lt;code&gt;define_method&lt;/code&gt;? One reason was the myth about
the performance impact. The other was that blocks could not accept other blocks
in 1.8.x. This prevented Rubyists from using &lt;code&gt;define_method&lt;/code&gt; to define methods
that accept blocks. However, blocks &lt;em&gt;can&lt;/em&gt; accept other blocks in 1.9.x:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;define_method name do |&amp;amp;block|
  value = get_data(name)
  block.call(value) if block
  value
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Given that Ruby 1.8.7 will officially reach &lt;a href=&quot;https://blog.engineyard.com/2012/ruby-1-8-7-and-ree-end-of-life&quot;&gt;End-of-Life&lt;/a&gt; in June,
Ruby developers &lt;em&gt;should&lt;/em&gt; be upgrading to Ruby 1.9.3 or 2.0.0.
In fact, according to RubyGems.org &lt;a href=&quot;https://twitter.com/drbrain/status/301884264214065152&quot;&gt;statistics&lt;/a&gt; the majority of Rubyists
have already upgraded to 1.9.x. There is no excuse not to use &lt;code&gt;define_method&lt;/code&gt;
for your metaprogramming needs.&lt;/p&gt;

&lt;h2&gt;Some other things you don't need eval for&lt;/h2&gt;

&lt;p&gt;Injecting reader/writer methods:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;module Mixin
  attr_accessor :foo
end

class Base
  include Mixin
end

obj.extend Mixin
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Defining Constants:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;klass.const_set(:FOO,foo)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Setting Instance Variables:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;obj.instance_variable_set('@foo',foo)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Setting Class Variables:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;klass.class_variable_set('@@foo',foo)
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;metaid.rb&lt;/h2&gt;

&lt;p&gt;As depicted above &lt;code&gt;define_method&lt;/code&gt; works great for defining instance methods.
If you want to define class methods with &lt;code&gt;define_method&lt;/code&gt;, you must open
the metaclass:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class &amp;lt;&amp;lt; self
  define_method name do
    # ...
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;class &amp;lt;&amp;lt; self&lt;/code&gt; syntax can be cumbersome. To alleviate this, there are
a set of helper methods called [metaid]:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;meta_def name do
  # ...
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Much cleaner!&lt;/p&gt;

&lt;h2&gt;It's time to kill eval&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;eval&lt;/code&gt; is a security risk and is not necessary in most cases. It is time to
&lt;del&gt;kill&lt;/del&gt; eradicate &lt;code&gt;eval&lt;/code&gt; from our code-bases, before it causes another
embarrassing Remote Code Execution (RCE) vulnerability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Challenge:&lt;/strong&gt; grep through as much Ruby code as possible looking for
&lt;code&gt;_eval [%\&quot;]&lt;/code&gt;, and replace as many instances as possible with &lt;code&gt;define_method&lt;/code&gt;,
const_set&lt;code&gt;,&lt;/code&gt;class_variable_set&lt;code&gt;,&lt;/code&gt;instance_variable_set&lt;code&gt;or even
&lt;/code&gt;*_eval` with a block:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ egrep -r &quot;_eval [%\&quot;&amp;lt;]&quot; */lib/
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  
  <entry>
    <title>RubyGems Tasks</title>
    <link href="http://postmodern.github.io/2012/05/22/rubygems-tasks.html" />
    <updated>2012-05-22T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2012/05/22/rubygems-tasks.html</id>
    <content type="html">&lt;div class=&quot;warning&quot;&gt;
  &lt;h3&gt;Warning: Controversial Content&lt;/h3&gt;

  &lt;p&gt;
  If you are morally or ethically opposed to building/releasing Ruby Gems
  with &lt;code&gt;rake&lt;/code&gt;, this blog post may anger you. If this is the case,
  you are advised to STOP READING and CLICK THE BACK BUTTON.
  &lt;/p&gt;
&lt;/div&gt;


&lt;p&gt;Ever since we could release Ruby Gems, we have had Gem helpers that
could generate new projects and provided Rake tasks to automate the
building/publishing of Gems. The most popular of these Gem helpers were &lt;a href=&quot;http://www.zenspider.com/projects/hoe.html&quot;&gt;Hoe&lt;/a&gt;
and &lt;a href=&quot;https://github.com/technicalpickles/jeweler#readme&quot;&gt;Jeweler&lt;/a&gt;. Both &lt;a href=&quot;http://www.zenspider.com/projects/hoe.html&quot;&gt;Hoe&lt;/a&gt; and &lt;a href=&quot;https://github.com/technicalpickles/jeweler#readme&quot;&gt;Jeweler&lt;/a&gt; required a certain project layout and
imposed a certain workflow onto the developer.&lt;/p&gt;

&lt;p&gt;Sometime before the &lt;a href=&quot;http://yehudakatz.com/2010/09/30/bundler-as-simple-as-what-you-did-before/&quot;&gt;introduction&lt;/a&gt; of &lt;a href=&quot;http://gembundler.com&quot;&gt;Bundler&lt;/a&gt;, Yehuda Katz &lt;a href=&quot;http://yehudakatz.com/2010/04/02/using-gemspecs-as-intended/&quot;&gt;proposed&lt;/a&gt;
a radically simpler way of building Gems, using the &lt;a href=&quot;http://docs.rubygems.org/read/chapter/20&quot;&gt;gemspec&lt;/a&gt; file.
Developers could use the built-in &lt;code&gt;gem build&lt;/code&gt; command to build a &lt;code&gt;.gem&lt;/code&gt; file
from a &lt;code&gt;.gemspec&lt;/code&gt;, and use the &lt;code&gt;gem push&lt;/code&gt; command to publish the Gem to
&lt;a href=&quot;https://rubygems.org/&quot;&gt;rubygems.org&lt;/a&gt;. This marked the start of an exodus of sorts,
away from using Gem helpers such as &lt;a href=&quot;http://www.zenspider.com/projects/hoe.html&quot;&gt;Hoe&lt;/a&gt; and &lt;a href=&quot;https://github.com/technicalpickles/jeweler#readme&quot;&gt;Jeweler&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;All you need is a Gemspec?&lt;/h2&gt;

&lt;p&gt;With the advent of building gems from a &lt;code&gt;.gemspec&lt;/code&gt;, a vocal minority formed
within the Ruby community. They proclaimed that all one needs is a gemspec,
and that all other tools (&lt;a href=&quot;http://www.zenspider.com/projects/hoe.html&quot;&gt;Hoe&lt;/a&gt;, &lt;a href=&quot;https://github.com/technicalpickles/jeweler#readme&quot;&gt;Jeweler&lt;/a&gt;, &lt;a href=&quot;http://gembundler.com&quot;&gt;Bundler&lt;/a&gt; and even &lt;a href=&quot;http://rake.rubyforge.org/&quot;&gt;Rake&lt;/a&gt;)
are now obsolete!&lt;/p&gt;

&lt;p&gt;Let us take a look at how they might release a Gem:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ git status
$ git push
$ gem build my_project.gemspec
$ gem push my_project-1.2.3.gem
$ git tag 1.2.3
$ git push --tags
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It takes roughly &lt;strong&gt;six&lt;/strong&gt; commands to release a Gem to &lt;a href=&quot;https://rubygems.org/&quot;&gt;rubygems.org&lt;/a&gt;.
A developer must remember to run each of these six commands, in order,
every time they release a new version of their Gem. The possibility for human
error increases.&lt;/p&gt;

&lt;p&gt;In fact, I have found Gems that contained newer source-code than their Git
repository; because the developer forgot to commit or push the changes
before pushing the Gem. I have also found Git repositories with no tags,
making it difficult to review what exactly changed between versions.&lt;/p&gt;

&lt;p&gt;Now, let us see how developers release gems using &lt;a href=&quot;http://rake.rubyforge.org/&quot;&gt;Rake&lt;/a&gt; tasks:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ rake release
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That's it! That one command will run each of the above &lt;strong&gt;six&lt;/strong&gt; commands.
If any of the commands fail, the release process will halt.
If there are uncommitted changes, the release process will halt.
The possibility for human error has been greatly minimized.&lt;/p&gt;

&lt;h2&gt;Alternatives&lt;/h2&gt;

&lt;p&gt;Having used &lt;a href=&quot;http://www.zenspider.com/projects/hoe.html&quot;&gt;Hoe&lt;/a&gt;, &lt;a href=&quot;https://github.com/technicalpickles/jeweler#readme&quot;&gt;Jeweler&lt;/a&gt; and then &lt;a href=&quot;http://gembundler.com&quot;&gt;Bundler&lt;/a&gt;, I missed some of the
workflow provided by these Gem helpers. So I began searching for lightweight
alternatives.&lt;/p&gt;

&lt;p&gt;I looked at &lt;a href=&quot;http://rubygems.rubyforge.org/rubygems-update/Gem/PackageTask.html&quot;&gt;Gem::PackageTask&lt;/a&gt;, &lt;a href=&quot;https://github.com/sr/mg#readme&quot;&gt;MG&lt;/a&gt;, &lt;a href=&quot;https://github.com/svenfuchs/gem-release#readme&quot;&gt;gem release&lt;/a&gt; and even
&lt;a href=&quot;https://github.com/bundler/bundler/blob/master/lib/bundler/gem_helper.rb&quot;&gt;bundler/gem_helper&lt;/a&gt;. Unfortunately they all were missing various features.
&lt;a href=&quot;http://rubygems.rubyforge.org/rubygems-update/Gem/PackageTask.html&quot;&gt;Gem::PackageTask&lt;/a&gt; only built the &lt;code&gt;.gem&lt;/code&gt; file, but did not check &lt;code&gt;git status&lt;/code&gt;,
tag the release or push the &lt;code&gt;.gem&lt;/code&gt;.
&lt;a href=&quot;https://github.com/sr/mg#readme&quot;&gt;MG&lt;/a&gt; also did not check &lt;code&gt;git status&lt;/code&gt; before releasing,
did not tag releases, and only supports Git. &lt;a href=&quot;https://github.com/svenfuchs/gem-release#readme&quot;&gt;gem release&lt;/a&gt; came close,
but did not check &lt;code&gt;git status&lt;/code&gt; before releasing, deleted the &lt;code&gt;.gem&lt;/code&gt; file,
only supports Git and tried to do too much
(auto-magically bumping the version of your project for you).
&lt;a href=&quot;https://github.com/bundler/bundler/blob/master/lib/bundler/gem_helper.rb&quot;&gt;bundler/gem_helper&lt;/a&gt; came the closest, although while it defined &lt;a href=&quot;http://rake.rubyforge.org/&quot;&gt;Rake&lt;/a&gt; tasks
it did not leverage Rake's powerful &lt;a href=&quot;http://jasonseifer.com/2010/04/06/rake-tutorial&quot;&gt;task =&gt; dependency&lt;/a&gt; system.&lt;/p&gt;

&lt;p&gt;So I decided to cherry-pick all of the nice features from &lt;a href=&quot;http://www.zenspider.com/projects/hoe.html&quot;&gt;Hoe&lt;/a&gt;, &lt;a href=&quot;https://github.com/technicalpickles/jeweler#readme&quot;&gt;Jeweler&lt;/a&gt;,
&lt;a href=&quot;https://github.com/sr/mg#readme&quot;&gt;MG&lt;/a&gt;, &lt;a href=&quot;https://github.com/svenfuchs/gem-release#readme&quot;&gt;gem release&lt;/a&gt; and &lt;a href=&quot;https://github.com/bundler/bundler/blob/master/lib/bundler/gem_helper.rb&quot;&gt;bundler/gem_helper&lt;/a&gt;, and leave out the
&lt;em&gt;opinionated&lt;/em&gt; features.&lt;/p&gt;

&lt;h2&gt;rubygems-tasks&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/postmodern/rubygems-tasks#readme&quot;&gt;rubygems-tasks&lt;/a&gt; provides agnostic and unobtrusive Rake tasks for building,
installing and releasing Ruby Gems.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ gem install rubygems-tasks
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Adding rubygems-tasks to an existing project is easy as:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;require 'rubygems/tasks'
Gem::Tasks.new

$ rake -T
rake build    # Builds all packages
rake console  # Spawns an Interactive Ruby Console
rake install  # Installs all built gem packages
rake release  # Performs a release
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Features&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Provides tasks to build, install and push gems to &lt;a href=&quot;https://rubygems.org/&quot;&gt;rubygems.org&lt;/a&gt;:

&lt;ul&gt;
&lt;li&gt;Loads all project metadata from the &lt;code&gt;.gemspec&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;Supports loading multiple &lt;code&gt;.gemspec&lt;/code&gt; files.&lt;/li&gt;
&lt;li&gt;Supports pushing gems to alternate &lt;a href=&quot;https://github.com/rubygems/rubygems.org#readme&quot;&gt;Gemcutter&lt;/a&gt; servers.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Supports optionally building &lt;code&gt;.tar.gz&lt;/code&gt; and &lt;code&gt;.zip&lt;/code&gt; archives.&lt;/li&gt;
&lt;li&gt;Supports &lt;a href=&quot;http://git-scm.com/&quot;&gt;Git&lt;/a&gt;, &lt;a href=&quot;http://mercurial.selenic.com/&quot;&gt;Mercurial&lt;/a&gt; and &lt;a href=&quot;http://subversion.tigris.org/&quot;&gt;SubVersion&lt;/a&gt; SCMs.

&lt;ul&gt;
&lt;li&gt;Supports creating &lt;a href=&quot;http://en.wikipedia.org/wiki/Pretty_Good_Privacy&quot;&gt;PGP&lt;/a&gt; signed Git/Mercurial tags.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Supports generating checksums of built packages:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Gem::Tasks.new(:sign =&amp;gt; {:checksum =&amp;gt; true})
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Supports generating &lt;a href=&quot;http://en.wikipedia.org/wiki/Pretty_Good_Privacy&quot;&gt;PGP&lt;/a&gt; signatures for built packages:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Gem::Tasks.new(:sign =&amp;gt; {:pgp =&amp;gt; true})
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provides a &lt;code&gt;console&lt;/code&gt; task, for jumping right into your code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;Defines task aliases for users coming from &lt;a href=&quot;https://github.com/technicalpickles/jeweler#readme&quot;&gt;Jeweler&lt;/a&gt; or &lt;a href=&quot;http://www.zenspider.com/projects/hoe.html&quot;&gt;Hoe&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;ANSI coloured messages!&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Anti-Features&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Does not&lt;/strong&gt; parse project metadata from the README or the ChangeLog.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Does not&lt;/strong&gt; generate or modify your code.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Does not&lt;/strong&gt; automatically commit changes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Does not&lt;/strong&gt; inject dependencies into gems.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Zero&lt;/strong&gt; dependencies.&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Examples&lt;/h3&gt;

&lt;p&gt;Specifying an alternate Ruby Console to run:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Gem::Tasks.new do |tasks|
  tasks.console.command = 'pry'
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Enable pushing gems to an in-house &lt;a href=&quot;https://github.com/rubygems/rubygems.org#readme&quot;&gt;Gemcutter&lt;/a&gt; server:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Gem::Tasks.new do |tasks|
  tasks.push.host = 'gems.company.com'
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Disable the &lt;code&gt;push&lt;/code&gt; task:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Gem::Tasks.new(:push =&amp;gt; false)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Enable building &lt;code&gt;.tar.gz&lt;/code&gt; and &lt;code&gt;.zip&lt;/code&gt; archives:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Gem::Tasks.new(:build =&amp;gt; {:tar =&amp;gt; true, :zip =&amp;gt; true})
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Enable Checksums and &lt;a href=&quot;http://en.wikipedia.org/wiki/Pretty_Good_Privacy&quot;&gt;PGP&lt;/a&gt; signatures for built packages:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Gem::Tasks.new(:sign =&amp;gt; {:checksum =&amp;gt; true, :pgp =&amp;gt; true})
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Selectively defining tasks:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Gem::Build::Tar.new
Gem::SCM::Status.new
Gem::SCM::Tag.new(:format =&amp;gt; 'REL-%s')
Gem::Sign::Checksum.new
Gem::Console.new
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  
  <entry>
    <title>You don't have to use Bundler to create new RubyGems</title>
    <link href="http://postmodern.github.io/2012/05/20/you-dont-have-to-use-bundler-to-create-new-rubygems.html" />
    <updated>2012-05-20T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2012/05/20/you-dont-have-to-use-bundler-to-create-new-rubygems.html</id>
    <content type="html">&lt;div class=&quot;warning&quot;&gt;
  &lt;h3&gt;Warning: Controversial Content&lt;/h3&gt;

  &lt;p&gt;
  If you are morally or ethically opposed to using Project Generators
  and prefer to create RubyGems by hand,
  &lt;strong&gt;STOP READING AND CLICK THE BACK BUTTON&lt;/strong&gt;.
  &lt;/p&gt;

  &lt;p&gt;
  I am perfectly aware that one does not need any tools to create a RubyGem,
  and that all you really need is RubyGems and a &lt;kbd&gt;*.gemspec&lt;/kbd&gt;
  file. However, the majority of users do not have the time or patience
  to create each Ruby project from scratch. Thus developers have historically
  used project &lt;em&gt;generators&lt;/em&gt; such as Hoe, Jeweler and now Bundler.
  &lt;/p&gt;

  &lt;p&gt;
  If you are a diehard Bundler user, please read the &lt;em&gt;entire&lt;/em&gt; blog post.
  This blog post &lt;strong&gt;is not&lt;/strong&gt; putting Bundler down,
  nor is it posing a binary choice between Bundler and some new tool.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h2&gt;Enter Bundler&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://gembundler.com/&quot;&gt;Bundler&lt;/a&gt; was initially created as a more robust way to &lt;a href=&quot;http://yehudakatz.com/2010/09/30/bundler-as-simple-as-what-you-did-before/&quot;&gt;manage dependencies
of Rails3 applications&lt;/a&gt;. Once Bundler was integrated
into the Rails3 generator templates, developers realized Bundler could also
be used to manage the dependencies of any large Ruby application or library.&lt;/p&gt;

&lt;p&gt;In order to help developers create projects with Bundler already setup,
&lt;a href=&quot;https://github.com/carlhuda/bundler/tree/master/lib/bundler/templates&quot;&gt;template files&lt;/a&gt; and a &lt;code&gt;bundle gem&lt;/code&gt; command were added.
Since Bundler was the &quot;new hotness&quot; and developers were becoming increasingly
dissatisfied with &lt;a href=&quot;https://github.com/technicalpickles/jeweler#readme&quot;&gt;Jeweler&lt;/a&gt;/&lt;a href=&quot;http://docs.seattlerb.org/hoe/&quot;&gt;Hoe&lt;/a&gt;, the community began to
&lt;a href=&quot;http://railscasts.com/episodes/245-new-gem-with-bundler&quot;&gt;cargo&lt;/a&gt; &lt;a href=&quot;https://github.com/radar/guides/blob/master/gem-development.md&quot;&gt;cult&lt;/a&gt; Bundler as the defacto way to create RubyGems.&lt;/p&gt;

&lt;h2&gt;Looking Back&lt;/h2&gt;

&lt;p&gt;After having extensively used &lt;a href=&quot;http://gembundler.com/&quot;&gt;Bundler&lt;/a&gt; with &lt;a href=&quot;https://github.com/ronin-ruby/ronin/blob/master/Gemfile&quot;&gt;Ronin&lt;/a&gt;, to keep it's many
&lt;a href=&quot;https://github.com/ronin-ruby/&quot;&gt;repositories&lt;/a&gt; in-sync with each other, I can definitely say Bundler
solved dependency management for large Ruby projects.
However, I began to question using &lt;code&gt;bundle gem&lt;/code&gt; to create new RubyGems.&lt;/p&gt;

&lt;p&gt;At first it made sense to provide a &lt;code&gt;bundle gem&lt;/code&gt; command, but project
generation is outside of the original scope of Bundler (dependency management).
Furthermore, adding Bundler to an existing project isn't that difficult;
just add a &lt;code&gt;.gemspec&lt;/code&gt; file and a &lt;code&gt;Gemfile&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Given that &lt;a href=&quot;http://gembundler.com/&quot;&gt;Bundler&lt;/a&gt;'s stated goal is to &quot;manage an application's dependencies&quot;,
it doesn't seem very pragmatic to use Bundler in libraries with
&lt;strong&gt;zero&lt;/strong&gt; or only &lt;strong&gt;one&lt;/strong&gt; runtime dependency.&lt;/p&gt;

&lt;p&gt;Bundler's &lt;a href=&quot;https://github.com/carlhuda/bundler/tree/master/lib/bundler/templates&quot;&gt;template files&lt;/a&gt; are a bit spartan as well.
The &lt;a href=&quot;https://github.com/carlhuda/bundler/blob/master/lib/bundler/templates/newgem/Rakefile.tt&quot;&gt;Rakefile&lt;/a&gt; template does not include Rake tasks for &lt;a href=&quot;http://rdoc.rubyforge.org/&quot;&gt;RDoc&lt;/a&gt; or &lt;a href=&quot;http://rspec.info/&quot;&gt;RSpec&lt;/a&gt;.
This omission might encourage developers to not write documentation or tests,
and rush to release.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;bundle gem&lt;/code&gt; command isn't very configurable either. If you want to generate
a project with &lt;a href=&quot;http://textile.sitemonks.com/&quot;&gt;Textile&lt;/a&gt; markup, &lt;a href=&quot;http://yardoc.org/&quot;&gt;YARD&lt;/a&gt; documentation, &lt;a href=&quot;http://rspec.info/&quot;&gt;RSpec&lt;/a&gt; tests and
&lt;a href=&quot;http://mercurial.selenic.com/&quot;&gt;Mercurial&lt;/a&gt;, you are out of luck.&lt;/p&gt;

&lt;p&gt;&lt;img class=&quot;span-18&quot; src=&quot;/images/2012/05/20/you-dont-have-to-use-bundler-to-create-new-rubygems/morpheus.jpg&quot; /&gt;&lt;/p&gt;

&lt;h2&gt;Enter Ore&lt;/h2&gt;

&lt;blockquote&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/ruby-ore/ore#readme&quot;&gt;Ore&lt;/a&gt; is a flexible Ruby project generator. Unlike other Ruby project
generators, Ore provides many built in templates and allows custom templates
to be installed from Git repositories.&lt;/p&gt;&lt;/blockquote&gt;

&lt;pre&gt;&lt;code&gt;$ gem install ore
$ mine my_project
Generating /home/postmodern/my_project
      create  lib
      create  lib/my_project
      create  spec
      create  .gitignore
      create  .rspec
      create  spec/my_project_spec.rb
      create  spec/spec_helper.rb
      create  .document
      create  my_project.gemspec
      create  ChangeLog.rdoc
      create  LICENSE.txt
      create  README.rdoc
      create  Rakefile
      create  lib/my_project/version.rb
      create  lib/my_project.rb
         run  git init from &quot;.&quot;
         run  git add . from &quot;.&quot;
         run  git commit -m &quot;Initial commit.&quot; from &quot;.&quot;
$ cd my_project/
$ rake -T
rake build         # Builds all packages
rake clobber_rdoc  # Remove RDoc HTML files
rake console       # Spawns an Interactive Ruby Console
rake install       # Installs all built gem packages
rake rdoc          # Build RDoc HTML files
rake release       # Performs a release
rake rerdoc        # Rebuild RDoc HTML files
rake spec          # Run RSpec code examples
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Ore generates new Ruby projects with sensible defaults, such as
a &lt;code&gt;.gemspec&lt;/code&gt; file, &lt;a href=&quot;https://github.com/postmodern/rubygems-tasks#readme&quot;&gt;rubygems-tasks&lt;/a&gt;, &lt;a href=&quot;http://rdoc.rubyforge.org/&quot;&gt;RDoc&lt;/a&gt;, &lt;a href=&quot;http://rspec.info/&quot;&gt;RSpec&lt;/a&gt;, a &lt;code&gt;.gitignore&lt;/code&gt; file
and initializes the &lt;a href=&quot;http://git-scm.com/&quot;&gt;Git&lt;/a&gt; repository.&lt;/p&gt;

&lt;p&gt;Ore also provides many different templates and options:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ mine --help
Usage:
  mine PATH

Options:
      [--gemspec-yml]               
      [--jeweler-tasks]             
      [--bundler]                   
      [--rubygems-tasks]            
                                    # Default: true
      [--yard]                      
      [--bundler-tasks]             
      [--hg]                        
      [--rspec]                     
                                    # Default: true
      [--rvmrc]                     
      [--gem-test]                  
      [--gem-package-task]          
      [--gemspec]                   
                                    # Default: true
      [--test-unit]                 
      [--git]                       
                                    # Default: true
      [--bin]                       
      [--rdoc]                      
                                    # Default: true
      [--markdown]                  
      [--textile]                   
  -T, [--templates=TEMPLATE [...]]  
  -n, [--name=NAME]                 
  -V, [--version=VERSION]           
                                    # Default: 0.1.0
  -s, [--summary=SUMMARY]           
                                    # Default: TODO: Summary
  -D, [--description=DESCRIPTION]   
                                    # Default: TODO: Description
  -a, [--authors=NAME [...]]        
                                    # Default: [&quot;postmodern&quot;]
  -e, [--email=EMAIL]               
  -U, [--homepage=HOMEPAGE]         
  -B, [--bug-tracker=BUG_TRACKER]   
  -L, [--license=LICENSE]           
                                    # Default: MIT
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As you can see, Ore is completely configurable and supports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://git-scm.com/&quot;&gt;Git&lt;/a&gt; / &lt;a href=&quot;http://mercurial.selenic.com/&quot;&gt;Mercurial&lt;/a&gt; / &lt;a href=&quot;http://subversion.tigris.org/&quot;&gt;SubVersion&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://rvm.io/workflow/rvmrc/#project&quot;&gt;.rvmrc&lt;/a&gt; files&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://gembundler.com/&quot;&gt;Bundler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/postmodern/rubygems-tasks#readme&quot;&gt;rubygems-tasks&lt;/a&gt; / &lt;a href=&quot;http://gembundler.com/&quot;&gt;Bundler tasks&lt;/a&gt; / &lt;a href=&quot;https://github.com/technicalpickles/jeweler#readme&quot;&gt;Jeweler::Tasks&lt;/a&gt; /
&lt;a href=&quot;http://rubygems.rubyforge.org/rubygems-update/Gem/PackageTask.html&quot;&gt;Gem::PackageTask&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://rspec.info/&quot;&gt;RSpec&lt;/a&gt; / &lt;a href=&quot;http://test-unit.rubyforge.org/&quot;&gt;Test::Unit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://yardoc.org/&quot;&gt;YARD&lt;/a&gt; / &lt;a href=&quot;http://rdoc.rubyforge.org/&quot;&gt;RDoc&lt;/a&gt; documentation&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://rdoc.rubyforge.org/&quot;&gt;RDoc&lt;/a&gt; / &lt;a href=&quot;http://daringfireball.net/projects/markdown/&quot;&gt;Markdown&lt;/a&gt; / &lt;a href=&quot;http://textile.sitemonks.com/&quot;&gt;Textile&lt;/a&gt; markup&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Unlike other project generators, Ore focuses &lt;em&gt;only&lt;/em&gt; on project generation and
does not force a specific project layout or workflow upon the developer.
You can even generate projects with &lt;a href=&quot;http://gembundler.com/&quot;&gt;Bundler&lt;/a&gt;, &lt;a href=&quot;http://yardoc.org/&quot;&gt;YARD&lt;/a&gt; + &lt;a href=&quot;http://daringfireball.net/projects/markdown/&quot;&gt;Markdown&lt;/a&gt; and
&lt;a href=&quot;http://mercurial.selenic.com/&quot;&gt;Mercurial&lt;/a&gt; instead of &lt;a href=&quot;http://git-scm.com/&quot;&gt;Git&lt;/a&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ mine my_project --bundler --yard --markdown --hg
Generating /home/postmodern/my_project
      create  lib
      create  lib/my_project
      create  spec
      create  .hgignore
      create  .document
      create  .yardopts
      create  Gemfile
      create  .rspec
      create  spec/my_project_spec.rb
      create  spec/spec_helper.rb
      create  my_project.gemspec
      create  ChangeLog.md
      create  LICENSE.txt
      create  README.md
      create  Rakefile
      create  lib/my_project/version.rb
      create  lib/my_project.rb
         run  hg init from &quot;.&quot;
         run  hg add . from &quot;.&quot;
         run  hg commit -m &quot;Initial commit.&quot; from &quot;.&quot;
$ cd my_project &amp;amp;&amp;amp; bundle install
$ rake spec
/home/postmodern/.rvm/rubies/ruby-1.9.3-p194/bin/ruby -S rspec ./spec/my_project_spec.rb

MyProject
  should have a VERSION constant

Finished in 0.00593 seconds
1 example, 0 failures
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Think Outside of the Bundle&lt;/h2&gt;

&lt;p&gt;Now that you have been introduced to &lt;a href=&quot;https://github.com/ruby-ore/ore#readme&quot;&gt;Ore&lt;/a&gt;, I hope you will at the very least
give it a try. I also hope you will understand that I am not
simply anti-Bundler / pro-Ore. Ore gives you the option of generating Ruby
projects with/without Bundler. The two tools are not mutually exclusive.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Reading RFID Cards on Linux (in the year 2012)</title>
    <link href="http://postmodern.github.io/2012/04/04/reading-rfid-cards-on-linux.html" />
    <updated>2012-04-04T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2012/04/04/reading-rfid-cards-on-linux.html</id>
    <content type="html">&lt;p&gt;A while back &lt;a href=&quot;https://twitter.com/#!/tenderlove&quot;&gt;tenderlove&lt;/a&gt; &lt;a href=&quot;http://tenderlovemaking.com/2009/09/19/ruby-and-rfid-tags/&quot;&gt;blogged&lt;/a&gt; about using Ruby to interact with
&lt;a href=&quot;http://en.wikipedia.org/wiki/Near_field_communication&quot;&gt;NFC&lt;/a&gt; &lt;a href=&quot;http://www.touchatag.com/&quot;&gt;tags&lt;/a&gt;. Near Field Communication (NFC) grew out of
the Radio Frequency Identification (&lt;a href=&quot;http://en.wikipedia.org/wiki/Radio-frequency_identification&quot;&gt;RFID&lt;/a&gt;) standard and has been used for
contact-less payment with SmartPhones. Although,
NFC tags are not yet widely deployed in the US, as opposed to Japan.
On the other hand, RFID &lt;em&gt;is&lt;/em&gt; widely deployed in the US, used in Payment systems,
Asset management, Inventory systems, Product tracking, ID cards,
Transportation tracking and even Passports. RFID is out there,
and in those tags may be interesting information.&lt;/p&gt;

&lt;p&gt;Not wanting to simply copy &lt;a href=&quot;https://twitter.com/#!/tenderlove&quot;&gt;tenderlove&lt;/a&gt; and purchase an NFC starter kit,
I went searching for a consumer grade RFID reader. I ended up purchasing
an &lt;a href=&quot;http://www.hidglobal.com/prod_detail.php?prod_id=274&quot;&gt;OmniKey 6321 USB&lt;/a&gt; reader/writer (ideal for mobile use) and
a couple blank &lt;a href=&quot;http://www.rfdump.org/&quot;&gt;Mifare Read/Write RFID cards&lt;/a&gt; (with 8K EEPROM!).
The next logical step is getting the reader working on Linux.&lt;/p&gt;

&lt;p&gt;Unless you have a serial RFID reader (or can setup a USB Serial device
with &lt;code&gt;udev&lt;/code&gt;), the classic &lt;a href=&quot;http://www.rfdump.org/&quot;&gt;rfdump&lt;/a&gt; program is pretty much useless.
&lt;a href=&quot;http://openmrtd.org/projects/librfid/&quot;&gt;librfid&lt;/a&gt; does not appear to be maintained any longer.
Also, &lt;code&gt;librfid-tool -S&lt;/code&gt; did not detect the OmniKey USB reader.
Google quickly found many tutorials for using &lt;a href=&quot;http://pcsclite.alioth.debian.org/&quot;&gt;pcsc-lite&lt;/a&gt; to interact with
SmartCard readers to read RFID tags.&lt;/p&gt;

&lt;h2&gt;Install pcscd&lt;/h2&gt;

&lt;p&gt;On Debian:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# apt-get install pcscd
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;On Fedora:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# yum install pcsc-lite
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Install the OmniKey 6321 PC/SC Driver&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Browser to [www.hidglobal.com/driverDownloads.php?techCat=19&amp;amp;prod_id=274][http://www.hidglobal.com/driverDownloads.php?techCat=19&amp;amp;prod_id=274].&lt;/li&gt;
&lt;li&gt;Select your Operating System. Choose &quot;Linux&quot; for 32bit or
&quot;Linux x64&quot; for 64bit.&lt;/li&gt;
&lt;li&gt;Download the &lt;code&gt;ifdokrfid_lnx&lt;/code&gt; tar archive file.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Extract the &lt;code&gt;ifdokrfid_lnx&lt;/code&gt; tar archive:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ tar xzvf ifdokrfid_lnx*.tar.gz
$ cd ifdokrfid_lnx*/
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install the proprietary PC/SC Driver:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ./install
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;


&lt;h2&gt;Start pcscd&lt;/h2&gt;

&lt;p&gt;Plugin the OmniKey 6321 USB reader and start &lt;code&gt;pcscd&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# pcscd -a -f -d
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then you should see the following output:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;00000083 pcscdaemon.c:575:main() pcsc-lite 1.7.4 daemon ready.
00002003 hotplug_libudev.c:258:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0001, path: /dev/bus/usb/002/001
00000196 hotplug_libudev.c:258:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0001, path: /dev/bus/usb/002/001
00000189 hotplug_libudev.c:258:get_driver() Looking for a driver for VID: 0x047D, PID: 0x2043, path: /dev/bus/usb/002/002
00000174 hotplug_libudev.c:258:get_driver() Looking for a driver for VID: 0x047D, PID: 0x2043, path: /dev/bus/usb/002/002
00000176 hotplug_libudev.c:258:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0001, path: /dev/bus/usb/002/001
00000180 hotplug_libudev.c:258:get_driver() Looking for a driver for VID: 0x046D, PID: 0xC069, path: /dev/bus/usb/002/003
00000207 hotplug_libudev.c:258:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0001, path: /dev/bus/usb/003/001
00000184 hotplug_libudev.c:258:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0001, path: /dev/bus/usb/003/001
00000190 hotplug_libudev.c:258:get_driver() Looking for a driver for VID: 0x076B, PID: 0x6321, path: /dev/bus/usb/003/002
00000081 hotplug_libudev.c:258:get_driver() Looking for a driver for VID: 0x076B, PID: 0x6321, path: /dev/bus/usb/003/002
00000056 hotplug_libudev.c:309:HPAddDevice() Adding USB device: OMNIKEY 6321
00000087 readerfactory.c:934:RFInitializeReader() Attempting startup of OMNIKEY 6321 (USB iClass Reader) 00 00 using /usr/lib64/pcsc/drivers/ifdokrfid_lnx_x64-2.10.0.1.bundle/Contents/Linux/ifdokrfid.so
00000423 readerfactory.c:824:RFBindFunctions() Loading IFD Handler 3.0
HID HID Global OMNIKEY RFID  X64 v2.10.0.1 
00304886 readerfactory.c:295:RFAddReader() Using the reader polling thread
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To test the reader, briefly place an RFID card near the reader then remove it:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;99999999 eventhandler.c:372:EHStatusHandlerThread() powerState: POWER_STATE_POWERED
00000030 eventhandler.c:387:EHStatusHandlerThread() Card inserted into OMNIKEY 6321 (USB iClass Reader) 00 01
00000015 Card ATR: 3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 00 03 00 00 00 00 68 
00462848 eventhandler.c:446:EHStatusHandlerThread() powerState: POWER_STATE_UNPOWERED
00305960 eventhandler.c:325:EHStatusHandlerThread() Card Removed From OMNIKEY 6321 (USB iClass Reader) 00 01
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  
  <entry>
    <title>DIY Pagination with DataMapper</title>
    <link href="http://postmodern.github.io/2012/04/04/diy-pagination-with-datamapper.html" />
    <updated>2012-04-04T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2012/04/04/diy-pagination-with-datamapper.html</id>
    <content type="html">&lt;p&gt;There are many pagination solutions out there. Of course there's the venerable
&lt;a href=&quot;https://github.com/mislav/will_paginate#readme&quot;&gt;will_pagination&lt;/a&gt; and the much newer &lt;a href=&quot;https://github.com/amatsuda/kaminari#readme&quot;&gt;Kaminari&lt;/a&gt;. However, all of the
pagination solutions usually contain boiler-plate HTML. What if we only
want the pagination logic, maybe in a JSON API, without using Rails or
ActiveRecord, but instead &lt;a href=&quot;http://sinatrarb.com/&quot;&gt;Sinatra&lt;/a&gt; and &lt;a href=&quot;http://datamapper.org/&quot;&gt;DataMapper&lt;/a&gt;. As it turns out,
DataMapper makes DIY pagination as simple as:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;@posts = Post[((page - 1) * per_page), per_page]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As a Sinatra helper method this would look like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def paginate(query)
  @page     = (params[:page] || 1).to_i
  @per_page = (params[:per_page] || 10).to_i

  query[((@page - 1) * @per_page), @per_page]
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now, what if we want to know the total number of pages and records? Enter the
&lt;a href=&quot;https://github.com/postmodern/dm-chunked_query#readme&quot;&gt;dm-chunked_query&lt;/a&gt; gem, which provides convenience methods for querying
chunks of records:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;require 'dm-chunked_query'

def paginate(query)
  @page        = (params[:page] || 1).to_i
  @per_page    = (params[:per_page] || 10).to_i

  @pages       = query.chunks_of(per_page)
  @total_count = @pages.count
  @page_count  = @pages.length

  @pages[@page - 1]
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Pagination is that simple.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Hexdump 0.2.x</title>
    <link href="http://postmodern.github.io/2011/06/11/hexdump-0.2.html" />
    <updated>2011-06-11T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2011/06/11/hexdump-0.2.html</id>
    <content type="html">&lt;p&gt;Recently &lt;a href=&quot;http://github.com/mephux&quot;&gt;mephux&lt;/a&gt; began working on a
&lt;a href=&quot;http://github.com/mephux/hexdump.js#readme&quot;&gt;hexdump.js&lt;/a&gt; library
(&lt;a href=&quot;http://mephux.github.com/hexdump.js&quot;&gt;epic demo&lt;/a&gt;). Naturally, I thought
I should go back and improve my Ruby
&lt;a href=&quot;http://github.com/postmodern/hexdump#readme&quot;&gt;Hexdump&lt;/a&gt; library.&lt;/p&gt;

&lt;h2&gt;Hexdump 0.2.x&lt;/h2&gt;

&lt;p&gt;Hexdump now supports word-sizes and endianness. This is useful for dumping
packed &lt;code&gt;unsigned int&lt;/code&gt;s:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Hexdump.dump(&quot;\x12\x34\x00\x00\x42\x42&quot;, :word_size =&amp;gt; 2, :endian =&amp;gt; :big)
# 00000000  1234 0000 4242                           |ሴ䉂|
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;code&gt;:word_size&lt;/code&gt; can have any value, and is not restricted to powers of 2.&lt;/p&gt;

&lt;p&gt;Now that Hexdump parses multi-byte words from data, displaying Unicode
characters was the next logical step:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Hexdump.dump(&quot;\xb6\x80&quot; * 10, :word_size =&amp;gt; 2)
# 00000000  80b6 80b6 80b6 80b6 80b6 80b6 80b6 80b6  |肶肶肶肶肶肶肶肶|
# 00000010  80b6 80b6                                |肶肶|
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Finally, Hexdump received some performance tuning which cut benchmark times
in half on Ruby 1.9.2:&lt;/p&gt;

&lt;h3&gt;Before&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;                                user     system      total        real
hexdump (block)             7.740000   0.030000   7.770000 (  8.138029)
hexdump                     9.590000   0.050000   9.640000 ( 10.178203)
hexdump width=256 (block)   7.280000   0.020000   7.300000 (  7.534507)
hexdump width=256           8.130000   0.030000   8.160000 (  8.342448)
hexdump ascii=true (block)  7.740000   0.030000   7.770000 (  7.958550)
hexdump ascii=true          9.550000   0.050000   9.600000 (  9.803758)
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;After&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;                                 user     system      total        real
hexdump (block)              3.010000   0.010000   3.020000 (  3.529396)
hexdump                      5.430000   0.030000   5.460000 (  6.216174)
hexdump width=256 (block)    3.010000   0.020000   3.030000 (  3.308961)
hexdump width=256            4.700000   0.040000   4.740000 (  5.520189)
hexdump ascii=true (block)   3.050000   0.010000   3.060000 (  3.501436)
hexdump ascii=true           5.450000   0.040000   5.490000 (  6.352144)
hexdump word_size=2 (block)  7.420000   0.050000   7.470000 (  9.174734)
hexdump word_size=2          9.500000   0.070000   9.570000 ( 11.228204)
hexdump word_size=4 (block)  4.110000   0.030000   4.140000 (  4.849785)
hexdump word_size=4          5.380000   0.060000   5.440000 (  6.209022)
hexdump word_size=8 (block)  3.350000   0.070000   3.420000 (  4.147304)
hexdump word_size=8          4.430000   0.040000   4.470000 (  5.930758)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Using &lt;a href=&quot;http://ruby-prof.rubyforge.org/&quot;&gt;ruby-prof&lt;/a&gt; and the
Rubinius Profiler (&lt;code&gt;rbx -Xprofile&lt;/code&gt;) I found that the majority of time spent
was in:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;Proc#call&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Array#join&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Integer#chr&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;String#%&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;Optimizing out these excess method calls involved:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Frequently called lambdas were replaced with methods.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Array#join&lt;/code&gt; was replaced with incremental String concatenating code.&lt;/li&gt;
&lt;li&gt;A lookup table of bytes and printable characters were added, to reduce
excess &lt;code&gt;Integer#chr&lt;/code&gt; calls.&lt;/li&gt;
&lt;li&gt;Interestingly, &lt;code&gt;Kernel#sprintf&lt;/code&gt; is slightly faster than &lt;code&gt;String#%&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Uses&lt;/h2&gt;

&lt;p&gt;Both &lt;a href=&quot;http://github.com/mephux#readme&quot;&gt;hexdump.js&lt;/a&gt; and Ruby
&lt;a href=&quot;http://github.com/postmodern/hexdump#readme&quot;&gt;Hexdump&lt;/a&gt; aim to provide
similar features and behaviors. hexdump.js is definitely useful for when
you want to offload the work of Hexdumping to the Browser, or when writing
&lt;a href=&quot;http://nodejs.org/&quot;&gt;node.js&lt;/a&gt; Apps.&lt;/p&gt;

&lt;p&gt;The Ruby Hexdump library is more suited for Ruby CLI Apps, but can also be
used in Web Apps:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;dump = []

Hexdump.dump(data) do |index,numeric,printable|
  dump &amp;lt;&amp;lt; [index, numeric, printable]
end

render :json =&amp;gt; dump
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  
  <entry>
    <title>Don't like WEBrick? Try net-http-server</title>
    <link href="http://postmodern.github.io/2011/05/08/dont-like-webrick-try-net-http-server.html" />
    <updated>2011-05-08T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2011/05/08/dont-like-webrick-try-net-http-server.html</id>
    <content type="html">&lt;h2&gt;TL;DR&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://github.com/postmodern/net-http-server&quot;&gt;net-http-server&lt;/a&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ gem install net-http-server
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;pure-Ruby HTTP &lt;a href=&quot;https://github.com/postmodern/net-http-server/blob/master/lib/net/http/server/parser.rb&quot;&gt;Parser&lt;/a&gt; and &lt;a href=&quot;https://github.com/postmodern/net-http-server/blob/master/lib/net/http/server/daemon.rb&quot;&gt;Server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/postmodern/net-http-server/tree/master/lib&quot;&gt;Small codebase&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Fast-ish&lt;/li&gt;
&lt;li&gt;Rack-like API&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/postmodern/net-http-server/blob/master/lib/rack/handler/http.rb&quot;&gt;Rack Handler&lt;/a&gt; included&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://rubydoc.info/gems/net-http-server/frames&quot;&gt;full YARD Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;WEBrick&lt;/h2&gt;

&lt;p&gt;Some have said that the &lt;a href=&quot;http://www.ruby-doc.org/stdlib/libdoc/webrick/rdoc/index.html&quot;&gt;WEBrick&lt;/a&gt;
HTTP Server is a &lt;a href=&quot;http://www.mikeperham.com/2010/11/22/the-ruby-stdlib-is-a-ghetto/&quot;&gt;Ghetto&lt;/a&gt;.
While WEBrick is &lt;strong&gt;very fast&lt;/strong&gt; for a pure-Ruby HTTP Server, the parsing
code is hand written and &lt;a href=&quot;https://github.com/ruby/ruby/blob/trunk/lib/webrick/httprequest.rb#L256-414&quot;&gt;difficult to read&lt;/a&gt;.
WEBrick is also one of the oldest Ruby HTTP Servers, but for some reason
lacks &lt;a href=&quot;http://www.ruby-doc.org/stdlib/libdoc/webrick/rdoc/classes/WEBrick/HTTPServer.html&quot;&gt;documentation coverage&lt;/a&gt;.
Given the rise of &lt;a href=&quot;http://rack.rubyforge.org/&quot;&gt;Rack&lt;/a&gt;, middleware
and Rack applications, WEBricks API now seems &lt;a href=&quot;http://segment7.net/projects/ruby/WEBrick/servlets.html&quot;&gt;awkward&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;The Parser&lt;/h2&gt;

&lt;p&gt;When &lt;a href=&quot;http://kschiess.github.com/parslet/&quot;&gt;Parslet&lt;/a&gt;
(a pure Ruby PEG Parser library) was announced, I wondered how hard would it
be to write a HTTP Parser with Parslet. After researching the other
Ragel based HTTP Parsers (&lt;a href=&quot;https://github.com/macournoyer/thin/blob/master/ext/thin_parser/common.rl&quot;&gt;Thin&lt;/a&gt;
and &lt;a href=&quot;https://github.com/defunkt/unicorn/blob/master/ext/unicorn_http/unicorn_http_common.rl&quot;&gt;Unicorn&lt;/a&gt;)
and double checking &lt;a href=&quot;http://www.w3.org/Protocols/rfc2616/rfc2616.html&quot;&gt;RFC 2616&lt;/a&gt;,
I suddenly had a &lt;a href=&quot;https://github.com/postmodern/net-http-server/blob/master/lib/net/http/server/parser.rb&quot;&gt;pure-Ruby HTTP Parser&lt;/a&gt;.
(in one file, that you can actually read!)&lt;/p&gt;

&lt;p&gt;I found that the way in which Parslet nested matches into Arrays of Hashes
resulted in data that looked very much like a Rack &lt;code&gt;env&lt;/code&gt; Hash.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;require 'net/http/server/parser'

parser = Net::HTTP::Server::Parser.new
parser.parse(&quot;GET /path?x=1&amp;amp;y=2 HTTP/1.1\r\nCookie: xyz;123\r\n\r\n&quot;)
# =&amp;gt; {
#      :method=&amp;gt;&quot;GET&quot;,
#      :uri=&amp;gt;{:path=&amp;gt;&quot;path&quot;, :query=&amp;gt;&quot;x=1&amp;amp;y=2&quot;},
#      :version=&amp;gt;&quot;1.1&quot;,
#      :headers=&amp;gt;[{:name=&amp;gt;&quot;Cookie&quot;, :value=&amp;gt;&quot;xyz;123&quot;}]
#    }
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;The Daemon&lt;/h2&gt;

&lt;p&gt;The next step was to write an actual Daemon that would:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Receive Connections&lt;/li&gt;
&lt;li&gt;Parse HTTP Requests&lt;/li&gt;
&lt;li&gt;Pass HTTP Requests to a Request Handler&lt;/li&gt;
&lt;li&gt;Receive HTTP Responses from the Request Handler&lt;/li&gt;
&lt;li&gt;Send HTTP Responses&lt;/li&gt;
&lt;li&gt;Close Connections&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;I settled on using the battle tested &lt;a href=&quot;http://rubydoc.info/stdlib/gserver/1.9.2/frames&quot;&gt;GServer&lt;/a&gt;
class to handle the Connections for
&lt;a href=&quot;https://github.com/postmodern/net-http-server/blob/master/lib/net/http/server/daemon.rb&quot;&gt;Nett:HTTP::Server::Daemon&lt;/a&gt;.
I also borrowed some ideas from Rack, such as passing
HTTP Requests via a &lt;code&gt;call&lt;/code&gt; method and returning HTTP Responses as an Array
(containing the HTTP Status, Headers and Body).&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;require 'net/http/server'
require 'pp'

Net::HTTP::Server.run(:host =&amp;gt; '127.0.0.1', :port =&amp;gt; 8080) do |request,socket|
  pp request

  [200, {'Content-Type' =&amp;gt; 'text/html'}, ['Hello World']]
end
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;The Rack Handler&lt;/h2&gt;

&lt;p&gt;Given that the API was already very Rack-ish, writing a &lt;a href=&quot;https://github.com/postmodern/net-http-server/blob/master/lib/rack/handler/http.rb&quot;&gt;Rack handler&lt;/a&gt; on top of &lt;code&gt;Net::HTTP::Server::Daemon&lt;/code&gt; was simple.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;require 'rack/handler/http'
require 'sinatra'

class HelloWorld &amp;lt; Sinatra::Base

  get '/' do
    [200, {'Content-Type' =&amp;gt; 'text/html'}, [&quot;Hello World&quot;]]
  end

end

Rack::Handler::HTTP.run HelloWorld, :Host =&amp;gt; 'localhost', :Port =&amp;gt; 1212
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Benchmarks&lt;/h2&gt;

&lt;p&gt;By now your probably wondering, how fast is this pure Ruby HTTP Server?&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;require 'net/http/server'

Net::HTTP::Server.run(:port =&amp;gt; 8080) do |request,socket|
  [200, {'Content-Type' =&amp;gt; 'text/html'}, ['Hello World']]
end

$ ab -n 4000 -c 4 http://localhost:8080/
This is ApacheBench, Version 2.3 &amp;lt;$Revision: 655654 $&amp;gt;
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
...

Finished 4000 requests


Server Software:        
Server Hostname:        localhost
Server Port:            8080

Document Path:          /
Document Length:        11 bytes

Concurrency Level:      4
Time taken for tests:   73.405 seconds
Complete requests:      4000
Failed requests:        0
Write errors:           0
Total transferred:      220000 bytes
HTML transferred:       44000 bytes
Requests per second:    54.49 [#/sec] (mean)
Time per request:       73.405 [ms] (mean)
Time per request:       18.351 [ms] (mean, across all concurrent requests)
Transfer rate:          2.93 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0       8
Processing:    24   73  31.5     62     236
Waiting:       24   72  31.4     60     236
Total:         25   73  31.5     62     236

Percentage of the requests served within a certain time (ms)
  50%     62
  66%     86
  75%     98
  80%    103
  90%    119
  95%    134
  98%    148
  99%    153
 100%    236 (longest request)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Definitely not as fast as &lt;a href=&quot;http://code.macournoyer.com/thin/&quot;&gt;Thin&lt;/a&gt; or even
WEBrick, but not too bad considering its pure-Ruby and the size of the
code-base.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Typos in your Documentation?</title>
    <link href="http://postmodern.github.io/2011/03/04/typos-in-your-documentation.html" />
    <updated>2011-03-04T00:00:00-08:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2011/03/04/typos-in-your-documentation.html</id>
    <content type="html">&lt;p&gt;&lt;strong&gt;More likely than you think.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Having good documentation (internal and external) can make or break bigger
projects. Good documentation helps skilled users/developers get up to
speed with your project. However, bad documentation will drive potential
users away. Typos are probably the most embarrassing thing to find in
documentation.&lt;/p&gt;

&lt;p&gt;One day I was fixing a trivial bug in my code for a new-user, and glanced
over the documentation. Low and behold I spot a typo right above the broken
method. In this moment of embarrassment (in front of the new-user),
I said enough is enough, &lt;strong&gt;no more typos!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since I use &lt;a href=&quot;http://yardoc.org/&quot;&gt;YARD&lt;/a&gt; for all of my projects, I decided
to write a YARD plugin which would scan all of my documentation text using
the &lt;a href=&quot;http://hunspell.sourceforge.net/&quot;&gt;Hunspell&lt;/a&gt; spellchecking library
(via &lt;a href=&quot;http://github.com/postmodern/ffi-hunspell#readme&quot;&gt;ffi-hunspell&lt;/a&gt;).
A couple days later,
&lt;a href=&quot;https://github.com/postmodern/yard-spellcheck#readme&quot;&gt;yard-spellcheck&lt;/a&gt;
was printing typos with file-names, line-numbers and ANSI highlighting.&lt;/p&gt;

&lt;p&gt;As I suspected, I was able to find and fix a handful of typos in my own
libraries, thanks to &lt;code&gt;yard-spellcheck&lt;/code&gt;. Next, I started scanning larger
projects with YARD documentation. I found a couple typos in
&lt;a href=&quot;http://datamapper.org/&quot;&gt;DataMapper&lt;/a&gt; and even
&lt;a href=&quot;http://github.com/lsegal/yard#readme&quot;&gt;YARD&lt;/a&gt; itself (all are fixed now).&lt;/p&gt;

&lt;p&gt;The lesson of this short story is that typos are lurking everywhere; too
numerous and well hidden for human eyes to catch them all. Luckily, we
now have an automated-tool in the fight against typos. The Ruby Community
is notably obsessed with testing and quality of software, we should feel
the same way about our documentation.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ gem install yard-spellcheck
$ cd my_project/
$ yard-spellcheck
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  
  <entry>
    <title>Introducing DeploYML</title>
    <link href="http://postmodern.github.io/2010/11/21/introducing-deployml.html" />
    <updated>2010-11-21T00:00:00-08:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2010/11/21/introducing-deployml.html</id>
    <content type="html">&lt;p&gt;When Rails 3.0.0.beta.1 was first released, there was some confusion about
how to deploy a Rails3 app with this new &lt;a href=&quot;http://gembundler.com&quot;&gt;Bundler&lt;/a&gt;
thing. A few blog posts were written with some monkey patches for injecting
into &lt;a href=&quot;https://github.com/capistrano/capistrano/wiki/Documentation-v2.x&quot;&gt;Capistrano&lt;/a&gt;,
which enable early Bundler support. Unfortunately, Bundler was still very
new and none of the deployment tools had official support yet.&lt;/p&gt;

&lt;p&gt;Around the same time, I needed to deploy a Rails3 app and I did not want to
deal with the heavy weight of Capistrano; nor did I want to rely on a
monkey patch from a blog post. Of course the first thing I did was
look at the alternatives, which were
&lt;a href=&quot;http://rubyhitsquad.com/Vlad_the_Deployer.html&quot;&gt;Vlad The Deployer&lt;/a&gt; or
write a bash script that used &lt;code&gt;rsync&lt;/code&gt; / &lt;code&gt;ssh&lt;/code&gt; / &lt;code&gt;git&lt;/code&gt;. After trying to run
the &lt;code&gt;vlad&lt;/code&gt; rake tasks, I hit some weird bugs with how it was calling
&lt;code&gt;git&lt;/code&gt; or &lt;code&gt;thin&lt;/code&gt;. Being on a dead-line and not wanting to wait on
Capistrano or Vlad, I thought it should be easy to create a simple
deployment utility with &lt;code&gt;git&lt;/code&gt; and &lt;code&gt;ssh&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;DeploYML&lt;/h2&gt;

&lt;p&gt;Introducing &lt;a href=&quot;http://github.com/postmodern/deployml#readme&quot;&gt;DeploYML&lt;/a&gt;,
a simple deployment solution for Ruby / Rails projects that uses a
&lt;strong&gt;single YAML file&lt;/strong&gt;, &lt;a href=&quot;http://www.git-scm.com&quot;&gt;Git&lt;/a&gt; and &lt;code&gt;ssh&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Configuring DeploYML requires at least &lt;strong&gt;two&lt;/strong&gt; things:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# config/deploy.yml
source: git@github.com:user/project.git
dest: deploy@www.example.com/var/www/site
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then one can deploy the project using the &lt;code&gt;deployml&lt;/code&gt; command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ deployml deploy
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;After making some changes, one can re-deploy the project:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ deployml redeploy
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Configuration&lt;/h2&gt;

&lt;p&gt;Of course, one will want to specify more information, such as what server
to run the project under:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;source: git@github.com:user/project.git
dest: deploy@www.example.com/var/www/site
server: apache
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or what options to run the server with:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;source: git@github.com:user/project.git
dest: deploy@www.example.com/var/www/site
server:
  name: thin
  options:
    servers: 4
    deamonize: true
    socket: /var/run/thin.sock
    rackup: true
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or more importantly, what Framework or ORM the project uses:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;source: git@github.com:user/project.git
dest: deploy@www.example.com/var/www/site
framework: rails3
orm: datamapper
server: apache
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;One can even specify multiple-environments:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# config/deploy.yml
source: git@github.com:user/project.git
framework: rails3
orm: datamapper

# config/deploy/staging.yml
dest: ssh://deploy@www.example.com/srv/staging
server:
  name: thin
  options:
    config: /etc/thin/staging.yml
    socket: /tmp/thin.staging.sock

# config/deploy/production.yml
dest: ssh://deploy@www.example.com/srv/project
server:
  name: thin
  options:
    config: /etc/thin/example.yml
    socket: /tmp/thin.example.sock
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Administration&lt;/h2&gt;

&lt;p&gt;DeploYML does more than just deploying, it also allows interacting with the
deployment server and deployed project.&lt;/p&gt;

&lt;p&gt;Need to quickly &lt;code&gt;ssh&lt;/code&gt; into the server as the deploy user?&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ deployml ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Need to quickly execute a command remotely, within the directory of the
deployed project?&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ deployml exec 'ps aux'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Need to execute a rake task remotely?&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ deployml rake db:autoupgrade
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Interested?&lt;/h2&gt;

&lt;p&gt;Install it today:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ gem install deployml
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I originally started &lt;a href=&quot;https://github.com/postmodern/deployml/commits/f287b187f585eb03c0eb2a13b4149501b43d7b4d&quot;&gt;DeploYML&lt;/a&gt;
before &lt;a href=&quot;http://ruby5.envylabs.com/episodes/96-episode-94-july-16-2010/stories/812-rails3-deployments-with-inploy&quot;&gt;Imploy&lt;/a&gt;
was released, and just now got around to making a release. If you feel
Capistrano is too heavy, I encourage you to also checkout
&lt;a href=&quot;https://github.com/dcrec1/inploy&quot;&gt;Imploy&lt;/a&gt; for deploying Rails3 apps.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Mining RubyGems from Ore</title>
    <link href="http://postmodern.github.io/2010/10/25/mining-rubygems-from-ore.html" />
    <updated>2010-10-25T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2010/10/25/mining-rubygems-from-ore.html</id>
    <content type="html">&lt;p&gt;Recently there has been some interesting discussion on the role of
Gem builders and gemspecs. &lt;a href=&quot;http://jeffkreeftmeijer.com/&quot;&gt;Jeff Kreeftmeijer&lt;/a&gt;
wrote about how easy it is to build a RubyGem using a hand-written
&lt;code&gt;.gemspec&lt;/code&gt; file. With just a stand-alone &lt;code&gt;.gemspec&lt;/code&gt; file one can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Build RubyGems: &lt;code&gt;gem build my-project.gemspec&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Publish RubyGems: &lt;code&gt;gem push my-project-0.1.0.gem&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;One thing worries me is the fact that you either have to specify
everything explicitly in the gemspec, or use inline &lt;code&gt;git&lt;/code&gt; commands to query
the files of a project. Copying and pasting all this boilerplate code around
seems like a potential future maintenance hassle; also not very DRY.&lt;/p&gt;

&lt;p&gt;The argument for just a &lt;code&gt;.gemspec&lt;/code&gt; file did get me thinking. I do find
myself regenerating the gemspec with
&lt;a href=&quot;http://github.com/technicalpickles/jeweler&quot;&gt;Jeweler&lt;/a&gt;, almost once per-day.
Also, these stand-alone gemspecs are pretty succinct. So when in doubt,
see how other languages solved the problem.&lt;/p&gt;

&lt;h2&gt;Code vs. Data&lt;/h2&gt;

&lt;p&gt;I asked one of my Haskell friends how &lt;a href=&quot;http://www.haskell.org/cabal/&quot;&gt;Cabal&lt;/a&gt;
(the Haskell packager of choice) solves this problem. He pointed me
to the &lt;a href=&quot;http://hpaste.org/40862/serialistnet_cabal_file&quot;&gt;Cabal file&lt;/a&gt; of his
Haskell webapp &lt;a href=&quot;http://serialist.net/&quot;&gt;serialist.net&lt;/a&gt;. Cabal uses easy to
read, easy to parse and easy to edit &lt;strong&gt;plain-text&lt;/strong&gt;. This reminded me,
Code is for describing logic and flat-files are for describing static data.
The majority of the information in the &lt;code&gt;.gemspec&lt;/code&gt; file, is static data.&lt;/p&gt;

&lt;p&gt;Now I am starting to really question the whole reason for an explicit
gemspec. The &lt;code&gt;.gemspec&lt;/code&gt; file only exists to create a
&lt;a href=&quot;http://rubygems.rubyforge.org/rubygems-update/Gem/Specification.html&quot;&gt;Gem::Specification&lt;/a&gt;
object, which is then passed to &lt;a href=&quot;http://rubygems.rubyforge.org/rubygems-update/Gem/Builder.html&quot;&gt;Gem::Builder&lt;/a&gt;
or loaded by &lt;a href=&quot;http://gembundler.com/&quot;&gt;Bundler&lt;/a&gt;. Why are we writing Ruby
code that normally would only exist in-memory? The gemspec purists
state this is to allow things such as, dynamically loading the &lt;code&gt;VERSION&lt;/code&gt;
constant from the project or dynamically listing files tracked by Git.
Although, both of these tasks can easily be automated by a library.&lt;/p&gt;

&lt;p&gt;So I wondered, why not have a small library that loads the project
information from a YAML file, fills in any missing information, and then
creates a new &lt;code&gt;Gem::Specification&lt;/code&gt; object. Furthermore, If we can call a
method and get a &lt;code&gt;Gem::Specification&lt;/code&gt; object back, we could place this in
the &lt;code&gt;.gemspec&lt;/code&gt; file for both &lt;code&gt;gem build&lt;/code&gt; and Bundler to make use of.&lt;/p&gt;

&lt;h2&gt;Introducing Ore&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://github.com/ruby-ore/ore&quot;&gt;Ore&lt;/a&gt; allows you to define all project
information for a RubyGem in a &lt;strong&gt;single YAML file&lt;/strong&gt; (&lt;code&gt;gemspec.yml&lt;/code&gt;).&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;name: ore
version: 0.1.2
summary: Cut raw RubyGems from YAML
description:
  Ore is a simple RubyGem building solution. Ore handles the
  creation of Gem::Specification objects as well as building '.gem'
  files. Ore allows the developer to keep all of the project information
  in a single YAML file.

license: MIT
authors: Postmodern
email: postmodern.mod3@gmail.com
homepage: http://github.com/postmodern/ore
has_yard: true

dependencies:
  thor: ~&amp;gt; 0.14.3

development_dependencies:
  yard: ~&amp;gt; 0.6.1
  rspec: ~&amp;gt; 2.0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;With Ore, one can write their description as free-text, no more using
with awkward Ruby &lt;code&gt;%Q{...}&lt;/code&gt; syntax.&lt;/p&gt;

&lt;p&gt;Dependencies are listed in a YAML Hash, no more repeating &lt;code&gt;add_dependency&lt;/code&gt;
or &lt;code&gt;add_development_dependency&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Ore can also infer missing information. If the &lt;code&gt;version&lt;/code&gt; is not specified,
Ore will search for and parse any &lt;code&gt;VERSION&lt;/code&gt; or &lt;code&gt;VERSION.yml&lt;/code&gt; files. Ore
can even slurp up any &lt;code&gt;VERSION&lt;/code&gt;, &lt;code&gt;MAJOR&lt;/code&gt;, &lt;code&gt;MINOR&lt;/code&gt;, &lt;code&gt;PATCH&lt;/code&gt; or &lt;code&gt;BUILD&lt;/code&gt;
constants from a &lt;code&gt;version.rb&lt;/code&gt; file in the &lt;code&gt;lib/&lt;/code&gt; directory. Also, notice
that &lt;code&gt;files&lt;/code&gt; is not listed, this is because Ore can detect the project is
using Git, and list all files tracked by Git.&lt;/p&gt;

&lt;p&gt;For a complete reference of everything that may go into a &lt;code&gt;gemspec.yml&lt;/code&gt;
file, and how Ore infers missing data, please see
&lt;a href=&quot;http://rubydoc.info/gems/ore-core/file/GemspecYML.md&quot;&gt;GemspecYML&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Building gems with Ore is easy as:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ore
Successfully built RubyGem
Name: ore
Version: 0.1.2
File: ore-0.1.2.gem
$ ls pkg/
ore-0.1.2.gem
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;One can still get the traditional gemspec from Ore:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ore gemspec
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
  s.name = %q{ore}
  s.version = &quot;0.1.2&quot;

  s.required_rubygems_version = Gem::Requirement.new(&quot;&amp;gt;= 0&quot;) if s.respond_to? :required_rubygems_version=
  s.authors = [&quot;Postmodern&quot;]
  s.date = %q{2010-10-25}
  s.default_executable = %q{ore}
...
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We can even use Ore in &lt;code&gt;.gemspec&lt;/code&gt; files:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# -*- encoding: utf-8 -*-

begin
  Ore::Specification.new do |gemspec|
    # custom logic here
  end
rescue NameError
  begin
    require 'ore/specification'
    retry
  rescue LoadError
    STDERR.puts &quot;The 'my-project.gemspec' file requires Ore.&quot;
    STDERR.puts &quot;Run `gem install ore-core` to install Ore.&quot;
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Ore will still work with &lt;code&gt;gem build&lt;/code&gt; and even Bundler.&lt;/p&gt;

&lt;h2&gt;Mining RubyGems from Ore&lt;/h2&gt;

&lt;p&gt;Ore also comes with an extendable generator, for creating new projects:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ mine my-project
Generating /home/hal/my-project
  create  lib
  create  lib/my/project
  create  spec
  create  .rspec
  create  spec/my/project_spec.rb
  create  spec/spec_helper.rb
  create  .document
  create  .gitignore
  create  my-project.gemspec
  create  ChangeLog.rdoc
  create  LICENSE.txt
  create  README.rdoc
  create  Rakefile
  create  gemspec.yml
  create  lib/my/project/version.rb
  create  lib/my/project.rb
     run  git init from &quot;.&quot;
     run  git add . from &quot;.&quot;
     run  git commit -m &quot;Initial commit.&quot; from &quot;.&quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;By default &lt;code&gt;mine&lt;/code&gt; will generate an RDoc and test-unit project. &lt;code&gt;mine&lt;/code&gt;
can also generate very customized projects:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ mine my-project --rspec --yard --markdown --bundler
Generating /home/hal/my-project
      create  lib
      create  lib/my/project
      create  spec
      create  .yardopts
      create  .rspec
      create  spec/my/project_spec.rb
      create  spec/spec_helper.rb
      create  Gemfile
      create  .document
      create  .gitignore
      create  my-project.gemspec
      create  ChangeLog.md
      create  LICENSE.txt
      create  README.md
      create  Rakefile
      create  gemspec.yml
      create  lib/my/project/version.rb
      create  lib/my/project.rb
         run  git init from &quot;.&quot;
         run  git add . from &quot;.&quot;
         run  git commit -m &quot;Initial commit.&quot; from &quot;.&quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;code&gt;mine&lt;/code&gt; simply renders Ore Templates. Unlike other generators which have
their logic hard-coded in Ruby, Ore Templates are simply
&lt;a href=&quot;http://github.com/ruby-ore/ore/tree/master/data/ore/templates/&quot;&gt;directories&lt;/a&gt;,
containing static and ERb files. One can make their own Ore template
by creating a directory, adding files and publishing a Git repository.&lt;/p&gt;

&lt;p&gt;Users can install custom Ore templates from Git repositories:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ore install http://github.com/user/awesometest.git
$ ore list
Builtin templates:
  base
  rspec
  test_unit
  yard
  bundler
  jeweler_tasks
  rdoc
  ore_tasks
Installed templates:
  awesometest
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then use the &lt;code&gt;-T&lt;/code&gt; option to specify additional custom templates:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ mine my-project --yard --markdown -T awesometest
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Workflow&lt;/h2&gt;

&lt;p&gt;By default Ore does not impose a workflow onto the developer. Even the &lt;code&gt;mine&lt;/code&gt;
utility does not add any additional Rake tasks to new projects. This allows the
developer to use &lt;code&gt;gem build&lt;/code&gt; and &lt;code&gt;gem push&lt;/code&gt;, or even use
&lt;a href=&quot;http://github.com/technicalpickles/jeweler&quot;&gt;Jeweler::Tasks&lt;/a&gt; with Ore.&lt;/p&gt;

&lt;p&gt;For those just wanting simple Rake tasks to build, push and tag releases, there
is &lt;a href=&quot;http://github.com/ruby-ore/ore-tasks&quot;&gt;ore-tasks&lt;/a&gt;. &lt;code&gt;Ore::Tasks&lt;/code&gt; provides
the following tasks:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;rake build            # Only builds a Gem
rake console[script]  # Start IRB with all runtime dependencies loaded
rake gem              # Alias to the 'build' task
rake install          # Builds and installs a Gem
rake push             # Builds and pushes a Gem
rake release          # Builds and Pushes a new Gem / Build, Tags and Pushe...
rake tag              # Tags a release and pushes the tag
rake version          # Displays the current version
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To generate a project with &lt;code&gt;Ore::Tasks&lt;/code&gt; included:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ mine my-project --ore-tasks
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To generate a project with &lt;code&gt;Jeweler::Tasks&lt;/code&gt; included:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ mine my-project --jeweler-tasks
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Dog Fooding&lt;/h2&gt;

&lt;p&gt;In order to do real-world testing with Ore, I created
&lt;a href=&quot;http://github.com/ruby-ore/ore-example&quot;&gt;ore-example&lt;/a&gt; which uses Bundler,
RSpec2, YARD and Ore::Tasks.&lt;/p&gt;

&lt;p&gt;As of now, I have also migrated my
&lt;a href=&quot;http://github.com/postmodern/chars&quot;&gt;chars&lt;/a&gt; and
&lt;a href=&quot;http://github.com/postmodern/uri-query_params&quot;&gt;uri-query_params&lt;/a&gt;
libraries to Ore.&lt;/p&gt;

&lt;h2&gt;Interested?&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;$ gem install ore
$ mine the-future
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;For questions or feedback, join &lt;code&gt;#ruby-ore&lt;/code&gt; on &lt;code&gt;irc.freenode.net&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;All source-code is located on &lt;a href=&quot;http://github.com/ruby-ore&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Ore is tested with &lt;a href=&quot;http://rspec.info/&quot;&gt;RSpec2&lt;/a&gt; and has extensive
&lt;a href=&quot;http://yardoc.org&quot;&gt;YARD&lt;/a&gt; &lt;a href=&quot;http://rubydoc.info/gems/ore&quot;&gt;documentation&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Introducing Combinatorics 0.2.0</title>
    <link href="http://postmodern.github.io/2010/10/03/introducing-combinatorics-0.2.0.html" />
    <updated>2010-10-03T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2010/10/03/introducing-combinatorics-0.2.0.html</id>
    <content type="html">&lt;p&gt;I decided to take my &lt;a href=&quot;/2010/10/01/list-comprehensions-in-ruby.html&quot;&gt;List Comprehension&lt;/a&gt;
code with some other Combinatorics code I had floating around and release
&lt;a href=&quot;http://rubydoc.info/gems/combinatorics&quot;&gt;Combinatorics&lt;/a&gt; 0.2.0:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ gem install combinatorics
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;After getting specs on the List Comprehension code, it became easy to
refactor it and get the specs passing on Ruby 1.8.7, 1.9.2 and JRuby.
Unfortunately, &lt;a href=&quot;http://rubini.us/&quot;&gt;Rubinius&lt;/a&gt; does not yet support
&lt;code&gt;Enumerator#next&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The Combinatorics library also contains the
&lt;a href=&quot;http://rubydoc.info/gems/combinatorics/Combinatorics/PowerSet/Mixin#powerset-instance_method&quot;&gt;powerset&lt;/a&gt;
method, added to &lt;code&gt;Array&lt;/code&gt; and &lt;code&gt;Set&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;require 'combinatorics'

[1,2,3].powerset
# =&amp;gt; [[],
      [3],
      [2],
      [2, 3],
      [1],
      [1, 3],
      [1, 2],
      [1, 2, 3]]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In Combinatorics 0.2.0,
&lt;a href=&quot;http://rubydoc.info/gems/combinatorics/Range#%26-instance_method&quot;&gt;Range#&amp;amp;&lt;/a&gt;,
&lt;a href=&quot;http://rubydoc.info/gems/combinatorics/Range#upto-instance_method&quot;&gt;Range#upto&lt;/a&gt;
and &lt;a href=&quot;http://rubydoc.info/gems/combinatorics/Range#downto-instance_method&quot;&gt;Range#downto&lt;/a&gt;
were also added:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;(1..50) &amp;amp; (20..100)
# =&amp;gt; (20..50)

(1..5).upto(2..10).to_a
# =&amp;gt; [1..5, 1..6, 1..7, 1..8, 1..9, 1..10,
      2..5, 2..6, 2..7, 2..8, 2..9, 2..10]

(2..10).downto(1..5).to_a
# =&amp;gt; [2..10, 2..9, 2..8, 2..7, 2..6, 2..5,
      1..10, 1..9, 1..8, 1..7, 1..6, 1..5]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Fork the &lt;a href=&quot;http://github.com/postmodern/combinatorics/#fork_box&quot;&gt;Combinatorics&lt;/a&gt;
library today, and add your own Combinatoric methods.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>List Comprehensions in Ruby</title>
    <link href="http://postmodern.github.io/2010/10/01/list-comprehensions-in-ruby.html" />
    <updated>2010-10-01T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2010/10/01/list-comprehensions-in-ruby.html</id>
    <content type="html">&lt;p&gt;Recently I have been interested in &lt;a href=&quot;http://haskell.org/&quot;&gt;Haskell&lt;/a&gt; and been
skimming the whimsical (yet informative)
&lt;a href=&quot;http://learnyouahaskell.com/&quot;&gt;Learn a Haskell, for Great Good!&lt;/a&gt;.
One feature I really like from Haskell is their implementation of
list comprehensions:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Prelude&amp;gt; [(x,y) | x &amp;lt;- [1..10], y &amp;lt;- [2..8]]
[(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8),
(2,2),(2,3),(2,4),(2,5),(2,6),(2,7),(2,8),
(3,2),(3,3),(3,4),(3,5),(3,6),(3,7),(3,8),
(4,2),(4,3),(4,4),(4,5),(4,6),(4,7),(4,8),
(5,2),(5,3),(5,4),(5,5),(5,6),(5,7),(5,8),
(6,2),(6,3),(6,4),(6,5),(6,6),(6,7),(6,8),
(7,2),(7,3),(7,4),(7,5),(7,6),(7,7),(7,8),
(8,2),(8,3),(8,4),(8,5),(8,6),(8,7),(8,8),
(9,2),(9,3),(9,4),(9,5),(9,6),(9,7),(9,8),
(10,2),(10,3),(10,4),(10,5),(10,6),(10,7),(10,8)]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This list comprehension is essentially a Set definition using first-order
predicate logic, with universal quantifiers on &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; (where the Set
contains the tuples composed of every &lt;code&gt;x&lt;/code&gt; and every &lt;code&gt;y&lt;/code&gt; from the ranges
&lt;code&gt;1..10&lt;/code&gt; and &lt;code&gt;2..8&lt;/code&gt;). Amazingly, the Haskell version looks almost exactly
like the Set definitions from my
&lt;a href=&quot;http://www.amazon.com/Discrete-Structures-Computability-Bartlett-Computer/dp/0763718432&quot;&gt;Discrete Structures, Logic, and Computability (2nd edition)&lt;/a&gt;
book, except without the curly-braces or universal quantifiers
(&lt;img src=&quot;http://upload.wikimedia.org/math/d/4/d/d4d49bead125261b226eaa867bd016ce.png&quot; alt=&quot;universal quantifier&quot; /&gt;).&lt;/p&gt;

&lt;p&gt;One does not have to learn functional programming and Haskell to use list
comprehensions, Python has them as well:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; [(x,y) for x in range(0,11) for y in range(2,9)]
[(0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8),
(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8),
(2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8),
(3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8),
(4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8),
(5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8),
(6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8),
(7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (7, 8),
(8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8),
(9, 2), (9, 3), (9, 4), (9, 5), (9, 6), (9, 7), (9, 8),
(10, 2), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (10, 8)]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Granted, using the &lt;code&gt;for&lt;/code&gt; loop syntax as constraints for the list
comprehension is not as sexy as the Haskell version, but it gets the job
done.&lt;/p&gt;

&lt;p&gt;Unfortunately, Ruby does not support list comprehensions, and only has
a couple methods for doing &lt;a href=&quot;http://en.wikipedia.org/wiki/Combinatorics&quot;&gt;Combinatorics&lt;/a&gt; (&lt;code&gt;Array#combination&lt;/code&gt; and &lt;code&gt;Array#permutation&lt;/code&gt;).
So, I &lt;a href=&quot;http://gist.github.com/605891&quot;&gt;implemented list comprehensions&lt;/a&gt;
for the Ruby &lt;code&gt;Array&lt;/code&gt; class:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; require './array_comprehension'
=&amp;gt; true
&amp;gt;&amp;gt; [(1..10), (2..8)].comprehension.to_a
=&amp;gt; [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8],
    [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8],
    [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8],
    [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8],
    [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8],
    [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [6, 8],
    [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [7, 8],
    [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8],
    [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8],
    [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8]] 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I used &lt;code&gt;yield&lt;/code&gt; to quickly pass results to the given block, to not
stress the Garbage Collector with building a huge Arrays. The method also
returns an &lt;a href=&quot;http://rubydoc.info/docs/ruby-core/1.9.2/Enumerator&quot;&gt;Enumerator&lt;/a&gt;
object if no block is given, to fake Haskells lazy evaluation.&lt;/p&gt;

&lt;p&gt;Note, that the &lt;code&gt;Array&lt;/code&gt; may contain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://rubydoc.info/docs/ruby-core/1.9.2/Enumerable&quot;&gt;Enumerable&lt;/a&gt; objects:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  &amp;gt;&amp;gt; [('a'..'f'),(0..10).step(2)].comprehension.to_a
  =&amp;gt; [[&quot;A&quot;, 0], [&quot;A&quot;, 2], [&quot;A&quot;, 4], [&quot;A&quot;, 6], [&quot;A&quot;, 8], [&quot;A&quot;, 10],
      [&quot;B&quot;, 0], [&quot;B&quot;, 2], [&quot;B&quot;, 4], [&quot;B&quot;, 6], [&quot;B&quot;, 8], [&quot;B&quot;, 10],
      [&quot;C&quot;, 0], [&quot;C&quot;, 2], [&quot;C&quot;, 4], [&quot;C&quot;, 6], [&quot;C&quot;, 8], [&quot;C&quot;, 10],
      [&quot;D&quot;, 0], [&quot;D&quot;, 2], [&quot;D&quot;, 4], [&quot;D&quot;, 6], [&quot;D&quot;, 8], [&quot;D&quot;, 10],
      [&quot;E&quot;, 0], [&quot;E&quot;, 2], [&quot;E&quot;, 4], [&quot;E&quot;, 6], [&quot;E&quot;, 8], [&quot;E&quot;, 10],
      [&quot;F&quot;, 0], [&quot;F&quot;, 2], [&quot;F&quot;, 4], [&quot;F&quot;, 6], [&quot;F&quot;, 8], [&quot;F&quot;, 10]] 
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Non-enumerable objects:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  &amp;gt;&amp;gt; [5,(6..9),10].comprehension.to_a
  =&amp;gt; [[5, 6, 10], [5, 7, 10], [5, 8, 10], [5, 9, 10]]
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Even other list comprehensions:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  &amp;gt;&amp;gt; syllable = (['a'..'z'] * 2).comprehension
  &amp;gt;&amp;gt; word = [syllable] * 4
  &amp;gt;&amp;gt; number = (1..100)
  &amp;gt;&amp;gt; [*word, number].comprehension { |*s| puts s.join }
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;This code does require Ruby 1.9 since &lt;a href=&quot;http://rubydoc.info/docs/ruby-core/1.9.2/Enumerator#peek-instance_method&quot;&gt;Enumerator#peek&lt;/a&gt;
was not back-ported to Ruby 1.8.7.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ rvm install 1.9.2
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  
  <entry>
    <title>Introducing OpenNamespace</title>
    <link href="http://postmodern.github.io/2010/09/03/introducing-open-namespace.html" />
    <updated>2010-09-03T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2010/09/03/introducing-open-namespace.html</id>
    <content type="html">&lt;p&gt;I have always liked how frameworks such as Rails can
&lt;a href=&quot;http://www.rubyinside.com/ruby-techniques-revealed-autoload-1652.html&quot;&gt;autoload&lt;/a&gt;
Classes. I wanted to provide similar behavior in
&lt;a href=&quot;http://ronin-ruby.github.com/&quot;&gt;Ronin&lt;/a&gt; and other frameworks, so I created
the &lt;a href=&quot;http://github.com/postmodern/open_namespace&quot;&gt;OpenNamespace&lt;/a&gt; library.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://rubydoc.info/gems/open_namespace&quot;&gt;OpenNamespace&lt;/a&gt; allows namespaces
to require and find classes and modules from RubyGems. Using &lt;code&gt;OpenNamespace&lt;/code&gt;
you can make a &lt;code&gt;Plugins&lt;/code&gt; module able to load plugin modules/classes from
other gems.&lt;/p&gt;

&lt;p&gt;More specifically, &lt;code&gt;OpenNamespace&lt;/code&gt; does not need to know where
the files are, it just guesses the file path based on the constant name,
attempts to require it then finds the constant in the namespace.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ gem install open_namespace
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Examples&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;require 'open_namespace'

module Project
  module Plugins
    include OpenNamespace
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Explicitly load constants:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Project::Plguins.require_const :foo_bar
# =&amp;gt; Project::Plugins::FooBar
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Explicitly load constants with odd capitalization:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Project::Plugins.require_const :tcp_session
# =&amp;gt; Project::Plugins::TCPSession
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Explicitly load constants via sub-paths:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Project::Plguins.require_const 'templates/erb'
# =&amp;gt; Project::Plugins::Templates::Erb
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Implicitly load constants via const_missing:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Project::Plugins::Other
# =&amp;gt; Project::Plugins::Other
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Enjoy.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Introducing uri-query_params</title>
    <link href="http://postmodern.github.io/2010/09/02/introducing-uri-query-params.html" />
    <updated>2010-09-02T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2010/09/02/introducing-uri-query-params.html</id>
    <content type="html">&lt;p&gt;&lt;a href=&quot;http://github.com/postmodern/uri-query_params&quot;&gt;uri-query_params&lt;/a&gt; is a new
library which allows accessing the individual parameters in the query
string of a HTTP URI in Ruby. The library
&lt;a href=&quot;http://en.wikipedia.org/wiki/Monkey_patch&quot;&gt;monkey-patches&lt;/a&gt; the &lt;code&gt;URI::HTTP&lt;/code&gt;
class to provide similar behavior to PHPs famous &lt;code&gt;$_GET&lt;/code&gt; hash.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ gem install uri-query_params
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Using &lt;code&gt;uri-query_params&lt;/code&gt; you can, inspect the URI query_params:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;require 'uri/query_params'

url = URI('http://www.google.com/search?hl=en&amp;amp;client=firefox-a&amp;amp;rls=org.mozilla%3Aen-US%3Aofficial&amp;amp;hs=1HY&amp;amp;q=bob+ross&amp;amp;btnG=Search')

url.query_params
# =&amp;gt; {&quot;btnG&quot;=&amp;gt;&quot;Search&quot;, &quot;hs&quot;=&amp;gt;&quot;1HY&quot;, &quot;rls&quot;=&amp;gt;&quot;org.mozilla:en-US:official&quot;, &quot;client&quot;=&amp;gt;&quot;firefox-a&quot;, &quot;hl&quot;=&amp;gt;&quot;en&quot;, &quot;q&quot;=&amp;gt;&quot;bob+ross&quot;}

url.query_params['q']
# =&amp;gt; &quot;bob+ross&quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Also, set the URI query_params:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;url.query_params['q'] = 'Upright Citizens Brigade'
url.to_s
# =&amp;gt; &quot;http://www.google.com/search?btnG=Search&amp;amp;hs=1HY&amp;amp;rls=org.mozilla:en-US:official&amp;amp;client=firefox-a&amp;amp;hl=en&amp;amp;q=Upright%20Citizens%20Brigade&quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Originally, the &lt;a href=&quot;http://rubydoc.info/gems/uri-query_params/URI/QueryParams/Mixin&quot;&gt;URI::QueryParams&lt;/a&gt;
mixin was developed for &lt;a href=&quot;http://ronin-ruby.github.com/&quot;&gt;Ronin&lt;/a&gt; and
&lt;a href=&quot;http://github.com/postmodern/gscraper/&quot;&gt;GScraper&lt;/a&gt;. I decided to split the
code out into a common library, to prevent conflicts between the two
separate versions.&lt;/p&gt;

&lt;p&gt;Enjoy.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>SimpleMarkup is dead. Long live MarkDown (and Textile)</title>
    <link href="http://postmodern.github.io/2010/02/02/simple_markup-is-dead.html" />
    <updated>2010-02-02T00:00:00-08:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2010/02/02/simple_markup-is-dead.html</id>
    <content type="html">&lt;p&gt;If you use &lt;a href=&quot;http://rdoc.sourceforge.net/&quot;&gt;RDoc&lt;/a&gt;, than you're probably familiar with it's markup, known as &lt;a href=&quot;http://rdoc.sourceforge.net/doc/files/markup/simple_markup_rb.html&quot;&gt;SimpleMarkup&lt;/a&gt;. If you've been using RDoc for a while, you are also probably aware that SimpleMarkup is horribly &lt;a href=&quot;http://redmine.ruby-lang.org/issues/show/1042&quot;&gt;broken&lt;/a&gt;, when it comes to handling odd formatting.&lt;/p&gt;

&lt;p&gt;Besides the usual formatting mistakes that can easily crash SimpleMarkup, I and other users began noticing odd &lt;a href=&quot;http://rubyforge.org/tracker/index.php?func=detail&amp;amp;aid=27674&amp;amp;group_id=627&amp;amp;atid=2472&quot;&gt;error messages&lt;/a&gt; when installing YARD documentation with SimpleMarkup:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Unhandled special: Special: type=65, name=CROSSREF,_SPECIAL_, text=&quot;Spidr&quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Even after ditching RDoc for &lt;a href=&quot;http://yardoc.org/&quot;&gt;YARD&lt;/a&gt;, SimpleMarkup (the default markup used by YARD) was able to reach forth from it's icy RubyGem and introduce bugs into my code. This was the last straw, SimpleMarkup is dead, time to move on.&lt;/p&gt;

&lt;p&gt;Luckily, YARD supports using alternate markup engines, such as &lt;a href=&quot;http://daringfireball.net/projects/markdown/basics&quot;&gt;MarkDown&lt;/a&gt; or &lt;a href=&quot;http://redcloth.org/textile&quot;&gt;Textile&lt;/a&gt;. Having used MarkDown regularly in the past, and that it matched SimpleMarkup's syntax in some ways, I decided to convert all of my Ruby project's to MarkDown formatted YARD documentation.&lt;/p&gt;

&lt;p&gt;First, I had to specify the &lt;kbd&gt;--markup markdown&lt;/kbd&gt; option in the &lt;a href=&quot;http://github.com/postmodern/spidr/commit/38546a27c5a399f4b54e723de2dfbb87f61c8762#L2L14&quot;&gt;yard_options&lt;/a&gt; setting (provided by the &lt;a href=&quot;http://hoe-yard.rubyforge.org/&quot;&gt;hoe-yard&lt;/a&gt; plugin) in the Rakefile.&lt;/p&gt;

&lt;p&gt;Second, I renamed the README.*, History.* files to README.md, History.md, respectively.&lt;/p&gt;

&lt;p&gt;Finally, I began the tedious process of converting SimpleMarkup formatted text to MarkDown:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Replace the &lt;kbd&gt;=&lt;/kbd&gt;, &lt;kbd&gt;==&lt;/kbd&gt;, &lt;kbd&gt;===&lt;/kbd&gt; headings with &lt;kbd&gt;#&lt;/kbd&gt;, &lt;kbd&gt;##&lt;/kbd&gt;, &lt;kbd&gt;###&lt;/kbd&gt;.&lt;/li&gt;
  &lt;li&gt;Indent all source-code examples not following a YARD &lt;kbd&gt;@example&lt;/kbd&gt; tag by 4 spaces.&lt;/li&gt;
  &lt;li&gt;Convert any raw URLs to MarkDown links.&lt;/li&gt;
  &lt;li&gt;Replace any +code+ or &amp;lt;tt&amp;gt;code&amp;lt;/tt&amp;gt; formatting with `code` or &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt;. (Note: `code` can handle spaces, numbers and symbols within the ` ` characters, where as +code+ cannot.)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In conclusion, that is how I ridded myself of the last buggy vestiges of RDoc, and increased the reliability of my documentation using YARD.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Introducing static_paths 0.1.0</title>
    <link href="http://postmodern.github.io/2010/01/25/introducing-static_paths-0.1.0.html" />
    <updated>2010-01-25T00:00:00-08:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2010/01/25/introducing-static_paths-0.1.0.html</id>
    <content type="html">&lt;p&gt;&lt;b&gt;Update 2:&lt;/b&gt; &lt;kbd&gt;static_paths&lt;/kbd&gt; has now be renamed to &lt;a href=&quot;http://github.com/postmodern/data_paths&quot;&gt;data_paths&lt;/a&gt; with documentation available on &lt;a href=&quot;http://rubydoc.info/gems/data_paths&quot;&gt;rubydoc.info&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Update:&lt;/b&gt; Documentation has now been posted on &lt;a href=&quot;http://static-paths.rubyforge.org/&quot;&gt;static-paths.rubyforge.org&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;When writing a library which bundles static-content in a directory named &lt;kbd&gt;data/&lt;/kbd&gt; or &lt;kbd&gt;static/&lt;/kbd&gt;, you usually need to find the directory using something like.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','..','static'))&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But then you want to allow plugins to extend the functionality of your library, and even add their own static-content. Now you have to manage more than one directory path.&lt;/p&gt;

&lt;p&gt;Enter &lt;a href=&quot;http://static-paths.rubyforge.org/&quot;&gt;StaticPaths&lt;/a&gt;, a Ruby library for managing and searching through directories containing static-content. &lt;kbd&gt;StaticPaths&lt;/kbd&gt; helps manage directories across multiple libraries in much the same way that RubyGems manages &lt;kbd&gt;lib/&lt;/kbd&gt; directories using &lt;kbd&gt;$LOAD_PATH&lt;/kbd&gt;. Except that &lt;kbd&gt;StaticPaths&lt;/kbd&gt; does not use global variables.&lt;/p&gt;

&lt;h2&gt;Example Usage&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;require 'static_paths'

module MyLibrary
  include StaticPaths

  # define the static dir(s)
  register_static_dir File.join(File.dirname(__FILE__),'..','..','static')
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href=&quot;http://static-paths.rubyforge.org/StaticPaths/Methods.html#register_static_dir-instance_method&quot;&gt;register_static_dir&lt;/a&gt; will expand the path, make sure the path points to a directory, then adds the path to &lt;a href=&quot;http://static-paths.rubyforge.org/StaticPaths.html#paths-class_method&quot;&gt;StaticPaths.paths&lt;/a&gt; and the local &lt;a href=&quot;http://static-paths.rubyforge.org/StaticPaths/Methods.html#static_paths-instance_method&quot;&gt;MyLibrary.static_paths&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;One can also unregister directories using &lt;a href=&quot;http://static-paths.rubyforge.org/StaticPaths/Methods.html#unregister_static_dir!-instance_method&quot;&gt;unregister_static_dir!&lt;/a&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;MyLibrary.unregister_static_dir! File.join(File.dirname(__FILE__),'..','..','static')&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or, one can use &lt;a href=&quot;http://static-paths.rubyforge.org/StaticPaths/Methods.html#unregister_static_dirs!-instance_method&quot;&gt;unregister_static_dirs!&lt;/a&gt; to unregister all directories registered within a module/class.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;module MyLibrary
  def MyLibrary.cleanup!
    unregister_static_dirs!
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To search through and access the content within registered directories, simply use the methods within the &lt;a href=&quot;http://static-paths.rubyforge.org/StaticPaths/Finders.html&quot;&gt;StaticPaths::Finders&lt;/a&gt; module.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;module MyLibrary
  class UsesContent

    include StaticPaths::Finders

    def index
      find_static_file('index.html')
    end

    def file_dirs
      all_static_dirs('extra')
    end

    def copy(src,dest)
      each_static_dir(src) do |dir|
        FileUtils.cp_r(dir,dest)
      end
    end

  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Installation:&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;$ sudo gem install static_paths&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  
  <entry>
    <title>(Fully) Document your DataMapper models with YARD</title>
    <link href="http://postmodern.github.io/2010/01/16/fully-document-your-datamapper.html" />
    <updated>2010-01-16T00:00:00-08:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2010/01/16/fully-document-your-datamapper.html</id>
    <content type="html">&lt;p&gt;Any release quality software has to provide documentation, for the future maintainers and other developers. Traditionally, Ruby projects would use &lt;a href=&quot;http://rdoc.rubyforge.org/&quot;&gt;RDoc&lt;/a&gt; and add custom documentation blurbs to their classes, methods, attributes and constants. Unfortunately, there's a major limitation to RDoc, I can't be extended to recognize new meta-programming method calls.&lt;/p&gt;

&lt;p&gt;This rigidness of RDoc really shows up when you need to document ORM backed projects, such as one containing &lt;a href=&quot;http://datamapper.org/&quot;&gt;DataMapper&lt;/a&gt; models. DataMapper allows one to define the &lt;a href=&quot;http://datamapper.org/docs/properties.html&quot;&gt;properties&lt;/a&gt; and &lt;a href=&quot;http://datamapper.org/docs/associations.html&quot;&gt;relations&lt;/a&gt; between models using handy class-methods:&lt;/p&gt;

&lt;pre&gt;class MyModel

  include DataMapper::Resource

  # The primary key of the model
  property :id, Serial

  # The name of the model
  property :name, String

  # The many authors contributing to the model
  has n, :authors

  # The user that owns the model
  belongs_to :user

end&lt;/pre&gt;

&lt;p&gt;RDoc will not recognize &lt;kbd&gt;property, &lt;kbd&gt;has&lt;/kbd&gt; or &lt;kbd&gt;belongs_to&lt;/kbd&gt;. Nor will RDoc know that &lt;kbd&gt;property&lt;/kbd&gt; adds a class-method and instance reader/writer methods with the given name to the model. Documentation fail.&lt;/p&gt;

&lt;h2&gt;Enter YARD&lt;/h2&gt;

&lt;blockquote&gt;YARD is a documentation generation tool for the Ruby programming language. It enables the user to generate consistent, usable documentation that can be exported to a number of formats very easily, and also supports extending for custom Ruby constructs such as custom class level definitions.&lt;/blockquote&gt;
&lt;a href=&quot;http://github.com/lsegal/yard&quot;&gt;http://github.com/lsegal/yard&lt;/a&gt;

&lt;p&gt;YARD organizes most of it's parsing logic into multiple handlers; essentially classes that inherit &lt;a href=&quot;http://yardoc.org/docs/yard/YARD/Handlers/Ruby/Base&quot;&gt;YARD::Handlers::Ruby::Base&lt;/a&gt; and define a &lt;kbd&gt;process&lt;/kbd&gt; method. YARD also supports a plugin system, by loading any RubyGems installed on the system that are prefixed with &lt;kbd&gt;yard-&lt;/kbd&gt; or &lt;kbd&gt;yard_&lt;/kbd&gt;. Using these two features of YARD, one can easily create a YARD plugin gem containing custom handlers, which YARD can automatically load and use.&lt;/p&gt;

&lt;h2&gt;yard-dm&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://github.com/postmodern/yard-dm&quot;&gt;yard-dm&lt;/a&gt; is a YARD plugin for parsing DataMapper model syntax. The plugin can handle the following statements:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;kbd&gt;property :name, Type&lt;/kbd&gt;&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;has n, :things&lt;/kbd&gt;&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;has 1, :thing&lt;/kbd&gt;&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;has 0..n, :things&lt;/kbd&gt;&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;has 1..n, :things&lt;/kbd&gt;&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;has 2..5, :things&lt;/kbd&gt;&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;belongs_to :stuff&lt;/kbd&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Install It&lt;/h3&gt;

&lt;pre&gt;$ sudo gem install yard-dm&lt;/pre&gt;

&lt;h3&gt;Use It&lt;/h3&gt;

&lt;pre&gt;$ cd dm-project/
$ yardoc&lt;/pre&gt;

&lt;p&gt;It's that easy.&lt;/p&gt;

&lt;p&gt;Next time you need complete documentation on your DataMapper backed project, just install &lt;a href=&quot;http://yardoc.org/&quot;&gt;YARD&lt;/a&gt; and &lt;a href=&quot;http://github.com/postmodern/yard-dm&quot;&gt;yard-dm&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Using YARD with Hoe, correctly</title>
    <link href="http://postmodern.github.io/2010/01/11/using-yard-with-hoe.html" />
    <updated>2010-01-11T00:00:00-08:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2010/01/11/using-yard-with-hoe.html</id>
    <content type="html">&lt;p&gt;When I first switched from the more traditional &lt;a href=&quot;http://episteme.arstechnica.com/eve/forums/a/ga/ul/299008287931/inlineimg/Y/train_wreck.jpg&quot;&gt;RDoc&lt;/a&gt; to &lt;a href=&quot;http://yardoc.org/&quot;&gt;YARD&lt;/a&gt;, I was only using the basic YARD task. In YARD 0.2.3.5, a gem plugin was added to YARD that would run &lt;kbd&gt;yardoc&lt;/kbd&gt; on an installed gem if &lt;kbd&gt;has_rdoc&lt;/kbd&gt; was set to &lt;kbd&gt;&quot;yard&quot;&lt;/kbd&gt; in the Gem Specification. The &lt;kbd&gt;yardoc&lt;/kbd&gt; command would also use the &lt;kbd&gt;rdoc_options&lt;/kbd&gt; and &lt;kbd&gt;extra_rdoc_files&lt;/kbd&gt; options from the Gem Specification.&lt;/p&gt;

&lt;p&gt;Since I use &lt;a href=&quot;http://seattlerb.rubyforge.org/hoe/&quot;&gt;Hoe&lt;/a&gt; for all my gem publishing needs, I got tired of having to specify all of this information explicitly in my Rakefiles; after all Hoe is suppose to make one's Rakefiles simple and elegant. So I took advantage of Hoe's plugin system and created a Hoe plugin to properly configure my projects for YARD.&lt;/p&gt;

&lt;p&gt;Introducing &lt;a href=&quot;http://github.com/postmodern/hoe-yard/&quot;&gt;hoe-yard&lt;/a&gt;, a Hoe plugin that will:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Automatically find the README and History files, irregardless of file extension.&lt;/li&gt;
  &lt;li&gt;Sets &lt;kbd&gt;has_rdoc&lt;/kbd&gt; to yard.&lt;/li&gt;
  &lt;li&gt;Sets &lt;kbd&gt;rdoc_options&lt;/kbd&gt;.&lt;/li&gt;
  &lt;li&gt;Sets &lt;kbd&gt;extra_rdoc_files&lt;/kbd&gt;.&lt;/li&gt;
  &lt;li&gt;Adds YARD and hoe-yard as development dependencies.&lt;/li&gt;
  &lt;li&gt;Adds the &lt;kbd&gt;yard&lt;/kbd&gt; and &lt;kbd&gt;docs&lt;/kbd&gt; Rake tasks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Install&lt;/h2&gt;
&lt;pre&gt;$ sudo gem install hoe-yard&lt;/pre&gt;

&lt;h2&gt;Usage&lt;/h2&gt;

&lt;pre&gt;require 'rubygems'
require 'hoe'

Hoe.plugin :yard

Hoe.spec('my_project') do
  # ...

  # optional YARD settings
  self.yard_title = 'My Project (0.1.0)'
  self.yard_markup = :markdown
  self.yard_opts = ['--protected'] # any additional YARD options

  # ...
end&lt;/pre&gt;

&lt;p&gt;Not only does hoe-yard make setting up YARD with a project extremely easy, it also ensures the documentation that is automatically generated when a gem is installed will match the documentation published for that gem.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Spidr 0.2.2 released.</title>
    <link href="http://postmodern.github.io/2010/01/11/spidr-0.2.2-released.html" />
    <updated>2010-01-11T00:00:00-08:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2010/01/11/spidr-0.2.2-released.html</id>
    <content type="html">Spidr 0.2.2 (code-named &quot;next-level&quot;) has been released. This release contains a lot of changes that pushes Spidr into a new level of web spidering.

&lt;h2&gt;Web Spider Obstacle Course (WSOC)&lt;/h2&gt;

Spidr 0.2.2 now requires and makes use of the new &lt;a href=&quot;http://github.com/postmodern/wsoc/&quot;&gt;Web Spider Obstacle Course (WSOC)&lt;/a&gt; for testing. Before one runs the RSpec test-suite for Spidr, the WSOC server must first be started:
&lt;pre&gt;$ wsoc_server&lt;/pre&gt;

Then simply run the specs as usual:
&lt;pre&gt;$ rake spec&lt;/pre&gt;

&lt;h2&gt;Cookie support&lt;/h2&gt;

As of 0.2.2, Spidr now comes with a &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/CookieJar.html&quot;&gt;CookieJar&lt;/a&gt;, thanks to the work of &lt;a href=&quot;http://twitter.com/zapnap/&quot;&gt;@zapnap&lt;/a&gt;. Now when the &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Agent.html&quot;&gt;Spidr::Agent&lt;/a&gt; visits a page, any new cookie values will be merged into the CookieJar, and sent back with any future requests.

Additionally, one can now access the Cookie values from a &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Page.html&quot;&gt;Spidr::Page&lt;/a&gt; object.
&lt;pre&gt;page.cookie
# =&amp;gt; &quot;COUNTRY=USA%2C97.100.45.38; expires=Mon, 18-Jan-2010 06:19:24 GMT; path=/; domain=.php.net&quot;&lt;/pre&gt;
&lt;pre&gt;page.cookies
# =&amp;gt; [&quot;COUNTRY=USA%2C97.100.45.38; expires=Mon, 18-Jan-2010 06:19:24 GMT; path=/; domain=.php.net&quot;]&lt;/pre&gt;

&lt;h2&gt;HTTP Basic Auth support&lt;/h2&gt;

Spidr 0.2.2 now comes with a brand new &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/AuthStore.html&quot;&gt;AuthStore&lt;/a&gt;, for organizing HTTP Authentication credentials; also thanks to the work of &lt;a href=&quot;http://twitter.com/zapnap/&quot;&gt;@zapnap&lt;/a&gt;.

Provided you have the credentials for the various HTTP Basic Auth protected areas that are to be spidered, Spidr can automatically respond to Basic Auth challenges. 

Simply specify the credentials to the &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Agent.html&quot;&gt;Spidr::Agent&lt;/a&gt; and the agent will do the rest:
&lt;pre&gt;Spidr.host('corporation.com') do |agent|
  agent.authorized.add('http://corporation.com/private/', 'user1233', 'motivate synergize')

  agent.every_page do |page|
    if page.url.path =~ /private/
      # ...
    end
  end
end&lt;/pre&gt;

&lt;h2&gt;URL Sanitization&lt;/h2&gt;

&lt;p&gt;A small yet important module was added in Spidr 0.2.2, and that is &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Sanitizers.html&quot;&gt;Spidr::Sanitizers&lt;/a&gt;. The &lt;kbd&gt;Sanitizers&lt;/kbd&gt; module adds configuration settings to &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Agent.html&quot;&gt;Spidr::Agent&lt;/a&gt; for how incoming URLs are to be sanitized.&lt;/p&gt;

&lt;p&gt;For instance, URL fragments are removed by default, but this can be changed:&lt;/p&gt;

&lt;pre&gt;agent.strip_fragments
# =&amp;gt; true
agent.strip_fragments = true&lt;/pre&gt;

&lt;p&gt;Additionally, perhaps one might wish to strip the query strings from all URLs:&lt;/p&gt;

&lt;pre&gt;agent.strip_query = true&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; If YARD documentation generation fails when installing Spidr 0.2.2, this is due to a &lt;a href=&quot;http://rubyforge.org/tracker/?func=detail&amp;amp;aid=27674&amp;amp;group_id=627&amp;amp;atid=2472&quot;&gt;bug in RDoc/SimpleMarkup generation&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Introducing the new Web Spider Obstacle Course</title>
    <link href="http://postmodern.github.io/2010/01/11/introducing-the-new-web-spider-obstacle-course.html" />
    <updated>2010-01-11T00:00:00-08:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2010/01/11/introducing-the-new-web-spider-obstacle-course.html</id>
    <content type="html">&lt;p&gt;The Web Spider Obstacle Course was originally developed for testing the &lt;a href=&quot;http://spidr.rubyforge.org/&quot;&gt;Spidr&lt;/a&gt; library. The Obstacle Course was essentially a set of static files containing valid links, invalid links, links to previously visited pages and links to non-existent hosts/ports. Having the course hosted on spidr.rubyforge.org made it difficult to do advanced testing (such as using HTTP Redirects), not to mention slow to access.&lt;/p&gt;

&lt;p&gt;Now the &lt;a href=&quot;http://github.com/postmodern/wsoc/&quot;&gt;Web Spider Obstacle Course (WSOC)&lt;/a&gt; has been rewritten as a Ruby &lt;a href=&quot;http://sinatrarb.com/&quot;&gt;Sinatra&lt;/a&gt; app that can be ran locally. Since most Ruby developers are familiar with Sinatra, it should not be too difficult to extend the Obstacle Course.&lt;/p&gt;

&lt;p&gt;Currently WSOC tests a Web Spider's ability to navigate:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Empty links.&lt;/li&gt;
  &lt;li&gt;Circular links.&lt;/li&gt;
  &lt;li&gt;Links with relative-paths.&lt;/li&gt;
  &lt;li&gt;Links with absolute-paths.&lt;/li&gt;
  &lt;li&gt;Remote links.&lt;/li&gt;
  &lt;li&gt;javascript: links.&lt;/li&gt;
  &lt;li&gt;Links within frameset and iframe tags.&lt;/li&gt;
  &lt;li&gt;Cookie protected pages.&lt;/li&gt;
  &lt;li&gt;HTTP 300, 301, 302, 303 and 307 Redirects.&lt;/li&gt;
  &lt;li&gt;HTTP Baisc Auth protected pages.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;3... 2... 1... Go&lt;/h2&gt;

&lt;h3&gt;Install:&lt;/h3&gt;
&lt;pre&gt;$ sudo gem install wsoc&lt;/pre&gt;

&lt;h3&gt;Run:&lt;/h3&gt;
&lt;pre&gt;wsoc_server -p 8080&lt;/pre&gt;

&lt;h3&gt;Visit:&lt;/h3&gt;
&lt;pre&gt;firefox http://localhost:8080/&lt;/pre&gt;

&lt;p&gt;The front page of WSOC will explain the rules of the Obstacle Course and providing the Start URL for any would-be Web Spiders. The WSOC server still contains the Obstacle Course Specs, available at &lt;a href=&quot;http://localhost:8080/specs&quot;&gt;http://localhost:8080/specs&lt;/a&gt;. The Obstace Course Specs are essentially a list of URLs, the expected behavior of the spider for the URL (&lt;kbd&gt;visit&lt;/kbd&gt;, &lt;kbd&gt;ignore&lt;/kbd&gt; or &lt;kbd&gt;fail&lt;/kbd&gt;) and a message about the given URL. These specs can be access by Web Spider test suites in JSON (&lt;a href=&quot;http://localhost:8080/specs.json&quot;&gt;http://localhost:8080/specs.json&lt;/a&gt;) or YAML (&lt;a href=&quot;http://localhost:8080/specs.json&quot;&gt;http://localhost:8080/specs.yaml&lt;/a&gt;) formats.&lt;/p&gt;

&lt;h2&gt;Use It&lt;/h2&gt;

&lt;p&gt;If you actively maintain a Web Spider, or are thinking of writing a Web Spider/Crawler/Scanner, I highly recommend you use the Web Spider Obstacle Course as part of your testing solution. The Obstacle Course will test more than a Web Spiders ability to resolve relative links or only visit a link once.&lt;/p&gt;

&lt;p&gt;The internet is a wild place, and will not always obey XHTML 1.1 Strict or HTTP 1.0 standards. Test your Web Spiders fully before setting them loose.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>ToorCamp: Ronin - A Platform for Publishing and Mayhem</title>
    <link href="http://postmodern.github.io/2009/11/01/toorcamp-ronin-a-platform-for-publishing-and-mayhem.html" />
    <updated>2009-11-01T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2009/11/01/toorcamp-ronin-a-platform-for-publishing-and-mayhem.html</id>
    <content type="html">&lt;p&gt;I was pretty surprised and pleased when ToorCon finally released videos of the talks at &lt;a href=&quot;http://toorcamp.org/&quot;&gt;ToorCamp 2009&lt;/a&gt;. At this years &lt;a href=&quot;http://sandiego.toorcon.org/&quot;&gt;ToorCon: San Diego&lt;/a&gt; DVDs of the talks, pressed by &lt;a href=&quot;http://www.mediaarchives.com/&quot;&gt;MediaArchives&lt;/a&gt;, were handed out. Thanks to &lt;a href=&quot;http://deanpierce.net/&quot;&gt;Mr. Pierce&lt;/a&gt; for grabbing a copy of my talk on &lt;a href=&quot;http://ronin.rubyforge.org/&quot;&gt;Ronin&lt;/a&gt; and getting it back to me for transcoding/uploading. The full talk has been transcoded to &lt;a href=&quot;http://theora.org/&quot;&gt;Ogg Theora&lt;/a&gt; and uploaded to &lt;a href=&quot;http://vimeo.com/&quot;&gt;vimeo.com&lt;/a&gt;. If you have a Vimeo account, you can download the original ogg file as well.&lt;/p&gt;

&lt;a href=&quot;http://vimeo.com/7359548&quot;&gt;ToorCamp: Ronin - A Platform for Publish and Mayhem&lt;/a&gt;

&lt;p&gt;Original slides can be found &lt;a href=&quot;http://ronin.rubyforge.org/talks/publishing_and_mayhem.html&quot;&gt;here&lt;/a&gt;, in XHTML form.&lt;/p&gt;

&lt;p&gt;Thanks go out to &lt;a href=&quot;http://github.com/cooperq/&quot;&gt;flatline&lt;/a&gt; and &lt;a href=&quot;http://github.com/evoltech/&quot;&gt;evoltech&lt;/a&gt; for going with me to ToorCamp, providing transportation and helping hitch-hike back when our van broke down. Also extra thanks to evoltech for letting me use his SUV sized laptop to run the slides on.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Introducing Wordlist 0.1.0</title>
    <link href="http://postmodern.github.io/2009/10/21/introducing-wordlist-0.1.0.html" />
    <updated>2009-10-21T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2009/10/21/introducing-wordlist-0.1.0.html</id>
    <content type="html">&lt;p&gt;&lt;b&gt;Update:&lt;/b&gt; Evoltech correctly pointed out that the Wordlist::Builders::Website example was incorrect. The Website.build method must take a path argument and then any additional options.&lt;/p&gt;

&lt;p&gt;For a while now people have asked/told me that I should write a Wordlist library for Ruby. People have also brought up the need to build wordlists from existing &lt;a href=&quot;http://en.wikipedia.org/wiki/Text_corpus&quot;&gt;corpora&lt;/a&gt;; such as the text from a website. After seeing varying attempts at this task, I finally got serious and released &lt;a href=&quot;http://wordlist.rubyforge.org/&quot;&gt;Wordlist 0.1.0&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Currently, the design of the Wordlist Ruby library is quite simple. &lt;a href=&quot;http://wordlist.rubyforge.org/Wordlist/Builder.html&quot;&gt;Wordlist::Builder&lt;/a&gt; is the base class for all wordlist builders. It handles parsing text, filtering out duplicate words, and writing the unique words to a file. The Builder class stores the CRC32 hash of each word in a Hash, mapping the word length to the Set of CRC32 hashes. Using a bucket system for the CRC32 hashes, keeps both word lookup time and memory usage to a minimum.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Wordlist::Builder.build('list.txt') do |builder|
  builder.parse(some_text)
  builder.parse_file('some/file.txt')
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Wordlist also provides &lt;a href=&quot;http://wordlist.rubyforge.org/Wordlist/Builders/Website.html&quot;&gt;Wordlist::Builders::Website&lt;/a&gt;, which uses &lt;a href=&quot;http://spidr.rubyforge.org/&quot;&gt;Spidr&lt;/a&gt; to completely spider a host, and build a wordlist from the inner-text recovered from every visited page.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;require 'wordlist/builders/website'

Wordlist::Builders::Website.build('list.txt',:host =&amp;gt; 'www.example.com')&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Wordlist doesn't just build wordlists, it can also enumerate them. Wordlist defines &lt;a href=&quot;http://wordlist.rubyforge.org/Wordlist/List.html&quot;&gt;Wordlist::List&lt;/a&gt; as the base class for all wordlist readers. Per convenience, Wordlist also defines &lt;a href=&quot;http://wordlist.rubyforge.org/Wordlist/FlatFile.html&quot;&gt;Wordlist::FlatFile&lt;/a&gt; which handles the enumeration of flat-file wordlists.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;list = Wordlist::FlatFile.new('list.txt')
list.each_word do |word|
  puts word
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &lt;a href=&quot;http://wordlist.rubyforge.org/Wordlist/List.html#M000021&quot;&gt;Wordlist::List&lt;/a&gt; also provides methods for defining text-mutation rules, which are applied in series to each enumerated word.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;list.mutate 'o', '0'
list.mutate '@', 0x41
list.mutate(/[hax]/i) { |match| match.swapcase }

list.each_mutation do |word|
  puts word
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;A mutation rule takes a String or Regexp (which is used to match a sub-string within a word) and another String, Integer or block which is used as a replacement for the matched sub-string. A mutation rule will perform every possible combination of sub-string replacement, passing each mutated word to the next mutation rule, and so on.&lt;/p&gt;

&lt;p&gt;One can install Wordlist using rubygems, by simply running the following command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ sudo gem install wordlist&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &lt;a href=&quot;http://www.git-scm.com/&quot;&gt;git&lt;/a&gt; repository for Wordlist is located on &lt;a href=&quot;http://github.com/sophsec/wordlist&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As of 0.1.0, Wordlist is fairly simple but it gets the job done. The library was fun to design and test, as it involved borrowing some techniques typically used in blind-fuzzing. Expect more features and updates to Wordlist as time goes on.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Ronin "big-push" 0.3.0 released</title>
    <link href="http://postmodern.github.io/2009/10/20/ronin-big-push-0.3.0-released.html" />
    <updated>2009-10-20T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2009/10/20/ronin-big-push-0.3.0-released.html</id>
    <content type="html">&lt;p&gt;The long wait is over. &lt;a href=&quot;http://ronin.rubyforge.org/&quot;&gt;Ronin&lt;/a&gt; 0.3.0, code-named &quot;big-push&quot;, has finally been released.&lt;/p&gt;

&lt;h2&gt;DataMapper 0.10.0&lt;/h2&gt;

&lt;p&gt;Ronin was probably one of the first big Ruby apps to upgrade to &lt;a href=&quot;http://datamapper.org/&quot;&gt;DataMapper&lt;/a&gt; 0.10.0. As a result of this, we had to postpone the release of Ronin 0.3.0, until DataMapper 0.10.0 had finished it's rigorous two month Q/A cycle.&lt;/p&gt;

&lt;p&gt;Once DataMapper 0.10.0 had been released, the two months of Q/A and almost a complete rewrite of the code-base really showed itself. I think &lt;a href=&quot;http://twitter.com/dkubb&quot;&gt;@dkubb&lt;/a&gt;, &lt;a href=&quot;http://twitter.com/dbussink&quot;&gt;@dbussink&lt;/a&gt;, &lt;a href=&quot;http://sick.snusnu.info/&quot;&gt;@snusnu&lt;/a&gt;, &lt;a href=&quot;http://twitter.com/xshay&quot;&gt;@xshay&lt;/a&gt;, &lt;a href=&quot;http://twitter.com/myabc&quot;&gt;@myabc&lt;/a&gt;, &lt;a href=&quot;http://twitter.com/rsim&quot;&gt;@rsim&lt;/a&gt;, &lt;a href=&quot;http://twitter.com/namelessjon&quot;&gt;@namelessjon&lt;/a&gt;, &lt;a href=&quot;http://twitter.com/knowtheory&quot;&gt;@knowtheory&lt;/a&gt; and everyone else who helped with 0.10.0 deserves applause for their hard work and dedication.&lt;/p&gt;

&lt;h2&gt;YARD&lt;/h2&gt;

&lt;p&gt;As of 0.3.0, Ronin has successfully moved to &lt;a href=&quot;http://yard.soen.ca/&quot;&gt;YARD&lt;/a&gt; based documentation. The new Ronin API docs can be found in the usual &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/&quot;&gt;location&lt;/a&gt;. YARD really helped improve the detail of the Ronin API docs, allowing developers to specify method arguments, accepted object-types, yield arguments, possible exceptions and return-types.&lt;/p&gt;

&lt;p&gt;Additionally, YARD handlers were added to Ronin that parsed and regenerated documentation for DataMapper properties/relations. These additional YARD handlers helped improve documentation coverage for Ronin models, such as &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/Arch.html&quot;&gt;Ronin::Arch&lt;/a&gt; or &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin-exploits/Ronin/Exploits/Exploit.html&quot;&gt;Ronin::Exploits::Exploit&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Ronin::UI::CommandLine&lt;/h2&gt;

&lt;p&gt;&lt;kbd&gt;Ronin::UI::CommandLine&lt;/kbd&gt; was almost entirely refactored in 0.3.0. &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/UI/CommandLine/Command.html&quot;&gt;Ronin::UI::CommandLine::Command&lt;/a&gt; was rewritten to use &lt;a href=&quot;http://yehudakatz.com/2008/05/12/by-thors-hammer/&quot;&gt;Thor&lt;/a&gt;. Switching to Thor greatly simplified the ronin commands, making it easier to write new commands. A good example of this, is the source-code for the &lt;kbd&gt;install&lt;/kbd&gt; command from &lt;a href=&quot;http://github.com/postmodern/ronin/blob/0.2.4/lib/ronin/ui/command_line/commands/install.rb#L31&quot;&gt;before&lt;/a&gt; and &lt;a href=&quot;http://github.com/postmodern/ronin/blob/0.3.0/lib/ronin/ui/command_line/commands/install.rb#L28&quot;&gt;after&lt;/a&gt; 0.3.0.&lt;/p&gt;

&lt;p&gt;Another benefit to using Thor, albeit cosmetic, was being able to use Thor's ANSI color-output. Normal output will now appear in green, warnings in yellow and error messages in red.&lt;/p&gt;

&lt;p&gt;New convenience methods were also added to &lt;kbd&gt;Ronin::UI::CommandLine::Command&lt;/kbd&gt; to help format and print various data: &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/UI/CommandLine/Command.html#indent-instance_method&quot;&gt;indent&lt;/a&gt;, &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/UI/CommandLine/Command.html#print_title-instance_method&quot;&gt;print_title&lt;/a&gt;, &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/UI/CommandLine/Command.html#print_array-instance_method&quot;&gt;print_array&lt;/a&gt; and &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/UI/CommandLine/Command.html#print_hash-instance_method&quot;&gt;print_hash&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Ronin::UI::Output&lt;/h2&gt;

&lt;p&gt;As of 0.3.0, &lt;kbd&gt;Ronin::UI::Diagnostics&lt;/kbd&gt; and &lt;kbd&gt;Ronin::UI::Verbose&lt;/kbd&gt; were replaced with the brand new &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/UI/Output.html&quot;&gt;Ronin::UI::Output&lt;/a&gt; module. &lt;kbd&gt;Ronin::UI::Output&lt;/kbd&gt; is designed to delegate how output is handled. By default all output is sent to &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/UI/Output/Handler.html&quot;&gt;Ronin::UI::Output::Handler&lt;/a&gt;, which prints the output to the terminal. One can override the default output handler by using &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/UI/Output.html#handler%3D-class_method&quot;&gt;Ronin::UI::Output.handler=&lt;/a&gt;, to specify the new handler module; which must define &lt;kbd&gt;print_info&lt;/kbd&gt;, &lt;kbd&gt;print_debug&lt;/kbd&gt;, &lt;kbd&gt;print_warning&lt;/kbd&gt; and &lt;kbd&gt;print_error&lt;/kbd&gt; methods.&lt;/p&gt;

&lt;p&gt;&lt;kbd&gt;Ronin::UI::Output&lt;/kbd&gt; also provides the &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/UI/Output/Helpers.html&quot;&gt;Helpers&lt;/a&gt; module, which can be included into any class and adds the &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/UI/Output/Helpers.html#print_info-instance_method&quot;&gt;print_info&lt;/a&gt;, &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/UI/Output/Helpers.html#print_debug-instance_method&quot;&gt;print_debug&lt;/a&gt;, &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/UI/Output/Helpers.html#print_warning-instance_method&quot;&gt;print_warning&lt;/a&gt; and &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/UI/Output/Helpers.html#print_error-instance_method&quot;&gt;print_error&lt;/a&gt; methods.&lt;/p&gt;

&lt;h2&gt;New Convenience Methods&lt;/h2&gt;

&lt;p&gt;New TCP and UDP networking methods were added to 0.3.0. Now one can easily create TCP/UDP servers using, &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Net.html#tcp_server-class_method&quot;&gt;Net.tcp_server&lt;/a&gt;, &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Net.html#tcp_server_session-class_method&quot;&gt;Net.tcp_server_session&lt;/a&gt;, &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Net.html#tcp_single_server-class_method&quot;&gt;Net.tcp_single_server&lt;/a&gt;, &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Net.html#udp_server-class_method&quot;&gt;Net.udp_server&lt;/a&gt; and &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Net.html#udp_server_session-class_method&quot;&gt;Net.udp_server_session&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/Network/HTTP/Proxy.html&quot;&gt;Ronin::Network::HTTP::Proxy&lt;/a&gt; was also added to 0.3.0. The &lt;kbd&gt;Ronin::Network::HTTP::Proxy&lt;/a&gt; helps parse and represent HTTP proxy addresses, and is now used by &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/Network/HTTP.html#proxy-class_method&quot;&gt;Ronin::Network::HTTP.proxy&lt;/a&gt; and all &lt;kbd&gt;:proxy&lt;/kbd&gt; options.&lt;/p&gt;

&lt;pre&gt;proxy = Network::HTTP::Proxy.parse('148.233.239.24:80')
# =&amp;gt; #&amp;lt;Ronin::Network::HTTP::Proxy: 148.233.239.24:80&amp;gt;&lt;/pre&gt;

&lt;p&gt;The &lt;kbd&gt;Proxy&lt;/kbd&gt; class can also be used to test a proxy.&lt;/p&gt;

&lt;pre&gt;proxy.valid?
# =&amp;gt; true
proxy.lag
# =&amp;gt; 0.003881&lt;/pre&gt;

&lt;h2&gt;Ronin::Platform&lt;/h2&gt;

&lt;p&gt;The &lt;a href=&quot;http://github.com/postmodern/ronin/blob/0.3.0/static/ronin/platform/overlay.xsl&quot;&gt;overlay.xsl&lt;/a&gt; file got a make-over in 0.3.0. &lt;kbd&gt;overlay.xsl&lt;/kbd&gt; is a XML StyleSheet, which helps render &lt;a href=&quot;http://github.com/postmodern/postmodern-overlay/raw/master/ronin.xml&quot;&gt;ronin.xml&lt;/a&gt; files from Overlays into proper XHTML when they are viewed in a web-browser. Now &lt;kbd&gt;ronin.xml&lt;/kbd&gt; files should appear more like a standard &quot;About&quot; web-page.&lt;/p&gt;

&lt;p&gt;Reloading Overlays/Extensions while ronin is running became possible with the addition of &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/Platform.html#reload%21-class_method&quot;&gt;Ronin::Platform.reload!&lt;/a&gt;. Now if an Extension is modified, one can simply call &lt;kbd&gt;Platform.reload!&lt;/kbd&gt; and get the updated version.&lt;/p&gt;

&lt;p&gt;Ronin Extensions gained convenience methods for defining reader/writer methods to instance variables: &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/Platform/Extension.html#attr_reader-instance_method&quot;&gt;attr_reader&lt;/a&gt;, &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/Platform/Extension.html#attr_writer-instance_method&quot;&gt;attr_writer&lt;/a&gt; and &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/Platform/Extension.html#attr_accessor-instance_method&quot;&gt;attr_accessor&lt;/a&gt;. They can be used in Ronin Extensions, just as one would use them in a class.&lt;/p&gt;

&lt;pre&gt;ronin_extension do

  attr_accessor :var
  attr_reader :result

  setup do
    @var = 5
    @result = nil
  end
  ...
end&lt;/pre&gt;

&lt;p&gt;Ronin Extensions also gained their own on-demand temp directory. When &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/Platform/Extension.html#tmp_dir-instance_method&quot;&gt;Ronin::Platform::Extension#tmp_dir&lt;/a&gt; is called, a temp directory specifically for the extension will be created within &lt;kbd&gt;~/.ronin/tmp/&lt;/kbd&gt;, and the path of the new temp directory will be returned.&lt;/p&gt;

&lt;h2&gt;Upgrading&lt;/h2&gt;

&lt;p&gt;As always, the rubygem files for Ronin 0.3.0 are available on &lt;a href=&quot;http://rubyforge.org/frs/?group_id=3798&quot;&gt;rubyforge.org&lt;/a&gt;. One can update Ronin using rubygems by simplying running:&lt;/p&gt;
&lt;pre&gt;$ gem update ronin&lt;/pre&gt;

&lt;p&gt;Likewise, one can also install Ronin using rubygems:&lt;/p&gt;

&lt;pre&gt;$ gem install ronin&lt;/pre&gt;

&lt;p&gt;Also, as of Ronin 0.3.0 all releases of Ronin will also be made available on &lt;a href=&quot;http://gemcutter.org/&quot;&gt;gemcutter.org&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>New project mailing lists</title>
    <link href="http://postmodern.github.io/2009/10/18/new-project-mailinglists.html" />
    <updated>2009-10-18T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2009/10/18/new-project-mailinglists.html</id>
    <content type="html">&lt;p&gt;As I've begun to get increasing amounts of email from other developers and users, I've wondered whether it's time to setup some mailing-lists.&lt;/p&gt;

&lt;p&gt;Well, thanks to the efforts of Franck D'agostini, &lt;a href=&quot;http://spidr.rubyforge.org/&quot;&gt;Spidr&lt;/a&gt; now has a &lt;a href=&quot;http://groups.google.com/group/spidr&quot;&gt;mailing-list&lt;/a&gt;. I hope this mailing-list will help foster interesting discussions between users/developers and possible improvements to Spidr.&lt;/p&gt;

&lt;p&gt;I also took the liberty of setting up an IRC channel for Spidr, since IRC is still a mainstay of developers (although I like &lt;a href=&quot;http://xmpp.org/about/&quot;&gt;XMPP&lt;/a&gt; a little more). Just join &lt;a href=&quot;irc://irc.freenode.net/#spidr&quot;&gt;#spidr&lt;/a&gt; on &lt;a href=&quot;http://freenode.net/&quot;&gt;irc.freenode.net&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Seeing the potential for how mailing-lists can help a project, I also setup a &lt;a href=&quot;http://groups.google.com/group/ronin-ruby&quot;&gt;Google Group&lt;/a&gt; for &lt;a href=&quot;http://ronin.rubyforge.org/&quot;&gt;Ronin&lt;/a&gt;. &lt;b&gt;Obvious Privacy Warning:&lt;/b&gt; Since Google indexes pretty much everything, sketchy discussions relating to Ronin should probably happen somewhere beyond Google's reach, for one's own security and privacy.&lt;/p&gt;

&lt;p&gt;So yeah, let's see what will happen.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Spidr "solid" 0.2.0</title>
    <link href="http://postmodern.github.io/2009/10/14/spidr-solid-0.2.0.html" />
    <updated>2009-10-14T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2009/10/14/spidr-solid-0.2.0.html</id>
    <content type="html">&lt;p&gt;After a period of refactoring, &lt;a href=&quot;http://spidr.rubyforge.org/&quot;&gt;Spidr&lt;/a&gt; 0.2.0 (code-named &quot;solid&quot;) has been released. Many things we're added to this release, along with some very important bug-fixes and optimizations.&lt;/p&gt;

&lt;h2&gt;Major changes&lt;/h2&gt;

&lt;p&gt;Spidr, along with many of my other projects, has moved to &lt;a href=&quot;http://yard.soen.ca/&quot;&gt;YARD&lt;/a&gt; based documentation. YARD's tag based documentation format really helped me annotate every method within Spidr. The new YARD docs can be found in the usual &lt;a href=&quot;http://spidr.rubyforge.org/docs/&quot;&gt;location&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Also following suite with many of my other projects, you can now find Spidr on the awesome and easy to use &lt;a href=&quot;http://gemcutter.org/gems/spidr&quot;&gt;gemcutter.org&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Spidr should be a little faster now. Thanks to the work of &lt;a href=&quot;http://github.com/justfalter/&quot;&gt;justfalter&lt;/a&gt;, HTTP sessions with unique hosts/ports are now cached and resued. HTTP sessions no longer have to be re-initialized upon every request. Also, the history and failures lists are now Ruby Sets, yielding improved lookup times for checking if a link has been previously visted.&lt;/p&gt;

&lt;p&gt;The code-base of Spidr should be a little more organized. Many methods within &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Agent.html&quot;&gt;Spidr::Agent&lt;/a&gt; were grouped by functionality and moved to separate modules (&lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Events.html&quot;&gt;Events&lt;/a&gt; and &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Filters.html&quot;&gt;Filters&lt;/a&gt;) which are included back into &lt;kbd&gt;Spidr::Agent&lt;/kbd&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Actions.html&quot;&gt;Spidr::Actions&lt;/a&gt; module was also added, which adds action methods that control spidering from within &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Events.html#every_url-instance_method&quot;&gt;every_url&lt;/a&gt;, &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Events.html#every_page-instance_method&quot;&gt;every_page&lt;/a&gt;, &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Events.html#every_failed_url-instance_method&quot;&gt;every_failed_url&lt;/a&gt;, &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Events.html#all_headers-instance_method&quot;&gt;all_headers&lt;/a&gt; event hooks. The &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Actions.html#pause%21-instance_method&quot;&gt;pause!&lt;/a&gt; method will pause the spider, while &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Actions.html#skip_page%21-instance_method&quot;&gt;skip_page!&lt;/a&gt; and &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Actions.html#skip_link%21-instance_method&quot;&gt;skip_link!&lt;/a&gt; can manipulate the processing of pages/links.&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Page.html#search-instance_method&quot;&gt;Spidr::Page#search&lt;/a&gt;, &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Page.html#at-instance_method&quot;&gt;Spidr::Page#at&lt;/a&gt;, &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Page.html#title-instance_method&quot;&gt;Spidr::Page#title&lt;/a&gt; methods were also added. These methods should make &lt;kbd&gt;Spidr::Page&lt;/kbd&gt; feel alittle more like &lt;a href=&quot;http://mechanize.rubyforge.org/mechanize/WWW/Mechanize/Page.html&quot;&gt;WWW::Mechanize::Page&lt;/a&gt;, allowing one to search the DOM (parsed by &lt;a href=&quot;http://nokogiri.rubyforge.org/nokogiri/&quot;&gt;Nokogiri&lt;/a&gt;) with XPath/CSS-path expressions.&lt;/p&gt;

&lt;p&gt;Lastly, many new examples which highlight some of the less-than-trivial things you can do with Spidr have been added to the &lt;a href=&quot;http://spidr.rubyforge.org/#examples&quot;&gt;website&lt;/a&gt; and &lt;a href=&quot;http://spidr.rubyforge.org/docs/&quot;&gt;docs&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Important bug-fixes&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Agent.html&quot;&gt;Spidr::Agent&lt;/a&gt; should now properly handle the spidering of SSL protected websites. Also thanks to &lt;a href=&quot;http://github.com/justfalter/&quot;&gt;justfalter&lt;/a&gt;, HTTPS sessions are now properly initialized and stored in the HTTP session cache; so the SSL-handshake only need be performed once per unique host/port.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Agent.html#get_page-instance_method&quot;&gt;Spidr::Agent#get_page&lt;/a&gt; will now correctly send the URI query along with the URI path for HTTP requests. Thanks go out to Damian Steer for reporting this.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Page.html#doc-instance_method&quot;&gt;Spidr::Page#doc&lt;/a&gt; now returns a &lt;a href=&quot;http://nokogiri.rubyforge.org/nokogiri/Nokogiri/XML/Document.html&quot;&gt;Nokogiri::XML::Document&lt;/a&gt; object for RSS/RDF/Atom pages, allowing one to properly search RSS/Atom feeds.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Page.html#code-instance_method&quot;&gt;Spidr::Page#code&lt;/a&gt; will now return the HTTP Status code as an Integer.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Page.html#links-instance_method&quot;&gt;Spidr::Page#links&lt;/a&gt; now properly handles the HTTP &lt;kbd&gt;Location&lt;/kbd&gt; header.&lt;/p&gt;

&lt;p&gt;The URI expansion/normalization performed by &lt;a href=&quot;http://spidr.rubyforge.org/docs/Spidr/Page.html#to_absolute-instance_method&quot;&gt;Spidr::Page#to_absolute&lt;/a&gt; was greatly improved. &lt;kbd&gt;Spidr::Page#to_absolute&lt;/kbd&gt; will now properly preserve trailing '/' characters on URI paths.&lt;/p&gt;

&lt;h2&gt;Shout Outs&lt;/h2&gt;

&lt;p&gt;A big thanks to everyone who helped with Spidr 0.2.0 by reporting bugs and testing new code. I hope this release will help users get more out of Spidr.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Ruby things worth looking into</title>
    <link href="http://postmodern.github.io/2009/09/26/ruby-things-worth-looking-into.html" />
    <updated>2009-09-26T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2009/09/26/ruby-things-worth-looking-into.html</id>
    <content type="html">&lt;p&gt;Over the past couple of months, I've been researching and playing with various up-and-coming Ruby libraries/services. So I thought it would be useful for other developers if I wrote something up.&lt;/p&gt;

&lt;h2&gt;Sinatra&lt;/h2&gt;

&lt;p&gt;If you already haven't heard, &lt;a href=&quot;http://www.sinatrarb.com/intro.html&quot;&gt;Sinatra&lt;/a&gt; is cool sauce. Sinatra is a Ruby Domain Specific Language for creating web-apps that can fit in a single file.&lt;/p&gt;

&lt;pre&gt;# myapp.rb
require 'rubygems'
require 'sinatra'
get '/' do
  'Hello world!'
end&lt;/pre&gt;

&lt;pre&gt;$ gem install sinatra
$ ruby myapp.rb&lt;/pre&gt;

&lt;p&gt;It's that easy. But let's say you want to create an app accessible as a Class, just inherit Sinatra::Base.&lt;/p&gt;

&lt;pre&gt;require 'rubygems'
require 'sinatra'

class MyApp &amp;lt; Sinatra::Base

  get &amp;#39;/&amp;#39; do
    &amp;#39;Hello world!&amp;#39;
  end

end&lt;/pre&gt;

&lt;p&gt;I found the URL param parsing and request routing on-par with that of Merb/Rails. I also enjoyed the &lt;kbd&gt;halt&lt;/kbd&gt; and &lt;kbd&gt;pass&lt;/kbd&gt; methods, which will cause Sinatra to re-route a request to other handlers.&lt;/p&gt;

&lt;p&gt;Defining helper methods which can be used within request handlers was as easy as creating a module with some instance methods, then registering the module using the &lt;kbd&gt;helpers&lt;/kbd&gt; method.&lt;/p&gt;

&lt;pre&gt;module Helpers
  module Rendering
    include Rack::Utils

    alias h escape_html
  end
end

class MyApp &amp;lt; Sinatra::Base

  helpers Helpers::Rendering

end&lt;/pre&gt;

&lt;p&gt;Sinatra is built on top of Rack, so reviewing the &lt;a href=&quot;http://rack.rubyforge.org/&quot;&gt;Rack API&lt;/a&gt; might not hurt. The current Rack::Request object can be accessed via the &lt;kbd&gt;request&lt;/kbd&gt; method. The return value of a request handler can be a String, Array of Strings or even a Rack::Response object. Sinatra also provides the Rack &lt;a href=&quot;http://vision-media.ca/resources/ruby/ruby-rack-middleware-tutorial&quot;&gt;call&lt;/a&gt; method, which can be overridden for more custom request routing (such as vhost routing to other Rack apps). Given Sinatra's &lt;a href=&quot;http://www.sinatrarb.com/api/index.html&quot;&gt;API Documentation&lt;/a&gt;, it's fairly easy to customize and extend your Sinatra app.&lt;/p&gt;

&lt;h2&gt;Thor&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://github.com/wycats/thor/&quot;&gt;Thor&lt;/a&gt; is an alternative to &lt;a href=&quot;http://rake.rubyforge.org/&quot;&gt;Rake&lt;/a&gt; or &lt;a href=&quot;http://www.rubyinside.com/sake-system-wide-rake-tasks-543.html&quot;&gt;Sake&lt;/a&gt;. Thor makes it very easy to define tasks as methods, and define command-line options/arguments for those tasks using a succinct syntax.&lt;/p&gt;

&lt;p&gt;Thor tasks can be invoked via the &lt;kbd&gt;thor command, or loading the Thor class and calling the &lt;kbd&gt;start&lt;/kbd&gt; method directly.&lt;/p&gt;

&lt;p&gt;I also noticed that Rails3 is using Thor::Group and Thor::Actions, to create &lt;a&gt;code generators&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;While documentation is scarce for Thor, I fould it's &lt;a href=&quot;http://github.com/wycats/thor/&quot;&gt;code-base&lt;/a&gt; fairly readable.&lt;/p&gt;

&lt;h2&gt;FFI&lt;/h2&gt;

&lt;p&gt;There's an easier way to write Ruby extensions to C libraries. It's called FFI, or Foreign Function Interface. &lt;a href=&quot;http://github.com/ffi/ffi/&quot;&gt;Ruby FFI&lt;/a&gt; is a rubygem (named &lt;kbd&gt;ffi&lt;/kbd&gt;) by Wayne Meissner which wraps around &lt;a href=&quot;http://sourceware.org/libffi/&quot;&gt;libffi&lt;/a&gt;, to provide a Ruby interface to load libraries, attach functions, variables and mapping in Structs/Unions/enums/callbacks.&lt;/p&gt;

&lt;p&gt;To create a Ruby interface to a library, simply create a module which extends FFI::Library and attach some functions as module methods.&lt;/p&gt;

&lt;pre&gt;module FFI
  module TRE
    extend FFI::Library

    ffi_lib 'tre' # finds and loads the library

    # attaches a function named tre_regcomp, and defines the
    # types for it's arguments and return value.
    attach_function :tre_regcomp, [:pointer, :pointer, :int], :int
    # ...
  end
end&lt;/pre&gt;

&lt;p&gt;More examples can be found &lt;a href=&quot;http://wiki.github.com/ffi/ffi/examples&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you need to quickly write bindings for a library, give FFI a shot. Another benefit of having FFI Ruby bindings, is that they will work seamlessly with &lt;a href=&quot;http://jruby.com/&quot;&gt;JRuby&lt;/a&gt; and &lt;a href=&quot;http://rubini.us/&quot;&gt;Rubinius&lt;/a&gt;, on any platform that is supported by libffi.&lt;/p&gt;

&lt;h2&gt;YARD&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://yard.soen.ca/&quot;&gt;YARD&lt;/a&gt; is an alternative to the defacto RDoc documentation generation, that allows one to annotate code using a &lt;a href=&quot;http://yard.soen.ca/getting_started#docing&quot;&gt;@tag&lt;/a&gt; based syntax and Markdown/Textile/RDoc formatting. YARD stores all the gathered documentation information in a Marshalable data-store file (&lt;kbd&gt;.yardoc&lt;/kbd&gt;), which opens the door to on-the-fly documentation searching. YARD can also export it's data to XML or XHTML+CSS+jQuery.&lt;/p&gt;

&lt;p&gt;Want to use YARD in your project? Drop this task into your Rakefile.&lt;/p&gt;

&lt;pre&gt;YARD::Rake::YardocTask.new do |t|
  t.files   = ['lib/**/*.rb']
  t.options = [
    '--protected',
    '--files', 'History.txt',
    '--title', 'MyProject'
  ]
end

task :docs =&amp;gt; :yardoc&lt;/pre&gt;

&lt;pre&gt;$ rake docs &amp;amp;&amp;amp; firefox doc/index.html&lt;/pre&gt;

&lt;p&gt;Want to use YARD on someone else's (github) project, checkout &lt;a href=&quot;http://rdoc.info/&quot;&gt;rdoc.info&lt;/a&gt;, it's built on YARD and Ruby 1.8.7.&lt;/p&gt;

&lt;p&gt;YARD can also be extended to detect and document meta-programming methods which define other methods at runtime. For example, this &lt;a href=&quot;http://github.com/postmodern/parameters/blob/master/lib/parameters/yard/handlers/ruby/parameter_handler.rb&quot;&gt;YARD handler&lt;/a&gt; (for Ruby 1.9.x) which documents &lt;kbd&gt;parameter&lt;/kbd&gt; method-calls from the &lt;a href=&quot;http://parameters.rubyforge.org/&quot;&gt;Parameters&lt;/a&gt; library.&lt;/p&gt;

&lt;p&gt;Loren Segal's &lt;a href=&quot;http://gnuu.org/2009/06/17/yard-at-montreal-rb/&quot;&gt;slides&lt;/a&gt; from his YARD presentation at Montreal.rb are also worth checking out.&lt;/p&gt;

&lt;h2&gt;Gemcutter&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://gemcutter.org/&quot;&gt;Gemcutter&lt;/a&gt; provides easy and fun RubyGem hosting, which is &lt;a href=&quot;http://github.com/qrush/gemcutter&quot;&gt;open-source&lt;/a&gt; and aims to become the &lt;a href=&quot;http://www.mail-archive.com/rubygems-developers@rubyforge.org/msg03123.html&quot;&gt;the default gem hosting solution&lt;/a&gt; for Ruby. Did I mention that it looks classy (thanks to a redesign by &lt;a href=&quot;http://robots.thoughtbot.com/post/165832471/gemcutter-org-redesign-preview&quot;&gt;ThoughtBot&lt;/a&gt;)?&lt;/p&gt;

&lt;p&gt;Publishing gems to Gemcutter is as easy as running:&lt;/p&gt;

&lt;pre&gt;gem push pkg/my_project-0.1.0.gem&lt;/pre&gt;

&lt;p&gt;The &lt;kbd&gt;gem push&lt;/kbd&gt; command can override previously uploaded versions of a gem. No more going into Rubyforge's File Admin panel to delete mistakenly uploaded versions, just run &lt;kbd&gt;gem push&lt;/kbd&gt; again.&lt;/p&gt;

&lt;p&gt;Also, Gemcutter is a &lt;a href=&quot;http://www.sinatrarb.com/&quot;&gt;Sinatra&lt;/a&gt; app running on &lt;a href=&quot;http://heroku.com/&quot;&gt;Heruko&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Ronin "toorcamp" 0.2.4 finally released</title>
    <link href="http://postmodern.github.io/2009/07/19/ronin-toorcamp-0.2.4-finally-released.html" />
    <updated>2009-07-19T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2009/07/19/ronin-toorcamp-0.2.4-finally-released.html</id>
    <content type="html">&lt;p&gt;&lt;b&gt;Update:&lt;/b&gt; As &lt;a href=&quot;http://carnal0wnage.attackresearch.com/blog/7&quot;&gt;CG&lt;/a&gt; points out, I forgot to post the slides from the ToorCamp presentation. Here they are in &lt;a href=&quot;http://ronin.rubyforge.org/talks/publishing_and_mayhem.html&quot;&gt;XHTML form&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Update:&lt;/b&gt; @&lt;a href=&quot;http://twitter.com/sanitybit&quot;&gt;sanitybit&lt;/a&gt; discovered that &lt;a href=&quot;http://rubyforge.org/projects/parameters&quot;&gt;parameters&lt;/a&gt; 0.1.7, which is required by ronin 0.2.4, was not released. Parameters 0.1.7 has now been released.&lt;/p&gt;

&lt;p&gt;As promised in the &lt;a href=&quot;http://toorcamp.org/content/B5&quot;&gt;Ronin: A Platform for Publishing and Mayhem&lt;/a&gt; talk at &lt;a href=&quot;http://toorcamp.org/&quot;&gt;ToorCamp&lt;/a&gt;, Ronin 0.2.4 has finally been released. I was wanting to release 0.2.4 before ToorCamp, and hand out copies while there, but due to time constraints I had to wait till after the event.&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;$ gem update&lt;/pre&gt;&lt;/code&gt;

&lt;h2&gt;Signed RubyGems&lt;/h2&gt;

&lt;p&gt;All released versions of Ronin, from 0.2.4 onward, will be signed. You can download the public certificate used to verify all of my gems &lt;a href=&quot;http://rubyforge.org/frs/download.php/57952/postmodern-public_cert.pem&quot;&gt;here&lt;/a&gt;. A more in depth explanation of RubyGem Signing is given in &lt;a href=&quot;http://rubygems.org/read/chapter/21&quot;&gt;Chapter 21&lt;/a&gt; of the &lt;a href=&quot;http://rubygems.org/read/&quot;&gt;RubyGems Manual&lt;/a&gt;.&lt;/p&gt;
 
&lt;h2&gt;Bug Fixes&lt;/h2&gt;

&lt;p&gt;Mr. &lt;a href=&quot;//github.com/evoltech/&quot;&gt;evoltech&lt;/a&gt; discovered and fixed a bug in the lookup of command names containing dashes, which was causing issues with the &lt;a href=&quot;http://ronin.rubyforge.org/gen/&quot;&gt;ronin-gen&lt;/a&gt; commands. &lt;a href=&quot;http://github.com/cooperq/&quot;&gt;flatline&lt;/a&gt; also improved the reliability of the caching of exploits from Overlays, now any exceptions raised during the caching of each exploit will be ignored.&lt;/p&gt;

&lt;h2&gt;Bytes and Chars&lt;/h2&gt;

&lt;p&gt;The 0.2.4 release now comes with new convenience methods to make working with byte and char &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Array.html&quot;&gt;Arrays&lt;/a&gt; easier:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;[0x41, 0x41, 0x42].chars
# =&amp;gt; [&quot;A&quot;, &quot;A&quot;, &quot;B&quot;]&lt;/pre&gt;&lt;/code&gt;

&lt;code&gt;&lt;pre&gt;[&quot;A&quot;, &quot;B&quot;].bytes
# =&amp;gt; [0x41, 0x42]&lt;/pre&gt;&lt;/code&gt;

&lt;code&gt;&lt;pre&gt;[0x41, 0x41, 0x41].char_string
# =&amp;gt; &quot;AAB&quot;&lt;/pre&gt;&lt;/code&gt;

&lt;h2&gt;Un-Hexdumping&lt;/h2&gt;

&lt;p&gt;The &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/File.html#unhexdump-class_method&quot;&gt;File.unhexdump&lt;/a&gt; method was also added, making it even easier to un-hexdump those dumps.&lt;/p&gt;

&lt;h2&gt;Exceptions&lt;/h2&gt;

&lt;p&gt;Occasionally one needs to run some code which may raise exceptions, but you might not care about such exceptions, and would rather have them printed out. The &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Kernel.html#catch_all-instance_method&quot;&gt;catch_all&lt;/a&gt; method does exactly that. &lt;kbd&gt;catch_all&lt;/kbd&gt; will catch all exceptions and print abbreviated back-traces.&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;require 'resolv'

catch_all do
  Resolv.getaddress('www.wired.com')
end&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;Another note-worth change in 0.2.4, was the renaming of the &lt;kbd&gt;try&lt;/kbd&gt; method to &lt;kbd&gt;attempt&lt;/kbd&gt;; so as not to conflict with JRuby's &lt;kbd&gt;try&lt;/kbd&gt; method.&lt;/p&gt;

&lt;h2&gt;HTTP&lt;/h2&gt;

&lt;p&gt;The &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Net.html#http_request-class_method&quot;&gt;Net.http_request&lt;/a&gt; method was added, allowing one to make arbitrary HTTP Requests, just specify the &lt;kbd&gt;:method&lt;/kbd&gt; option.&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;Net.http_request(:host =&amp;gt; 'www.example.com', :method =&amp;gt; :head)&lt;/pre&gt;&lt;/code&gt;

&lt;h2&gt;Templates::Erb&lt;/h2&gt;

&lt;p&gt;The &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/Templates/Erb.html&quot;&gt;Templates::Erb&lt;/a&gt; module was added in 0.2.4, providing convenience methods for rendering &lt;a href=&quot;http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/index.html&quot;&gt;Embedded Ruby&lt;/a&gt; (ERB) templates.&lt;/p&gt;

&lt;h2&gt;Scanners::Scanner&lt;/h2&gt;

&lt;p&gt;The &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/Scanners/Scanner.html&quot;&gt;Scanners::Scanner&lt;/a&gt; module was also added in 0.2.4. The Scanner module can be included into any class and allows one to define multiple scanner rules by name, which are ran against each target, returning results in real-time via a callback.&lt;/p&gt;

&lt;p&gt;An example usage of Scanners::Scanner would be to add scanner rules to all IPAddr objects, having each IP address within a netmask scanned.&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
require 'ronin/scanners/scanner'
require 'ronin/extensions/ip_addr'

class IPAddr

  include Ronin::Scanners::Scanner

  scanner(:dns) do |ip,results|
    Resolve.getnames(ip).each do |name|
      results.call(name)
    end
  end

  def each_target(&amp;amp;block)
    each(&amp;amp;block)
  end

end&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;First we include Ronin::Scanners::Scanner into the IPAddr class. Then we define a simple scanner rule to perform reverse DNS lookup on an IP address and returns the results using the &lt;kbd&gt;result&lt;/kbd&gt; callback. Finally we define the &lt;kbd&gt;each_target&lt;/kbd&gt; method which enumerates over each IP address in the netmask, passing each to the block to be scanned.&lt;/p&gt;

&lt;p&gt;To run all scanner rules on an IPAddr range:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;ip = IPAddr.new('10.1.1.1/24')
ip.scan&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;To only run the DNS scanner rule:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;ip.dns_scan&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;The SQL Injection, LFI and RFI scanning code has now been ported to use Scanners::Scanner.&lt;/p&gt;

&lt;h2&gt;Accessible Extensions&lt;/h2&gt;

&lt;p&gt;Extensions from Overlays are now more accessible. Within the Ronin console, they can be accessed as local variables:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;puts milw0rm.remote.first_page&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;This is all thanks to the new Ronin#method_missing method; which catches missing instance method calls, and attempts to load the appropriate extension.&lt;/p&gt;

&lt;h2&gt;Command Name Changes&lt;/h2&gt;

&lt;p&gt;The &lt;kbd&gt;ls&lt;/kbd&gt; and &lt;kbd&gt;rm&lt;/kbd&gt; ronin commands have now been renamed to &lt;kbd&gt;list&lt;/kbd&gt; and &lt;kbd&gt;remove&lt;/kbd&gt;, respectively.&lt;/p&gt;

&lt;p&gt;To list all installed Overlays:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;$ ronin list&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;To remove (but not delete) an Overlay:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;$ ronin remove overlay-name&lt;/pre&gt;&lt;/code&gt;

&lt;h2&gt;New Dorks&lt;/h2&gt;

&lt;p&gt;ronin-dorks 0.1.2 saw the addition of the &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin-dorks/Ronin/Web/Dorks.html#intext-class_method&quot;&gt;intext&lt;/a&gt;, &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin-dorks/Ronin/Web/Dorks.html#allintext-class_method&quot;&gt;allintext&lt;/a&gt;, &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin-dorks/Ronin/Web/Dorks.html#string_intext-class_method&quot;&gt;string_intext&lt;/a&gt;, &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin-dorks/Ronin/Web/Dorks.html#all_strings_intext-class_method&quot;&gt;all_strings_intext&lt;/a&gt;, &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin-dorks/Ronin/Web/Dorks.html#intitle-class_method&quot;&gt;intitle&lt;/a&gt;, &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin-dorks/Ronin/Web/Dorks.html#allintitle-class_method&quot;&gt;allintitle&lt;/a&gt;, &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin-dorks/Ronin/Web/Dorks.html#string_intitle-class_method&quot;&gt;string_intitle&lt;/a&gt; methods to &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin-dorks/Ronin/Web/Dorks.html&quot;&gt;Web::Dorks&lt;/a&gt;. The new intext and intitle convenience methods should simplify the creation of future dorks.&lt;/p&gt;

&lt;h2&gt;ronin.rubyforge.org Open Sourced&lt;/h2&gt;

&lt;p&gt;Last but not least, the source-code for the &lt;a href=&quot;http://ronin.rubyforge.org/&quot;&gt;ronin.rubyforge.org&lt;/a&gt; website has been open-sourced on &lt;a href=&quot;http://github.com/postmodern/ronin.rubyforge.org/&quot;&gt;GitHub&lt;/a&gt;. Now if you want to make a correction or add a How-To, just &lt;a href=&quot;http://github.com/postmodern/ronin.rubyforge.org/fork/&quot;&gt;fork it&lt;/a&gt;, commit your changes, then send &lt;a href=&quot;http://github.com/postmodern/&quot;&gt;me&lt;/a&gt; a &lt;a href=&quot;http://github.com/guides/pull-requests&quot;&gt;pull-request&lt;/a&gt; and I'll upload your changes.&lt;/p&gt;

&lt;p&gt;The collaborative editing is already happening, &lt;a href=&quot;http://github.com/evoltech/&quot;&gt;evoltech&lt;/a&gt; already wrote up a new badass &lt;a href=&quot;http://ronin.rubyforge.org/contribute/&quot;&gt;Contribute&lt;/a&gt; page, that explains typical Git(Hub) workflow.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Sketches: Aftermath</title>
    <link href="http://postmodern.github.io/2009/06/13/sketches-aftermath.html" />
    <updated>2009-06-13T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2009/06/13/sketches-aftermath.html</id>
    <content type="html">&lt;p&gt;Apologies for not updating this blog more often. I have been very busy preparing for &lt;a href=&quot;http://toorcamp.org/&quot;&gt;ToorCamp&lt;/a&gt; and releasing code.&lt;/p&gt;

&lt;p&gt;One of my newer projects is &lt;a href=&quot;http://sketches.rubyforge.org/&quot;&gt;Sketches&lt;/a&gt;. The idea for Sketches came from hacking sessions with &lt;a href=&quot;http://ronin.rubyforge.org/&quot;&gt;Ronin&lt;/a&gt;. Eventually you need to automate some small task, this requires that you write a small method in the Ronin Console. I would find myself either writing methods directly into the console or cluttering my home directory with small Ruby scripts that I would load into the console. Usually after testing my code, I realized some changes needed to be made, and the code redefined/reloaded.&lt;/p&gt;

&lt;p&gt;This became tedious and was cramping my work-flow. I just wanted to write code in my editor of choice and have it reloaded into the console like magic.&lt;/p&gt;

&lt;p&gt;I remembered that &lt;a href=&quot;http://utilitybelt.rubyforge.org/&quot;&gt;Utility Belt&lt;/a&gt; had the ability to spawn an editor from IRB and load the resulting code after you exited it. Although, Utility Belt wont track the edited files and reload them whenever they change. Also, Utility Belt comes with a lot of OSX/S3 specific features that I didn't really need.&lt;/p&gt;

&lt;p&gt;So I dug up &lt;a href=&quot;http://gist.github.com/20920&quot;&gt;reval.rb&lt;/a&gt;, borrowed the name Sketches from &lt;a href=&quot;http://processing.org/&quot;&gt;Processing's&lt;/a&gt; idea of code &quot;sketches&quot; and one week later I had Sketches working in IRB (and Ronin).&lt;/p&gt;

&lt;p&gt;Sketches is easy to install:&lt;/p&gt;

&lt;pre&gt;$ sudo gem install sketches&lt;/pre&gt;

&lt;p&gt;Then just drop it into your &lt;kbd&gt;.irbrc&lt;/kbd&gt;:&lt;/p&gt;

&lt;pre&gt;require 'sketches'

Sketches.config :editor =&amp;gt; 'gvim'&lt;/pre&gt;

&lt;p&gt;When you want to pop open a new sketch:&lt;/p&gt;

&lt;pre&gt;sketch&lt;/pre&gt;

&lt;p&gt;You can also name your sketches:&lt;/p&gt;

&lt;pre&gt;sketch :foo&lt;/pre&gt;

&lt;p&gt;See all of your current sketches:&lt;/p&gt;

&lt;pre&gt;sketches&lt;/pre&gt;

&lt;p&gt;Don't worry about closing the editor, sketches will persist until you exit IRB and can be re-opened using the &lt;kbd&gt;sketch&lt;/kbd&gt; method:&lt;/p&gt;

&lt;pre&gt;sketch :foo&lt;/pre&gt;

&lt;p&gt;After posting it to &lt;a href=&quot;http://www.reddit.com/r/ruby/comments/8nrwd/introducing_sketches_a_liveprogramming_gem/&quot;&gt;reddit&lt;/a&gt; I was surprised to see such an immediate positive reaction to the little project. I even saw posts on Twitter were people were using &lt;a href=&quot;http://www.gnu.org/software/screen/&quot;&gt;GNU Screen&lt;/a&gt; with &lt;a href=&quot;http://www.vim.org/&quot;&gt;vim&lt;/a&gt; for the editor command. I never thought of using &lt;kbd&gt;screen&lt;/kbd&gt;, totally clever.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Ronin "faster" 0.2.3 has been released</title>
    <link href="http://postmodern.github.io/2009/05/07/ronin-faster-0.2.3-has-been-released.html" />
    <updated>2009-05-07T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2009/05/07/ronin-faster-0.2.3-has-been-released.html</id>
    <content type="html">&lt;p&gt;The wait is over, Ronin 0.2.3 (code-named &quot;faster&quot;) has finally been released. This release contains new code, more specs, some very important architectural changes and a few bug-fixes.&lt;/p&gt;

&lt;h2&gt;Ronin on Ruby 1.9.1&lt;/h2&gt;

&lt;p&gt;Probably the most important news in Ronin 0.2.3, is that Ronin is now Ruby 1.9.1 compatible. Ronin can now take advantage of the considerable performance improvements in Ruby 1.9.1-p0. If you tend to do security research and find yourself having to use Ruby 1.9.1, you should look into using Ronin.&lt;/p&gt;

&lt;h2&gt;Faster Load-Times&lt;/h2&gt;

&lt;p&gt;Ronin also saw various architectural changes to help reduce load-times. The &lt;kbd&gt;ronin/models.rb&lt;/kbd&gt; file was removed, which loaded models from the other Ronin libraries before the Database was setup. Now other Ronin libraries can call the &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/Database.html#update%21-class_method&quot;&gt;Database.update!&lt;/a&gt; method, which will run non-destructive auto-migrations on the Database. &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/UI/CommandLine.html&quot;&gt;Ronin::UI::CommandLine&lt;/a&gt; saw yet more refactoring. With the new &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/UI/CommandLine.html&quot;&gt;Ronin::UI::CommandLine&lt;/a&gt;, sub-commands are loaded on-demand, instead of all at once.&lt;/p&gt;

&lt;p&gt;Together these architectural changes have dramatically improved the load-time of Ronin's console. On systems that rarely run the Ruby interpreter, start-up times for Ronin should look like the following:&lt;/p&gt;

&lt;pre&gt;$ time (echo exit | (ronin &amp;gt; /dev/null))

real	0m3.841s
user	0m1.141s
sys	0m0.514s&lt;/pre&gt;

&lt;p&gt;On systems that regularly run the Ruby interpreter (thus caching frequently used memory and data) start-up times for Ronin will be a little quicker:&lt;/p&gt;

&lt;pre&gt;$ time (echo exit | (ronin &amp;gt; /dev/null))

real	0m1.656s
user	0m1.137s
sys	0m0.478s&lt;/pre&gt;

&lt;h2&gt;New Convenience Methods&lt;/h2&gt;

&lt;p&gt;In 0.2.3 the &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/IPAddr.html#each-instance_method&quot;&gt;IPAddr#each&lt;/a&gt; and &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/IPAddr.html#each-class_method&quot;&gt;IPAddr.each&lt;/a&gt; methods were added. It's somewhat common to need to iterate over a range of IP addresses. Say you have a CIDR notation IP address, and need to iterate over every IP address covered by it's netmask. Simply create a new &lt;kbd&gt;IPAddr&lt;/kbd&gt; object and call &lt;kbd&gt;each&lt;/kbd&gt;:&lt;/p&gt;

&lt;pre&gt;ip = IPAddr.new('10.1.1.1/24')
ip.each do |addr|
  ...
end&lt;/pre&gt;

&lt;p&gt;Well that's sort of cool, but what if you have a globbed IP address, similar to the ones &lt;a href=&quot;http://www.insecure.org/&quot;&gt;nmap&lt;/a&gt; accepts? &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/IPAddr.html#each-class_method&quot;&gt;IPAddr.each&lt;/a&gt; has you covered:&lt;/p&gt;

&lt;pre&gt;IPAddr.each('10.1.1-5.*') do |addr|
  ...
end&lt;/pre&gt;

&lt;p&gt;Both &lt;kbd&gt;IPAddr#each&lt;/kbd&gt; and &lt;kbd&gt;IPAddr.each&lt;/kbd&gt; can  iterate over IPv6 addresses.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Net.html#http_powered_by-class_method&quot;&gt;Net.http_powered_by&lt;/a&gt; and &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Net.html#http_server-class_method&quot;&gt;Net.http_server&lt;/a&gt; also got added in 0.2.3. These methods provide quick access to the &lt;kbd&gt;X-Powered-By&lt;/kbd&gt; and &lt;kbd&gt;Server&lt;/kbd&gt; HTTP headers, respectively.&lt;/p&gt;

&lt;pre&gt;Net.http_powered_by(:url =&amp;gt; 'http://www.stalkdaily.com/')
# =&amp;gt; &quot;PHP/5.2.9&quot;

Net.http_server(:url =&amp;gt; 'http://www.darkc0de.com/)
# =&amp;gt; &quot;Apache/2.2.11 (Unix) PHP/4.4.9 mod_ssl/2.2.11 OpenSSL/0.9.8c mod_fastcgi/2.4.6 Phusion_Passenger/2.1.2 DAV/2 SVN/1.4.2&quot;&lt;/pre&gt;

&lt;p&gt;&lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/String.html#pad-instance_method&quot;&gt;String#pad&lt;/a&gt; was also added in 0.2.3. The pad method doesn't do a lot, it merely pads a String out to a maximum length:&lt;/p&gt;

&lt;pre&gt;&quot;hello&quot;.pad('A', 48)
# =&amp;gt; &quot;helloAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&quot;&lt;/pre&gt;

&lt;p&gt;If you hate having to deal with exceptions in Ruby, the &lt;kbd&gt;try&lt;/kbd&gt; method might prove useful. The &lt;kbd&gt;try&lt;/kbd&gt; method simple attempts to run a block of code, catching and ignoring any exceptions that were raised:&lt;/p&gt;

&lt;pre&gt;require 'resolv'

try do
  Resolv.getaddress('might.not.exist.com')
end&lt;/pre&gt;

&lt;h2&gt;Cacheable&lt;/h2&gt;

&lt;p&gt;&lt;kbd&gt;Ronin::Objectify&lt;/kbd&gt; was replaced by the new &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/Cacheable.html&quot;&gt;Ronin::Cacheable&lt;/a&gt; module. Cacheable provides reliable caching and loading of &lt;a href=&quot;http://contextify.rubyforge.org/&quot;&gt;Contextified&lt;/a&gt; objects with Ronin's Database. Using the new Cacheble module, the data you want cached into the database must be defined in a &lt;kbd&gt;cache&lt;/kbd&gt; block:&lt;/p&gt;

&lt;pre&gt;ronin_exploit do
  cache do
    self.name = 'stupidhttpd'
    self.version = '0.2'
    self.author(:name =&amp;gt; 'Postmodern')
  end

  ...
end&lt;/pre&gt;

&lt;p&gt;The use of a &lt;kbd&gt;cache&lt;/kbd&gt; block creates a separation between the data to be cached and the code which will eventually be loaded.&lt;/p&gt;

&lt;h2&gt;Overlays&lt;/h2&gt;

&lt;p&gt;As of 0.2.3, overlays now support the automatic loading of the &lt;kbd&gt;lib/init.rb&lt;/kbd&gt; file. So if you have code you'd like automatically loaded (maybe extensions to the Array class) from your Overlay, simply require it in the &lt;kbd&gt;lib/init.rb&lt;/kbd&gt; file.&lt;/p&gt;

&lt;p&gt;The loading of Extensions from Overlays became a little more robust in 0.2.3. If an exception is encountered when loading an extension file, the exception will be printed and the file ignored.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Ronin "theouterlibs" 0.2.2 released</title>
    <link href="http://postmodern.github.io/2009/03/31/ronin-theouterlibs-0.2.2-released.html" />
    <updated>2009-03-31T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2009/03/31/ronin-theouterlibs-0.2.2-released.html</id>
    <content type="html">&lt;p&gt;Ronin 0.2.2, code-named &quot;theouterlibs&quot;, has been released. This release of Ronin has seen more action in the other libraries which support Ronin.&lt;/p&gt;

&lt;p&gt;Ronin::Chars was split out of Ronin into the &lt;a href=&quot;http://chars.rubyforge.org/&quot;&gt;Chars&lt;/a&gt; 0.1.0 library, in order to help other frameworks and code which work with characters.&lt;/p&gt;

&lt;p&gt;The ronin-overlay and ronin-ext sub-commands which handled generating skeleton Overlays and Extensions have been moved to the &lt;a href=&quot;http://ronin.rubyforge.org/gen/&quot;&gt;ronin-gen&lt;/a&gt; library. The ronin-gen library provides various code-generates which allow other Ronin libraries to create their own custom code-generators.&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;http://repertoire.rubyforge.org/&quot;&gt;R'epertoire&lt;/a&gt; library saw significant refactoring after various bugs were uncovered while testing Ronin 0.2.2. Now R'epertoire 0.2.1 has improved Git support, but CVS and Darcs support was removed.&lt;/p&gt;

&lt;p&gt;Ronin also saw some minor improvements in 0.2.2. New convenience methods were added for formatting binary data:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Integer.html#bytes-instance_method&quot;&gt;Integer#bytes&lt;/a&gt;: returns the bytes that make up the Integer.
    &lt;pre&gt;0xff41.bytes(2)
# =&amp;gt; [65, 255]&lt;/pre&gt;

    &lt;pre&gt;0xff41.bytes(4, :big)
# =&amp;gt; [0, 0, 255, 65]&lt;/pre&gt;
  &lt;/li&gt;

  &lt;li&gt;&lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/String.html#hex_unescape-instance_method&quot;&gt;String#hex_unescape&lt;/a&gt;: unescape those annoying hex-escaped Strings.
    &lt;pre&gt;&quot;\\x68\\x65\\x6c\\x6c\\x6f&quot;.hex_unescape
# =&amp;gt; &quot;hello&quot;&lt;/pre&gt;
  &lt;/li&gt;

  &lt;li&gt;&lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/String.html#unhexdump-instance_method&quot;&gt;String#unhexdump&lt;/a&gt;: un-hexdump a variety of hexdump formats.
    &lt;pre&gt;File.read('data_dump.txt').unhexdump
# =&amp;gt; &quot;...&quot;&lt;/pre&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/Static.html&quot;&gt;Ronin::Static&lt;/a&gt; was also added in 0.2.2. The Ronin::Static module handles static resource directories which Ronin can search within for various files and directories. &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/Static/Finders.html&quot;&gt;Ronin::Static::Finders&lt;/a&gt; provides path/file/directory finder methods that can be included into classes. Ronin Overlays and Extensions can now have static/ directories of their own, which are accessible via the Ronin::Static::Finders methods.&lt;/p&gt;

&lt;p&gt;Loaded extensions can now be reloaded on the fly:&lt;/p&gt;

&lt;pre&gt;Platform.extensions.reload!&lt;/pre&gt;

&lt;p&gt;Ronin Extensions also can be accessed via constants within the Ronin namespace:&lt;/p&gt;

&lt;pre&gt;Ronin::HelloWord.name
# =&amp;gt; &quot;hello_word&quot;&lt;/pre&gt;
</content>
  </entry>
  
  <entry>
    <title>Introducing Chars 0.1.0</title>
    <link href="http://postmodern.github.io/2009/03/17/introducing-chars-0.1.0.html" />
    <updated>2009-03-17T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2009/03/17/introducing-chars-0.1.0.html</id>
    <content type="html">&lt;p&gt;Yesterday I released the first version of &lt;a href=&quot;http://chars.rubyforge.org/&quot;&gt;Chars&lt;/a&gt;. Chars is a Ruby library for working with character sets, generating random text and determining whether Strings or Integers belong to specific sets. Originally, Chars was part of the &lt;a href=&quot;http://github.com/postmodern/ronin&quot;&gt;Ronin&lt;/a&gt; code-base, but was split-out in order to keep Ronin small and to promote code-reuse. So without further ado, here's some examples of what Chars can do:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    Determine whether a byte belongs to a character set: 
    &lt;pre&gt;0x41.alpha?
# =&amp;gt; true&lt;/pre&gt;
  &lt;/li&gt;

  &lt;li&gt;
    Determine whether a String belongs to a character set: 
    &lt;pre&gt;&quot;hello;&quot;.printable?
# =&amp;gt; true&lt;/pre&gt;
  &lt;/li&gt;

  &lt;li&gt;
    Find all sub-strings that belong to a character set within a String:
    &lt;pre&gt;ls = File.read('/bin/ls')
Chars.printable.strings_in(ls)
# =&amp;gt; [&quot;/lib64/ld-linux-x86-64.so.2&quot;, &quot;KIq/&quot;, &quot;5J~!&quot;, &quot;%L~!&quot;, ...]&lt;/pre&gt;
  &lt;/li&gt;

  &lt;li&gt;
    Return a random character from the set of all characters:
    &lt;pre&gt;Chars.all.random_char
# =&amp;gt; &quot;\x94&quot;&lt;/pre&gt;
  &lt;/li&gt;

  &lt;li&gt;
    Return a random Array of characters from the alpha-numeric character set:
    &lt;pre&gt;Chars.alpha_numeric.random_array(10)
# =&amp;gt; [&quot;Q&quot;, &quot;N&quot;, &quot;S&quot;, &quot;4&quot;, &quot;x&quot;, &quot;z&quot;, &quot;3&quot;, &quot;M&quot;, &quot;F&quot;, &quot;F&quot;]&lt;/pre&gt;
  &lt;/li&gt;

  &lt;li&gt;
    Return a random String from the set of all characters: 
    &lt;pre&gt;Chars.all.random_string(10)
# =&amp;gt; &quot;\xc2h\xad\xccm7\x1e6J\x13&quot;&lt;/pre&gt;
  &lt;/li&gt;

  &lt;li&gt;
    Return a random String with a random length between 5 and 10, from the set of space characters:
    &lt;pre&gt;Chars.space.random_string(5..10)
# =&amp;gt; &quot;\r\v\n\t\n\f&quot;&lt;/pre&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can install Chars as a rubygem using the following command:&lt;/p&gt;

&lt;pre&gt;$ sudo gem install chars&lt;/pre&gt;

&lt;p&gt;If you want to hack on Chars, the code-base is available on &lt;a href=&quot;http://github.com/postmodern/chars/tree/master&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Ronin 0.2.1 "notashellscript" released</title>
    <link href="http://postmodern.github.io/2009/02/25/ronin-0.2.1-notashellscript-released.html" />
    <updated>2009-02-25T00:00:00-08:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2009/02/25/ronin-0.2.1-notashellscript-released.html</id>
    <content type="html">&lt;p&gt;Yesterday Ronin 0.2.1, code-name &quot;notashellscript&quot;, was released. That's right, we finally surpassed the awkward 0.1.x phase. Although, I completely forgot to write about Ronin 0.2.0, code-named &quot;solid&quot;, which is where most of the action occurred.&lt;/p&gt;

&lt;p&gt;Ronin 0.2.0 saw the complete refactoring and specing of the &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/Platform.html&quot;&gt;Platform&lt;/a&gt; code, which manages Overlays and their Extensions. Besides the huge amount of bug-fixes, modularization and renaming, Overlays can now have their own top-level &lt;kbd&gt;lib/&lt;/kbd&gt; directories. Also, all of the &lt;kbd&gt;lib/&lt;/kbd&gt; directories contained within an Overlay and it's Extensions are added to the &lt;kbd&gt;$LOAD_PATH&lt;/kbd&gt; upon activation. This allows for easier requiring of code embedded within Overlays.&lt;/p&gt;

&lt;p&gt;Ronin 0.2.0 also saw the addition of the &lt;kbd&gt;ronin/environment&lt;/kbd&gt; file, which loads all of the convenience methods, configuration from &lt;kbd&gt;~/.ronin/config.rb&lt;/kbd&gt; and starts Ronin's Database. The environment file makes it easier to load up all of Ronin (minus the Platform code) in an IRB session and get hacking.&lt;/p&gt;

&lt;p&gt;Grey bearded hackers bemoan how every exploit, library and framework have their own special &lt;i&gt;leet&lt;/i&gt; diagnostic printing format. Some prefer the defacto &quot;[*] Message&quot; while others go for the saucy &quot;{+} Message&quot;. Well grey beards you have one more reason to bemoan, &lt;kbd&gt;UI::Diagnostics&lt;/kbd&gt; was added to Ronin 0.2.0. The UI::Diagnostics module adds the &lt;kbd&gt;print_info&lt;/kbd&gt;, &lt;kbd&gt;print_warning&lt;/kbd&gt; and &lt;kbd&gt;print_error&lt;/kbd&gt; methods to a class. The output of these methods are controlled by the &lt;kbd&gt;UI::Verbose&lt;/kbd&gt; module.&lt;/p&gt;

&lt;p&gt;Ronin 0.2.1, code-name &quot;notashellscript&quot;, had a couple but still important changes. Ronin 0.2.1 has dropped &lt;a href=&quot;http://enfranchisedmind.com/blog/2008/03/24/rexml-dynamic-typing-lose/&quot;&gt;REXML&lt;/a&gt; in favour of &lt;a href=&quot;http://nokogiri.rubyforge.org/&quot;&gt;Nokogiri&lt;/a&gt; for XML support. Nokogiri brings faster XML/HTML parsing and building to Ronin, providing it's own set of bindings to libxml2.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/UI/CommandLine.html&quot;&gt;UI::CommandLine&lt;/a&gt; was rewritten in Ronin 0.2.1. Now sub-commands are accessible by both the &lt;kbd&gt;ronin sub-command --options&lt;/kbd&gt; style and git style sub-commands, such as &lt;kbd&gt;ronin-command --options&lt;/kbd&gt;. The git style sub-commands provide a more direct way of calling sub-commands.&lt;/p&gt;

&lt;p&gt;Many of Ronin's other libraries received convenience sub-commands which simply start the Ronin console with the specific library pre-loaded. Ever wanted to jump right into Ronin Dorks or Ronin Scanners, now you totally can:&lt;/p&gt;

&lt;pre&gt;$ ronin-scanners
&amp;gt;&amp;gt; Scanners::Nmap.scan(:targets =&amp;gt; '10.1.1.*', :syn_scan =&amp;gt; true)
...&lt;/pre&gt;

&lt;p&gt;Finally, I've started to practice what I preach by setting up my own Ronin &lt;a href=&quot;http://github.com/postmodern/postmodern-ronin/tree/master&quot;&gt;Overlay&lt;/a&gt; to experiment with. Of course, the Overlay is hosted on &lt;a href=&quot;http://github.com/&quot;&gt;github.com&lt;/a&gt;, so feel free to clone and fork away. To install the Overlay under Ronin, use the following command:&lt;/p&gt;

&lt;pre&gt;$ ronin install git://github.com/postmodern/postmodern-ronin.git&lt;/pre&gt;

&lt;p&gt;So far, I've added an &lt;a href=&quot;http://github.com/postmodern/postmodern-ronin/tree/master/milw0rm&quot;&gt;extension&lt;/a&gt; which parses the exploit lists on &lt;a href=&quot;http://milw0rm.com/&quot;&gt;milw0rm.com&lt;/a&gt;. The milw0rm extensions is accessible within Ronin using the following code:&lt;/p&gt;

&lt;pre&gt;$ ronin
&amp;gt;&amp;gt; puts Ronin.milw0rm.remote.recent
...&lt;/pre&gt;

&lt;p&gt;Ironically, while testing the extension I noticed that &lt;a href=&quot;http://milw0rm.com/&quot;&gt;milw0rm&lt;/a&gt; does not properly escape the titles of their exploits, resulting in unescaped &lt;kbd&gt;&amp;lt;&lt;/kbd&gt; and &lt;kbd&gt;&amp;gt;&lt;/kbd&gt; characters in their HTML.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>The Push to Ruby 1.9</title>
    <link href="http://postmodern.github.io/2009/02/06/the-push-to-ruby-1.9.html" />
    <updated>2009-02-06T00:00:00-08:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2009/02/06/the-push-to-ruby-1.9.html</id>
    <content type="html">&lt;p&gt;So you probably heard that &lt;a href=&quot;http://www.ruby-lang.org/en/news/2007/12/25/ruby-1-9-0-released/&quot;&gt;Ruby 1.9.1&lt;/a&gt; has been &lt;a href=&quot;http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/326276&quot;&gt;released&lt;/a&gt;. That's right, no more testing release candidates, Ruby 1.9.1 has been marked stable. The 1.9.x series of Ruby comes with improved encoding support, includes &lt;a href=&quot;http://www.rubygems.org/&quot;&gt;RubyGems&lt;/a&gt; by default and has merged with &lt;a href=&quot;http://www.atdot.net/yarv/&quot;&gt;YARV&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Including RubyGems was a good move, since it's always been a pain dealing with out-dated Debian packages of RubyGems, setting RUBYOPT or having &lt;kbd&gt;gem update --system&lt;/kbd&gt; conflict with the customized Debian version of RubyGems. The inclusion of YARV, which implements a byte-code VM for Ruby, has brought considerable performance increases to Ruby. I've been having fun using the 1.9.1 release candidates to brute-force &lt;a href=&quot;http://projecteuler.net/&quot;&gt;Project Euler&lt;/a&gt; problems.&lt;/p&gt;

&lt;p&gt;So here's the catch, most of the RubyGems for Ruby do not work properly with the 1.9.x series and it's minor API changes. This poses a good dev challenge to the Ruby community: test, fix, fork or rewrite the offending RubyGems.&lt;/p&gt;

&lt;p&gt;Some would say this will take some time, slowing the adoption of 1.9.1 or even stunting the Ruby community. But we came prepared, we got &lt;a href=&quot;http://en.wikipedia.org/wiki/Test-driven_development&quot;&gt;TDD&lt;/a&gt;, &lt;a href=&quot;http://en.wikipedia.org/wiki/Behavior_Driven_Development&quot;&gt;BDD&lt;/a&gt;, &lt;a href=&quot;http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit.html&quot;&gt;Unit::Test&lt;/a&gt;, &lt;a href=&quot;http://rspec.info/&quot;&gt;Rspec&lt;/a&gt; and &lt;a href=&quot;http://github.com/&quot;&gt;github.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Also, a handy site just popped up today, &lt;a href=&quot;http://isitruby19.com/&quot;&gt;Is it Ruby 1.9&lt;/a&gt;: Community-powered gem compatibility for Ruby 1.9. People can search for RubyGems and add testing information to them.&lt;/p&gt;

&lt;p&gt;To help with the push to Ruby 1.9.1, I threw together a shell script that installs Ruby 1.9.1 alongside 1.8.x. It's hosted on &lt;a href=&quot;http://gist.github.com/59130&quot;&gt;gist.github.com&lt;/a&gt;, so feel free to fork it.&lt;/p&gt;

&lt;pre&gt;#!/bin/sh
 
mkdir -p /usr/local/src &amp;amp;&amp;amp; cd /usr/local/src
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.bz2
tar -xjvf ruby-1.9.1-p0.tar.bz2
cd ruby-1.9.1-p0
./configure --prefix=/usr --program-suffix=19 --enable-shared
make &amp;amp;&amp;amp; make install&lt;/pre&gt;

&lt;p&gt;I'll be testing the RubyGems I use the most and my own projects. So far I've found that &lt;a href=&quot;http://contextify.rubyforge.org/&quot;&gt;Contextify&lt;/a&gt;, &lt;a href=&quot;http://parameters.rubyforge.org&quot;&gt;Parameters&lt;/a&gt;, &lt;a href=&quot;http://gscraper.rubyforge.org/&quot;&gt;GScraper&lt;/a&gt; and &lt;a href=&quot;http://spidr.rubyforge.org/&quot;&gt;Spidr&lt;/a&gt; all work with Ruby 1.9.1.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Ronin 0.1.3 "shake down" Released</title>
    <link href="http://postmodern.github.io/2009/01/09/ronin-0.1.3-shake-down-released.html" />
    <updated>2009-01-09T00:00:00-08:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2009/01/09/ronin-0.1.3-shake-down-released.html</id>
    <content type="html">&lt;p&gt;After many bug-fixes and testing Ronin 0.1.3, codenamed &quot;shake down&quot;, has finally been released. I split out Ronin::Context into the &lt;a href=&quot;http://contextify.rubyforge.org/&quot;&gt;Contextify&lt;/a&gt; library. Contextify is very handy for frameworks that want to load objects from Ruby files (without using YAML or defining specially named Classes/Modules). I've also refactored &lt;a href=&quot;http://reverserequire.rubyforge.org/&quot;&gt;reverse-require&lt;/a&gt;, integrating it closer with RubyGems 1.3.0. Again, reverse-require is useful for frameworks that want to have a plugin system, but don't want to mess with the archaic gem_plugin. I eventually hope to get some of the code from reverse-requires merged into RubyGems. The &lt;kbd&gt;Ronin::Objectify&lt;/kbd&gt; and &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin/Ronin/UI/CommandLine.html&quot;&gt;Ronin::UI::CommandLine&lt;/a&gt; modules also got a fresh refactoring.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://github.com/postmodern/ronin-sql/&quot;&gt;ronin-sql&lt;/a&gt; also received some refactoring love. It's SQL/Injection DSL was rewritten to uses a token emitter / formatter strategy for generating SQL syntax from the DSL. The use of tokens greatly simplified generating complex syntax from an Abstract Syntax Tree (AST).&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; require 'ronin/sql'
=&amp;gt; true
&amp;gt;&amp;gt; puts Code.sql_injection { has_table?(:users) }
AND (SELECT count(*) FROM users) = 1
=&amp;gt; nil
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Not only were there updates, but also some libraries released for the very first time. After sitting on github for a while, &lt;a href=&quot;http://github.com/postmodern/ronin-exploits/&quot;&gt;ronin-exploits&lt;/a&gt; and &lt;a href=&quot;http://github.com/postmodern/ronin-scanners/&quot;&gt;ronin-scanners&lt;/a&gt; were finally released.&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;http://github.com/postmodern/ronin-exploits/&quot;&gt;ronin-exploits&lt;/a&gt; library provides the ability to define exploits and payloads, as well as caching them in Ronin's database. Since ronin-exploits uses Contextify, writing exploits becomes easy and elegant:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# test_exploit.rb
require 'ronin/sessions/tcp'

ronin_exploit do

  extend Sessions::TCP

  self.name = 'test'
  self.version = '0.2'
  self.license = License.cc_by_nc

  self.author(:name =&amp;gt; 'postmodern', :organization =&amp;gt; 'SophSec')

  def builder
    @buffer = 'some data'
  end

  def deployer
    tcp_send(@buffer)
  end

end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The library also allows one to associate Vulnerability Taxonomy information with Exploits or Payloads.&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;http://github.com/postmodern/ronin-scanners/&quot;&gt;ronin-scanners&lt;/a&gt; library provides interfaces to various security scanners. Currently, ronin-scanners provides a &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin-scanners/Ronin/Scanners/Nmap.html&quot;&gt;Rubyful interface&lt;/a&gt; to the &lt;a href=&quot;http://nmap.org/&quot;&gt;Nmap&lt;/a&gt; network scanner and &lt;a href=&quot;http://ronin.rubyforge.org/docs/ronin-scanners/Ronin/Scanners/NmapTask.html&quot;&gt;all of it's options&lt;/a&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; require 'ronin/scanners'
=&amp;gt; true
&amp;gt;&amp;gt; puts Scanners::Nmap.scan(:targets =&amp;gt; 'www.google.com', :ports =&amp;gt; [80,21,25], :service_scan =&amp;gt; true)
Starting Nmap 4.68 ( http://nmap.org ) at 2009-01-09 16:51 PST
Interesting ports on mh-in-f99.google.com (209.85.173.99):
PORT   STATE    SERVICE VERSION
21/tcp filtered ftp
25/tcp filtered smtp
80/tcp open     http    Google httpd 1.3 (GFE)
Service Info: OS: Linux

Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 11.627 seconds
=&amp;gt; nil
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The library also uses &lt;a href=&quot;http://scandb.rubyforge.org/&quot;&gt;ScanDB&lt;/a&gt;, so that Nmap scan results can be stored or queried using ScanDB's database.&lt;/p&gt;

&lt;p&gt;Now that I've completed another round of refactoring and releasing updated libraries, I can focus on other things, such as improving Ronin's &lt;a href=&quot;http://ronin.rubyforge.org&quot;&gt;website&lt;/a&gt; and build a presentation for Ronin. Recently I was invited by evoltech from &lt;a href=&quot;http://hackbloc.org&quot;&gt;HackBloc&lt;/a&gt; to trek down to the Bay Area and give a mini-presentation on Ronin at this years &lt;a href=&quot;http://hackmeet.org/&quot;&gt;Hack Meet&lt;/a&gt;. Hack Meet is a semi-regular non-corporate hacker meet-up / mini-conference, where hackers gather and share their latest projects.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Spidr and Raingrams are back, now with specs</title>
    <link href="http://postmodern.github.io/2008/11/13/spidr-and-rangraims-are-back.html" />
    <updated>2008-11-13T00:00:00-08:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2008/11/13/spidr-and-rangraims-are-back.html</id>
    <content type="html">&lt;p&gt;&lt;a href=&quot;http://raingrams.rubyforge.org/&quot;&gt;Raingrams&lt;/a&gt; is back in action. After sitting on &lt;a href=&quot;http://rubyforge.org/&quot;&gt;rubyforge&lt;/a&gt; for quite some time, I was asked to add some features to the general purpose Ngrams Ruby library. I ended up refactoring the code to handle probability calculations better (only recalculate the Maximum Likelihood Estimation (MLE) when the set of ngrams changes), removed the Unigram model (kinda pointless in a ngrams library), allow a trained model to be dumped to a file using Marshal and added the ability to generate random text from trained models. Raingrams also received a total of 133 new &lt;a href=&quot;http://github.com/postmodern/raingrams/tree/master/spec/&quot;&gt;spec tests&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Install Raingrams:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ sudo gem install raingrams&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href=&quot;http://spidr.rubyforge.org/&quot;&gt;Spidr&lt;/a&gt; also received some new spec tests. After fixing a link handling bug in Spidr 0.1.1, I decided to create a &lt;a href=&quot;http://spidr.rubyforge.org/course/start.html&quot;&gt;Web Spider Obstacle Course&lt;/a&gt; for testing purposes. The course contains all manner of links (remote, local, relative, absolute, javascript, empty URLs and infinite looping links). The course also provides a &lt;a href=&quot;http://spidr.rubyforge.org/course/specs.json&quot;&gt;JSON file&lt;/a&gt; containing spec information for how a web-spider should navigate the links. I also wrote a &lt;a href=&quot;http://github.com/postmodern/spidr/blob/master/spec/helpers/course.rb&quot;&gt;RSpec helper&lt;/a&gt; which imports the spec information from the JSON file and auto-generates spec tests for how Spidr::Agent should navigate the links in the obstacle course.&lt;/p&gt;

&lt;p&gt;Install Spidr:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ sudo gem install spidr&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  
  <entry>
    <title>RDoc can let you down, can give you up, can run around and desert you...</title>
    <link href="http://postmodern.github.io/2008/10/24/rdoc-can-let-you-down.html" />
    <updated>2008-10-24T00:00:00-07:00</updated>
    <author>
      <name>Postmodern</name>
      <email>postmodern.mod3@gmail.com</email>
    </author>
    <id>http://postmodern.github.io/2008/10/24/rdoc-can-let-you-down.html</id>
    <content type="html">&lt;p&gt;&lt;b&gt;Update:&lt;/b&gt; The Ruby Core developers have finally fixed
&lt;a href=&quot;http://redmine.ruby-lang.org/issues/show/1042&quot;&gt;this bug&lt;/a&gt; in RDoc.
Thanks go out to Eric Hodel (for recently refactoring RDoc) and the
Ruby Core developers for maintaining Ruby.&lt;/p&gt;

&lt;p&gt;Normally &lt;a href=&quot;http://rdoc.sourceforge.net/&quot;&gt;RDoc&lt;/a&gt; is there for you when it comes to auto-generating nice HTML documentation for your Ruby projects. But just now, it flat out failed while generating &lt;a href=&quot;http://www.graphviz.org/&quot;&gt;Graphviz&lt;/a&gt; diagrams of my code.&lt;/p&gt;

&lt;p&gt;I was attempting to generate some documentation for the &lt;a href=&quot;http://github.com/postmodern/ronin-sql/tree/dsl_refactor&quot;&gt;Ronin SQL library&lt;/a&gt; in order to test the formatting of README.txt. To my surprise &lt;code&gt;rake docs&lt;/code&gt; failed without any informative error message describing which file caused RDoc to chock.&lt;/p&gt;

&lt;p&gt;Here's the output of &lt;code&gt;rake --trace docs&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;[ &lt;a href=&quot;http://gist.github.com/19353&quot;&gt;gist.github.com/19353&lt;/a&gt; ]&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
Generating HTML...
Diagrams: ...
/usr/lib64/ruby/1.8/rdoc/markup/simple_markup/fragments.rb:291: warning: Object#type is deprecated; use Object#class
rake aborted!
undefined method `level' for nil:NilClass
/usr/lib64/ruby/1.8/rdoc/markup/simple_markup/fragments.rb:292:in `add_list_breaks'
/usr/lib64/ruby/1.8/rdoc/markup/simple_markup/fragments.rb:282:in `each'
/usr/lib64/ruby/1.8/rdoc/markup/simple_markup/fragments.rb:282:in `add_list_breaks'
/usr/lib64/ruby/1.8/rdoc/markup/simple_markup/fragments.rb:153:in `normalize'
/usr/lib64/ruby/1.8/rdoc/markup/simple_markup.rb:459:in `group_lines'
/usr/lib64/ruby/1.8/rdoc/markup/simple_markup.rb:255:in `convert'
/usr/lib64/ruby/1.8/rdoc/generators/html_generator.rb:246:in `markup'
/usr/lib64/ruby/1.8/rdoc/generators/html_generator.rb:818:in `value_hash'
/usr/lib64/ruby/1.8/rdoc/generators/html_generator.rb:865:in `write_on'
/usr/lib64/ruby/1.8/rdoc/generators/html_generator.rb:1293:in `gen_into'
/usr/lib64/ruby/1.8/rdoc/generators/html_generator.rb:1293:in `open'
/usr/lib64/ruby/1.8/rdoc/generators/html_generator.rb:1293:in `gen_into'
/usr/lib64/ruby/1.8/rdoc/generators/html_generator.rb:1289:in `each'
/usr/lib64/ruby/1.8/rdoc/generators/html_generator.rb:1289:in `gen_into'
/usr/lib64/ruby/1.8/rdoc/generators/html_generator.rb:1276:in `generate_html'
/usr/lib64/ruby/1.8/rdoc/generators/html_generator.rb:1197:in `generate'
/usr/lib64/ruby/1.8/rdoc/rdoc.rb:284:in `document'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake/rdoctask.rb:113:in `define'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `call'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `execute'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `each'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `execute'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in `invoke_with_call_chain'
/usr/lib64/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in `invoke_with_call_chain'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:588:in `invoke_prerequisites'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:585:in `each'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:585:in `invoke_prerequisites'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:577:in `invoke_with_call_chain'
/usr/lib64/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in `invoke_with_call_chain'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in `invoke'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in `invoke_task'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `each'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_handling'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in `top_level'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:in `run'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_handling'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in `run'
/usr/lib64/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Suddenly, all that talk about &lt;a href=&quot;http://www.infoq.com/news/2008/07/yard-documentation-generator&quot;&gt;YARD&lt;/a&gt; replacing RDoc is sounding a lot more pragmatic. YARD has certainly worked out for &lt;a href=&quot;http://datamapper.rubyforge.org/&quot;&gt;DataMapper&lt;/a&gt; and &lt;a href=&quot;http://merbivore.com/documentation.html&quot;&gt;Merb&lt;/a&gt; thus far. Maybe &lt;a href=&quot;http://ronin.rubyforge.org/&quot;&gt;Ronin&lt;/a&gt; will give &lt;a href=&quot;http://yard.rubyforge.org/&quot;&gt;YARD&lt;/a&gt; a try.&lt;/p&gt;
</content>
  </entry>
  
</feed>
