Class: Colora::Data
- Inherits:
-
Object
- Object
- Colora::Data
- Defined in:
- lib/colora/data.rb
Overview
Data class for processing git-diff lines. :reek:DuplicateMethodCall :reek:UncommunicativeVariableName :reek:TooManyStatements
Instance Attribute Summary collapse
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(lines) ⇒ Data
constructor
A new instance of Data.
Constructor Details
#initialize(lines) ⇒ Data
Returns a new instance of Data.
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/colora/data.rb', line 44 def initialize(lines) @lines = [] @codes = {} @comments = {} @edits = Set.new populate_lines(lines) populate_edits @lines.each do |line| next unless line.is_a?(Array) post_process line end end |
Instance Attribute Details
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
42 43 44 |
# File 'lib/colora/data.rb', line 42 def lines @lines end |
Class Method Details
.reflag(flag) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/colora/data.rb', line 34 def self.reflag(flag) if flag == '-' '-' else flag == '+' ? '+' : flag end end |
.split(line) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/colora/data.rb', line 9 def self.split(line) case line[1..] when /^\s*#/ [line[0], nil, line[1..]] when %r{^(.*?)(\s*#[^`'")/\}\]]*)$} [line[0], $LAST_MATCH_INFO[1], $LAST_MATCH_INFO[2]] else [line[0], line[1..], nil] end # [flag, code, comment] end |
.update(hash, key, flag) ⇒ Object
:reek:NilCheck
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/colora/data.rb', line 22 def self.update(hash, key, flag) k = key.strip hash[k] = case hash[k] when nil flag # added or removed when 'd', 't', flag 'd' # duplicate else 't' # touched end end |