Class: PhpExpectationsHook
- Inherits:
-
Mumukit::Templates::MulangExpectationsHook
- Object
- Mumukit::Templates::MulangExpectationsHook
- PhpExpectationsHook
- Defined in:
- lib/expectations_hook.rb
Constant Summary collapse
- SEPARATOR =
'==> JSON dump:'
Instance Method Summary collapse
- #default_smell_exceptions ⇒ Object
- #domain_language ⇒ Object
- #language ⇒ Object
- #mulang_code(request) ⇒ Object
- #to_mulang_ast(output) ⇒ Object
Instance Method Details
#default_smell_exceptions ⇒ Object
31 32 33 |
# File 'lib/expectations_hook.rb', line 31 def default_smell_exceptions LOGIC_SMELLS + FUNCTIONAL_SMELLS + OBJECT_ORIENTED_SMELLS end |
#domain_language ⇒ Object
35 36 37 38 39 40 |
# File 'lib/expectations_hook.rb', line 35 def domain_language { minimumIdentifierSize: 3, jargon: [] } end |
#language ⇒ Object
8 9 10 |
# File 'lib/expectations_hook.rb', line 8 def language 'Mulang' end |
#mulang_code(request) ⇒ Object
12 13 14 15 16 |
# File 'lib/expectations_hook.rb', line 12 def mulang_code(request) result = request.result[:ast] Mulang::Code.new(mulang_language, to_mulang_ast(result)) end |
#to_mulang_ast(output) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/expectations_hook.rb', line 18 def to_mulang_ast(output) unless output.include? SEPARATOR return ['Unable to get Mulang AST - Command failed!', :errored] end json = output.split(SEPARATOR).last ast = JSON.parse json, symbolize_names: true Mulang::PHP.parse(ast) rescue => e raise Mumukit::CompilationError, e end |