0.6 almost there

Posted almost 7 years back at The Hobo Blog

Wow – getting all our tests upgraded to the new DRYML, not to mention getting them all to pass, has been a real slog, but we just crossed the finish line. All the tests are green. We now have to make sure things like Pod and the to-do demo are working, and that fresh Hobo apps with all the Rapid pages work too. Then there’s the changelog, and we’ll be ready for take-off.

This has been a huge effort to get working, as we’ve had three major upheavals: new DRYML, much improved standard tag libraries, and a move from Rails 1.2 to Edge Rails (don’t forget to rake rails:freeze:edge – that’s required now, and will be until we hit 1.0).

Almost there!

0.6 almost there

Posted almost 7 years back at The Hobo Blog

Wow – getting all our tests upgraded to the new DRYML, not to mention getting them all to pass, has been a real slog, but we just crossed the finish line. All the tests are green. We now have to make sure things like Pod and the to-do demo are working, and that fresh Hobo apps with all the Rapid pages work too. Then there’s the changelog, and we’ll be ready for take-off.

This has been a huge effort to get working, as we’ve had three major upheavals: new DRYML, much improved standard tag libraries, and a move from Rails 1.2 to Edge Rails (don’t forget to rake rails:freeze:edge – that’s required now, and will be until we hit 1.0).

Almost there!

NetBeans Rocks

Posted almost 7 years back at zerosum dirt(nap) - Home

NetBeans really is the BOMB, as Charles Nutter notes over on his blog. Check out that link. I wanted to make sure I echoed his thoughts here, because for me, NetBeans really is the best Rails IDE on the planet. I switched over from IntelliJ some time ago and haven’t regretted it even briefly.

I really can’t say enough things about NetBeans. What other IDE makes it painless to debug (yes debug, within the IDE), refactor, and test your Ruby applications? Plus, the syntax highlighting is rockin and you get all the standard NetBeans goodness out of the box. Don’t want a huge download? No big deal, there’s a slimmed-down Ruby-only version available. Give it a shot. Even if you’re a hardcore Textmate geek, I think you’ll at least be able to see why I’m raving about it.

DRYML Tour (0.6 not quite ready)

Posted almost 7 years back at The Hobo Blog

Nope, sorry. No Hobo 0.6 today, but to whet your appetites a little further, here’s an example of how clean a full DRYML template can look in the new DRYML. We’re pretty happy with the result over here - hope you like it :-)

In particular, look out for the new “smart HTML tags”. These aren’t a new DRYML feature, but a new style for the Rapid tag library. They’re just regular DRYML tags that have the same name as HTML tags. Want a link?

<a href="...">My Link</a>

Want Hobo to fill the href in for you? Say, to the author of the article you are rendering:

<a:author>...</a>

How about a form? Hobo will provide the attributes that make the form work (action, method…):

<form with="&Story.new">...</form>

Want to make that an ajax form? Just name the part (or parts) you want updated and Hobo does the rest:

<form with="&Story.new" update="stories">...</form>

So, on to that full page. It’s an index page BTW:

<Page title="Admin Home">

  <intro>
    <h1>Admin Home</h1>
  </intro>

  <maincol>
    <panel>
      <h2>All Accounts by client</h2>

      <section>
        <h3>Create a new client</h3>
        <form with="&Client.new">
          Name: <input:name/>
          <submit label="Create"/>
        </form>
      </section>

      <section>
        <p>Click on a client name to edit.</p>
      </section>

      <section repeat class="client">
        <h3><editor:name/></h3>

        <Table:accounts>
          <tr>
            <td><a/></td>
            <td>Created: <view:created_at.to_date/></td>
            <td>
              <a:quarters.latest if="&this.site_exists?">View Site</a>
            </td>
          </tr>
        </Table>

        <p>
          <b>&raquo; <a:accounts.new>Create a new account for 
              <name with="&this_parent"/></a></b>
        </p>

        <delete_button label="Delete #{this.name} permanently"/>
      </section>

      <section><page_nav/></section>

    </panel>
  </maincol>

