Class: Cp8Cli::Repo

Inherits:
Object
  • Object
show all
Defined in:
lib/cp8_cli/repo.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Repo

Returns a new instance of Repo.



8
9
10
# File 'lib/cp8_cli/repo.rb', line 8

def initialize(path)
  @path = path
end

Class Method Details

.currentObject



3
4
5
6
# File 'lib/cp8_cli/repo.rb', line 3

def self.current
  path = Command.read("git config --get remote.origin.url").match(/github.com[:\/](\S+\/\S+)\.git/)[1]
  new(path)
end

Instance Method Details

#shorthandObject



12
13
14
# File 'lib/cp8_cli/repo.rb', line 12

def shorthand
  "#{user}/#{name}"
end

#urlObject



16
17
18
# File 'lib/cp8_cli/repo.rb', line 16

def url
  "https://github.com/#{shorthand}"
end

#userObject



20
21
22
# File 'lib/cp8_cli/repo.rb', line 20

def user
  path.split('/').first
end