Sha256: 28a2ca27dceb535929a1d81040368cb94da3578c069dda1978734b7bb8165585

Contents?: true

Size: 832 Bytes

Versions: 4

Compression:

Stored size: 832 Bytes

Contents

module Merb
  module ChefServerSlice
    module SearchHelper
      def output_path(attributes)
        res = Hash.new
        attributes.each do |path|
          parts = path.split("/")
          unless parts[0].nil?
            parts.shift if parts[0].length == 0
          end
          res[path] = ohai_walk(parts)
        end
        res
      end
      
      def ohai_walk(path)
        unless path[0]
          @@ohai.to_json
        else
          ohai_walk_r(@@ohai, path)
        end
      end
          
      def ohai_walk_r(ohai, path)
        hop = (ohai.is_a?(Array) ? path.shift.to_i : path.shift)
        if ohai[hop]
          if path[0]
            ohai_walk_r(ohai[hop], path)
          else
            ohai[hop].to_json
          end
        else
          nil
        end
      end
    end
  end  
end # Merb

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chef-server-slice-0.7.16 app/helpers/search_helper.rb
chef-server-slice-0.7.14 app/helpers/search_helper.rb
chef-server-slice-0.7.12 app/helpers/search_helper.rb
chef-server-slice-0.7.10 app/helpers/search_helper.rb