class Ayadn::CheckADN

Public Instance Methods

check() click to toggle source
# File lib/ayadn/diagnostics.rb, line 109
def check
  begin
    check_root_api
    @status.say_header "checking ADN server response"
    get_response "#{@baseURL}/config"
    check_response_code
    body = JSON.parse(@response.body)
    if body.blank? || body["data"].blank?
      @status.say_red(:config, "no data")
    else
      @status.say_green(:config, "OK")
    end
  rescue => e
    rescue_network(e)
  end
end

Private Instance Methods

check_root_api() click to toggle source
# File lib/ayadn/diagnostics.rb, line 128
def check_root_api
  @status.say_header("default root API endpoint")
  api_file = Dir.home + "/ayadn/.api.yml"
  @baseURL = if File.exist?(api_file)
    YAML.load(File.read(api_file))[:root]
  else
    "https://api.app.net"
  end
  @status.say_green(:url, @baseURL)
end