{ i ♥ code }

One of my favorite development tools is Rake. Not so long ago I discovered how great this tool is and started using it for automating development chores.

The Rakefile of a static site project would look something like this:

require "s3"
require "mimemagic"

desc "Deploys the site to S3"
task :upload do |t, args|
  service = S3::Service.new(:access_key_id => "...",
                            :secret_access_key => "...")

  bucket = service.buckets.find("mybucket")

  files = Dir['*.html'].to_a
  files += Dir['css/*.css'].to_a
  files += Dir['js/*.js'].to_a
  files += Dir['img/*.*'].to_a

  files.each do |source|
    object = bucket.objects.build(source)
    object.content = File.open(source)
    object.content_type = MimeMagic.by_path(source)
    object.save
    puts "Uploaded https://#{bucket.name}.s3.amazonaws.com/#{source}"
  end
end

Dependency Management

To manage our dependencies we will use Bundler. The Gemfile should look something like this:

source "http://rubygems.org"

gem "s3"
gem "mimemagic"
blog comments powered by Disqus

Ramon Torres - iOS developer/product designer

My name is Ramon Torres. I'm a software developer and product designer, currently working at Inkboard building cool stuff.