Way back in the day, source control was so clunky and frustrating (or non-existent), that sometimes the easiest way to share code was to zip it up and send it over email to your fellow developer. There are tons of source control options now, all quite mature and most very easy to use.

However (heh), every now and again you need to package up your files in a “zip” or some other archive form for including in a set of final deliverables, or to transfer them to someone who doesn’t use (or even understand) source control. In those cases, I’ve often gone through and manually ensured that I don’t include items that I don’t want to (local db configs, for example) in the final archive. Then I was working on a ruby gem and realized that the package task is absolutely perfect for this (and makes “zipping stuff up” a breeze).

I prefer git, and will generally create a local repo even if I’m not pushing to centralized server or sharing code with anyone. So this little snippet is a bit git-specific, but it should be easy to convert for other scm’s. Anyways, if what you want in your archive is what you store in git (which is likely how you have things set up already), then just do this:

1
2
3
4
5
6
require 'rake/packagetask'
 
Rake::PackageTask.new("myfile", "0.1.0") do |p|
  p.need_zip = true
  p.package_files = `git ls-files`.split(/\n/)
end

You can see at line three I pretty much use an arbitrary version number, since it’s rake you could extract a revision or another identifier if need be. Then you can zip ‘er all up with “rake package” or “rake repackage” — and bring back some of that old-school “no-scm” vibe…

cheers

{ 0 comments }

install netdisco on ubuntu from source

April 20, 2010

netdisco can be a pain… even just getting it to run… I found some neat installation scripts for installing netdisco on some other linux flavors, but I prefer ubuntu. I took those scripts and quickly hammered out one that’s ubuntu-specific. It’s not as pretty, and doesn’t allow you to do as much config by responding [...]

Read the full article →

autotest with rspec-2.0 beta

March 19, 2010

Just saw this, made me happy: http://github.com/rspec/rspec-core/commit/c1d600cd4367fb24a333c3f27f3b27693745ad14 So you can now run autotest without a bunch of (uglier) hacks just by adding the file autotest/discover.rb to the root of your project with this inside: Autotest.add_discovery { "rspec2" } note that you’ll need at least rspec version 2.0.0.beta4 (beta3 does *not* have this) and once again [...]

Read the full article →

rails 3, bundler, capistrano

March 17, 2010

Deploying a rails app with capistrano got just a little bit trickier with the new bundler integration. Here’s a super-simplified task you can tack onto the end of your deployment recipe to make sure that your server gets a bundle set up (and updated, if need be): namespace :bundler do task :create_symlink, :roles => :app [...]

Read the full article →

word movement in mac os x terminal (bash) — ctrl-left and ctrl-right

March 15, 2010

I’ve been irritated by this for quite a while, I’m surprised it took me this long to “fix”… In bash there are two keyboard shortcuts that generally work by default on most linux systems: control-left and control-right, mapped to movement by word. For some reason on mac os x (at least for me), the default [...]

Read the full article →

rails 3 beta – “uninitialized constant ActionDispatch::Integration::Session::Test”

March 15, 2010

I just set up a new rails project with the 3.0 beta, and when I tried to run some cucumber tests I got the following: uninitialized constant ActionDispatch::Integration::Session::Test (NameError) Seems that there isn’t an explicit require of ‘test/unit/testcase’ in rails/actionpack/lib/action_dispatch/testing/integration.rb, but here is this line: 127 include Test::Unit::Assertions To get around the problem you can [...]

Read the full article →

disable php in an apache virtualhost

March 14, 2010

As long as I’m messing with apache configs, I’ll share another quick tip. If you have PHP generally enabled in apache, but you want to disable it in a certain VirtualHost, just add the line “php_admin_value engine off” and you’ll be all good. PHP will work elsewhere, but it will be off inside your described [...]

Read the full article →