rjurado01
rjurado01

Reputation: 5535

Extract comments

I have this code in a controller:

# =begin action
# url: /albums
# method: GET
# autentication: true
# return: [json, xml]
# =end
def show
    ...
end

Is there some gem that reads comments and returns info in json format, or does something like this? I want to get it to manipulate and generate files with this information.

{
    "url" => /albums
    "method" => GET
    "autentication" => true 
    "return" => [json, xml]
}

Upvotes: 0

Views: 131

Answers (1)

roman-roman
roman-roman

Reputation: 2796

I don't think there is a gem doing exactly what you want, but the task seems to be pretty easy to devide: first, you need to parse the file and pull that comments - it shouldn't be difficult to do it with a simple ruby script. Then having info in format like:

url: /albums
method: GET
autentication: true
return: [json, xml]

which seems pretty like a YAML, you can do simply

YAML::load(string).to_json

Upvotes: 1

Related Questions