Class: Bunup::Gem

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

Overview

Easily access gem attributes

Constant Summary collapse

SPECIAL_CHARACTERS =
'.-_'
ALLOWED_CHARACTERS =
'[A-Za-z0-9' \
"#{Regexp.escape(SPECIAL_CHARACTERS)}]+"
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.



17
18
19
20
21
22
# File 'lib/bunup/gem.rb', line 17

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.



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

def installed_version
  @installed_version
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#newest_versionObject

Returns the value of attribute newest_version.



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

def newest_version
  @newest_version
end

Instance Method Details

#installed_from_git?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/bunup/gem.rb', line 24

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