<commit_before>#
# Helper utilities for puppetdb faces
#
#
module PuppetX
  class Puppetdb_query
    def self.setting
      begin
        require 'puppet'
        require 'puppet/util/puppetdb'
        host = Puppet::Util::Puppetdb.server || 'localhost'
        port = 8080
        #port = Puppet::Util::Puppetdb.port || 8080
      rescue Exception => e
        Puppet.debug(e.message)
        host = 'localhost'
        port = 8080
      end

      Puppet.debug(host)
      Puppet.debug(port)

      { :host => host,
        :port => port }
    end

    def self.add_puppetdb_host_option(action)
      action.option '--puppetdb_host PUPPETDB' do
        summary "Host running PuppetDB. "

        default_to { PuppetX::Puppetdb_query.setting[:host] }
      end
    end

    def self.add_puppetdb_port_option(action)
      action.option '--puppetdb_port PORT' do
        summary 'Port PuppetDB is running on'
        default_to { PuppetX::Puppetdb_query.setting[:port] }
      end
    end<commit_msg>Default to use the port Puppet actually uses.<commit_after>#
# Helper utilities for puppetdb faces
#
#
module PuppetX
  class Puppetdb_query
    def self.setting
      begin
        require 'puppet'
        require 'puppet/util/puppetdb'
        host = Puppet::Util::Puppetdb.server || 'localhost'
        port = Puppet::Util::Puppetdb.port || 8080
      rescue Exception => e
        Puppet.debug(e.message)
        host = 'localhost'
        port = 8080
      end

      Puppet.debug(host)
      Puppet.debug(port)

      { :host => host,
        :port => port }
    end

    def self.add_puppetdb_host_option(action)
      action.option '--puppetdb_host PUPPETDB' do
        summary "Host running PuppetDB. "

        default_to { PuppetX::Puppetdb_query.setting[:host] }
      end
    end

    def self.add_puppetdb_port_option(action)
      action.option '--puppetdb_port PORT' do
        summary 'Port PuppetDB is running on'
        default_to { PuppetX::Puppetdb_query.setting[:port] }
      end
    end
{'fraction_non_alphanumeric': 0.09497762307309796, 'fraction_numerical': 0.009945300845350571, 'mean_word_length': 2.3092105263157894, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4797283', 'n_tokens_mistral': 716, 'n_tokens_neox': 686, 'n_words': 146}