Class: LearnTest::RepoParser

Inherits:
Object
  • Object
show all
Defined in:
lib/learn_test/repo_parser.rb

Class Method Summary collapse

Class Method Details

.dieObject



21
22
23
# File 'lib/learn_test/repo_parser.rb', line 21

def self.die
  exit
end

.get_repoObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/learn_test/repo_parser.rb', line 5

def self.get_repo
  begin
    repo = Git.open(FileUtils.pwd)
  rescue
    puts "You don't appear to be in a Learn lesson's directory. Please cd to an appropriate directory and try again."
    die
  end

  if url = repo.remote.url
    url.match(/(?:https:\/\/|git@).*\/(.+?)(?:\.git)?$/)[1]
  else
    puts "You don't appear to be in a Learn lesson's directory. Please cd to an appropriate directory and try again."
    die
  end
end