lib/pdd.rb in pdd-0.17.8 vs lib/pdd.rb in pdd-0.17.9
- old
+ new
@@ -29,11 +29,11 @@
require_relative 'pdd/rule/text'
require_relative 'pdd/rule/duplicates'
require_relative 'pdd/rule/roles'
# PDD main module.
-# Author:: Yegor Bugayenko (yegor@teamed.io)
+# Author:: Yegor Bugayenko (yegor256@gmail.com)
# Copyright:: Copyright (c) 2014-2017 Yegor Bugayenko
# License:: MIT
module PDD
# If it breaks.
class Error < StandardError
@@ -136,10 +136,14 @@
end
def rules(xml)
doc = Nokogiri::XML(xml)
total = 0
- (@opts[:rule] || []).push('max-duplicates:1').map do |r|
+ list = @opts[:rule] || []
+ unless list.select { |r| r.start_with?('max-duplicates:') }.empty?
+ raise PDD::Error, 'You can\'t modify max-duplicates, it\'s always 1'
+ end
+ list.push('max-duplicates:1').map do |r|
name, value = r.split(':')
rule = RULES[name]
raise "rule '#{name}' doesn't exist" if rule.nil?
rule.new(doc, value).errors.each do |e|
PDD.log.error e