<commit_before>#
# Author:: <NAME> (<<EMAIL>>)
# Copyright:: Copyright (c) 2008 OpsCode, Inc.
# License:: GNU GPL, Version 3
#
# Copyright (C) 2008, OpsCode Inc. 
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

require 'extlib'
require 'ohai/log'
require 'ohai/mixin/from_file'
require 'ohai/mixin/command'
require 'json'

module Ohai
  class System
    attr_accessor :data, :seen_plugins
    
    include Ohai::Mixin::FromFile
    include Ohai::Mixin::Command
    
    def initialize
      @data = Mash.new
      @seen_plugins = Hash.new
    end
    
    def attribute?(name)
      Ohai::Log.debug("Attribute #{name} is #{@data.has_key?(name)}")
      @data.has_key?(name) 
    end
    
    def set(name, *value)
      set_attribute(name, *value)
    end
    
    def from(cmd)
      status, stdout, stderr = run_command(:command => cmd)
      stdout.chomp!
    end
    
    # Set the value equal to the stdout of the command, plus run through a regex - the first piece of match data is the value.
    def from_with_regex(cmd, *regex_list)
      regex.flatten.each do |regex|
        status, stdout, stderr = run_command(:command => cmd)
        stdout.chomp!<commit_msg>thats what I get for not writing specs - regex_list!<commit_after>#
# Author:: <NAME> (<<EMAIL>>)
# Copyright:: Copyright (c) 2008 OpsCode, Inc.
# License:: GNU GPL, Version 3
#
# Copyright (C) 2008, OpsCode Inc. 
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

require 'extlib'
require 'ohai/log'
require 'ohai/mixin/from_file'
require 'ohai/mixin/command'
require 'json'

module Ohai
  class System
    attr_accessor :data, :seen_plugins
    
    include Ohai::Mixin::FromFile
    include Ohai::Mixin::Command
    
    def initialize
      @data = Mash.new
      @seen_plugins = Hash.new
    end
    
    def attribute?(name)
      Ohai::Log.debug("Attribute #{name} is #{@data.has_key?(name)}")
      @data.has_key?(name) 
    end
    
    def set(name, *value)
      set_attribute(name, *value)
    end
    
    def from(cmd)
      status, stdout, stderr = run_command(:command => cmd)
      stdout.chomp!
    end
    
    # Set the value equal to the stdout of the command, plus run through a regex - the first piece of match data is the value.
    def from_with_regex(cmd, *regex_list)
      regex_list.flatten.each do |regex|
        status, stdout, stderr = run_command(:command => cmd)
        stdout.chomp!
{'fraction_non_alphanumeric': 0.09507829977628636, 'fraction_numerical': 0.005592841163310962, 'mean_word_length': 3.2131919905771498, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3053760', 'n_tokens_mistral': 1111, 'n_tokens_neox': 1085, 'n_words': 419}