diff options
| author | Lorenzo Manacorda | 2015-06-03 21:16:27 +0200 |
|---|---|---|
| committer | Lorenzo Manacorda | 2015-06-03 21:16:27 +0200 |
| commit | 7c025df3c27c3090417d2fdbb174ad0942e24d86 (patch) | |
| tree | 984feaadba0a58cfc7a0ee73636ffdb884178c16 | |
| parent | 4e7b486093d85d52083f93d6bb68ae5584351473 (diff) | |
| download | hcl-7c025df3c27c3090417d2fdbb174ad0942e24d86.tar.bz2 | |
parse and output response
| -rw-r--r-- | lib/hcl/commands.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/hcl/commands.rb b/lib/hcl/commands.rb index 7a1d124..9800c95 100644 --- a/lib/hcl/commands.rb +++ b/lib/hcl/commands.rb @@ -15,8 +15,12 @@ module HCl result = Faraday.new("http://kccljmymlslr.statuspage.io/api/v2") do |f| f.adapter Faraday.default_adapter end.get('status.json').body - date = Time.at(result[:last_check_time].to_i) - "Harvest is #{result[:status]}, response time: #{result[:last_response_time]}ms. [#{date}]" + + json = Yajl::Parser.parse result, symbolize_keys: true + status = json[:status][:description] + updated_at = DateTime.parse(json[:page][:updated_at]).strftime "%F %T %:z" + + "#{status} [#{updated_at}]" end def console |
