Class: Redmine::UnifiedDiff
Overview
Class used to parse unified diffs
Instance Method Summary
-
- (UnifiedDiff) initialize(diff, options = {})
constructor
A new instance of UnifiedDiff.
- - (Boolean) truncated?
Methods inherited from Array
#to_ber, #to_ber_appsequence, #to_ber_contextspecific, #to_ber_sequence, #to_ber_set, #to_csv
Methods included from Diffable
#diff, #patch, #replacenextlarger, #reverse_hash
Constructor Details
- (UnifiedDiff) initialize(diff, options = {})
A new instance of UnifiedDiff
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/redmine/unified_diff.rb', line 21 def initialize(diff, ={}) .assert_valid_keys(:type, :max_lines) diff = diff.split("\n") if diff.is_a?(String) diff_type = [:type] || 'inline' lines = 0 @truncated = false diff_table = DiffTable.new(diff_type) diff.each do |line| unless diff_table.add_line line self << diff_table if diff_table.length > 1 diff_table = DiffTable.new(diff_type) end lines += 1 if [:max_lines] && lines > [:max_lines] @truncated = true break end end self << diff_table unless diff_table.empty? self end |
Instance Method Details
- (Boolean) truncated?
44 |
# File 'lib/redmine/unified_diff.rb', line 44 def truncated?; @truncated end |