Class: Creategem::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/creategem/repository.rb

Constant Summary collapse

REPOSITORIES =
{ github: "github.com", bitbucket: "bitbucket.org" }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Repository

Returns a new instance of Repository.



10
11
12
13
14
15
16
17
18
19
# File 'lib/creategem/repository.rb', line 10

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

Instance Attribute Details

#gem_server_urlObject (readonly)

Returns the value of attribute gem_server_url.



8
9
10
# File 'lib/creategem/repository.rb', line 8

def gem_server_url
  @gem_server_url
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/creategem/repository.rb', line 8

def name
  @name
end

#privateObject (readonly)

Returns the value of attribute private.



8
9
10
# File 'lib/creategem/repository.rb', line 8

def private
  @private
end

#userObject (readonly)

Returns the value of attribute user.



8
9
10
# File 'lib/creategem/repository.rb', line 8

def user
  @user
end

#user_emailObject (readonly)

Returns the value of attribute user_email.



8
9
10
# File 'lib/creategem/repository.rb', line 8

def user_email
  @user_email
end

#user_nameObject (readonly)

Returns the value of attribute user_name.



8
9
10
# File 'lib/creategem/repository.rb', line 8

def user_name
  @user_name
end

#vendorObject (readonly)

Returns the value of attribute vendor.



8
9
10
# File 'lib/creategem/repository.rb', line 8

def vendor
  @vendor
end

Instance Method Details

#bitbucket?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/creategem/repository.rb', line 25

def bitbucket?
  vendor == :bitbucket
end

#github?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/creategem/repository.rb', line 21

def github?
  vendor == :github
end

#originObject



42
43
44
# File 'lib/creategem/repository.rb', line 42

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

#private?Boolean

this could change later. For now all private repositories are on bitbucket and all private ones on github

Returns:

  • (Boolean)


30
31
32
# File 'lib/creategem/repository.rb', line 30

def private?
  self.private
end

#public?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/creategem/repository.rb', line 34

def public?
  !private?
end

#urlObject



38
39
40
# File 'lib/creategem/repository.rb', line 38

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