danryan / spice

A zesty Chef server API wrapper
http://documentup.com/danryan/spice
MIT License
103 stars 22 forks source link

Rebuild search #7

Closed meineerde closed 13 years ago

meineerde commented 13 years ago

Search is now called by method_missing. This allows to search for arbitrary data bags. I also added a convenience API. If only a string is passed instead of a Hash, it is search for with default parameters.

Also fixed is the escaping which now uses CGI::escape. The original escape somehow got injected into my test environment...

This pull request should by used instead of https://github.com/danryan/spice/pull/6. Sorry for the noise and confusion. Guess we really need some specs here.

portertech commented 13 years ago

Fantastic!

portertech commented 13 years ago

I did like the idea of Search.index, Search.search seems redundant :P

meineerde commented 13 years ago

Generally, you'd use Spice::Search.node("recipe:debian"). The actual search method is then just called by method_missing and parametrized with the correct index to search for.

meineerde commented 13 years ago

I did like the idea of Search.index, Search.search seems redundant :P

Also, there never was a method called Search.index. The generate_method calls used index as a variable which contained the names of the actual generated methods (node, role, client, and user). Metaprogramming at its best :)

portertech commented 13 years ago

Yes. Above, I was referring to the generated methods by saying Search.index (index as a var). Should have been clearer. I do like the new Search :)