Sha256: f8f0d9b063d9b872a7ecec7dce6e4ac731a7c51492b80b7844e44bcd8d148f8b

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

require 'git'

# Creategem::Repository contains informations about the git repository and the git user
module Creategem
  class Repository
    REPOSITORIES = { github: "github.com", bitbucket: "bitbucket.org" }

    attr_reader :vendor, :name, :user, :user_name, :user_email, :gem_server_url, :private

    def initialize(options)
      @vendor = options[:vendor]
      @private = options[:private]
      @name = options[:name]
      @user = options[:user]
      @user_name = ::Git.global_config "user.name"
      @user_email = ::Git.global_config "user.email"
      @gem_server_url = options[:gem_server_url]
      @private = options[:private]
    end

    def github?
      vendor == :github
    end

    def bitbucket?
      vendor == :bitbucket
    end

    # this could change later. For now all private repositories are on bitbucket and all private ones on github
    def private?
      self.private
    end

    def public?
      !private?
    end

    def url
      "https://#{REPOSITORIES[vendor]}/#{user}/#{name}"
    end

    def origin
      "git@#{REPOSITORIES[vendor]}:#{user}/#{name}.git"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
creategem-0.7.4 lib/creategem/repository.rb
creategem-0.7.3 lib/creategem/repository.rb
creategem-0.7.2 lib/creategem/repository.rb
creategem-0.7.1 lib/creategem/repository.rb
creategem-0.7.0 lib/creategem/repository.rb