Class: Hubless::GemDescription
- Inherits:
-
Object
- Object
- Hubless::GemDescription
- Defined in:
- lib/gem_description.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
-
.local_gems ⇒ Object
GemDescriptions of all gems installed locally.
Instance Method Summary collapse
-
#gemcutter? ⇒ Boolean
Does a gem exist on Gemcutter that matches this gem.
-
#gemcutter_name ⇒ Object
Likely name of this gem on Gemcutter (without the GitHub username).
-
#github? ⇒ Boolean
Does a repo exist on GitHub that matches this gem.
- #github_like? ⇒ Boolean
-
#github_name ⇒ Object
Full name of this gem including GitHub username.
-
#initialize(*args) ⇒ GemDescription
constructor
New GemDescription from a one-liner or options Hash Hubless::GemDescription.new(‘my-awesome_gem-3.4.5’) Hubless::GemDescription.new(:name => ‘my-awesome_gem’, :version => ‘3.4.5’).
-
#install_cmd ⇒ Object
Command to install gem from Gemcutter.
-
#uninstall_cmd ⇒ Object
Command to uninstall gem.
Constructor Details
#initialize(*args) ⇒ GemDescription
New GemDescription from a one-liner or options Hash Hubless::GemDescription.new(‘my-awesome_gem-3.4.5’) Hubless::GemDescription.new(:name => ‘my-awesome_gem’, :version => ‘3.4.5’)
20 21 22 23 24 25 26 27 28 |
# File 'lib/gem_description.rb', line 20 def initialize(*args) case args.first when String self.attributes_from_one_liner(args.first) when Hash self.name = args.first[:name] self.version = args.first[:version] end end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/gem_description.rb', line 9 def name @name end |
#version ⇒ Object
Returns the value of attribute version.
10 11 12 |
# File 'lib/gem_description.rb', line 10 def version @version end |
Class Method Details
.local_gems ⇒ Object
GemDescriptions of all gems installed locally
13 14 15 |
# File 'lib/gem_description.rb', line 13 def self.local_gems @@local_gems ||= Gem.cache.map {|g| new(g.first) }.sort!{|x,y| y.name <=> x.name } end |
Instance Method Details
#gemcutter? ⇒ Boolean
Does a gem exist on Gemcutter that matches this gem
55 56 57 58 59 60 61 |
# File 'lib/gem_description.rb', line 55 def gemcutter? if @is_gemcutter.nil? @is_gemcutter = self.gemcutter_gem_exist? else @is_gemcutter end end |
#gemcutter_name ⇒ Object
Likely name of this gem on Gemcutter (without the GitHub username)
64 65 66 |
# File 'lib/gem_description.rb', line 64 def gemcutter_name self.github? ? self.github_repo_name : self.name end |
#github? ⇒ Boolean
Does a repo exist on GitHub that matches this gem
37 38 39 40 41 42 43 |
# File 'lib/gem_description.rb', line 37 def github? if @is_github.nil? @is_github = (self.github_like? && self.github_repo_exist?) else @is_github end end |
#github_like? ⇒ Boolean
50 51 52 |
# File 'lib/gem_description.rb', line 50 def github_like? self.github_user_name && self.github_repo_name end |
#github_name ⇒ Object
Full name of this gem including GitHub username
46 47 48 |
# File 'lib/gem_description.rb', line 46 def github_name self.name if self.github_user_name end |
#install_cmd ⇒ Object
Command to install gem from Gemcutter
69 70 71 72 73 74 |
# File 'lib/gem_description.rb', line 69 def install_cmd cmd = ["gem install"] cmd << self.gemcutter_name cmd << "-v #{self.version}" if self.version cmd.join(' ') end |
#uninstall_cmd ⇒ Object
Command to uninstall gem
77 78 79 80 81 82 |
# File 'lib/gem_description.rb', line 77 def uninstall_cmd cmd = ["gem uninstall"] cmd << self.name cmd << "-v #{self.version}" if self.version cmd.join(' ') end |