Module: Alexa

Defined in:
lib/alexa.rb,
lib/alexa/config.rb,
lib/alexa/url_info.rb,
lib/alexa/container.rb,
lib/alexa/url_info/usage.rb,
lib/alexa/traffic_history.rb,
lib/alexa/sites_linking_in.rb,
lib/alexa/url_info/related.rb,
lib/alexa/url_info/categories.rb,
lib/alexa/sites_linking_in/site.rb,
lib/alexa/url_info/contact_info.rb,
lib/alexa/url_info/content_data.rb,
lib/alexa/url_info/traffic_data.rb,
lib/alexa/traffic_history/historical_data.rb,
lib/alexa/url_info/contributing_subdomains.rb

Defined Under Namespace

Modules: Container Classes: Config, SitesLinkingIn, TrafficHistory, UrlInfo

Constant Summary collapse

SERVICE_HOST =
'awis.amazonaws.com'

Class Method Summary collapse

Class Method Details

.configObject



9
10
11
12
13
14
# File 'lib/alexa/config.rb', line 9

def self.config
  if block_given?
    yield Config.instance
  end
  Config.instance
end

.query_string(options) ⇒ Object



20
21
22
# File 'lib/alexa.rb', line 20

def self.query_string(options)
  options.keys.sort.map { |k| k + '=' + self.uri_escape(options[k].to_s) }.join('&')
end

.sign(options) ⇒ Object



24
25
26
27
# File 'lib/alexa.rb', line 24

def self.sign(options)
  sign_str  = "GET\n" + SERVICE_HOST + "\n/\n" + query_string(options)
  self.uri_escape(Base64.encode64( OpenSSL::HMAC.digest( OpenSSL::Digest::Digest.new( "sha256" ), Alexa.config.secret_access_key, sign_str)).strip)
end

.uri_escape(input) ⇒ Object



16
17
18
# File 'lib/alexa.rb', line 16

def self.uri_escape(input)
  URI.escape(input, /[^A-Za-z0-9\-_.~]/)
end