forked from roodi/roodi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
factored out some duplication in naming checks.
- Loading branch information
1 parent
e606318
commit 32ed522
Showing
4 changed files
with
43 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'roodi/checks/check' | ||
|
||
module Roodi | ||
module Checks | ||
class NameCheck < Check | ||
def initialize(interesting_nodes, pattern, message_prefix) | ||
super() | ||
@interesting_nodes = interesting_nodes | ||
@pattern = pattern | ||
@message_prefix = message_prefix | ||
end | ||
|
||
def interesting_nodes | ||
@interesting_nodes | ||
end | ||
|
||
def evaluate(node) | ||
name = find_name(node) | ||
add_error "#{@message_prefix} name \"#{name}\" should match pattern #{@pattern.inspect}" unless name.to_s =~ @pattern | ||
end | ||
end | ||
end | ||
end |