Class: Capillary::Commit
- Inherits:
-
Object
- Object
- Capillary::Commit
- Defined in:
- lib/capillary/commit.rb
Constant Summary collapse
- LOG_SEPARATOR =
"ยง"
Instance Attribute Summary collapse
-
#committed_at ⇒ Object
Returns the value of attribute committed_at.
-
#committer_email ⇒ Object
Returns the value of attribute committer_email.
-
#id ⇒ Object
Returns the value of attribute id.
- #message ⇒ Object
-
#parent_ids ⇒ Object
Returns the value of attribute parent_ids.
-
#refs ⇒ Object
readonly
Returns the value of attribute refs.
-
#seq_id ⇒ Object
Returns the value of attribute seq_id.
Class Method Summary collapse
-
.parse(git_line) ⇒ Object
Creates an instance from Git output.
Instance Method Summary collapse
-
#initialize ⇒ Commit
constructor
A new instance of Commit.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize ⇒ Commit
Returns a new instance of Commit.
30 31 32 |
# File 'lib/capillary/commit.rb', line 30 def initialize @refs = RefCollection.new end |
Instance Attribute Details
#committed_at ⇒ Object
Returns the value of attribute committed_at.
25 26 27 |
# File 'lib/capillary/commit.rb', line 25 def committed_at @committed_at end |
#committer_email ⇒ Object
Returns the value of attribute committer_email.
25 26 27 |
# File 'lib/capillary/commit.rb', line 25 def committer_email @committer_email end |
#id ⇒ Object
Returns the value of attribute id.
25 26 27 |
# File 'lib/capillary/commit.rb', line 25 def id @id end |
#message ⇒ Object
69 70 71 |
# File 'lib/capillary/commit.rb', line 69 def HTMLEntities.new.encode(@message) end |
#parent_ids ⇒ Object
Returns the value of attribute parent_ids.
25 26 27 |
# File 'lib/capillary/commit.rb', line 25 def parent_ids @parent_ids end |
#refs ⇒ Object (readonly)
Returns the value of attribute refs.
27 28 29 |
# File 'lib/capillary/commit.rb', line 27 def refs @refs end |
#seq_id ⇒ Object
Returns the value of attribute seq_id.
25 26 27 |
# File 'lib/capillary/commit.rb', line 25 def seq_id @seq_id end |
Class Method Details
.parse(git_line) ⇒ Object
Creates an instance from Git output
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/capillary/commit.rb', line 35 def self.parse(git_line) git_line = git_line.gsub(/^[^a-f0-9]+/, "") return nil if git_line == "" parts = git_line.force_encoding('utf-8').split(LOG_SEPARATOR) result = new result.id = parts[0] result.parent_ids = parts[1].split(" ") result.committed_at = Time.parse(parts[2]) result.committer_email = parts[3] result.refs.parse(parts[4]) result. = parts[5] result end |
Instance Method Details
#to_hash ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/capillary/commit.rb', line 50 def to_hash { "id" => id, "parent_ids" => parent_ids, "committed_at" => committed_at, "committer_email" => committer_email, "refs" => refs.to_hash, "message" => } end |
#to_json ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/capillary/commit.rb', line 59 def to_json JSON.unparse({ "id" => id, "parentIds" => parent_ids, "committedAt" => committed_at, "committerEmail" => committer_email, "refs" => refs.to_hash, "message" => , "seqId" => seq_id}) end |