Class: GemItem
Overview
gemItem is created from gem command output in command line
and used for inserting item to Qt::TableWidget.
Instance Attribute Summary collapse
-
#author ⇒ Object
(also: #authors)
Returns the value of attribute author.
-
#downloads ⇒ Object
Returns the value of attribute downloads.
-
#filePath ⇒ Object
readonly
Returns the value of attribute filePath.
-
#homepage ⇒ Object
Returns the value of attribute homepage.
-
#package ⇒ Object
(also: #name)
Returns the value of attribute package.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#rubyforge ⇒ Object
Returns the value of attribute rubyforge.
-
#spec ⇒ Object
Returns the value of attribute spec.
-
#status ⇒ Object
Returns the value of attribute status.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
- .getGemfromCache(filePath) ⇒ Object
- .getGemfromPath(path) ⇒ Object
- .parseGemSpec(spec) ⇒ Object
- .parseHashGem(hGem) ⇒ Object
Instance Method Summary collapse
- #addLocalPath(filePath) ⇒ Object
-
#availableVersions ⇒ Object
available versions at remote server.
-
#initialize(pkg_and_ver, ver = nil) ⇒ GemItem
constructor
A new instance of GemItem.
- #installedLocal? ⇒ Boolean
-
#nowVersion ⇒ Object
return versoin knowing newest, not latest.
Constructor Details
#initialize(pkg_and_ver, ver = nil) ⇒ GemItem
Returns a new instance of GemItem.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gemitem.rb', line 20 def initialize(pkg_and_ver, ver=nil) if ver.nil? pkg, ver = pkg_and_ver.split(/ /, 2) ver.tr!('()', '') ver.strip! else pkg = pkg_and_ver end @package = pkg @version = ver @author = '' @rubyforge = '' @homepage = '' @platform = '' @summary = '' @spec = nil @downloads = 0 end |
Instance Attribute Details
#author ⇒ Object Also known as:
Returns the value of attribute author.
16 17 18 |
# File 'lib/gemitem.rb', line 16 def @author end |
#downloads ⇒ Object
Returns the value of attribute downloads.
17 18 19 |
# File 'lib/gemitem.rb', line 17 def downloads @downloads end |
#filePath ⇒ Object (readonly)
Returns the value of attribute filePath.
39 40 41 |
# File 'lib/gemitem.rb', line 39 def filePath @filePath end |
#homepage ⇒ Object
Returns the value of attribute homepage.
16 17 18 |
# File 'lib/gemitem.rb', line 16 def homepage @homepage end |
#package ⇒ Object Also known as: name
Returns the value of attribute package.
16 17 18 |
# File 'lib/gemitem.rb', line 16 def package @package end |
#platform ⇒ Object
Returns the value of attribute platform.
16 17 18 |
# File 'lib/gemitem.rb', line 16 def platform @platform end |
#rubyforge ⇒ Object
Returns the value of attribute rubyforge.
16 17 18 |
# File 'lib/gemitem.rb', line 16 def rubyforge @rubyforge end |
#spec ⇒ Object
Returns the value of attribute spec.
17 18 19 |
# File 'lib/gemitem.rb', line 17 def spec @spec end |
#status ⇒ Object
Returns the value of attribute status.
17 18 19 |
# File 'lib/gemitem.rb', line 17 def status @status end |
#summary ⇒ Object
Returns the value of attribute summary.
17 18 19 |
# File 'lib/gemitem.rb', line 17 def summary @summary end |
#version ⇒ Object
Returns the value of attribute version.
16 17 18 |
# File 'lib/gemitem.rb', line 16 def version @version end |
Class Method Details
.getGemfromCache(filePath) ⇒ Object
93 94 95 96 97 98 |
# File 'lib/gemitem.rb', line 93 def self.getGemfromCache(filePath) res = %x{ tar xf #{filePath.shellescape} metadata.gz -O | gunzip -c } return nil if res.empty? spec = YAML::load(res) GemItem::parseGemSpec(spec) end |
.getGemfromPath(path) ⇒ Object
86 87 88 89 90 91 |
# File 'lib/gemitem.rb', line 86 def self.getGemfromPath(path) res = %x{ gem specification #{path} -b --marshal } return nil if res.empty? spec = Marshal.load(res) GemItem::parseGemSpec(spec) end |
.parseGemSpec(spec) ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/gemitem.rb', line 77 def self.parseGemSpec(spec) gem = self.new(spec.name, spec.version.to_s) gem. = spec. || '' gem.homepage = spec.homepage || '' gem.summary = spec.summary || '' gem.spec = spec gem end |
.parseHashGem(hGem) ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/gemitem.rb', line 68 def self.parseHashGem(hGem) gem = self.new(hGem['name'], hGem['version'].to_s) gem. = hGem['authors'] gem.homepage = hGem['homepage_uri'] gem.downloads = hGem['downloads'] gem.summary = hGem['info'] gem end |
Instance Method Details
#addLocalPath(filePath) ⇒ Object
40 41 42 |
# File 'lib/gemitem.rb', line 40 def addLocalPath(filePath) @filePath = filePath end |
#availableVersions ⇒ Object
available versions at remote server.
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/gemitem.rb', line 50 def availableVersions return @versions if instance_variable_defined? :@versions res = %x{ gem list #{name} -a -r } res =~ /#{Regexp.escape(name)}\s+\(([^\)]+)\)/ res = $1.split(/,\s+/).map { |v| v.split(/ /).first.strip } if res then @versions = res else @versions = nil end end |
#installedLocal? ⇒ Boolean
63 64 65 66 |
# File 'lib/gemitem.rb', line 63 def installedLocal? res = %x{ gem query -l -d -n '^#{@package}$' } res =~ /#{@package}/ and res =~ %r? /home/? end |
#nowVersion ⇒ Object
return versoin knowing newest, not latest.
45 46 47 |
# File 'lib/gemitem.rb', line 45 def nowVersion version.split(/,/, 2).first end |