Method: Blufin::SiteResolver.validate_site

Defined in:
lib/core/site/site_resolver.rb

.validate_site(site, location = true) ⇒ Object

Checks if the site exists and takes ‘aliases’ into account. Throws ERROR if site doesn’ts exist.

Returns:

  • String



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/core/site/site_resolver.rb', line 61

def self.validate_site(site, location = true)
    if @site_valid[site].nil?
        sitemap = get_sitemap
        if !sitemap.keys.include?(site) || site.nil?
            Blufin::Terminal::error("An API by the name \"#{Blufin::Terminal::format_highlight(site.nil? ? '[nil]' : site)}\" cannot be found \xe2\x80\x94 available APIs are:", get_available_apis, true)
        else
            validate_location(get_sitemap[site][:site_location]) if location
            validate_ports_internal(get_sitemap[site][:site_ports].port_range_raw)
            @site_valid[site] = true
            site
        end
    else
        site
    end
end