Class: Dod::GitHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/dod/helpers/git_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGitHelper

Returns a new instance of GitHelper.



8
9
10
# File 'lib/dod/helpers/git_helper.rb', line 8

def initialize
  @g = Git.open(".")
end

Instance Attribute Details

#gObject

Returns the value of attribute g.



6
7
8
# File 'lib/dod/helpers/git_helper.rb', line 6

def g
  @g
end

Instance Method Details

#current_branchObject



12
13
14
# File 'lib/dod/helpers/git_helper.rb', line 12

def current_branch 
  g.current_branch
end

#project_nameObject



21
22
23
24
# File 'lib/dod/helpers/git_helper.rb', line 21

def project_name
  url_components = URI.parse(g.remote('origin').url)
  url_components.path.split('/')[2].upcase
end

#repo_nameObject



16
17
18
19
# File 'lib/dod/helpers/git_helper.rb', line 16

def repo_name
  url_components = URI.parse(g.remote('origin').url)
  url_components.path.split('/')[3].split('.').first
end