Class: CIJoe::Commit

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#projectObject

Returns the value of attribute project

Returns:

  • (Object)

    the current value of project



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

def project
  @project
end

#project_pathObject

Returns the value of attribute project_path

Returns:

  • (Object)

    the current value of project_path



2
3
4
# File 'lib/cijoe/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/cijoe/commit.rb', line 2

def sha
  @sha
end

#userObject

Returns the value of attribute user

Returns:

  • (Object)

    the current value of user



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

def user
  @user
end

Instance Method Details

#authorObject



11
12
13
# File 'lib/cijoe/commit.rb', line 11

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

#committed_atObject



15
16
17
# File 'lib/cijoe/commit.rb', line 15

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

#messageObject



19
20
21
# File 'lib/cijoe/commit.rb', line 19

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

#raw_commitObject



23
24
25
# File 'lib/cijoe/commit.rb', line 23

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

#raw_commit_linesObject



27
28
29
# File 'lib/cijoe/commit.rb', line 27

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

#urlObject



3
4
5
6
7
8
9
# File 'lib/cijoe/commit.rb', line 3

def url
  # BeanStalk
  "https://oxygenwebs.beanstalkapp.com/#{project}/changesets/#{sha}"
  
  # GitHub
  # "http://github.com/#{user}/#{project}/commit/#{sha}"
end