Class: GemUpdateChecker::Client
- Inherits:
-
Object
- Object
- GemUpdateChecker::Client
- Defined in:
- lib/gem_update_checker/client.rb
Constant Summary collapse
- RUBYGEMS_API =
"https://rubygems.org/api/v1/versions"
Instance Attribute Summary collapse
-
#current_version ⇒ Object
readonly
Returns the value of attribute current_version.
-
#gem_name ⇒ Object
readonly
Returns the value of attribute gem_name.
-
#latest_version ⇒ Object
readonly
Returns the value of attribute latest_version.
-
#update_available ⇒ Object
readonly
Returns the value of attribute update_available.
Instance Method Summary collapse
-
#initialize(gem_name, current_vesion) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(gem_name, current_vesion) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/gem_update_checker/client.rb', line 7 def initialize(gem_name, current_vesion) @gem_name = gem_name @current_version = current_vesion uri = URI("#{RUBYGEMS_API}/#{@gem_name}/latest.json") respose = Net::HTTP.get_response uri json = JSON.parse(respose.body) @latest_version = json["version"] @update_available = @latest_version && Gem::Version.new(@latest_version) > Gem::Version.new(@current_version) end |
Instance Attribute Details
#current_version ⇒ Object (readonly)
Returns the value of attribute current_version.
4 5 6 |
# File 'lib/gem_update_checker/client.rb', line 4 def current_version @current_version end |
#gem_name ⇒ Object (readonly)
Returns the value of attribute gem_name.
4 5 6 |
# File 'lib/gem_update_checker/client.rb', line 4 def gem_name @gem_name end |
#latest_version ⇒ Object (readonly)
Returns the value of attribute latest_version.
4 5 6 |
# File 'lib/gem_update_checker/client.rb', line 4 def latest_version @latest_version end |
#update_available ⇒ Object (readonly)
Returns the value of attribute update_available.
4 5 6 |
# File 'lib/gem_update_checker/client.rb', line 4 def update_available @update_available end |