</Page>

Let’s go over that again with some explanation. First the <page> tag.

<Page title="Admin Home">

<page> is a template. That’s a new DRYML feature. Where a normal tag has a single body, a template has a bunch of named parameters, and they can be placed wherever you like in the templates output. It’s a fill-in-the-blanks kind of model. Look up at the full listing again and you’ll see that <page> has two children – <intro> and <maincol>. These are not normal tags that are being called, they are named parameters to the <page> template. Whenever you see a tag with a capitalised name, remember that the children are parameters rather than tag calls.

Next, forms. Forms are blissfully neat now in Hobo.

<form with="&Client.new">
  Name: <input:name/>
  <submit label="Create"/>
</form>

Because the context for the form is a new AR object, Hobo knows to create a POST to the relevant RESTful create method. Furthermore, if you create the object via a has_many collection, the hidden field will be included so that the created object has the required foreign key.

Also notice the new tag for form controls: <input>, and the nice syntax to set the context to a given field: <input:name/>.

There are three general purpose tags of this kind: <view> for read-only views, <input> for form input fields and <editor> for ajax in-place editors. They all create the right stuff automatically depending on the type of the context, and it’s very easy to extend this with your own types. These replace the old show, form_field and edit (we’ve realised that nouns are better than verbs - they’re more declarative).

If the context is something enumerable, look how easy it is to repeat a tag for each item in the collection:

<section repeat class="client">

A quick click-to-edit title:

<h3><editor:name/></h3>

A table with a row for each account:

<Table:accounts>
  <tr>
    <td><a/></td>
    <td>Created: <view:created_at.to_date/></td>
    <td>
      <a:quarters.latest if="site_exists?">View Site</a>
    </td>
  </tr>
</Table>

That’s a template too - <tr> is a parameter and there are others for giving a thead and tfoot. Also Note the new in-line if syntax on that link.

And finally the page navigation:

<section><page_nav/></section>

That whole section will only appear if there is more than one page.

Sweet :-)

DRYML Tour (0.6 not quite ready)

Posted almost 7 years back at The Hobo Blog

Nope, sorry. No Hobo 0.6 today, but to whet your appetites a little further, here’s an example of how clean a full DRYML template can look in the new DRYML. We’re pretty happy with the result over here - hope you like it :-)

In particular, look out for the new “smart HTML tags”. These aren’t a new DRYML feature, but a new style for the Rapid tag library. They’re just regular DRYML tags that have the same name as HTML tags. Want a link?

<a href="...">My Link</a>

Want Hobo to fill the href in for you? Say, to the author of the article you are rendering:

<a:author>...</a>

How about a form? Hobo will provide the attributes that make the form work (action, method…):

<form with="&Story.new">...</form>

Want to make that an ajax form? Just name the part (or parts) you want updated and Hobo does the rest:

<form with="&Story.new" update="stories">...</form>

So, on to that full page. It’s an index page BTW:

<Page title="Admin Home">

  <intro>
    <h1>Admin Home</h1>
  </intro>

  <maincol>
    <panel>
      <h2>All Accounts by client</h2>

      <section>
        <h3>Create a new client</h3>
        <form with="&Client.new">
          Name: <input:name/>
          <submit label="Create"/>
        </form>
      </section>

      <section>
        <p>Click on a client name to edit.</p>
      </section>

      <section repeat class="client">
        <h3><editor:name/></h3>

        <Table:accounts>
          <tr>
            <td><a/></td>
            <td>Created: <view:created_at.to_date/></td>
            <td>
              <a:quarters.latest if="&this.site_exists?">View Site</a>
            </td>
          </tr>
        </Table>

        <p>
          <b>&raquo; <a:accounts.new>Create a new account for 
              <name with="&this_parent"/></a></b>
        </p>

        <delete_button label="Delete #{this.name} permanently"/>
      </section>

      <section><page_nav/></section>

    </panel>
  </maincol>

