Class: Rbcli::Autoupdate::GemUpdater

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/rbcli/autoupdate/gem_updater.rb

Instance Method Summary collapse

Methods included from Common

#show_message, #update_available?

Constructor Details

#initialize(gemname, force_update) ⇒ GemUpdater

Returns a new instance of GemUpdater.



8
9
10
11
12
# File 'lib/rbcli/autoupdate/gem_updater.rb', line 8

def initialize gemname, force_update
	@gemname = gemname
	@uri = URI.parse "https://rubygems.org/api/v1/versions/#{gemname}/latest.json"
	@force_update = force_update
end

Instance Method Details

#get_latest_versionObject



14
15
16
17
# File 'lib/rbcli/autoupdate/gem_updater.rb', line 14

def get_latest_version
	response = Net::HTTP.get(@uri)
	JSON.parse(response)['version']
end

#update_messageObject



19
20
21
# File 'lib/rbcli/autoupdate/gem_updater.rb', line 19

def update_message
	"Please check the Ruby gem #{@gemname} for instructions. You can see it at: https://rubygems.org/gems/#{@gemname}/versions/#{@latest_version}"
end