Erik A. Hanson's Weblog

Archive for the 'Ruby' Category

A Ruby Client for Angular

Posted: Thursday, November 19th, 2009    Tags: My Software, Ruby, Web development

Here’s a little Ruby client for storing data in Angular, a system for creating simple database-backed web apps extremely easily.

#!/usr/bin/ruby

require ‘rubygems’
require ‘httpclient’
require ‘json’

class Angular
def initialize(username, password, library)
@http = HTTPClient.new
@library = library
post(“/login”, :email => username, :password => password)
end

[...]

Testing File Uploads To A Rack Server

Posted: Saturday, March 28th, 2009    Tags: Howto, Ruby

I wrote a web app on top of Rack that includes the ability to accept file uploads. It took some time to figure out how to successfully test the file upload using Rack::Test.
The trick was to encode the file exactly correctly, and then post it with the correct headers. I wrote a simple post_file [...]