Class: JewelryPortfolio::Repo
- Inherits:
-
Object
- Object
- JewelryPortfolio::Repo
- Defined in:
- lib/jewelry_portfolio/repo.rb
Defined Under Namespace
Classes: InvalidError
Instance Attribute Summary collapse
-
#account ⇒ Object
The GitHub user account that this repo belongs to.
-
#description ⇒ Object
The description of the project.
-
#name ⇒ Object
The name of the repo.
-
#summary ⇒ Object
The summary of the project.
-
#version ⇒ Object
The version of the current version of the project.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#clone_url ⇒ Object
Returns the public clone URL.
-
#gem? ⇒ Boolean
Returns whether or not there’s a Ruby gem for this repo.
-
#gem_install_command ⇒ Object
Returns the command to install the gem.
-
#gem_name ⇒ Object
Returns the name of the gem file from GitHub, which is made up of the account name and the gem name.
- #hash ⇒ Object
-
#initialize(account = nil, spec = nil) ⇒ Repo
constructor
A new instance of Repo.
-
#url ⇒ Object
Returns the URL to the project page on GitHub.
-
#valid? ⇒ Boolean
Raises a JewelryPortfolio::Repo::InvalidError if any of: account, name, version, summary, or description is
nil
.
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(account = nil, spec = nil) @account = 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
#account ⇒ Object
The GitHub user account that this repo belongs to.
6 7 8 |
# File 'lib/jewelry_portfolio/repo.rb', line 6 def account @account end |
#description ⇒ Object
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 |
#name ⇒ Object
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 |
#summary ⇒ Object
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 |
#version ⇒ Object
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_url ⇒ Object
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.
38 39 40 |
# File 'lib/jewelry_portfolio/repo.rb', line 38 def gem? @gem end |
#gem_install_command ⇒ Object
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_name ⇒ Object
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 |
#hash ⇒ Object
69 70 71 |
# File 'lib/jewelry_portfolio/repo.rb', line 69 def hash @name.hash end |
#url ⇒ Object
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
.
65 66 67 |
# File 'lib/jewelry_portfolio/repo.rb', line 65 def valid? @account && @name && @version && @summary && @description end |