lib/errata/erratum/simplify.rb in errata-1.0.3 vs lib/errata/erratum/simplify.rb in errata-1.1.0
- old
+ new
@@ -1,10 +1,13 @@
class Errata
class Erratum
class Simplify < Erratum
- def second_section
- options['x']
+ attr_reader :second_section
+
+ def initialize(responder, options = {})
+ super
+ @second_section = options[:x]
end
def targets?(row)
!row[section].blank? and !row[second_section].blank? and conditions_match?(row) and special_matcher(row).match(row[section])
end
@@ -13,9 +16,11 @@
if targets? row
row[section].gsub! special_matcher(row), ''
end
end
+ private
+
def special_matcher(row)
/[\s\(\[\'\"]*#{::Regexp.escape(row[second_section])}[\s\)\]\'\"]*/
end
end
end