Class: Jive::Repo

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

Constant Summary collapse

SSH_REGEX =
%r{\Agit@(?<host>.+):(?<account>.+)/(?<repo>.+)\z}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Repo

Returns a new instance of Repo.



7
8
9
# File 'lib/jive/repo.rb', line 7

def initialize(path)
  @repo = Rugged::Repository.new(path.to_s)
end

Class Method Details

.currentObject



32
33
34
# File 'lib/jive/repo.rb', line 32

def current
  @current ||= new(Pathname.pwd)
end

Instance Method Details

#branchObject



27
28
29
# File 'lib/jive/repo.rb', line 27

def branch
  uri.path[1..-1]
end

#canonical_urlObject



15
16
17
18
19
20
# File 'lib/jive/repo.rb', line 15

def canonical_url
  remote = @repo.remotes.find { |x| x.name == "origin" }
  return if remote.nil?

  ssh?(remote) ? url_for_ssh(remote) : url_for(remote)
end

#nwoObject



22
23
24
25
# File 'lib/jive/repo.rb', line 22

def nwo
  segments = uri.path.split("/")
  "#{segments[1]}/#{segments[2].gsub(".git", "")}"
end

#uriObject



11
12
13
# File 'lib/jive/repo.rb', line 11

def uri
  @uri ||= URI.parse(canonical_url)
end