mirror of
https://github.com/inspec/inspec
synced 2024-11-14 17:07:09 +00:00
4b9acb4800
* Bump Rubocop to 0.49.1 This change bumps Rubocop to 0.49.1. There have been a lot of changes since 0.39.0 and this PR is hopefully a nice compromise of turning off certain cops and updating our codebase to take advantage of new Ruby 2.3 methods and operators. Signed-off-by: Adam Leff <adam@leff.co> * Set end-of-line format to line-feed only, avoid Windows-related CRLF issues Signed-off-by: Adam Leff <adam@leff.co>
22 lines
517 B
Ruby
22 lines
517 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',
|
|
open_timeout: 0.5, read_timeout: 0.5
|
|
) { |http|
|
|
http.get(uri.path)
|
|
}
|
|
inspec_info = JSON.parse(res.body)
|
|
inspec_info['version']
|
|
rescue StandardError
|
|
nil
|
|
end
|
|
end
|