diff options
| author | Zack Hobson | 2014-02-04 08:11:18 -0800 | 
|---|---|---|
| committer | Zack Hobson | 2014-02-04 08:11:18 -0800 | 
| commit | f2a4e5543eaa4024d69c271f820d34f29dc0578d (patch) | |
| tree | 86aa3b793534566befa1e70414cdda3d6a841d07 /lib | |
| parent | fedd5c7dc23996512e41a9ee4eb37bc88a640f3a (diff) | |
| download | hcl-f2a4e5543eaa4024d69c271f820d34f29dc0578d.tar.bz2 | |
commands: add status command
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/hcl/app.rb | 2 | ||||
| -rw-r--r-- | lib/hcl/commands.rb | 10 | 
2 files changed, 11 insertions, 1 deletions
| diff --git a/lib/hcl/app.rb b/lib/hcl/app.rb index 47a87af..5c98452 100644 --- a/lib/hcl/app.rb +++ b/lib/hcl/app.rb @@ -181,7 +181,7 @@ EOM      def read_settings        if File.exists? SETTINGS_FILE -        @settings = YAML.load(File.read(SETTINGS_FILE)) +        @settings = YAML.load(File.read(SETTINGS_FILE)) || {}        else          @settings = {}        end diff --git a/lib/hcl/commands.rb b/lib/hcl/commands.rb index 4156a69..3e68c2b 100644 --- a/lib/hcl/commands.rb +++ b/lib/hcl/commands.rb @@ -10,6 +10,16 @@ module HCl        http.config_hash.merge(password:'***').map {|k,v| "#{k}: #{v}" }.join("\n")      end +    # Show the network status of the Harvest service. +    def status +      result = Faraday.new("http://harveststatus.com/") do |f| +        f.use :harvest, '', '' +        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}]" +    end +      def console        Console.new(self)        nil | 
