Class: CIQuantum::Commit

Inherits:
Struct
  • Object
show all
Defined in:
lib/ciquantum/commit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#project_pathObject

Returns the value of attribute project_path

Returns:

  • (Object)

    the current value of project_path



2
3
4
# File 'lib/ciquantum/commit.rb', line 2

def project_path
  @project_path
end

#shaObject

Returns the value of attribute sha

Returns:

  • (Object)

    the current value of sha



2
3
4
# File 'lib/ciquantum/commit.rb', line 2

def sha
  @sha
end

#urlObject (readonly)

Returns the value of attribute url.



4
5
6
# File 'lib/ciquantum/commit.rb', line 4

def url
  @url
end

Instance Method Details

#authorObject



10
11
12
# File 'lib/ciquantum/commit.rb', line 10

def author
  raw_commit_lines.grep(/Author:/).first.split(':', 2)[-1]
end

#committed_atObject



14
15
16
# File 'lib/ciquantum/commit.rb', line 14

def committed_at
  raw_commit_lines.grep(/Date:/).first.split(':', 2)[-1]
end

#get_url!(adapter) ⇒ Object



6
7
8
# File 'lib/ciquantum/commit.rb', line 6

def get_url! adapter
  @url = adapter.commit_url self
end

#messageObject



18
19
20
# File 'lib/ciquantum/commit.rb', line 18

def message
  raw_commit.split("\n\n", 3)[1].to_s.strip
end

#raw_commitObject



22
23
24
# File 'lib/ciquantum/commit.rb', line 22

def raw_commit
  @raw_commit ||= `cd #{project_path} && git show #{sha}`.chomp
end

#raw_commit_linesObject



26
27
28
# File 'lib/ciquantum/commit.rb', line 26

def raw_commit_lines
  @raw_commit_lines ||= raw_commit.split("\n")
end