Part 1: Using WebORB to access ActiveRecords from a Flex application.

On Friday I started for a customer an investigation in providing a Flex front-end for an Ruby on Rails backend using WebORB. In parallel I will push this investigation further for myself in order to find a nice mechanisms to support CRUD operations with relationship support using WebORB. Over the next couple of weeks I will write some of my findings on this blog. So this week-end I started to put in place an environment where I can unit test the interaction between Flex and Ruby on Rails using WebORB. In this first part I will show how to extend WebORB to perform a deep find, how to write a Flex unit test to test asynchronous remote calls, and how to use Ruby on Rails fixtures for the Flex unit tests.

This is an extract of the ‘final’ version of the Flex unit test (as of Part 1 of the article). The full version is at the end of the article.

public function testGetFirstCustomer():void {
var activeRecordService:RemoteObject = getActiveRecordService(onGetFirstCustomerResult);
create_fixtures([“customers”, “addresses”, “orders”, “items”], doGetCustomerFirstCustomer, activeRecordService);
}
private function doGetCustomerFirstCustomer(activeRecordService:Object):void {
var options:Object = {’include’:[‘bill_to_address’, {’orders’:’items’}]};
activeRecordService.get(“Customer”, 1, options);
}
private function onGetFirstCustomerResult(event:Event, token:Object=null):void
{
assertTrue(event.toString(), event is ResultEvent); // First param is message.
var customer:Object = ResultEvent(event).result;
assertEquals(“Daniel”, customer.name);
assertEquals(“Littleton”, customer.bill_to_address.city);
assertEquals(2, customer.orders.length); // 2 order
assertEquals(3, customer.orders0.items.length); // the first has 3 items
assertEquals(“Remote Control”, customer.orders0.items2.product);
}

RubyConf2006 – Ruby on Rails Podcast

A chat with Greg Edwards of EyeTools (blog), a user interface research lab.
Elsewhere: Matz Keynote, Adam Keys USSRuby Sketch (alt), and the Erlang promo video.

RubyConf2006 – Ruby on Rails Podcast

A chat with Greg Edwards of EyeTools (blog), a user interface research lab.
Elsewhere: Matz Keynote, Adam Keys USSRuby Sketch (alt), and the Erlang promo video.

RubyConf 2006 – Day 3

Here we go again. Let’s how long my battery is going to last today.

Bruce Williams posted the cool RubyConf 2006 logo on his blog.
rubyconf2006-140x85.png
9am: Streamlined, Justin Gehtland
Why Streamlined? Remove repetitiveness in web development mostly for back-end type of application. Streamlined is build on top of Ruby on Rails. Build from their needs to build client applications. Goal to bring declarative goodness of ActiveRecord to the view layer. Streamlines is not a code generator like scaffolding. He now moves on to demo an application build with the framework. Streamlined support nicely relationship management. By default a new streamlined folder is add at the same level than the controllers, views, and models level. The streamline folder contains StreamlinedUI class allowing the modify declaratively the default behavior and representation of the views. Note that Justing presents the new css look and feel that Streamlined supports, named ‘grail’, which looks way better than the prior default look and feel. The default behavior uses Ajax, this can be turned off. No views are generate by default, they are dynamically rendered. For customization that goes beyond the features provided by Streamlined, a view can be generated and customized at will and will then be used instead of the generic view. Supports the acts_as_authenticated plugin, and provides user preferences. Justin now shows some upcoming features, like model specific behavior, layer specific field, tabbed views, multiple windowing toolkits, visual configuration.

YARV: on Rails? by Koichi SASADA
He starts with a tour on how Ruby activities in Japaon, from the RubyConf, to books and magazines. Japanese are very enthusiastic about Ruby. He mentions the Rubyist magazine (this is the link to the google translated version). He now moves on to YARV (Yet Another Ruby Vm). Which is going to be the new interpreter, which will have several advantages and optimizations. The demo continues buy showing a Rails application running on Yarv. YARV passes most of tests, but make ‘test/test-all’ still reports some errors. He demystifies some of the myth related to yard and mentions that Yarv is not a Silver Bullet. It doesn’t make all programs 50 times faster, nor makes you slim and rich. The whole presentation is pretty funny.
You got your Ruby in my CLR!, by John Lam
no comments for that one…I was heads down coding…
USS Ruby
Where Star Treck joins Ruby. A one man act, somebody is taping this…I gotta find that link, it’s too funny.
Summer of Code 2006 – Google & Ruby Central, Inc.
Austin Zigler was one mentor of the summer of code. He presents the principles of the Summer of code. 17 volunteers reviewed 96 applications for projects. 84 projects where eligible. 25 found a mentor, and google accepted 10. 3 of projects will be presented here. Ariel, A Ruby Information Extraction Library, train a program how to scan web pages. Root Port, Makerf, …..
1. Gregory Brown presents his project, Ruby Reports (ruport). Plays also nice with Rails via acts_as_reportable. Gregory is not a Rails programmer, but wanted to get a plugin out there and let it grow.

