DHH releases make_refactorable

David Hennemeier Hannson just released a plugin to sort of “level the field” a bit within the rails community. Simply put, make_refactorable takes normal Ruby code and converts it into a more verbose, redundant format.
make_refactorable is like adding milk to your scrambled eggs. It’s passing the ball, when you know that you could make the shot. It’s less Don’t Repeat Yourself and more We’re Everybody’s Team. It’s a clever way of generating bad-to-not-too-bad-to-really-good-looking-but-still-bad code quickly and easily, and it rocks.
h4. Installation


script/plugin install make_refactorable

h4. Basic Usage
Let’s say you have a simple Post model defined in app/models/post.rb with a single method for returning the user’s most important data:

class Post < ActiveRecord::Base
  def age_sex_location
    "#{self.name}/#{self.sex}/#{self.location}" 
  end
end

To use make_refactorable, simply call the ‘script/unrefactor’ command from the root of your application directory, passing it the name of whatever file you want to, duh… make refactorable.

script/generate refactorable app/models/post.rb

This generates a new file, app/models/refactorable_post.rb, that looks something like the following:

class RefactorablePost < Post
  def age_sex_location
    str = "" 
    1.times do |i|
     str << "#{self.name}/#{self.sex}/#{self.location}".gsub("#{self.name}","#{self.name.upcase.downcase}")
    end
    return str
  end
end

Note that the above version of app/models/refactorable_post.rb is only an example of what the output MIGHT look like. make_refactorable will generate pseudo-random yet verifiably redundant output, depending on the options passed to the script/make_refactorable call.
The following command…

script/generate refactorable app/models/post.rb calculate_state:private

Generates the following app/models/refactorable_post.rb

class RefactorablePost < Post
  def age_sex_location
    return calculate_state
  end

  private

  def calculate_state
    mystring = ""  
    1.times do |i|
      mystring << "#{self.name}/#{self.sex}/#{self.location}".gsub("#{self.name}","#{self.name.upcase.downcase}")
    end
    return mystring
  end
end

h4. Advanced Usage

# make two files refactorable
script/generate refactorable app/models/post.rb app/helpers/post_helper.rb

# cross-unrefactor two files
script/generate refactorable app/models/post.rb app/helpers/post_helper.rb cross:true

h4. But why, DHH? Why?!
Hannson explains that, “sometimes, even I write code that is TOO neat.. too DRY. At 37signals, we needed a tool to help some of the less experienced rails developers feel like they had something to contribute to the code I was writing. Naturally, we turned to Ruby, and the result of our investigation was make_refactorable.”

Read more...

Comments 0 comments

Topfunky founder discloses origins of company name: "I was high."

Geoffrey Grosenbach of Peepcode screencasts and The Ruby on Rails Podcast recently sat down with RailsRumours.com while he had a few spare moments during an interview wiht Ryan Bates of Railscasts.com about podcasting, meta-podcasting, and, unfortunately, meta-meta-podcasting.
We asked the lead visionary over at Topfunky Corp. how he came up with his clever ‘Topfunky’ moniker:

“I was rolling around some names for the business, and I knew I wanted something that conveyed the fact that I’m the best AND the coolest. Fortunately, TheShitAndTheSuave.com was already taken, so I ended up with Topfunky. I was high on marijuana at the time.”

Read more...

Comments 0 comments

Mephisto vs. Beast

Everyone knows that Rick Olson (aka technoweenie) wrote mephisto (the best blogging system ever) and the Beast forum engine (with Josh Goebel). If you’re like me, you’ve installed both of them and now you’re wondering “which of these apps would win in a fight? Which is the better app? Are there any tools to help me figure out which one I should use for a particular project?”
I’ve discovered a free, online tool that will help you figure out, once and for all, whether you need the awesome power and richness of complexity of Mephisto or the lithe codebase of Beast. I think it uses javascript, but I’m not sure. Enjoy:
Mephisto vs. Beast

Read more...

Comments 0 comments

Haml creator releases make_breakfast

Hampton Catlin, creater of Haml and make_resourceful, announced Thursday the release of his latest plugin, make_breakfast, giving rails developers an easy interface to that most important meal of the day.
In a nutshell, make_breakfast is to breakfast what make_resourceful is to resources. It employs Ruby’s awesome meta-programming features to eliminate virtually all that “I need to hack together a controller that makes me breakfast… AGAIN” code that we’re all so sick of writing. The syntax is uber simple, and the results are super sweet – especially the pancakes.

Read more...

Comments 0 comments

Capistrano author to release next child under MIT license

Jamis Buck, creator of the application deployment tool capistrano, announced earlier this week that he would release his next child, Gertrude, under the liberal MIT license.

Read more...

Comments 0 comments