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.
82 83 84 85 86 |
# File 'lib/foodcritic/domain.rb', line 82 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.
76 77 78 |
# File 'lib/foodcritic/domain.rb', line 76 def applies_to @applies_to end |
#attributes ⇒ Object
Returns the value of attribute attributes.
76 77 78 |
# File 'lib/foodcritic/domain.rb', line 76 def attributes @attributes end |
#code ⇒ Object
Returns the value of attribute code.
76 77 78 |
# File 'lib/foodcritic/domain.rb', line 76 def code @code end |
#cookbook ⇒ Object
Returns the value of attribute cookbook.
76 77 78 |
# File 'lib/foodcritic/domain.rb', line 76 def cookbook @cookbook end |
#environment ⇒ Object
Returns the value of attribute environment.
76 77 78 |
# File 'lib/foodcritic/domain.rb', line 76 def environment @environment end |
#library ⇒ Object
Returns the value of attribute library.
76 77 78 |
# File 'lib/foodcritic/domain.rb', line 76 def library @library end |
#metadata ⇒ Object
Returns the value of attribute metadata.
76 77 78 |
# File 'lib/foodcritic/domain.rb', line 76 def @metadata end |
#name ⇒ Object
Returns the value of attribute name.
76 77 78 |
# File 'lib/foodcritic/domain.rb', line 76 def name @name end |
#provider ⇒ Object
Returns the value of attribute provider.
76 77 78 |
# File 'lib/foodcritic/domain.rb', line 76 def provider @provider end |
#recipe ⇒ Object
Returns the value of attribute recipe.
76 77 78 |
# File 'lib/foodcritic/domain.rb', line 76 def recipe @recipe end |
#resource ⇒ Object
Returns the value of attribute resource.
76 77 78 |
# File 'lib/foodcritic/domain.rb', line 76 def resource @resource end |
#role ⇒ Object
Returns the value of attribute role.
76 77 78 |
# File 'lib/foodcritic/domain.rb', line 76 def role @role end |
#tags ⇒ Object
The tags associated with this rule. Rule is always tagged with the tag ‘any` and the rule code.
90 91 92 |
# File 'lib/foodcritic/domain.rb', line 90 def ["any"] + @tags end |
#template ⇒ Object
Returns the value of attribute template.
76 77 78 |
# File 'lib/foodcritic/domain.rb', line 76 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
95 96 97 98 99 |
# File 'lib/foodcritic/domain.rb', line 95 def (tag_expr) ::Foodcritic::Gherkin::TagExpression.new(tag_expr).evaluate( .map { |tag| ::Foodcritic::Gherkin::Tag.new(nil, tag) } ) end |
#to_s ⇒ Object
Returns a string representation of this rule.
102 103 104 |
# File 'lib/foodcritic/domain.rb', line 102 def to_s "#{@code}: #{@name}" end |