Class: Hubless::GemDescription
- Inherits:
-
Object
- Object
- Hubless::GemDescription
- Defined in:
- lib/gem_description.rb
Constant Summary collapse
- BLACKLIST =
File.join(File.dirname(__FILE__), '..', 'BLACKLIST.yml')
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
-
#blacklisted? ⇒ Boolean
Does this name appear on the blacklist.
-
#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’)
22 23 24 25 26 27 28 29 30 |
# File 'lib/gem_description.rb', line 22 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.
11 12 13 |
# File 'lib/gem_description.rb', line 11 def name @name end |
#version ⇒ Object
Returns the value of attribute version.
12 13 14 |
# File 'lib/gem_description.rb', line 12 def version @version end |
Class Method Details
.local_gems ⇒ Object
GemDescriptions of all gems installed locally
15 16 17 |
# File 'lib/gem_description.rb', line 15 def self.local_gems @@local_gems ||= Gem.cache.map {|g| new(g.first) }.sort!{|x,y| x.name <=> y.name } end |
Instance Method Details
#blacklisted? ⇒ Boolean
Does this name appear on the blacklist
39 40 41 |
# File 'lib/gem_description.rb', line 39 def blacklisted? ! self.class.blacklist.detect{|b| /\A#{b}\Z/i =~ self.name }.nil? end |
#gemcutter? ⇒ Boolean
Does a gem exist on Gemcutter that matches this gem
62 63 64 65 66 67 68 |
# File 'lib/gem_description.rb', line 62 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)
71 72 73 |
# File 'lib/gem_description.rb', line 71 def gemcutter_name self.github? ? self.github_repo_name : self.name end |
#github? ⇒ Boolean
Does a repo exist on GitHub that matches this gem
44 45 46 47 48 49 50 |
# File 'lib/gem_description.rb', line 44 def github? if @is_github.nil? @is_github = (self.github_like? && self.github_repo_exist?) else @is_github end end |
#github_like? ⇒ Boolean
57 58 59 |
# File 'lib/gem_description.rb', line 57 def github_like? self.github_user_name && self.github_repo_name end |
#github_name ⇒ Object
Full name of this gem including GitHub username
53 54 55 |
# File 'lib/gem_description.rb', line 53 def github_name self.name if self.github_user_name end |
#install_cmd ⇒ Object
Command to install gem from Gemcutter
76 77 78 79 80 81 |
# File 'lib/gem_description.rb', line 76 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
84 85 86 87 88 89 |
# File 'lib/gem_description.rb', line 84 def uninstall_cmd cmd = ["gem uninstall"] cmd << self.name cmd << "-v #{self.version}" if self.version cmd.join(' ') end |