<commit_before>require "fileutils"
require "boxen/util"

module Boxen

  # Manages an invocation of puppet.

  class Puppeteer

    class Status < Struct.new(:code)
      # Puppet's detailed exit codes reserves 2 for a successful run with changes
      def success?
        [0,2].include?(code)
      end
    end

    attr_reader :config

    def initialize(config)
      @config = config
    end

    def command
      manifestdir = "#{config.repodir}/manifests"
      puppet      = "#{config.repodir}/bin/puppet"

      [puppet, "apply", flags, manifestdir].flatten
    end

    def hiera_config
      if File.exist? "#{config.repodir}/config/hiera.yaml"
        "#{config.repodir}/config/hiera.yaml"
      else
        "/dev/null"
      end
    end

    def flags
      flags = []
      root  = File.expand_path "../../..", __FILE__

      flags << ["--group",       "admin"]
      flags << ["--confdir",     "#{config.puppetdir}/conf"]
      flags << ["--vardir",      "#{config.puppetdir}/var"]
      flags << ["--libdir",      "#{config.repodir}/lib"]#:#{root}/lib"]
      flags << ["--libdir",      "#{root}/lib"]
      flags << ["--modulepath",  "#{config.repodir}/modules:#{config.repodir}/shared"]

      # Don't ever complain about Hiera to me
      flags << ["--hiera_config", hiera_config]

      # Log to both the console and a file.

      flags << ["--logdest", config.logfile]
      flags << ["--logdest", "console"]

      # For some reason Puppet tries to set up a bunch of rrd stuff
      # (user, group) unless reports are completely disabled.

      flags << "--no-report" unless config.report?
      flags << "--detailed-exitcodes"

      flags << "--graph" if config.graph?

      flags << "--show_diff"

      if config.profile?
        flags << "--evaltrace"
        flags << "--summarize"
      end

      if config.future_parser?
        flags << "--parser=future"
      end

      flags << "--debug" if config.debug?
      flags << "--noop"  if config.pretend?

      flags << "--color=false" unless config.color?

      flags.flatten
    end
<commit_msg>update flags for profiling<commit_after>require "fileutils"
require "boxen/util"

module Boxen

  # Manages an invocation of puppet.

  class Puppeteer

    class Status < Struct.new(:code)
      # Puppet's detailed exit codes reserves 2 for a successful run with changes
      def success?
        [0,2].include?(code)
      end
    end

    attr_reader :config

    def initialize(config)
      @config = config
    end

    def command
      manifestdir = "#{config.repodir}/manifests"
      puppet      = "#{config.repodir}/bin/puppet"

      [puppet, "apply", flags, manifestdir].flatten
    end

    def hiera_config
      if File.exist? "#{config.repodir}/config/hiera.yaml"
        "#{config.repodir}/config/hiera.yaml"
      else
        "/dev/null"
      end
    end

    def flags
      flags = []
      root  = File.expand_path "../../..", __FILE__

      flags << ["--group",       "admin"]
      flags << ["--confdir",     "#{config.puppetdir}/conf"]
      flags << ["--vardir",      "#{config.puppetdir}/var"]
      flags << ["--libdir",      "#{config.repodir}/lib"]#:#{root}/lib"]
      flags << ["--libdir",      "#{root}/lib"]
      flags << ["--modulepath",  "#{config.repodir}/modules:#{config.repodir}/shared"]

      # Don't ever complain about Hiera to me
      flags << ["--hiera_config", hiera_config]

      # Log to both the console and a file.

      flags << ["--logdest", config.logfile]
      flags << ["--logdest", "console"]

      # For some reason Puppet tries to set up a bunch of rrd stuff
      # (user, group) unless reports are completely disabled.

      flags << "--no-report" unless config.report?
      flags << "--detailed-exitcodes"

      flags << "--graph" if config.graph?

      flags << "--show_diff"

      if config.profile?
        flags << "--evaltrace"
        flags << "--summarize"
        flags << "--verbose"
      end

      if config.future_parser?
        flags << "--parser=future"
      end

      flags << "--debug" if config.debug?
      flags << "--noop"  if config.pretend?

      flags << "--color=false" unless config.color?

      flags.flatten
    end

{'fraction_non_alphanumeric': 0.1524940617577197, 'fraction_numerical': 0.0014251781472684087, 'mean_word_length': 2.1169504071058474, 'pattern_counts': {'":': 0, '<': 83, '<?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': '6575211', 'n_tokens_mistral': 1336, 'n_tokens_neox': 1294, 'n_words': 339}