Sha256: 66aa750e1e0a69cc30d083db64ac72b4f6f9031b02ef39fafafad997277a8924

Contents?: true

Size: 663 Bytes

Versions: 12

Compression:

Stored size: 663 Bytes

Contents

# frozen_string_literal: true

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

12 entries across 12 versions & 1 rubygems

Version Path
learn-test-3.2.4 lib/learn_test/repo_parser.rb
learn-test-3.2.3 lib/learn_test/repo_parser.rb
learn-test-3.2.2 lib/learn_test/repo_parser.rb
learn-test-3.2.1 lib/learn_test/repo_parser.rb
learn-test-3.2.1.pre.7 lib/learn_test/repo_parser.rb
learn-test-3.2.1.pre.6 lib/learn_test/repo_parser.rb
learn-test-3.2.1.pre.5 lib/learn_test/repo_parser.rb
learn-test-3.2.1.pre.4 lib/learn_test/repo_parser.rb
learn-test-3.2.1.pre.3 lib/learn_test/repo_parser.rb
learn-test-3.2.1.pre.2 lib/learn_test/repo_parser.rb
learn-test-3.2.1.pre.1 lib/learn_test/repo_parser.rb
learn-test-3.2.0 lib/learn_test/repo_parser.rb