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.
29 30 31 |
# File 'lib/capillary/commit.rb', line 29 def initialize @refs = RefCollection.new end |
Instance Attribute Details
#committed_at ⇒ Object
Returns the value of attribute committed_at.
24 25 26 |
# File 'lib/capillary/commit.rb', line 24 def committed_at @committed_at end |
#committer_email ⇒ Object
Returns the value of attribute committer_email.
24 25 26 |
# File 'lib/capillary/commit.rb', line 24 def committer_email @committer_email end |
#id ⇒ Object
Returns the value of attribute id.
24 25 26 |
# File 'lib/capillary/commit.rb', line 24 def id @id end |
#message ⇒ Object
68 69 70 |
# File 'lib/capillary/commit.rb', line 68 def @message.gsub(/[^A-Za-z0-9\s\'\n\.,\/]/,"") end |
#parent_ids ⇒ Object
Returns the value of attribute parent_ids.
24 25 26 |
# File 'lib/capillary/commit.rb', line 24 def parent_ids @parent_ids end |
#refs ⇒ Object (readonly)
Returns the value of attribute refs.
26 27 28 |
# File 'lib/capillary/commit.rb', line 26 def refs @refs end |
#seq_id ⇒ Object
Returns the value of attribute seq_id.
24 25 26 |
# File 'lib/capillary/commit.rb', line 24 def seq_id @seq_id end |
Class Method Details
.parse(git_line) ⇒ Object
Creates an instance from Git output
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/capillary/commit.rb', line 34 def self.parse(git_line) git_line = git_line.gsub(/^[^a-f0-9]+/, "") return nil if git_line == "" parts = git_line.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
49 50 51 52 53 54 55 56 |
# File 'lib/capillary/commit.rb', line 49 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
58 59 60 61 62 63 64 65 66 |
# File 'lib/capillary/commit.rb', line 58 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 |