Class: GitDiffService
- Inherits:
-
Object
- Object
- GitDiffService
- Defined in:
- lib/git_diff_service.rb
Constant Summary collapse
- PATTERN_MATCH =
/^diff --git\s/- EXCLUDE_ROOT_FOLDERS =
restrict scope: for Rails app exclude autogenerated code and omit any files except .rb
['db/', 'spec/', 'config/']
- ALLOWED_EXTENSION =
'.rb'
Class Method Summary collapse
Class Method Details
.call(diff_lines, exclude_folders = []) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/git_diff_service.rb', line 8 def call(diff_lines, exclude_folders = []) @diff_lines = diff_lines # TO-DO: support @only_folders @exclude_folders = exclude_folders + EXCLUDE_ROOT_FOLDERS patch_pos_start = lines_with_file_paths.map { |line| patch_start_pos(line) } # array with start and end positions for each patch @patches_pos = patch_pos_start.zip(patch_end_pos(patch_pos_start)) slice_diff @patches = @patches.select { |patch| allowed_patch?(patch) } @diff_data = @patches.map { |patch| fname_diff(patch) } @diff_data += @patches.map { |patch| class_diff(patch) } @diff_data.compact end |