mirror of
https://github.com/inspec/inspec
synced 2024-12-19 17:43:44 +00:00
f0cdad800f
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
20 lines
525 B
Ruby
20 lines
525 B
Ruby
# encoding: utf-8
|
|
# author: Christoph Hartmann
|
|
|
|
require 'json'
|
|
require 'net/http'
|
|
|
|
class LatestInSpecVersion
|
|
# fetches the latest version from rubygems server
|
|
def latest
|
|
uri = URI('https://rubygems.org/api/v1/gems/inspec.json')
|
|
res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') {|http|
|
|
http.read_timeout = 0.5
|
|
http.get(uri.path)
|
|
}
|
|
inspec_info = JSON.parse(res.body)
|
|
inspec_info['version']
|
|
rescue Exception # rubocop:disable Lint/RescueException
|
|
nil
|
|
end
|
|
end
|