1
0
Fork 0
mirror of https://github.com/jnunemaker/httparty synced 2023-03-27 23:23:07 -04:00

removed comments that weren't needed from examples.

This commit is contained in:
John Nunemaker 2008-07-28 17:03:14 -04:00
parent 03e8213c7d
commit 06c0463102
3 changed files with 1 additions and 15 deletions

View file

@ -6,24 +6,18 @@ config = YAML::load(File.read(File.join(ENV['HOME'], '.aaws')))
module AAWS module AAWS
class Book class Book
include HTTParty include HTTParty
# sets the base url for each request
base_uri 'http://ecs.amazonaws.com' base_uri 'http://ecs.amazonaws.com'
# adds default parameters for each request
default_params :Service => 'AWSECommerceService', :Operation => 'ItemSearch', :SearchIndex => 'Books' default_params :Service => 'AWSECommerceService', :Operation => 'ItemSearch', :SearchIndex => 'Books'
# parse xml automatically
format :xml format :xml
def initialize(key) def initialize(key)
# update default params with amazon access key
self.class.default_params :AWSAccessKeyId => key self.class.default_params :AWSAccessKeyId => key
end end
def search(options={}) def search(options={})
raise ArgumentError, 'You must search for something' if options[:query].blank? raise ArgumentError, 'You must search for something' if options[:query].blank?
# amazon uses camelized query params # amazon uses nasty camelized query params
options[:query] = options[:query].inject({}) { |h, q| h[q[0].to_s.camelize] = q[1]; h } options[:query] = options[:query].inject({}) { |h, q| h[q[0].to_s.camelize] = q[1]; h }
# make a request and return the items (NOTE: this doesn't handle errors at this point) # make a request and return the items (NOTE: this doesn't handle errors at this point)

View file

@ -5,15 +5,10 @@ config = YAML::load(File.read(File.join(ENV['HOME'], '.delicious')))
class Delicious class Delicious
include HTTParty include HTTParty
# sets the base url for each request
base_uri 'https://api.del.icio.us/v1' base_uri 'https://api.del.icio.us/v1'
# parse xml automatically
format :xml format :xml
def initialize(user, pass) def initialize(user, pass)
# set basic http authentication for all requests
self.class.basic_auth(user, pass) self.class.basic_auth(user, pass)
end end

View file

@ -5,12 +5,9 @@ config = YAML::load(File.read(File.join(ENV['HOME'], '.twitter')))
class Twitter class Twitter
include HTTParty include HTTParty
# sets the base url for each request
base_uri 'twitter.com' base_uri 'twitter.com'
def initialize(user, pass) def initialize(user, pass)
# set basic http authentication for all requests
self.class.basic_auth user, pass self.class.basic_auth user, pass
end end