Class: GemItem
- Inherits:
-
Object
- Object
- GemItem
- Defined in:
- lib/gemitem.rb
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
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.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/gemitem.rb', line 19 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 = '' @rubyforge = '' @homepage = '' @platform = '' @summary = '' @spec = nil @downloads = 0 end |
Instance Attribute Details
#author ⇒ Object Also known as:
Returns the value of attribute author.
15 16 17 |
# File 'lib/gemitem.rb', line 15 def end |
#downloads ⇒ Object
Returns the value of attribute downloads.
16 17 18 |
# File 'lib/gemitem.rb', line 16 def downloads @downloads end |
#filePath ⇒ Object (readonly)
Returns the value of attribute filePath.
38 39 40 |
# File 'lib/gemitem.rb', line 38 def filePath @filePath end |
#homepage ⇒ Object
Returns the value of attribute homepage.
15 16 17 |
# File 'lib/gemitem.rb', line 15 def homepage @homepage end |
#package ⇒ Object Also known as: name
Returns the value of attribute package.
15 16 17 |
# File 'lib/gemitem.rb', line 15 def package @package end |
#platform ⇒ Object
Returns the value of attribute platform.
15 16 17 |
# File 'lib/gemitem.rb', line 15 def platform @platform end |
#rubyforge ⇒ Object
Returns the value of attribute rubyforge.
15 16 17 |
# File 'lib/gemitem.rb', line 15 def rubyforge @rubyforge end |
#spec ⇒ Object
Returns the value of attribute spec.
16 17 18 |
# File 'lib/gemitem.rb', line 16 def spec @spec end |
#status ⇒ Object
Returns the value of attribute status.
16 17 18 |
# File 'lib/gemitem.rb', line 16 def status @status end |
#summary ⇒ Object
Returns the value of attribute summary.
16 17 18 |
# File 'lib/gemitem.rb', line 16 def summary @summary end |
#version ⇒ Object
Returns the value of attribute version.
15 16 17 |
# File 'lib/gemitem.rb', line 15 def version @version end |
Class Method Details
.getGemfromPath(path) ⇒ Object
85 86 87 88 89 90 |
# File 'lib/gemitem.rb', line 85 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
76 77 78 79 80 81 82 83 |
# File 'lib/gemitem.rb', line 76 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
67 68 69 70 71 72 73 74 |
# File 'lib/gemitem.rb', line 67 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
39 40 41 |
# File 'lib/gemitem.rb', line 39 def addLocalPath(filePath) @filePath = filePath end |
#availableVersions ⇒ Object
available versions at remote server.
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/gemitem.rb', line 49 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
62 63 64 65 |
# File 'lib/gemitem.rb', line 62 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.
44 45 46 |
# File 'lib/gemitem.rb', line 44 def nowVersion version.split(/,/, 2).first end |