Class: JewelryPortfolio::Repo

Inherits:
Object
  • Object
show all
Defined in:
lib/jewelry_portfolio/repo.rb

Defined Under Namespace

Classes: InvalidError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account = nil, spec = nil) ⇒ Repo

Returns a new instance of Repo.



28
29
30
31
32
33
34
35
# File 'lib/jewelry_portfolio/repo.rb', line 28

def initialize( = nil, spec = nil)
  @account = 
  @gem = !spec.nil?
  
  %w{ name version summary description }.each do |attr|
    send("#{attr}=", spec.send(attr).to_s)
  end if spec
end

Instance Attribute Details

#accountObject

The GitHub user account that this repo belongs to.



6
7
8
# File 'lib/jewelry_portfolio/repo.rb', line 6

def 
  @account
end

#descriptionObject

The description of the project.

Not needed when initialized with a Gem::Specification.



26
27
28
# File 'lib/jewelry_portfolio/repo.rb', line 26

def description
  @description
end

#nameObject

The name of the repo.

Not needed when initialized with a Gem::Specification.



11
12
13
# File 'lib/jewelry_portfolio/repo.rb', line 11

def name
  @name
end

#summaryObject

The summary of the project.

Not needed when initialized with a Gem::Specification.



21
22
23
# File 'lib/jewelry_portfolio/repo.rb', line 21

def summary
  @summary
end

#versionObject

The version of the current version of the project.

Not needed when initialized with a Gem::Specification.



16
17
18
# File 'lib/jewelry_portfolio/repo.rb', line 16

def version
  @version
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



73
74
75
# File 'lib/jewelry_portfolio/repo.rb', line 73

def ==(other)
  other.is_a?(Repo) && hash == other.hash
end

#clone_urlObject

Returns the public clone URL.



48
49
50
# File 'lib/jewelry_portfolio/repo.rb', line 48

def clone_url
  "git://github.com/#{@account}/#{name}.git"
end

#gem?Boolean

Returns whether or not there’s a Ruby gem for this repo.

Returns:

  • (Boolean)


38
39
40
# File 'lib/jewelry_portfolio/repo.rb', line 38

def gem?
  @gem
end

#gem_install_commandObject

Returns the command to install the gem. This is a helper for your views.



59
60
61
# File 'lib/jewelry_portfolio/repo.rb', line 59

def gem_install_command
  "sudo gem install #{gem_name} -s http://gems.github.com"
end

#gem_nameObject

Returns the name of the gem file from GitHub, which is made up of the account name and the gem name.



54
55
56
# File 'lib/jewelry_portfolio/repo.rb', line 54

def gem_name
  "#{@account}-#{@name}"
end

#hashObject



69
70
71
# File 'lib/jewelry_portfolio/repo.rb', line 69

def hash
  @name.hash
end

#urlObject

Returns the URL to the project page on GitHub.



43
44
45
# File 'lib/jewelry_portfolio/repo.rb', line 43

def url
  "http://github.com/#{@account}/#{name}/tree/master"
end

#valid?Boolean

Raises a JewelryPortfolio::Repo::InvalidError if any of: account, name, version, summary, or description is nil.

Returns:

  • (Boolean)


65
66
67
# File 'lib/jewelry_portfolio/repo.rb', line 65

def valid?
  @account && @name && @version && @summary && @description
end