<commit_before># No shebang; We assume something has found ruby for us

require 'json'
require 'pp'

# A more clever thing to do would be to run ohai as a gem, and interact intelligently
# require 'ohai'
# For today, cleverness--

def puts_nad (key, type, value)
  if value.nil? then
    puts "#{key}\t#{type}"
  else
    puts "#{key}\t#{type}\t#{value}"
  end
end

def handle_top_level(p, r)
  # this could be less dumb
  case p
  when *[
         # These are all simple scalars
         "uptime", 
         "uptime_seconds", 
         "hostname", 
         "fqdn", 
         "domain", 
         "os",
         "os_version", 
         "platform", 
         "platform_version", 
         "platform_family",
         "ipaddress", 
         "macaddress",
        ]
    h_scalar(p,r)
  when *[
        # We ignore these explicitly
        "command",
        "ohai_time",
         "languages",
        "chef_packages",
        "keys",
        "current_user",
        "idletime",
        "idletime_seconds",
        "memory",   # Nad provides vm.sh for this
        "block_device",
        "dmi",
        "lsb",
        "virtualization",
        "network", # Nad provides if.sh for this 
        "counters", # Nad provides if.sh for this 
       ]

  when "filesystem"
    h_filesystem(p,r) # custom
  when "etc"
    h_etc(p,r) # custom
  when "cpu"
    h_cpu(p,r) # custom
  when "kernel"
    h_kernel(p,r) # custom
  else
    # Ignore if unknown
    # puts "Unknown ohai plugin #{p}"
  end
end

def h_inspect(p,r)
  puts "----"
  puts p<commit_msg>Don't load pp unless someone calls the debugging method<commit_after># No shebang; We assume something has found ruby for us

require 'json'

# A more clever thing to do would be to run ohai as a gem, and interact intelligently
# require 'ohai'
# For today, cleverness--

def puts_nad (key, type, value)
  if value.nil? then
    puts "#{key}\t#{type}"
  else
    puts "#{key}\t#{type}\t#{value}"
  end
end

def handle_top_level(p, r)
  # this could be less dumb
  case p
  when *[
         # These are all simple scalars
         "uptime", 
         "uptime_seconds", 
         "hostname", 
         "fqdn", 
         "domain", 
         "os",
         "os_version", 
         "platform", 
         "platform_version", 
         "platform_family",
         "ipaddress", 
         "macaddress",
        ]
    h_scalar(p,r)
  when *[
        # We ignore these explicitly
        "command",
        "ohai_time",
         "languages",
        "chef_packages",
        "keys",
        "current_user",
        "idletime",
        "idletime_seconds",
        "memory",   # Nad provides vm.sh for this
        "block_device",
        "dmi",
        "lsb",
        "virtualization",
        "network", # Nad provides if.sh for this 
        "counters", # Nad provides if.sh for this 
       ]

  when "filesystem"
    h_filesystem(p,r) # custom
  when "etc"
    h_etc(p,r) # custom
  when "cpu"
    h_cpu(p,r) # custom
  when "kernel"
    h_kernel(p,r) # custom
  else
    # Ignore if unknown
    # puts "Unknown ohai plugin #{p}"
  end
end

def h_inspect(p,r)
  require 'pp'
  puts "----"
  puts p
{'fraction_non_alphanumeric': 0.12029355456285896, 'fraction_numerical': 0.0, 'mean_word_length': 1.9492003762935088, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7116043', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1044, 'n_words': 303}