Microformat DSL... would like some feedback

I have been working on a DSL to make it easy to define Microformats and
then using that to generate migrations, database models and eventually
view helpers, hence making it so easy to include microformats that it
would be foolish not too.

I would appreciate any opinions people have on the example so far and
what I may need to include.

I have posted an example uFormat definition at;
http://fluct.isono.us/2006/10/15/microformats-in-the-heart-of-rails

Feedback, brutal or otherwise would be great.

Thanks,
James

On 10/17/06, J2M [email protected] wrote:

I would appreciate any opinions people have on the example so far and
what I may need to include.

I checked out the article and I have a couple of suggestions to make
the
syntax less repetitive.

  1. Instead of “has_one” being repeated over and over, why not provide a
    block & use method_missing (or ara’s excellect attributes library, just
    released) to define all the “has_one” attributes at once:

has_one do
type :required => true, :length => 10, :select_from => type_options
item, :type => :pseudoformat
end

Single items are a problem above if you are using method_missing,
because
Ruby can’t ttell if they refere to a method or local variable. That is,
this
wouldn’t work quite right:

has_one do
version
summary
end

In that case, maybe provide an array of words instead:

has_one %w(version summary)

  1. The ratings options is pretty ugly. All that repetition. How about
    something like:

rating_options 1 … 5, :worst => 1, :best => 5

Also notice the removal of the “=”. Getters can be setters pretty easily
(see again, the attributes gem) and it keeps the syntax simple.

Hope that helps!

Justin

Justin, Thank you, excellent suggestions all. Really helpful.

James

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs