class Uri::Health::Status

Public Class Methods

new(path_to_yaml) click to toggle source
# File lib/uri/health/status.rb, line 7
def initialize(path_to_yaml)
  @uris = YAML.load_file(path_to_yaml)
end

Public Instance Methods

go() click to toggle source
# File lib/uri/health/status.rb, line 11
def go
  responses = {}
  @uris.each do |uri|
    responses.merge!({uri => HTTParty.get(uri).code})
  end

  output_json(responses)
  responses
end
output_json(output) click to toggle source
# File lib/uri/health/status.rb, line 21
def output_json(output)
  Dir.mkdir 'uri-health' unless File.directory? 'uri-health'
  File.open('uri-health/last_run.json', 'w') do |f|
    f.write(output.to_json)
  end
end