diff options
author | Adam Jacob <adam@opscode.com> | 2009-06-03 23:10:59 -0700 |
---|---|---|
committer | Adam Jacob <adam@opscode.com> | 2009-06-03 23:10:59 -0700 |
commit | be3d8a8707d3e611a7cc3a767dbc0c01eee08819 (patch) | |
tree | 96604aec4717ebea8302c804be697566a3e672bd | |
parent | 7d2f7cf9b4701e057fd77c6b96cf1b818a02ae80 (diff) | |
download | chef-be3d8a8707d3e611a7cc3a767dbc0c01eee08819.tar.gz |
Adding Chef::Search::Result, and auto-inflating them
-rw-r--r-- | Rakefile | 4 | ||||
-rw-r--r-- | chef-server/lib/chef/search.rb | 3 | ||||
-rw-r--r-- | chef/lib/chef/recipe.rb | 2 | ||||
-rw-r--r-- | cucumber.yml | 1 | ||||
-rw-r--r-- | example-repository/cookbooks/fakefile/metadata.json | 16 | ||||
-rw-r--r-- | example-repository/cookbooks/tempfile/metadata.json | 16 |
6 files changed, 25 insertions, 17 deletions
@@ -146,6 +146,10 @@ namespace :features do t.profile = "client" end + Cucumber::Rake::Task.new(:search) do |t| + t.profile = "search" + end + namespace :provider do Cucumber::Rake::Task.new(:remote_file) do |t| t.profile = "provider_remote_file" diff --git a/chef-server/lib/chef/search.rb b/chef-server/lib/chef/search.rb index 3ecd89cbdd..0d0c176921 100644 --- a/chef-server/lib/chef/search.rb +++ b/chef-server/lib/chef/search.rb @@ -16,6 +16,7 @@ # limitations under the License. # +require 'chef/search/result' require 'ferret' class Chef @@ -77,7 +78,7 @@ class Chef end def build_hash(doc) - result = Hash.new + result = Chef::Search::Result.new doc.fields.each do |f| result[f] = doc[f] end diff --git a/chef/lib/chef/recipe.rb b/chef/lib/chef/recipe.rb index 7417407924..ea11d3b8e8 100644 --- a/chef/lib/chef/recipe.rb +++ b/chef/lib/chef/recipe.rb @@ -23,6 +23,7 @@ require 'chef/mixin/language' require 'chef/resource_collection' require 'chef/cookbook_loader' require 'chef/rest' +require 'chef/search/result' class Chef class Recipe @@ -89,6 +90,7 @@ class Chef def search(type, query, attributes=[], &block) Chef::Log.debug("Searching #{type} index with #{query}") r = Chef::REST.new(Chef::Config[:search_url]) + results = r.get_rest("search/#{type}?q=#{query}&a=#{attributes.join(',')}") Chef::Log.debug("Searching #{type} index with #{query} returned #{results.length} entries") if block diff --git a/cucumber.yml b/cucumber.yml index a837201662..af3710a7df 100644 --- a/cucumber.yml +++ b/cucumber.yml @@ -1,6 +1,7 @@ default: -f pretty features -r features/steps -r features/support api: --tags api --format pretty -r features/steps -r features/support features client: --tags client --format pretty -r features/steps -r features/support features +search: --tags search --format pretty -r features/steps -r features/support features provider_remote_file: --tags provider,remote_file --format pretty -r features/steps -r features/support features provider_package_macports: --tags macports --format pretty -r features/steps -r features/support features diff --git a/example-repository/cookbooks/fakefile/metadata.json b/example-repository/cookbooks/fakefile/metadata.json index 02d17674a8..93bc5937cc 100644 --- a/example-repository/cookbooks/fakefile/metadata.json +++ b/example-repository/cookbooks/fakefile/metadata.json @@ -1,15 +1,14 @@ { - "maintainer": "Your Name", "recommendations": { }, "maintainer_email": "youremail@example.com", - "recipes": { - "fakefile": "" - }, "suggestions": { }, + "recipes": { + "fakefile": "" + }, "dependencies": { "tempfile": [ @@ -18,25 +17,26 @@ ] }, + "license": "Apache v2.0", "attributes": { }, - "license": "Apache v2.0", - "name": "fakefile", "conflicting": { }, + "name": "fakefile", "providing": { "fakefile": [ ] }, - "description": "A fabulous new cookbook", "replacing": { }, "long_description": "", + "description": "A fabulous new cookbook", "platforms": { - } + }, + "maintainer": "Your Name" }
\ No newline at end of file diff --git a/example-repository/cookbooks/tempfile/metadata.json b/example-repository/cookbooks/tempfile/metadata.json index d778c651ed..c97773ead3 100644 --- a/example-repository/cookbooks/tempfile/metadata.json +++ b/example-repository/cookbooks/tempfile/metadata.json @@ -1,39 +1,39 @@ { - "maintainer": "Your Name", "recommendations": { }, "maintainer_email": "youremail@example.com", - "recipes": { - "tempfile": "" - }, "suggestions": { }, + "recipes": { + "tempfile": "" + }, "dependencies": { "fakefile": [ ] }, + "license": "Apache v2.0", "attributes": { }, - "license": "Apache v2.0", - "name": "tempfile", "conflicting": { }, + "name": "tempfile", "providing": { "tempfile": [ ] }, - "description": "A fabulous new cookbook", "replacing": { }, "long_description": "", + "description": "A fabulous new cookbook", "platforms": { - } + }, + "maintainer": "Your Name" }
\ No newline at end of file |