Class: Epuber::Checker::TextChecker
- Inherits:
-
Epuber::Checker
- Object
- Epuber::CheckerTransformerBase
- Epuber::Checker
- Epuber::Checker::TextChecker
- Defined in:
- lib/epuber/checker/text_checker.rb
Defined Under Namespace
Classes: MatchProblem
Instance Attribute Summary collapse
Attributes inherited from Epuber::CheckerTransformerBase
#block, #options, #source_type
Instance Method Summary collapse
-
#call(file_path, text, compilation_context) ⇒ Object
Nil.
- #should_not_contain(regexp, message) ⇒ Object
Methods inherited from Epuber::Checker
Methods inherited from Epuber::CheckerTransformerBase
class_for_source_type, #initialize, map_source_type__class, #valid_options
Constructor Details
This class inherits a constructor from Epuber::CheckerTransformerBase
Instance Attribute Details
#file_path ⇒ String
95 96 97 |
# File 'lib/epuber/checker/text_checker.rb', line 95 def file_path @file_path end |
#text ⇒ String
91 92 93 |
# File 'lib/epuber/checker/text_checker.rb', line 91 def text @text end |
Instance Method Details
#call(file_path, text, compilation_context) ⇒ Object
Returns nil.
105 106 107 108 109 110 111 112 113 |
# File 'lib/epuber/checker/text_checker.rb', line 105 def call(file_path, text, compilation_context) @file_path = file_path @text = text @block.call(self, text, compilation_context) @text = nil @file_path = nil end |
#should_not_contain(regexp, message) ⇒ Object
118 119 120 121 122 123 124 125 126 |
# File 'lib/epuber/checker/text_checker.rb', line 118 def should_not_contain(regexp, ) # find all matches # taken from http://stackoverflow.com/questions/6804557/how-do-i-get-the-match-data-for-all-occurrences-of-a-ruby-regular-expression-in matches = text.to_enum(:scan, regexp).map { Regexp.last_match } matches.each do |match| # @type match [MatchData] UI.print_processing_problem MatchProblem.new(match, , Config.instance.pretty_path_from_project(file_path)) end end |