Skip to content

{ Tag Archives } Ruby

Ruby Dir.glob bug

To further elaborate on Yehuda’s twit:

[~/tmp][rando@apollo] % mkdir first first/second [~/tmp][rando@apollo] % touch first/second/test.txt [~/tmp][rando@apollo] % chmod -x first [~/tmp][rando@apollo] % ls first/second/*.txt ls: cannot access first/second/*.txt: Permission denied [~/tmp][rando@apollo] % irb irb(main):001:0> Dir.glob(’first/second/*.txt’) => []

If you try to glob some things in a directory that has some ancestor missing the eXecute permission, ruby doesn’t give any indication of an error.

This took [...]

Also tagged

HOWTO: Better JSON parsing when POSTing to Merb Apps

Where I work, we have fairly extensive, JSON-based web services in all out applications. As a quick example, here’s what you would get if you were to GET http://config.ssbe.example.com/configurations/90 with the mime-type application/vnd.absperf.sscj1+json:

{ “_type”: [...]

Also tagged ,

HOWTO: Exception Handling in Merb

Our app is very (JSON) web-service heavy, and so having helpful error messages in our web service documents is pretty important. Luckily, Merb makes this, like everything, a metric shitton easier than it is in rails. There are a couple poorly documented things I had to stumble through, so I thought I would write some [...]

Also tagged ,

HOWTO: Getting a sidebar in Merb

In several of my pages, I have a side-bar menu-y thingie. I didn’t want to have to rewrite a controller-specific layout each time, but luckily Merb supports something similar to Rails’s content_for block that I wrote about earlier. In Merb, its done using throw_content(API) and catch_content(API).

Put the catch_content into your application layout view. You probably [...]

Also tagged ,

Application-wide Config loader for Merb Apps

I saw this post by Stephen Bartholomew and thought that it was a pretty neat idea, so I adapted it for Merb applications. Merb already has the Merb::Config for storing config options, so I just added the config options to that, rather than the AppConfig class used in Steve’s post. That also greatly simplifies its [...]

Also tagged

Resourceful - Adding default options

I just commited a change that allows you to specify some default headers to attach to all requests made on a resource. Best shown in an example, I’ll use the sample code I gave in my last post:

require ‘rubygems’ require ‘resourceful’

http = Resourceful::HttpAccessor.new(:logger => Resourceful::StdOutLogger.new, [...]

Also tagged

Resourceful 0.2.1

I’m pleased to introduce the next release of Resourceful, 0.2.1. This one has tons of bugfixes over 0.2, and is actually being used in production. There’s only one real new feature to speak of is prettier logging output. It shows the runtime for requests, the resulting status code, and if it was retrieved from the [...]

Also tagged , , ,

Announcing Resourceful

Resourceful is an advanced http library for Ruby that does all the fancy stuff that makes HTTP an amazing protocol. I’m pleased to announce the initial release of Resourceful, 0.2. It already has some pretty cool features, with more to come.

This library is intended to make it easier for you to write your next whiz-bang [...]

Also tagged

Spec’ing Migrations (A Tutorial)

I realized I haven’t blogged about (IMHO) the neatest feature of DataMapper’s migrations yet. One of the more harrowing experiences for me in Rails is upgrading a production server with live data, and hoping your migration handles all the existing data correctly. You can dump the database, and attempt the migration on a clone, and [...]

Also tagged , ,

MWRC

Well, I’m off to Mountain West Ruby Conf. If any of you Datamapper freaks are going, leave a comment, or email/jabber me at psadauskas@gmail.com. Maybe we can meet up for a beer.

Also tagged