class Harvest::Vcs

Attributes

current_branch[R]
project_code[R]

Public Class Methods

current_project() click to toggle source
# File lib/harvest/vcs.rb, line 5
def self.current_project
  remote_url = `git config --local remote.origin.url`.strip

  URI(remote_url).path.split('/').last.gsub('.git', '')
end
new(project_code) click to toggle source
# File lib/harvest/vcs.rb, line 11
def initialize(project_code)
  @project_code = project_code
  @current_branch = git_command_for_current_branch[0..-2]
end

Public Instance Methods

ticket_id() click to toggle source
# File lib/harvest/vcs.rb, line 16
def ticket_id
  branch_names = current_branch.gsub(/[^0-9a-z]/i, ' ').split
  
  return nil if branch_names.index(project_code).nil?
  
  branch_names[branch_names.index(project_code)+1]
end

Private Instance Methods

git_command_for_current_branch() click to toggle source
# File lib/harvest/vcs.rb, line 26
def git_command_for_current_branch
  `git rev-parse --abbrev-ref HEAD`
end