Sha256: 2b1b670133151c81a0bdd926b966e20c9367d5113c764100a872f6d35e004658

Contents?: true

Size: 832 Bytes

Versions: 7

Compression:

Stored size: 832 Bytes

Contents

module Merb
  module ChefServerWebui
    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

7 entries across 7 versions & 1 rubygems

Version Path
chef-server-webui-0.8.16 app/helpers/search_helper.rb
chef-server-webui-0.8.14 app/helpers/search_helper.rb
chef-server-webui-0.8.10 app/helpers/search_helper.rb
chef-server-webui-0.8.8 app/helpers/search_helper.rb
chef-server-webui-0.8.6 app/helpers/search_helper.rb
chef-server-webui-0.8.4 app/helpers/search_helper.rb
chef-server-webui-0.8.2 app/helpers/search_helper.rb