class ChunkyBacon < ActiveRecord::Base
    acts_as_reportable
end
class MyReport < Ruport::Report
    prepare do
        @table = ChunkyBacon.report_table(:all)
     end

    generate do
        @table.to_s
     end
end

There are many features like graph generation, pdf support for Ruport, so check it out.
2. Rockin' the Pcoket - Ruby on Phones, by Jeff Hughes. He is just another Ruby Hacker that likes phones. He went with Symbian, Nokia mostly. Based on Python for Symbian open source project. Perl did it too. His motivation where that the phone is the ideal platform, every body has one, it's always connected, but where is Ruby. 2 weeks just to get it to compile. Another 2 weeks for linking. He is new to Ruby internal, in one summer he came out with a working prototype. Today, the core interpreter, a simple and basic file io. Future development: GUI, Symbian modules (socket, bluetooth, messaging). Matz is very excited about this project. See http://ruby-symbian.rubyforge.org/

3. Jason Morisson - Type inference & Code Completion for RDT Well, I didn't follow this talk as I was talking with Laurent Sansonetti about RubyOSA as I am waiting eagerly for the WebKit bindings.

That's all Folks. Another great Ruby conference is under wrap.

RubyConf 2006 – Day 2

9am – Open Classes, Open Companies,by Nathaniel Talbott
In this talk Nathaniel reflects upon how features of the Ruby language that make it so efficient can be applied to business. Duck Typing, Interpreted language, Flexibility, Succinctness, Reflection, Open classes. It’s a great way to present business concepts to a bunch of Ruby developers. Obie also wrote down some notes.
10am – Mac OS X and Ruby, by Laurent Sansonetti
Laurent is from Apple. Author of 5 Ruby libraries and maintains Ruby inside of OSX. For OSX Leopard, Ruby will be bundled as an OSX framework (Ruby.framework). Support 64bit, universal binary. IRB history support and line editing. Bundle gems (Rake, Rails, Mongrel, Capistrano, Libxml2, SQLit3, DNSDD,…). Ruby can control scriptable applications.

1. RubyAEOSA: app = OSX:AEDesc.application('iTunes')
2. Applescript using RubyAEOSA: result = OSX.do_osascript "tel application 'iTunes'...
3. RubyOSA: new project since June 2006. puts OSA.app('iTunes').current_track.name

RubyOSA is the successor of RubyAEOSA, and is simpler to use and still efficient.

require 'rbosa'
itunes = OSA.app('iTunes')
itunes.play
# Let increase the volume...
100.times { |i| itunes.sound_volume = i; sleep 0.1 }

He will release version 0.1.0 today, it will be available as a gem.
Now onto Cocoa. RubyCocoa, is not Cocoa specific can be used to bridge Ruby with Objective-C code. Is widely used in free and commercials products. Laurent now demos a small Cocoa application written using XCode, in Ruby, to select and control songs in iTunes.

Rinda in the real world, by Glenn Vanderbug
Rinda is based on Linda, a distributed coordination system. Similar to JavaSpaces. Communication based on Drb.
Lightning Talks
Josh Susser having the flu, his session has been replaced by 9 x 5 minutes presentations.
1. kylemaxwell.com – I missed this presentation.
2. Ara T. Howard – ruby queue. Ruby based linux clustering solution used at NORA. nfs priority queue sqlite ruby.

3. Ben Bleything Shell-Style history for irb (in 75 lines). See at blog.bleything.net
4. Andre Louis – wifi.earthcode.com. A community Wifi Cafe Listings allowing to enter cafes and ratings for working condition. Great site for the Rails developer on the go. Currently listing more than 1000 entries. With a open source zoom control for google maps.
5. Ryan Davis – Hoe. A tool to compliment rake.
6. Daniel Burger – Win32Util project. Memory Mapped IO on Windows with Ruby.
7. Aaron Patterson, http://tenderlovemaking.com (despite the site url, can be viewed at work). The presentation is named “I saw the sign” – Control a electrical sign panel from Ruby.

