Class: Spoom::Git::Commit

Inherits:
Object
  • Object
show all
Defined in:
lib/spoom/context/git.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sha:, time:) ⇒ Commit

: (sha: String, time: Time) -> void



28
29
30
31
# File 'lib/spoom/context/git.rb', line 28

def initialize(sha:, time:)
  @sha = sha
  @time = time
end

Instance Attribute Details

#sha ⇒ Object (readonly)

: String



22
23
24
# File 'lib/spoom/context/git.rb', line 22

def sha
  @sha
end

#time ⇒ Object (readonly)

: Time



25
26
27
# File 'lib/spoom/context/git.rb', line 25

def time
  @time
end

Class Method Details

.parse_line(string) ⇒ Object

Parse a line formatted as %h %at into a Commit : (String string) -> Commit?



12
13
14
15
16
17
18
# File 'lib/spoom/context/git.rb', line 12

def parse_line(string)
  sha, epoch = string.split(" ", 2)
  return unless sha && epoch

  time = Time.strptime(epoch, "%s")
  Commit.new(sha: sha, time: time)
end

Instance Method Details

#timestamp ⇒ Object

: -> Integer



34
35
36
# File 'lib/spoom/context/git.rb', line 34

def timestamp
  time.to_i
end