Class: AIRefactor::CommandFileParser
- Inherits:
-
Object
- Object
- AIRefactor::CommandFileParser
- Defined in:
- lib/ai_refactor/command_file_parser.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path) ⇒ CommandFileParser
constructor
A new instance of CommandFileParser.
- #parse ⇒ Object
Constructor Details
#initialize(path) ⇒ CommandFileParser
Returns a new instance of CommandFileParser.
11 12 13 |
# File 'lib/ai_refactor/command_file_parser.rb', line 11 def initialize(path) @path = path end |
Class Method Details
.command_file?(name) ⇒ Boolean
7 8 9 |
# File 'lib/ai_refactor/command_file_parser.rb', line 7 def self.command_file?(name) name.match?(/\.ya?ml$/) end |
Instance Method Details
#parse ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ai_refactor/command_file_parser.rb', line 15 def parse raise StandardError, "Invalid command file: file does not exist" unless File.exist?(@path) = YAML.safe_load_file(@path, permitted_classes: [Symbol], symbolize_names: true, aliases: true) unless && [:refactor] raise StandardError, "Invalid command file format, a 'refactor' key is required" end end |