Class: Rbcli::Autoupdate::GemUpdater
- Inherits:
-
Object
- Object
- Rbcli::Autoupdate::GemUpdater
- Includes:
- Common
- Defined in:
- lib/rbcli/autoupdate/gem_updater.rb
Instance Method Summary collapse
- #get_latest_version ⇒ Object
-
#initialize(gemname, force_update) ⇒ GemUpdater
constructor
A new instance of GemUpdater.
- #update_message ⇒ Object
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_version ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/rbcli/autoupdate/gem_updater.rb', line 14 def get_latest_version begin response = Net::HTTP.get(@uri) JSON.parse(response)['version'] rescue SocketError => e # Capture connection errors end end |
#update_message ⇒ Object
23 24 25 |
# File 'lib/rbcli/autoupdate/gem_updater.rb', line 23 def "Please check the Ruby gem #{@gemname} for instructions. You can see it at: https://rubygems.org/gems/#{@gemname}/versions/#{@latest_version}" end |