lib/pdd.rb in pdd-0.15.4 vs lib/pdd.rb in pdd-0.16
- old
+ new
@@ -48,11 +48,11 @@
'min-estimate' => PDD::Rule::Estimate::Min,
'max-estimate' => PDD::Rule::Estimate::Max,
'min-words' => PDD::Rule::Text::MinWords,
'max-duplicates' => PDD::Rule::MaxDuplicates,
'available-roles' => PDD::Rule::Roles::Available
- }
+ }.freeze
# Get logger.
def self.log
unless @logger
@logger = Logger.new(STDOUT)
@@ -139,27 +139,27 @@
doc = Nokogiri::XML(xml)
total = 0
(@opts[:rule] || []).push('max-duplicates:1').map do |r|
name, value = r.split(':')
rule = RULES[name]
- fail "rule '#{name}' doesn't exist" if rule.nil?
+ raise "rule '#{name}' doesn't exist" if rule.nil?
rule.new(doc, value).errors.each do |e|
PDD.log.error e
total += 1
end
end
- fail PDD::Error, "#{total} errors, see log above" unless total == 0
+ raise PDD::Error, "#{total} errors, see log above" unless total == 0
xml
end
def sanitize(xml)
xsd = Nokogiri::XML::Schema(
File.read(File.join(File.dirname(__FILE__), '../assets/puzzles.xsd'))
)
errors = xsd.validate(Nokogiri::XML(xml)).map(&:message)
errors.each { |e| PDD.log.error e }
PDD.log.error(xml) unless errors.empty?
- fail SchemaError, errors.join('; ') unless errors.empty?
+ raise SchemaError, errors.join('; ') unless errors.empty?
xml
end
end
end