# Microformat DSL... would like some feedback

**URL:** <https://www.ruby-forum.com/t/microformat-dsl-would-like-some-feedback/72482>\
**Category:** Ruby\
**Created:** [October 17, 2006, 3:28pm UTC](https://www.ruby-forum.com/t/microformat-dsl-would-like-some-feedback/72482 "2006-10-17T15:28:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![noagenda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8c91f0/32.png) [@noagenda](https://www.ruby-forum.com/u/noagenda)\
**Post date:** [October 17, 2006, 3:28pm UTC](https://www.ruby-forum.com/t/microformat-dsl-would-like-some-feedback/72482/1 "2006-10-17T15:28:39Z")

</div>

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](http://fluct.isono.us/2006/10/15/microformats-in-the-heart-of-rails)

Feedback, brutal or otherwise would be great.

Thanks,  
James

---

<div class="post-metadata">

**Author:** ![noagenda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8c91f0/32.png) [@noagenda](https://www.ruby-forum.com/u/noagenda)\
**Post date:** [October 17, 2006, 5:20pm UTC](https://www.ruby-forum.com/t/microformat-dsl-would-like-some-feedback/72482/2 "2006-10-17T17:20:58Z")

</div>

On 10/17/06, J2M [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![noagenda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8c91f0/32.png) [@noagenda](https://www.ruby-forum.com/u/noagenda)\
**Post date:** [October 17, 2006, 5:37pm UTC](https://www.ruby-forum.com/t/microformat-dsl-would-like-some-feedback/72482/3 "2006-10-17T17:37:12Z")

</div>

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

James