8. Charles Nutter – JRuby – presents the functionality of JRuby (0.9.1)
9. Charles Queen, James Grey – Heartbeat. Deploy your application from a web page. Using Capistrano and Rake tasks. see http://highgroove.com/
10.Bryan Takita – FJSON, Fast JSON.
Web 2.0 Beyond the Browser, by Rich Kilmer
Rich is presenting a Ruby based desktop runtime with a Rails based central service, named Indi. The UI is build in Flash.

Lot’s of good information can be found on these blogs:

RubyConf 2006 – Day 1

Thursday night the crew (Chad, Rich, ..) preparing the name tags.
nametags.jpg
nametags2.jpg
It’s starting stay tunned.
RubyConfDenverLogo.jpg
8:57am The room is pretty full.
starting.jpg
RubyConf T-Shirt && Lee
lee.jpg
T-Shirt design by Bruce Williams.
Erlang: The Movie
We are in advance on the schedule, so Rich Kilmer decided to show a video on scripting languages that is in the same vain as DHH’s webcast that really brought TextMate and Ruby on Rails into limelight. You can see it on youtube
here. Erlang is 10x more productive, 7x shorter programs. 🙂
10am: The History of Ruby, by Masayoshi Takahashi
Why is Takahashi presenting The History of Ruby and not “matz”? Because Matz loves the Ruby, not the history of Ruby. By the way Masayoshi is the inventor of the Takahashi “Method”
This presentation is a detailed and well informed recollection of how the Ruby community was created and spread from Japan to the rest of the world. Here are Lee’s notes that will give you an idea but don’t give justice to the presentation it self:

History of Ruby - Masayoshi Takahashi (from the Takahashi Method)
    - 5 periods of Ruby history
        - Pre-history
            - Feburary 24, 1993 - "Ruby" name proposed by Keiju
        - Ancient Age
            - Ruby 0.95 released December 21, 1995
            - "Rubyist" first used August 9, 1996
        - Middle Age
            - Ruby spread in Japan since all the developers spoke
                  Japanese, developers could learn English (for other
                  languages) or learn Ruby
        - Modern Age
            - Ruby outside Japan
            - 2/16/2002 - English ML volume overtook Japanese ML
        - Contemporary Age (Rails Age)
            - RoR - The killer application on Ruby
11am: Sydney & Rubinius – An experiment in improving, by Evan Phoenix (a.k.a Evan Webb)
    - Current interpreter: dump truck - reliable, sometimes slow,
          can throw everything in it
    - YARV: fire engine - shiny and fast
    - Rubinius: Dune buggy - fun but you'll get sand in your eyes
    - Simple == Powerful
    - Sydney
        - What was it?
            - giant patch to 1.8.2
            - reentrant and threadsafe
        - Hit dead end
    - Rubinius
        - Prototype A
            - ported most of Smalltalk blue book to Ruby
            - worked but slow
        - Prototype B
            - implemented bytecode interpreter and compiler
        - Prototype S
            - hand translation of proto-B into C code
        - Evan has a nice conversational style to his talk
    - SegfaultProtection
        - protects extensions from crashing
        - turns a segfault into a raised exception
    - Bytecode interpreter architected via TDD
1:30pm Programming Graphics with Ruby, by Geoffrey Grosenbach
The presentation went through many visual examples, showed the code behind some of them. The presenter mentioned the following libraries: Scruffy – generates SVG, gnuplot, mrplot, asset_compiler from Jeremy Voorhis – Rake tasks for image manipulation, and his own library Gruff (which is pretty cool), sparkline. He went on showing how the different screencast headers on peopcode.com are generated using RMagick.
2pm: Life After mkmf, Kevin Clark
Iron Mongrel: Fuzzing, Auditing, Thrashing, Risk and The Ways Of Mongrel Destruction, Zed Shaw
More notes to come, my neighbor at the conference and former colleague Tom is taking good notes…I will point to his blog as soon as he gets a network connection. Also check out Nick Blogs. We gave him so much crap after RailsConf where he was bragging about how much he would blog on it and didn’t do any writing that he is currently trying to prove us wrong, but provides some good information.
7:30pm – Yukihiro “matz” Matsumoto Roundtable

Note that as you notice the picture are taken with a phone or photobooth.

From RubyConf 2005 to RubyConf 2006

RubyConf is a great point in time to have a retrospective on the past year. And what at year it was.

