Sha256: 88ee6c7ed6aefa39dbe6ddf46780af53b3bce77b9803d49ed17c3d97041e7bc6
Contents?: true
Size: 1.45 KB
Versions: 2
Compression:
Stored size: 1.45 KB
Contents
require 'net/http' require 'semantic' module Hobo module Lib module HostCheck def latest_hobo_version opts installed = ::Semantic::Version.new Hobo::VERSION return if installed >= get_latest_hobo_version if opts[:raise] answer = Hobo.ui.ask("A new version of hobo is available. Would you like to install it?", :default => 'y') if answer =~ /^[yY](es)?/ shell "gem install hobo-inviqa", :realtime => true Hobo.relaunch! end else raise Hobo::HostCheckError.new("A new version of hobo is available", "Install it with `gem install hobo-inviqa`") end end private def get_latest_hobo_version one_day = 3600 * 24 file = File.join(Hobo.config_path, 'latest') if !File.exists? file or File.mtime(file) < Time.now - one_day Hobo.ui.success "Checking for new hobo version..." uri = URI.parse('http://s3-eu-west-1.amazonaws.com/inviqa-hobo/version.txt') http = Net::HTTP.new(uri.host, uri.port) http.open_timeout = 5 http.read_timeout = 5 response = http.get(uri.path) if response.is_a? Net::HTTPOK File.write( file, response.body ) end end latest = File.read(file).strip if File.exists?(file) ::Semantic::Version.new(latest || Hobo::VERSION) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hobo-inviqa-0.0.9.pre.rc1 | lib/hobo/lib/host_check/hobo.rb |
hobo-inviqa-0.0.9.pre.alpha | lib/hobo/lib/host_check/hobo.rb |