Sha256: 597bf83b615be1ec4b2e52b6194d10f0e418e4b384e4271ea0117fa7a4949efb

Contents?: true

Size: 818 Bytes

Versions: 3

Compression:

Stored size: 818 Bytes

Contents

class Errata
  class Erratum
    class Simplify < Erratum
      attr_accessor :second_column
      
      def initialize(errata, options = {})
        super
        @second_column = options[:x]
      end

      def inspect
        super + " second_column=#{second_column}>"
      end
      
      def targets?(row)
        !row[column].blank? and !row[second_column].blank? and method_matches?(row) and matching_expression(row).match(row[column])
      end
      
      def correct!(row)
        super(row) do
          row[column].gsub!(matching_expression(row), '')
        end
      end
      
      def matching_expression(row)
        @_matching_expressions ||= {}
        @_matching_expressions[row[second_column]] ||= /[\s\(\[\'\"]*#{Regexp.escape(row[second_column])}[\s\)\]\'\"]*/
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
errata-0.2.1 lib/erratum/simplify.rb
errata-0.2.0 lib/erratum/simplify.rb
errata-0.1.9 lib/erratum/simplify.rb