Class: MountainBerryFields::Test::RubySyntaxChecker
- Inherits:
-
Object
- Object
- MountainBerryFields::Test::RubySyntaxChecker
- Defined in:
- lib/mountain_berry_fields/test.rb
Overview
checks syntax of a code example
Instance Method Summary collapse
-
#initialize(code_to_test) ⇒ RubySyntaxChecker
constructor
A new instance of RubySyntaxChecker.
- #invalid_message ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(code_to_test) ⇒ RubySyntaxChecker
Returns a new instance of RubySyntaxChecker.
68 69 70 |
# File 'lib/mountain_berry_fields/test.rb', line 68 def initialize(code_to_test) @code_to_test = code_to_test end |
Instance Method Details
#invalid_message ⇒ Object
79 80 81 82 |
# File 'lib/mountain_berry_fields/test.rb', line 79 def valid? "#{@stderr.chomp}\n\noriginal file:\n#@code_to_test" end |
#valid? ⇒ Boolean
72 73 74 75 76 77 |
# File 'lib/mountain_berry_fields/test.rb', line 72 def valid? return @valid if defined? @valid out, err, status = Open3.capture3 'ruby -c', stdin_data: @code_to_test @stderr = err @valid = status.exitstatus.zero? end |