<commit_before>class FixedWidth
  class Column
    DEFAULT_PADDING = ' '
    DEFAULT_ALIGNMENT = :right
    DEFAULT_TRUNCATE = false
    DEFAULT_FORMATTER = :to_s

    attr_reader :name, :length, :alignment, :padding, :truncate, :group

    def initialize(name, length, options={})
      assert_valid_options(options)
      @name = name
      @length = length
      @alignment = options[:align] || DEFAULT_ALIGNMENT
      @padding = options[:padding] || DEFAULT_PADDING
      @truncate = options[:truncate] || DEFAULT_TRUNCATE

      @group = options[:group]

      @parser = options[:parser]
      @parser = @parser.to_proc if @parser.is_a?(Symbol)

      @formatter = options[:formatter]
      @formatter ||= DEFAULT_FORMATTER
      @formatter = @formatter.to_proc if @formatter.is_a?(Symbol)

      @nil_blank = options[:nil_blank]
    end

    def parse(value)
      if @nil_blank && blank?(value)
        return nil
      elsif @parser
        @parser.call(value)
      else
        case @alignment
          when :right
            value.lstrip
          when :left
            value.rstrip
          when :none
            value
        end
      end
    rescue
      raise ParserError.new("The value '#{value}' could not be parsed: #{$!}")
    end

    def format(value)
      pad(
          validate_size(
              @formatter.call(value)
          )
      )
    end

    private
    BLANK_REGEX = /^\s*$/

    def blank?(value)
      value =~ BLANK_REGEX
    end

    def pad(value)
      case @alignment
        when :left
          value.ljust(@length, @padding)
        when :right
          value.rjust(@length, @padding)
      end
    end

    def assert_valid_options(options)
      unless options[:align].nil? || [:left, :right, :none].include?(options[:align])
        raise ArgumentError.new("Option :align only accepts :right (default) or :left")
      end
    end

    def validate_size(result)
      return result if result.length <= @length
      raise FixedWidth::FormattedStringExceedsLengthError.new(
                "The formatted value '#{result}' in column '#{@name}' exceeds the allowed length of #{@length} chararacters.") unless @truncate
      case @alignment
        when :right then
          result[-@length, @length]
        when :left then
          result[0, @length]
      end
    end
  end
end<commit_msg>column.rb: removed :none from :alignment -- not sure if this code is even being used... poa_file_spec.rb: added final check that no more files need importing<commit_after>class FixedWidth
  class Column
    DEFAULT_PADDING = ' '
    DEFAULT_ALIGNMENT = :right
    DEFAULT_TRUNCATE = false
    DEFAULT_FORMATTER = :to_s

    attr_reader :name, :length, :alignment, :padding, :truncate, :group

    def initialize(name, length, options={})
      assert_valid_options(options)
      @name = name
      @length = length
      @alignment = options[:align] || DEFAULT_ALIGNMENT
      @padding = options[:padding] || DEFAULT_PADDING
      @truncate = options[:truncate] || DEFAULT_TRUNCATE

      @group = options[:group]

      @parser = options[:parser]
      @parser = @parser.to_proc if @parser.is_a?(Symbol)

      @formatter = options[:formatter]
      @formatter ||= DEFAULT_FORMATTER
      @formatter = @formatter.to_proc if @formatter.is_a?(Symbol)

      @nil_blank = options[:nil_blank]
    end

    def parse(value)
      if @nil_blank && blank?(value)
        return nil
      elsif @parser
        @parser.call(value)
      else
        case @alignment
          when :right
            value.lstrip
          when :left
            value.rstrip
        end
      end
    rescue
      raise ParserError.new("The value '#{value}' could not be parsed: #{$!}")
    end

    def format(value)
      pad(
          validate_size(
              @formatter.call(value)
          )
      )
    end

    private
    BLANK_REGEX = /^\s*$/

    def blank?(value)
      value =~ BLANK_REGEX
    end

    def pad(value)
      case @alignment
        when :left
          value.ljust(@length, @padding)
        when :right
          value.rjust(@length, @padding)
      end
    end

    def assert_valid_options(options)
      unless options[:align].nil? || [:left, :right].include?(options[:align])
        raise ArgumentError.new("Option :align only accepts :right (default) or :left")
      end
    end

    def validate_size(result)
      return result if result.length <= @length
      raise FixedWidth::FormattedStringExceedsLengthError.new(
                "The formatted value '#{result}' in column '#{@name}' exceeds the allowed length of #{@length} chararacters.") unless @truncate
      case @alignment
        when :right then
          result[-@length, @length]
        when :left then
          result[0, @length]
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.10504376823676533, 'fraction_numerical': 0.00041684035014589413, 'mean_word_length': 2.264625850340136, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2941174', 'n_tokens_mistral': 1448, 'n_tokens_neox': 1383, 'n_words': 370}