thanks
On Tue, Sep 20, 2011 at 2:11 AM, Lasse Bunk
<lassebunk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> I have created ApiBuilder which is a Ruby on Rails plugin/template engine
> that allows for multiple formats being laid out in a single specification,
> currently XML and JSON.
> You lay out your spec in one file and it automatically generates both XML
> and JSON from that specification.
>
> Install it using
>
> $ rails plugin install git://github.com/lassebunk/api_builder.git
>
> And then, in e.g. *app/views/api/users/index.apibuilder*:
>
> array :users do
> @users.each do |user|
> element :user do
> id @user.id
> name @user.name
> end
> end
> end
>
> Returns:
>
> [
> {
> "id": 1234,
> "name": "Peter Jackson"
> },
> {
> "id": 1235,
> "name": "Marilyn Monroe"
> }
> ]
>
> And the equivalent XML.
>
> In *app/views/api/users/show.apibuilder*:
>
> element :user do
> id @user.id
> name @user.name
> address do
> street @user.street
> city @user.city
> end
> array :interests do
> @user.interests.each do |interest|
> element :interest, interest.name
> end
> end
> end
>
> Returns:
>
> {
> "id": 1234,
> "name": "Peter Jackson",
> "address": {
> "street": "123 High Way",
> "city": "Gotham City"
> },
> "interests": [
> "Movies",
> "Computers",
> "Internet"
> ]
> }
>
> And the equivalent XML.
>
> You can then call your API like this:
>
> http://example.com/api/users?format=json
>
> or
>
> http://example.com/api/users?format=xml
>
> and so on.
>
> What do you think?
>
> More information at GitHub (https://github.com/lassebunk/api_builder) and
> my website (
>
http://lassebunk.dk/2011/09/12/introducing-apibuilder-xml-and-json-builder-in-one/
> ).
>
> /Lasse Bunk
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.