Class: FoodCritic::Rule
- Inherits:
-
Object
- Object
- FoodCritic::Rule
- Defined in:
- lib/foodcritic/domain.rb
Overview
A rule to be matched against.
Instance Attribute Summary collapse
-
#applies_to ⇒ Object
Returns the value of attribute applies_to.
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#code ⇒ Object
Returns the value of attribute code.
-
#cookbook ⇒ Object
Returns the value of attribute cookbook.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#library ⇒ Object
Returns the value of attribute library.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#name ⇒ Object
Returns the value of attribute name.
-
#provider ⇒ Object
Returns the value of attribute provider.
-
#recipe ⇒ Object
Returns the value of attribute recipe.
-
#resource ⇒ Object
Returns the value of attribute resource.
-
#role ⇒ Object
Returns the value of attribute role.
-
#tags ⇒ Object
The tags associated with this rule.
-
#template ⇒ Object
Returns the value of attribute template.
Instance Method Summary collapse
-
#initialize(code, name) ⇒ Rule
constructor
A new instance of Rule.
-
#matches_tags?(tag_expr) ⇒ Boolean
Checks the rule tags to see if they match a Gherkin (Cucumber) expression.
-
#to_s ⇒ Object
Returns a string representation of this rule.
Constructor Details
#initialize(code, name) ⇒ Rule
Returns a new instance of Rule.
84 85 86 87 88 |
# File 'lib/foodcritic/domain.rb', line 84 def initialize(code, name) @code, @name = code, name @tags = [code] @applies_to = Proc.new { |version| true } end |
Instance Attribute Details
#applies_to ⇒ Object
Returns the value of attribute applies_to.
78 79 80 |
# File 'lib/foodcritic/domain.rb', line 78 def applies_to @applies_to end |
#attributes ⇒ Object
Returns the value of attribute attributes.
78 79 80 |
# File 'lib/foodcritic/domain.rb', line 78 def attributes @attributes end |
#code ⇒ Object
Returns the value of attribute code.
78 79 80 |
# File 'lib/foodcritic/domain.rb', line 78 def code @code end |
#cookbook ⇒ Object
Returns the value of attribute cookbook.
78 79 80 |
# File 'lib/foodcritic/domain.rb', line 78 def cookbook @cookbook end |
#environment ⇒ Object
Returns the value of attribute environment.
78 79 80 |
# File 'lib/foodcritic/domain.rb', line 78 def environment @environment end |
#library ⇒ Object
Returns the value of attribute library.
78 79 80 |
# File 'lib/foodcritic/domain.rb', line 78 def library @library end |
#metadata ⇒ Object
Returns the value of attribute metadata.
78 79 80 |
# File 'lib/foodcritic/domain.rb', line 78 def @metadata end |
#name ⇒ Object
Returns the value of attribute name.
78 79 80 |
# File 'lib/foodcritic/domain.rb', line 78 def name @name end |
#provider ⇒ Object
Returns the value of attribute provider.
78 79 80 |
# File 'lib/foodcritic/domain.rb', line 78 def provider @provider end |
#recipe ⇒ Object
Returns the value of attribute recipe.
78 79 80 |
# File 'lib/foodcritic/domain.rb', line 78 def recipe @recipe end |
#resource ⇒ Object
Returns the value of attribute resource.
78 79 80 |
# File 'lib/foodcritic/domain.rb', line 78 def resource @resource end |
#role ⇒ Object
Returns the value of attribute role.
78 79 80 |
# File 'lib/foodcritic/domain.rb', line 78 def role @role end |
#tags ⇒ Object
The tags associated with this rule. Rule is always tagged with the tag ‘any` and the rule code.
92 93 94 |
# File 'lib/foodcritic/domain.rb', line 92 def ["any"] + @tags end |
#template ⇒ Object
Returns the value of attribute template.
78 79 80 |
# File 'lib/foodcritic/domain.rb', line 78 def template @template end |
Instance Method Details
#matches_tags?(tag_expr) ⇒ Boolean
Checks the rule tags to see if they match a Gherkin (Cucumber) expression
97 98 99 100 101 |
# File 'lib/foodcritic/domain.rb', line 97 def (tag_expr) Cucumber::Core::Gherkin::TagExpression.new(tag_expr).evaluate( .map { |tag| Cucumber::Core::Ast::Tag.new(nil, tag) } ) end |
#to_s ⇒ Object
Returns a string representation of this rule.
104 105 106 |
# File 'lib/foodcritic/domain.rb', line 104 def to_s "#{@code}: #{@name}" end |