Archive for the 'Ruby' Category

Posted on July 30, 2006 at 1:20 pm

I’ve written a DBF database access library in Ruby, but so far I’ve only tested it with files created with a couple of versions of FoxPro. I need files created with different flavors of DBase, XBase, Clipper, and FoxPro in order to flesh out the test suite. Ultimately, I would like to library to handle all the known variations of the DBF file format.

The project will be available on rubyforge.com within in a couple of days. I’ll post the link as soon as it’s available. The project is hosted on Rubyforge and can be found here.

If you have any files with the following characteristics, please email them to me at keithm@infused.org. Better yet, if you want to take the time to create a fresh sample database for me that would be awesome. Here’s what I’m looking for:

  • Small dataset. Prefer less than 100 rows
  • At least one field from each of the general data types. This means:
    • At least one Character field (if using software that supports fields larger than 254 characters, also include at least one field that is larger)
    • At least one Number field
    • At least one Boolean field
    • At least one Date field
    • At least one Memo field (please include the memo file along with the dbf file)
  • Fields to include if supported by the software:
    • At least one Floating Point field
    • At least one Binary, General, or Picture field (not neccessary to have one of each)
    • At least one Currency field
    • At least one Integer field
    • At lease one DateTime field
    • At lease one Timestamp field

There are a few other data types such as VariField which I don’t really care about right now.

Special Bonus Offer:
If you have access to 3 or more of the software packages and/or versions and are willing to create good sample databases I will pay you for your efforts. Contact me at the email above for details.

Posted on July 28, 2006 at 5:56 pm

I’ve been working on a very large Rails projects at work and found myself spending a lot of time writing the same unit tests over and over again. The application has a very complex database schema and has 159 ActiveRecord models so far. With this many models, there are obviously a ton of associations. I decided that I needed a way to automatically test every association that is defined in a model.

The TestInjector plugin is the result. I still have a lot of functionality that I want to add, but it works very well and it’s ready for others to use.

I posted the details on the Rails wiki:
http://wiki.rubyonrails.org/rails/pages/TestInjector

Or just install it using the plugin manager and take a look at the README file for more details:

script/plugin install http://www.infused.org/svn/plugins/test_injector

or:

script/plugin discover
script/plugin install test_injector
Posted on July 20, 2006 at 12:09 pm

Anybody else have this problem with Anna Chan’s ScopedAccess plugin?

Using a around_filter with ScopedAccess::Filter or the scoped_access helper works fine in normal usage, but when running rake test:functionals, the scope from previously run tests carries over into later tests. In other words with_scope is being set but not removed.

Maybe this is because the controllers are not being torn down after the corresponding functional test is run? I’m tired of peppering my functional test setup methods with Whatever.reset_scope. Anybody have a quick fix for me? I have other things to do, and I’d like to avoid looking deeper into this one…

Posted on June 15, 2006 at 2:09 pm

I’ve been keeping myself user busy the last few weeks and haven’t made the time to post anything.

  • RailsConf 2006 is only 5 days away. I’m flying. While the ArgonExpress would be a good opportunity to hang out with the cool kids, I can’t stomach the thought of being stuck in on a train for several days. I hope they make it to Chicago alive.
  • The server migration is almost complete. Last night I installed lighttpd on the new box, setup Apache to proxy requests to the Rails sites running under lighttpd, and migrated all of the Subversion repositories. There is only one site left to move. Just waiting on the client.
  • I’ve written a lot of stuff in Rails over the last several weeks which may be useful to others. I’ll try to package these up and post them before or during RailsConf:
    • Global unit tests: Tests that are defined in one place that will run for any ActiveRecord model with the right attributes. So far I have test_acts_as_versioned, test_optimisitic_locking, and test_fixtures_loaded_for_all_associations. The last one is very handy. It reflects on all associations and gives you a list of fixtures that need to be defined in each unit test.
    • Plugin: update_attributes_if_changed. Only updates the attributes if anything has changed. If you are using update_attributes on models with updated_at columns and acts_as_versioned you’ll want this.
    • ActiveRecord synchronizer: One way synchronization with data transformations, conditions, defaults, etc. Very handy for synchronizing with legacy databases. Complete with DSL.
    • Datadumper plugin: Dump data in several format, but mosty used for dumping data into a format usable in migrations. Especially nice for prepopulating domain tables using migrations.
    • Validation: validates_association. Not to be confused with validates_associated. Validates_association validates that the associated object is of the correct class as specified in the association declaration.
  • Surprisingly, I found out that I really like watching soccer.
Posted on April 18, 2006 at 6:14 pm

If you’re heavily using the AJAX helpers in Ruby on Rails like I am, you may want to check out Thomas Fuchs’ awesome presentation from Canada on Rails 2006.

You may find a few little tasty morsels that aren’t adequately (at all?) documented.

My favorite? Call your own. Although… respond_to is a close runner up, though I’ve been aware of it for a whie now.

BTW- If you are still building new sites/application in PHP, can I just ask… WTF?