lib/ssh_scan/update.rb in ssh_scan-0.0.20 vs lib/ssh_scan/update.rb in ssh_scan-0.0.21

- old
+ new

@@ -2,10 +2,11 @@ require 'ssh_scan/ssh_lib' require 'ssh_scan/version' require 'net/http' module SSHScan + # Handle {SSHScan} updates. class Update def initialize @errors = [] end @@ -31,10 +32,13 @@ major_num += 1 return [major_num.to_s, "0", "0"].join(".") end + # Returns true if the given gem version exists. + # @param version [String] version string + # @return [Boolean] true if given gem exists, else false def gem_exists?(version = SSHScan::VERSION) uri = URI("https://rubygems.org/gems/ssh_scan/versions/#{version}") begin res = Net::HTTP.get_response(uri) @@ -52,9 +56,14 @@ def errors @errors.uniq end + # Tries to check if the next patch, minor or major version + # is available or not. If so, returns true. + # @param version [String] version string + # @return [Boolean] true if next major/minor version available, + # else false def newer_gem_available?(version = SSHScan::VERSION) if gem_exists?(next_patch_version(version)) return true end