Ruby

DB Content Rails Plugin

Tagged:  

The DB Content Rails plugin adds tasks to save and restore database content.  read more »

Usage

— dump the development database to db/archive/development-content.sql.gz
rake db:content:dump
 
— load the dumped database, and apply any necessary migrations
$ rake db:content:load
 
— dump the production database to db/archive/production-content.sql.gz
$ RAILS_ENV=production rake db:content:dump
 
— save the development database to db/archive/{timestamp}.sql.gz
$ rake db:content:save
 
— save the (compressed) database to my-data.sql.gz
$ rake db:content:save FILE=my-data.sql.gz

JCON: Ruby Gem for JSON type conformance

JCON (the JavaScript Conformance gem) tests JSON values against ECMAScript 4.0-style type definitions
(PDF) such as string?, (int, boolean), or [string, (int, boolean), {x:double, y:double}?].

Usage

type = JCON::parse "[string, int]"
type.contains?([‘a’, 1])     # => true
type.contains?([‘a’, ‘b’])   # => false
type.contains?([‘a’, 1, 2])  # => true

JCON also defines an RSpec matcher, conforms_to_js:  read more »

JavaScript Fu Rails Plugin

JavaScript Fu extends Rails with a few facilities to better integrate JavaScript into Rails development:

1. The notes and statistics rake tasks compass JavaScript files in the public/javascript directory:

$ rake notes
public/javascripts/controls.js:
  * [782] [TODO] improve sanity check
$ rake stats
| Name                 | Lines |   LOC | Classes | Methods | M/C | LOC/M |
[...]
| JavaScript           |  7287 |  6322 |       0 |       0 |   0 |     0 |
[...]

2. The call_js RSpec matcher asserts that a string or response contains a script tag, that contains JavaScript that calls the named function or method:  read more »

FizzBuzz Station

reWork: an online workbench for regular expressions

reAnimator got me interested in writing something that would let you use regular expressions. That something is reWork. This web page has a couple of fields where you can type in a regular expression and a string to match it against, and see the results update as you type. It also displays the code to perform the match in some of the languages (JavaScript, PHP, Python, and Ruby) that I use with regular expressions.

reWork limited to the features of the JavaScript regex engine. In particular, it’s missing dotall (/.../s), because JavaScript is. I actually figured out a hack to implement dotall anyway, but this will have to wait for another day.  read more »

OpenLaszlo Ruby library

openlaszlo.rb is a Ruby library for compiling OpenLaszlo programs. I use it to build this, this, and the toolbar here. This article describes how to use it with Rake.

Update: This is now available as a gem.  read more »

Ruby and Laszlo

I first heard of Ruby at the second Lightweight Languages Workshop 2, where Matz and I were both speakers. This was first public disclosure of the then-proprietary Laszlo platform language. I’m afraid I was more worried about preparing my talk then listening to Matz at the time!

Since then, a number of different people have expressed interest in both Laszlo and Ruby. I figured I had finally better take a look at it.  read more »

Syndicate content