Skip to content

Commit

Permalink
Refactor Yardstick::RuleConfig to use concord
Browse files Browse the repository at this point in the history
  • Loading branch information
John Backus committed Oct 4, 2015
1 parent 25a8676 commit 4a23563
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/yardstick/rule_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ module Yardstick
# It is used to check if document should be validated or not.
#
class RuleConfig
include Concord.new(:enabled, :exclude)

METHOD_SEPARATOR = /\#|\./.freeze

# Initializes new instance of rule config
Expand All @@ -17,8 +19,7 @@ class RuleConfig
#
# @api private
def initialize(options = {})
@enabled = options.fetch(:enabled, true)
@exclude = options.fetch(:exclude, [])
super(options.fetch(:enabled, true), options.fetch(:exclude, []))
end

# Checks if given path should be checked using this rule
Expand All @@ -31,7 +32,7 @@ def initialize(options = {})
#
# @api private
def enabled_for_path?(path)
@enabled && !exclude?(path)
enabled && !exclude?(path)
end

private
Expand All @@ -49,8 +50,8 @@ def enabled_for_path?(path)
#
# @api private
def exclude?(path)
@exclude.include?(path) ||
@exclude.include?(path.split(METHOD_SEPARATOR).first)
exclude.include?(path) ||
exclude.include?(path.split(METHOD_SEPARATOR).first)
end
end
end

0 comments on commit 4a23563

Please sign in to comment.