</Page>

Let’s go over that again with some explanation. First the <page> tag.

<Page title="Admin Home">

<page> is a template. That’s a new DRYML feature. Where a normal tag has a single body, a template has a bunch of named parameters, and they can be placed wherever you like in the templates output. It’s a fill-in-the-blanks kind of model. Look up at the full listing again and you’ll see that <page> has two children – <intro> and <maincol>. These are not normal tags that are being called, they are named parameters to the <page> template. Whenever you see a tag with a capitalised name, remember that the children are parameters rather than tag calls.

Next, forms. Forms are blissfully neat now in Hobo.

<form with="&Client.new">
  Name: <input:name/>
  <submit label="Create"/>
</form>

Because the context for the form is a new AR object, Hobo knows to create a POST to the relevant RESTful create method. Furthermore, if you create the object via a has_many collection, the hidden field will be included so that the created object has the required foreign key.

Also notice the new tag for form controls: <input>, and the nice syntax to set the context to a given field: <input:name/>.

There are three general purpose tags of this kind: <view> for read-only views, <input> for form input fields and <editor> for ajax in-place editors. They all create the right stuff automatically depending on the type of the context, and it’s very easy to extend this with your own types. These replace the old show, form_field and edit (we’ve realised that nouns are better than verbs - they’re more declarative).

If the context is something enumerable, look how easy it is to repeat a tag for each item in the collection:

<section repeat class="client">

A quick click-to-edit title:

<h3><editor:name/></h3>

A table with a row for each account:

<Table:accounts>
  <tr>
    <td><a/></td>
    <td>Created: <view:created_at.to_date/></td>
    <td>
      <a:quarters.latest if="site_exists?">View Site</a>
    </td>
  </tr>
</Table>

That’s a template too - <tr> is a parameter and there are others for giving a thead and tfoot. Also Note the new in-line if syntax on that link.

And finally the page navigation:

<section><page_nav/></section>

That whole section will only appear if there is more than one page.

Sweet :-)

Speaking at the Lone Star Ruby Conference

Posted almost 7 years back at PJ Hyett

If you need to hone your Ruby chops prior to heading to Berlin for RailsConf Europe check out the Lone Star Ruby Conference in Austin, TX September 7-8. I was digging the city hard after visiting for SXSW and can’t wait to get back there.

Chris and I will be representing Err Free at the conference with talks entitled On Your Best Behavior: BDD in Ruby and I Built this Killer Rails site, Now What?, respectively.

I promise mine will be entertaining, with the large caveat that it’s the first talk on Saturday after what will surely have been a long night of drinking on Friday.

There’s an early-bird registration ending tomorrow night, so if you were at all interested in attending, I’d recommend doing so soon.

Speaking at the Lone Star Ruby Conference

Posted almost 7 years back at PJ Hyett

If you need to hone your Ruby chops prior to heading to Berlin for RailsConf Europe check out the Lone Star Ruby Conference in Austin, TX September 7-8. I was digging the city hard after visiting for SXSW and can’t wait to get back there.

Chris and I will be representing Err Free at the conference with talks entitled On Your Best Behavior: BDD in Ruby and I Built this Killer Rails site, Now What?, respectively.

I promise mine will be entertaining, with the large caveat that it’s the first talk on Saturday after what will surely have been a long night of drinking on Friday.

There’s an early-bird registration ending tomorrow night, so if you were at all interested in attending, I’d recommend doing so soon.

Pardon the Dust

Posted almost 7 years back at Shane's Brain Extension

I recently migrated this blog from Typo to Mephisto and have a few cleanup activities to perform. Markdown formatting has to be converted, sidebar stuff has to be added, and the design needs some minor tweaks to get things looking like how they did before. So sorry for the temporary ugliness.

