Class: Bunup::Gem

Inherits:
Object
  • Object
show all
Defined in:
lib/bunup/gem.rb

Overview

Easily access gem attributes

Constant Summary collapse

SPECIAL_CHARACTERS =
'.-_'.freeze
ALLOWED_CHARACTERS =
'[A-Za-z0-9' \
"#{Regexp.escape(SPECIAL_CHARACTERS)}]+".freeze
NAME_PATTERN =
/\A#{ALLOWED_CHARACTERS}\Z/.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: nil, installed_version: nil, newest_version: nil) ⇒ Gem

Returns a new instance of Gem.



15
16
17
18
19
20
# File 'lib/bunup/gem.rb', line 15

def initialize(name: nil, installed_version: nil, newest_version: nil)
  @name = name
  @installed_version = Values::Version.new(installed_version)
  @newest_version = Values::Version.new(newest_version)
  validate
end

Instance Attribute Details

#installed_versionObject

Returns the value of attribute installed_version.



13
14
15
# File 'lib/bunup/gem.rb', line 13

def installed_version
  @installed_version
end

#nameObject

Returns the value of attribute name.



13
14
15
# File 'lib/bunup/gem.rb', line 13

def name
  @name
end

#newest_versionObject

Returns the value of attribute newest_version.



13
14
15
# File 'lib/bunup/gem.rb', line 13

def newest_version
  @newest_version
end

Instance Method Details

#installed_from_git?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/bunup/gem.rb', line 22

def installed_from_git?
  installed_version.from_git? || newest_version.from_git?
end