Sha256: bb46ac5b976994dab5619ad6b53b4875d29d85ea8143f3a49e5a635f179cdf83
Contents?: true
Size: 752 Bytes
Versions: 1
Compression:
Stored size: 752 Bytes
Contents
require 'net/http' require 'json' require 'yaml' module Soaring class Detailer def initialize(options) @options = options end def detail url = URI.parse(@options[:url]) req = Net::HTTP::Get.new(url.to_s) res = Net::HTTP.start(url.host, url.port) {|http| http.request(req) } if '200' != res.code $stderr.puts "Failed to connect with http error code #{res.code}" exit 1 end puts JSON.parse(res.body) if 'json' == @options[:format] print JSON.parse(res.body).to_yaml if 'yaml' == @options[:format] rescue StandardError => exception message = "#{exception.class}: #{exception.message}" $stderr.puts "#{message}" exit 1 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
soaring-0.1.16 | lib/soaring/detailer.rb |