Class: BundleOutdated::GemDependency

Inherits:
Object
  • Object
show all
Defined in:
lib/bundle_outdated/gem_dependency.rb

Constant Summary collapse

VERSION_REGEXP =
/^(['"])([!~><=]*)\s*(.+?)\1$/
GEMNAME_REGEXP =
/gem\s(['"])(.+?)\1/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gemfile_string) ⇒ GemDependency

Returns a new instance of GemDependency.



8
9
10
# File 'lib/bundle_outdated/gem_dependency.rb', line 8

def initialize(gemfile_string)
  self.name, self.version = gemfile_string.split(/,\s*/)
end

Instance Attribute Details

#handwavingObject (readonly)

Returns the value of attribute handwaving.



3
4
5
# File 'lib/bundle_outdated/gem_dependency.rb', line 3

def handwaving
  @handwaving
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/bundle_outdated/gem_dependency.rb', line 3

def name
  @name
end

#versionObject

Returns the value of attribute version.



3
4
5
# File 'lib/bundle_outdated/gem_dependency.rb', line 3

def version
  @version
end

Instance Method Details

#handwaving?Boolean

Returns:

  • (Boolean)


27
# File 'lib/bundle_outdated/gem_dependency.rb', line 27

def handwaving?; !!handwaving; end

#latest_versionObject



33
34
35
# File 'lib/bundle_outdated/gem_dependency.rb', line 33

def latest_version
  @latest_version ||= Gem.latest_version_for(name)
end

#outdated?Boolean

Returns:

  • (Boolean)


37
38
39
40
# File 'lib/bundle_outdated/gem_dependency.rb', line 37

def outdated?
  return false unless version && latest_version
  version < latest_version
end

#to_sObject



29
30
31
# File 'lib/bundle_outdated/gem_dependency.rb', line 29

def to_s
  "#{name}, Version: #{ version || 'Any' }"
end