Sha256: fd1dcbd9978964e01b70e4697b0e3d5251302b03fe521e1165b8fcc34a6644a4
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
class Chef class Knife module PartialSearch def define_partial_search(keys) Chef::Search::Query.class_eval do @@keys = keys alias_method :old_search, :search unless method_defined? :old_search def search(type, query="*:*", sort='X_CHEF_id_CHEF_X asc', start=0, rows=1000, &block) q = Chef::PartialSearch.new args = Hash.new args[:keys] = @@keys args[:sort] = sort args[:start] = start args[:rows] = rows if block_given? q.search(type, query, args) do |node_hash| n = Chef::Knife::PartialSearch::FakeNode.new do |h,k| h[k] = node_hash[k] end @@keys.each do |k,v| n[k] end block.call(n) end else res = q.search(type, query, args) [res.first] end end end end end end end class Chef class Knife module Core class GenericPresenter alias_method :old_extract, :extract_nested_value unless method_defined? :old_extract def extract_nested_value(data, nested_value_spec) if data.kind_of?(Chef::Knife::PartialSearch::FakeNode) data[nested_value_spec] else old_extract(data, nested_value_spec) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
knife-partial-search-0.0.2 | lib/chef/knife/partial_search/partial_search.rb |