I’ve been really busy working on client projects and trying to get my own startup launched, and therefore have been falling behind on the open source work. Thanks to those who sent me contributions to the youtube gem. I plan on making one more release before working on version 2. youtube2 will use the GData format since YouTube is changing the API to fit more with Google’s other APIs. It is slated for release later in the year.

Pardon the Dust

Posted almost 7 years back at Shane's Brain Extension

I recently migrated this blog from Typo to Mephisto and have a few cleanup activities to perform. Markdown formatting has to be converted, sidebar stuff has to be added, and the design needs some minor tweaks to get things looking like how they did before. So sorry for the temporary ugliness.

I’ve been really busy working on client projects and trying to get my own startup launched, and therefore have been falling behind on the open source work. Thanks to those who sent me contributions to the youtube gem. I plan on making one more release before working on version 2. youtube2 will use the GData format since YouTube is changing the API to fit more with Google’s other APIs. It is slated for release later in the year.

A ruby API to the Ensembl database

Posted almost 7 years back at Saaien Tist

"Joy to the world, lalaa la laaaa." I can finally announce that I've released the ruby API to the Ensembl core database under the bioruby-annex umbrella. Go here for the release.

What is it?
The Ensembl database stores genetic and genomic data on a variety of species: sequences of chromosomes and positions of features such as genes and polymorphisms. This data is browseable using their genome browser, but is also directly accessible if you connect to their mysql database. A perl API to that database has been available from the start and is used by the ensembl people themselves to handle the data. A java implementation (called Ensj) is also available, but I don't know the status of that one. The ruby version should provide similar functionality to the perl API, albeit for querying only and not for writing to the database.

This API is aimed at the core database. Ensembl also provides the variation and compara databases, but these are not the focus of the current API implementation.

A minimal interface to the data of Ensembl was already available through Mitsuteru Nakao's ensembl.rb library in the bioruby project, and is based on the exportview functionality of Ensembl's web interface. Although very useful, it does not give the full functionality that can be achieved by accessing the database directly.

The ruby API basically provides two things: access to the data in the database, and transformations of those data.
Access to the data. (Virtually) all tables of the database are available through ActiveRecord, with all the automated query methods associated with that ('find_by_anything_you_like'). Say you want to get the object of a transcript with stable_id "ENST00000380593", you'd do

transcript = Ensembl::Core::Transcript.find_by_stable_id('ENST00000380593')

Transformations of the data. You might have the coordinates of a gene on the chromosome, but actually want them on a contig or supercontig. This is where the Sliceable#transform and Slice#project methods come in. In contrast to the perl API, there is no Sliceable#transfer method, because my interpretation of a 'slice' is slightly different from the perl implementation. Read the tutorial for more information.

Minimal script
Any script using the API would have to these steps:
  1. require the library
  2. include the Ensembl::Core namespace (not strictly necessary, but saves typing)
  3. connect to the database
  4. start doing stuff

So for example:
#!/usr/bin/ruby
require 'rubygems'
require_gem 'ensembl-api'

include Ensembl::Core

CoreDBConnection.connect('homo_sapiens')

transcript = Transcript.find_by_stable_id('ENST00000380593')
puts "5'UTR: " + transcript.five_prime_utr_seq


How to install
The API has been released as a gem file, which you can either download from the website and install using the command
gem install ensembl-api-0.9.gem

, or export from the SubVersion repository using the command
svn export svn://rubyforge.org/var/svn/bioruby-annex/ensembl-api
This gem depends on bioruby and ActiveRecord.

UPDATE: The code has been moved from rubyforge to github. Get it from http://github.com/jandot/ruby-ensembl-api


Documentation
Check the website at rubyforge, which will show the tutorial (based on the perl version) and the rdoc documentation. In addition, there are the tests in your gem directory, plus a sample script that shows all functionality of the perl-version of the API called examples_perl_tutorial.rb.

