Class: Amazon::Awis
- Inherits:
-
Object
- Object
- Amazon::Awis
- Defined in:
- lib/awis-wrapper.rb
Defined Under Namespace
Constant Summary collapse
- NAMESPACE =
{:aws => "http://awis.amazonaws.com/doc/2005-07-11"}
- AWIS_DOMAIN =
'awis.amazonaws.com'
- @@options =
{ :action => "UrlInfo", :responsegroup => "Rank" }
- @@debug =
false
Class Method Summary collapse
- .camel_case(str) ⇒ Object
- .configure {|@@options| ... } ⇒ Object
-
.debug ⇒ Object
Get debug flag.
-
.debug=(dbg) ⇒ Object
Set debug flag to true or false.
- .get_batch_info(domains) ⇒ Object
- .get_info(domain) ⇒ Object
-
.options ⇒ Object
Default service options.
-
.options=(opts) ⇒ Object
Set default service options.
Class Method Details
.camel_case(str) ⇒ Object
70 71 72 73 74 |
# File 'lib/awis-wrapper.rb', line 70 def self.camel_case(str) return str if str !~ /_/ && str =~ /[A-Z]+.*/ str.split('_').map{|e| e.capitalize}.join # str.split('_').each_with_index.map { |v,i| v.capitalize }.join end |
.configure {|@@options| ... } ⇒ Object
76 77 78 79 |
# File 'lib/awis-wrapper.rb', line 76 def self.configure(&proc) raise ArgumentError, "Block is required." unless block_given? yield @@options end |
.debug ⇒ Object
Get debug flag.
61 62 63 |
# File 'lib/awis-wrapper.rb', line 61 def self.debug @@debug end |
.debug=(dbg) ⇒ Object
Set debug flag to true or false.
66 67 68 |
# File 'lib/awis-wrapper.rb', line 66 def self.debug=(dbg) @@debug = dbg end |
.get_batch_info(domains) ⇒ Object
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/awis-wrapper.rb', line 92 def self.get_batch_info(domains) url = self.batch_urls(domains) log "Request URL: #{url}" res = Net::HTTP.get_response(url) unless res.kind_of? Net::HTTPSuccess raise Amazon::RequestError, "HTTP Response: #{res.code} #{res.} #{res.body}" end log "Response text: #{res.body}" Response.new(res.body) end |
.get_info(domain) ⇒ Object
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/awis-wrapper.rb', line 81 def self.get_info(domain) url = self.prepare_url(domain) log "Request URL: #{url}" res = Net::HTTP.get_response(url) unless res.kind_of? Net::HTTPSuccess raise Amazon::RequestError, "HTTP Response: #{res.code} #{res.} #{res.body}" end log "Response text: #{res.body}" Response.new(res.body) end |
.options ⇒ Object
Default service options
51 52 53 |
# File 'lib/awis-wrapper.rb', line 51 def self. @@options end |
.options=(opts) ⇒ Object
Set default service options
56 57 58 |
# File 'lib/awis-wrapper.rb', line 56 def self.(opts) @@options = opts end |