Class: Capillary::LogParser
- Inherits:
-
Object
- Object
- Capillary::LogParser
- Defined in:
- lib/capillary/log_parser.rb
Instance Attribute Summary collapse
-
#branches ⇒ Object
readonly
Returns the value of attribute branches.
Instance Method Summary collapse
- #<<(commit) ⇒ Object
-
#initialize ⇒ LogParser
constructor
A new instance of LogParser.
- #to_json ⇒ Object
Constructor Details
#initialize ⇒ LogParser
Returns a new instance of LogParser.
25 26 27 28 29 30 |
# File 'lib/capillary/log_parser.rb', line 25 def initialize @commit_count = 0 @branches = [] @seq_ids = {} @commit_positions = {} end |
Instance Attribute Details
#branches ⇒ Object (readonly)
Returns the value of attribute branches.
23 24 25 |
# File 'lib/capillary/log_parser.rb', line 23 def branches @branches end |
Instance Method Details
#<<(commit) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/capillary/log_parser.rb', line 32 def <<(commit) commit = Capillary::Commit.parse(commit) if String === commit return if commit.nil? seq_id = @commit_count @commit_count += 1 commit.parent_ids.each do |parent_id| place_commit(CommitNode.new(seq_id, commit, parent_id)) end place_commit(CommitNode.new(seq_id, commit, nil)) if commit.parent_ids.empty? end |
#to_json ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/capillary/log_parser.rb', line 46 def to_json branches_json = branches.collect do |b| "[" + b.collect { |c| "#{c.to_json}" }.join(",") + "]" end "[#{branches_json.join(', ')}]" end |