2005 October Started my first paid Ruby On Rails consulting gig to create an eCommerce platform for Gatelys.
October 14th-16th RubyConf 2005 in San Diego, very technical. The creator and some of the key players in making Ruby were there: Yukihiro "matz" Matsumoto, Akira Tanaka, Koichi Sasada… While at the conference I started implementing time.onrails.org and started using it internally to log all my consulting time.
October 19th Lee and I launched AutumnRidersTees.com, our first Ruby on Rails online eCommerce website, created for Lee’s dad.
2006  
March Gatelys deploys internally the order fulfillment section of their eCommerce Platform.
April Based on the success off the first part of the eCommerce platform at Gatelys they asked me to work full time on their project. 27th of April: deployed www.nationaltabletennis.com, the first public facing part of the application went life. Since October I also had spend about 50 development hours on time.onrails.org and thought it was getting pretty usable. So on the 13th of April, I launched time.onrails.org.
June Started working on Maestro, a new kind of multimedia-based learning platform written in Ruby on Rails. At that point I was over committed with all the different gigs I said yes to. Hopefully I learned a lesson from that. However Maestro was fun and invigorating to work on and you saw it in the results. We spend about 30 hours each in June with Lee and where able to put together an impressive Application under the lead of Sean Voisen. Rails really rocks. June 21th: my birthday and RailsConf 2006. It was impressive to see how positive the spirit of everyone was at that conference. More than 700 people attended, the rooms where packed, the presentations where just awesome.
September Integrated time.onrails.org with Blinksale using their RESTFull API.
October

Time.onrails.org has now 475 registered users, I estimate around 100 active users. Thanks to everyone who tried the application out, and especially for the users that provided feedback. I started working on the next version, it is a complete rewrite, but will stay as easy to use, with several valuable new features. Gatelys deploys Gatelys.com, their flagship store using the eCommerce platform. More than 13 of their high volume stores are now powered by Ruby on Rails. I can tell you, Rails scales. RubyConf 2006 is in just two days. I hope I’ll see you there…I am the other Denver Ruby on Rails developer with a French accent. Swiss-French accent to be more precise.

See you at RubyConf!

BillMonk – Ruby on Rails Podcast

The founders of BillMonk talk about building a community site with Rails, email as an API, and dynamically generated graphics.

BillMonk – Ruby on Rails Podcast

The founders of BillMonk talk about building a community site with Rails, email as an API, and dynamically generated graphics.

Aslak Hellesoy – Ruby on Rails Podcast

A member of the rSpec team talks about Behavior Driven Development. From the offices of Bekk in Oslo, Norway.

Aslak Hellesoy – Ruby on Rails Podcast

A member of the rSpec team talks about Behavior Driven Development. From the offices of Bekk in Oslo, Norway.

Time.onrails.org now with Blinksale integration.

Blinksale is the easiest way to send invoices online. Now time.onrails.org is the easiest way to create Blinksale invoices. Check http://time.onrails.org/doc/blinksale/blinksale.html for more details.

Blinksale API

Today Blinksale published it’s data API. See http://www.blinksale.com/api for the details.

It’s good news for time.onrails.org as now we can use the api to generate a draft Blinksale invoice with one click. I have started coding the integration and expect to release it once I have completed extensive testing.

In short, time.onrails.org interacts in the following way with Blinksale:

  1. get list of client names
  2. get highest invoice number
  3. create invoice

Let’s have a peek at how this is implemented.

Accessing Blinksale

A Blinksale class is provided to interact with your Blinksale data. You need to provide your blinksale id, username, and password.

@blinksale = Blinksale.new ‘blinksaleid’, ‘username’, ‘password’

In time.onrails.org we will let you define your Blinksale credentials once to avoid having to retype them each time you create an invoice. Storing the password is optional, and if not provided it will be prompted each time. A use_ssl flag can also be specified if you have a paid Blinksale subscription. This is of course recommended for security reasons.

Get the list of clients

clients = @blinksale.clients
names = clients.collect { |c| c.name }

Get the highest invoice number

invoices = @blinksale.invoices
invoices.collect{|invoice| invoice.number}.max

Create An Invoice

invoice_data = BlinksaleGenerator.to_xml(INVOICE)
new_invoice = @blinksale.invoices.new invoice_data
new_invoice.save

BlinksaleGenerator is a time.onrails.org class that helps creating the following ‘invoice’ xml.

<?xml version="1.0" encoding="UTF-8"?>
<invoice>
   <client>http://#{blinksaleid}.blinksale.com/clients/#{@client_id}</client>
   <number>34</number>
   <date>2006-09-27</date>
   <terms>30</terms>
   <currency>USD</currency>
   <lines>
     <line>
       <name>Consulting</name>
       <quantity>2.0</quantity>
       <kind>Hours</kind>
       <unit_price>150.00</unit_price>
       <taxed>false</taxed>
     </line>
   </lines>
 </invoice>

The integration is pretty straight forward. Don’t you think? Thanks Scott and your team for this cool application. To find out more on the blinksale api see the online documentation at http://www.blinksale.com/api