Class: Rbcli::Autoupdate::GemUpdater
- Inherits:
-
Object
- Object
- Rbcli::Autoupdate::GemUpdater
- Includes:
- Common
- Defined in:
- lib/rbcli/features/autoupdate/gem_updater.rb
Instance Method Summary collapse
- #get_latest_version ⇒ Object
-
#initialize(gemname, force_update, message) ⇒ GemUpdater
constructor
A new instance of GemUpdater.
- #update_message ⇒ Object
Methods included from Common
#show_message, #update_available?
Constructor Details
#initialize(gemname, force_update, message) ⇒ GemUpdater
Returns a new instance of GemUpdater.
29 30 31 32 33 34 |
# File 'lib/rbcli/features/autoupdate/gem_updater.rb', line 29 def initialize gemname, force_update, @gemname = gemname @uri = URI.parse "https://rubygems.org/api/v1/versions/#{gemname}/latest.json" @force_update = force_update @message = end |
Instance Method Details
#get_latest_version ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/rbcli/features/autoupdate/gem_updater.rb', line 36 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
45 46 47 |
# File 'lib/rbcli/features/autoupdate/gem_updater.rb', line 45 def "Please run `gem update #{@gemname}` to upgrade to the latest version. You can see it at: https://rubygems.org/gems/#{@gemname}/versions/#{@latest_version}" end |