Sha256: be29580baf649edd70ef975346b6d0d3dd3b0c908a8e7c063f25debc2d28f322

Contents?: true

Size: 491 Bytes

Versions: 3

Compression:

Stored size: 491 Bytes

Contents

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

    def initialize(path)
      @path = path
    end

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

    def name
      path.split('/').last
    end

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

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

    private

      attr_reader :path
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cp8_cli-6.0.1 lib/cp8_cli/repo.rb
cp8_cli-6.0.0 lib/cp8_cli/repo.rb
cp8_cli-5.0.0 lib/cp8_cli/repo.rb