runpacker.
I’ve noticed that RubyGems(as of version 1.0.1, anyway) does not offer a convenient way to unpack a specified gem and all of its dependencies. So, I decided to try to come up with something simple to work around that. After a few minutes inspecting the Gem API and some help from drbrain, I ended up with this:
#!/usr/bin/env ruby
if ARGV.empty?
puts "Usage: runpack gem_name"
exit
end
require "rubygems"
gem_specified = ARGV.first
Gem.gem gem_specified
gems_to_unpack = [gem_specified] +
Gem.loaded_specs[gem_specified].dependencies.map { |d| d.name }
gems_to_unpack.each { |g| system "gem unpack #{g}" }
be offended. be very offended.
I left the following as a comment on a recent failure, and I was just pleased enough with its coherence that I thought I would post it here:
Taking personal offense to something is a subjective experience. Everyone has the right to that experience, but what I don’t think they have the right to is asking somebody to take back something like this. Where do you draw the line? “OK, this is offensive, but that is not.” Great. What about me? What about that guy? What about the guy who hasn’t even entered the situation yet?
Be offended if you must, but leave it at that and move on.
a poor man’s YouTube API in Ruby.
I’ve been playing with a little Merb app for my new personal website. One of the focuses of the project is for me to focus less on engineering principles and so-called best practices and more on features and doing new, creative things.
Recently I thought it would be cool if YouTube videos I linked to via my Delicious account were automatically embedded in the HTML representation of the Yahoo! Pipes feed which powers the main view of my new site. I came up with this:
CGI.unescapeHTML Hpricot(open(link)).at("#embed_code")[:value]
Now, if you want to split hairs, it’s definitely questionable. However, context is everything, and in my current one, this solution works great.



leave a comment