Class: Mumukit::Templates::ExpectationsHook
- Defined in:
- lib/mumukit/templates/expectations_hook.rb
Direct Known Subclasses
Defined Under Namespace
Classes: SourceExpectation
Constant Summary collapse
- SOURCE_EXPECTATION_EVALUATORS =
{ 'SourceRepeats' => lambda { |source, target| source.scan(target).count > 1 }, 'SourceContains' => lambda { |source, target| source.include? target }, 'SourceEquals' => lambda { |source, target| source == target }, 'SourceEqualsIgnoreSpaces' => lambda { |source, target| source.delete(' ') == target.delete(' ') } }
- SOURCE_EXPECTATIONS =
SOURCE_EXPECTATION_EVALUATORS.keys.flat_map { |it| [it, "Not:#{it}"] }
Instance Attribute Summary
Attributes inherited from Hook
Instance Method Summary collapse
Methods inherited from Hook
#env, #initialize, #logger, #method_missing, #should_forward_to_config?, stateful_through, #t
Methods included from WithContentType
Constructor Details
This class inherits a constructor from Mumukit::Hook
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Mumukit::Hook
Instance Method Details
#compile(request) ⇒ Object
11 12 13 |
# File 'lib/mumukit/templates/expectations_hook.rb', line 11 def compile(request) { request: request, expectations: compile_expectations(request) } end |
#run!(spec) ⇒ Object
15 16 17 |
# File 'lib/mumukit/templates/expectations_hook.rb', line 15 def run!(spec) spec[:expectations][:source].map { |it| it.evaluate spec[:request][:content] } end |