Class: Deproll::ProjectGem

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/deproll.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#file

Constructor Details

#initialize(gemspec) ⇒ ProjectGem

Returns a new instance of ProjectGem.


79
80
81
# File 'lib/deproll.rb', line 79

def initialize(gemspec)
  @gemspec = gemspec
end

Instance Attribute Details

#gemspecObject (readonly)

Returns the value of attribute gemspec


77
78
79
# File 'lib/deproll.rb', line 77

def gemspec
  @gemspec
end

Instance Method Details

#libObject


104
105
106
# File 'lib/deproll.rb', line 104

def lib
  gemspec.lib
end

#nameObject


96
97
98
# File 'lib/deproll.rb', line 96

def name
  gemspec.name
end

#requirementObject


92
93
94
# File 'lib/deproll.rb', line 92

def requirement
  gemspec.requirement
end

#sourceObject


100
101
102
# File 'lib/deproll.rb', line 100

def source
  gemspec.source || Gem.sources.first
end

#to_hashObject


83
84
85
86
87
88
89
90
# File 'lib/deproll.rb', line 83

def to_hash
  { :name               => name.to_s,
    :current_version    => version.to_s,
    :available_version  => latest_version.to_s,
    :source             => source.to_s,
    :lib                => lib.to_s,
    :requirement        => requirement.to_s }
end

#to_sObject


113
114
115
116
117
118
119
120
# File 'lib/deproll.rb', line 113

def to_s
  case
    when vendored? then  "#{name} is #{version} (vendored), can be updated to #{latest_version} from #{source}"
    when installed? then "#{name} is #{version} (installed), can be updated to #{latest_version} from #{source}"
  else
    "#{name} is not yet installed. Version #{latest_version} is available on #{source}"
  end
end

#updateable?Boolean

Returns:

  • (Boolean)

108
109
110
111
# File 'lib/deproll.rb', line 108

def updateable?
  return false if available_versions.empty?
  latest_version > version
end

#versionObject


122
123
124
125
126
127
128
129
# File 'lib/deproll.rb', line 122

def version
  case
    when vendored? then vendored_version
    when installed? then installed_version
    else
      '0'
    end
end