<commit_before>class Pups::FileCommand < Pups::Command
  attr_accessor :path, :contents, :params, :type, :chmod

  def self.from_hash(hash, params)
    command = new
    command.path = hash["path"]
    command.contents = hash["contents"]
    command.chmod = hash["chmod"]
    command.params = params

    command
  end

  def initialize
    @params = {}
    @type = :bash
  end

  def params=(p)
    return @params = p unless type == :bash

    @params = p.dup
    @params.each do |k,v|
      if Hash === v
        @params[k] = v.map{|k,v| "export #{k}=#{v}"}.join("\n")
      end
    end
  end

  def run
    `mkdir -p #{File.dirname(@path)}`
    File.open(@path, "w") do |f|
      f.write(interpolate_params(contents))
    end
    if @chmod
      `chmod #{@chmod} #{@path}`
    end
    Pups.log.info("File > #{@path}  chmod: #{@chmod}")
  end

end

<commit_msg>allow for params in path<commit_after>class Pups::FileCommand < Pups::Command
  attr_accessor :path, :contents, :params, :type, :chmod

  def self.from_hash(hash, params)
    command = new
    command.path = hash["path"]
    command.contents = hash["contents"]
    command.chmod = hash["chmod"]
    command.params = params

    command
  end

  def initialize
    @params = {}
    @type = :bash
  end

  def params=(p)
    return @params = p unless type == :bash

    @params = p.dup
    @params.each do |k,v|
      if Hash === v
        @params[k] = v.map{|k,v| "export #{k}=#{v}"}.join("\n")
      end
    end
  end

  def run
    path = interpolate_params(@path)

    `mkdir -p #{File.dirname(path)}`
    File.open(@path, "w") do |f|
      f.write(interpolate_params(contents))
    end
    if @chmod
      `chmod #{@chmod} #{path}`
    end
    Pups.log.info("File > #{path}  chmod: #{@chmod}")
  end

end


{'fraction_non_alphanumeric': 0.1630925507900677, 'fraction_numerical': 0.0, 'mean_word_length': 2.625766871165644, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6925838', 'n_tokens_mistral': 658, 'n_tokens_neox': 640, 'n_words': 158}