lib/zold/gem.rb in zold-0.14.39 vs lib/zold/gem.rb in zold-0.14.40

- old
+ new

@@ -19,28 +19,23 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. require 'uri' -require 'net/http' require_relative 'json_page' +require_relative 'http' +require_relative 'score' # Class representing the Zold gem on Rubygems # Author:: Yegor Bugayenko (yegor256@gmail.com) # Copyright:: Copyright (c) 2018 Yegor Bugayenko # License:: MIT module Zold # Gem class Gem - BASE_URI = 'rubygems.org' - API_VERSION = '/api/v1/' - def last_version - uri = URI(API_VERSION + 'versions/zold/latest.json') - http = Net::HTTP.new(BASE_URI) - path = uri.path - path += '?' + uri.query if uri.query - res = http.request_get(path) - JsonPage.new(res.body).to_hash['version'] + JsonPage.new( + Http.new(uri: 'https://rubygems.org/api/v1/versions/zold/latest.json', score: Score::ZERO).get.body + ).to_hash['version'] end end end