Class: Testgenai::CodeExtractor
- Inherits:
-
Object
- Object
- Testgenai::CodeExtractor
- Defined in:
- lib/testgenai/code_extractor.rb
Class Method Summary collapse
Class Method Details
.extract(response) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/testgenai/code_extractor.rb', line 5 def self.extract(response) if (match = response.match(/```ruby\n(.*?)```/m)) match[1] elsif (match = response.match(/```\w*\n(.*?)```/m)) match[1] else response end end |
.valid_ruby?(code) ⇒ Boolean
15 16 17 18 19 20 |
# File 'lib/testgenai/code_extractor.rb', line 15 def self.valid_ruby?(code) Testgenai::CurrentParser.parse(code) true rescue Parser::SyntaxError false end |