Sha256: b53faa55404927a8a7b701172500cfb72825dee8e56b52b7a408866723e3d6b2

Contents?: true

Size: 632 Bytes

Versions: 5

Compression:

Stored size: 632 Bytes

Contents

require 'git'

module LearnTest
  class RepoParser
    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 enter 'learn open' or 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 enter 'learn open' or cd to an appropriate directory and try again."
        die
      end
    end

    def self.die
      exit
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
learn-test-3.1.2 lib/learn_test/repo_parser.rb
learn-test-3.1.1 lib/learn_test/repo_parser.rb
learn-test-3.1.0 lib/learn_test/repo_parser.rb
learn-test-3.0.0 lib/learn_test/repo_parser.rb
learn-test-2.7.0 lib/learn_test/repo_parser.rb