Credits
I owe a lot to the Ensembl core team for helping me out when I was at the Ensembl site as a "Geek for a Week"...

Call for help
If anyone would be interested in improving the API, don't hesitate to contact me. At the moment, for example, projections between coordinate systems only work if they're directly linked in the assembly table, and projections of the haplotype assembly_exceptions will now raise a NotImplementedError error. In addition, it would be very useful if we could add the variation and compara databases to the API.

Hobo 0.6 - Still lots to do

Posted almost 7 years back at The Hobo Blog

Quick update - tomorrow is looking a bit doubtful for a Hobo 0.6 release. We’ll try for Wednesday.

Hobo 0.6 - Still lots to do

Posted almost 7 years back at The Hobo Blog

Quick update - tomorrow is looking a bit doubtful for a Hobo 0.6 release. We’ll try for Wednesday.

Episode 66: Custom Rake Tasks

Posted almost 7 years back at Railscasts

Rake is one of those tools that you don't realize how powerful it is until you start using it. In this episode you will learn how to create custom rake tasks and improve them by using rake features.

Heads: Flexmock; Tails: Mocha

Posted almost 7 years back at Alloy Code - Home

So I've been wavering for the past couple of days on which Mocking/Stubbing libraries to embrace for my Ruby coding. The Rails core code uses Flexmock, which is a pretty strong endorsement. The OpenID Authentication plugin by David Heinemeier Hansson uses Mocha. The community does tend to look to DHH for cues as to where to follow.

When I saw that the charity Testing Workshop at Ruby Hoedown was going to include information on mocking and stubbing, I became excited. Here was a chance to hear what some industry heavyweights thought about Flexmock vs. Mocha. Bruce Tate managed to discuss Mocking and Stubbing without explicitly naming a preference.

Then Chad & Marcel took the stage with their Test Driven Development approach to recreating Luigi Poker in Ruby. When the mocking question came up, Marcel simply replied (and I'm paraphrasing here), "Jim Weirich write Flexmock. He wrote Rake. He wrote RubyGems. We trust Jim."

Functionally, both libraries support the same operations. It comes down to a question of syntax. But since I've come from a "seat of the pants" PHP background, I don't have extensive mocking experience, so I don't already have a preferred mocking syntax.

Maybe I need to sidestep the question all together. If I switch from Test::Unit to rspec, I can just use rspec's built in mocking and stubbing libraries.

Related reading: Viget Labs "Mockfight!"

Heads: Flexmock; Tails: Mocha

Posted almost 7 years back at Alloy Code - Home

So I've been wavering for the past couple of days on which Mocking/Stubbing libraries to embrace for my Ruby coding. The Rails core code uses Flexmock, which is a pretty strong endorsement. The OpenID Authentication plugin by David Heinemeier Hansson uses Mocha. The community does tend to look to DHH for cues as to where to follow.

When I saw that the charity Testing Workshop at Ruby Hoedown was going to include information on mocking and stubbing, I became excited. Here was a chance to hear what some industry heavyweights thought about Flexmock vs. Mocha. Bruce Tate managed to discuss Mocking and Stubbing without explicitly naming a preference.

Then Chad & Marcel took the stage with their Test Driven Development approach to recreating Luigi Poker in Ruby. When the mocking question came up, Marcel simply replied (and I'm paraphrasing here), "Jim Weirich write Flexmock. He wrote Rake. He wrote RubyGems. We trust Jim."

Functionally, both libraries support the same operations. It comes down to a question of syntax. But since I've come from a "seat of the pants" PHP background, I don't have extensive mocking experience, so I don't already have a preferred mocking syntax.

Maybe I need to sidestep the question all together. If I switch from Test::Unit to rspec, I can just use rspec's built in mocking and stubbing libraries.

Related reading: Viget Labs "Mockfight!"