Module: Legion::Extensions::Developer::Helpers::ChangeParser
- Extended by:
- ChangeParser
- Included in:
- ChangeParser
- Defined in:
- lib/legion/extensions/developer/helpers/change_parser.rb
Constant Summary collapse
- FILE_COMMENT_PATTERN =
/\A#\s*file:\s*(.+)\z/- CODE_BLOCK_PATTERN =
/```\w*\n(.*?)```/m
Instance Method Summary collapse
Instance Method Details
#file_paths_only(changes:) ⇒ Object
20 21 22 |
# File 'lib/legion/extensions/developer/helpers/change_parser.rb', line 20 def file_paths_only(changes:) changes.map { |c| c[:path] } end |
#parse(content:) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/legion/extensions/developer/helpers/change_parser.rb', line 13 def parse(content:) return [] if content.nil? || content.strip.empty? blocks = content.scan(CODE_BLOCK_PATTERN).flatten blocks.filter_map { |block| extract_file_change(block) } end |