Permalink
Browse files

merge

  • Loading branch information...
2 parents 4d3a19d + 1b15a05 commit 5a960ff53da1a8da4734b8437cb7ea9f3cf1ff47 @phoet phoet committed Oct 28, 2010
Showing with 18 additions and 31 deletions.
  1. +0 −4 .gems
  2. +7 −17 README.rdoc
  3. +4 −5 asin.gemspec
  4. +7 −5 lib/asin.rb
View
4 .gems
@@ -1,4 +0,0 @@
-crack --version 0.1.7
-hashie --version 0.2.1
-httpclient --version 2.1.5.2
-mocha --version 0.9.8
View
24 README.rdoc
@@ -1,18 +1,6 @@
-= Introduction
-
-There is already a sophisticated amazon gem out there called ruby-aaws[http://raa.ruby-lang.org/project/ruby-aws/], but ASIN in comparison is _reaaaaaaaaaly_ easy to use!
-
-It currently just supports the _ItemLookup_ via REST but is easy to extend and understand!
-
-Have a look at the RDOC[http://rdoc.info/projects/phoet/asin] for this project, if you want further information.
-
-For more information on the REST calls, have a look at the whole Amazon E-Commerce-API[http://docs.amazonwebservices.com/AWSEcommerceService/4-0/].
-
-The code currently runs only on Ruby-1.9 due to encoding issues with the Amazon REST output (if *YOU* know how to backport this, you are welcome!).
-
== Installation
-The gem is tested only against 1.9.1 (to be compatible with Heroku Bamboo Stack) and requires Ruby 1.9 or higher.
+The gem is tested against 1.9.1 and 1.8.7 (compatibility with Heroku-Bamboo-Stack[http://docs.heroku.com/stack]) and runs smoothly with Rails 3.
rvm use 1.9.1
gem install asin
@@ -36,8 +24,10 @@ The gem is tested only against 1.9.1 (to be compatible with Heroku Bamboo Stack)
item.raw.ItemAttributes.ListPrice.FormattedPrice
=> $39.99
-== TODO
+== Infos
+
+Have a look at the RDOC[http://rdoc.info/projects/phoet/asin] for this project, if you want further information.
+
+For more information on the REST calls, have a look at the whole Amazon E-Commerce-API[http://docs.amazonwebservices.com/AWSEcommerceService/4-0/].
- * Logging
- * More Docs
- * More Tests
+The code currently runs best on Ruby-1.9 due to encoding issues with the Amazon REST output (if *YOU* know how to backport this to 1.8.7, you are welcome!).
View
9 asin.gemspec
@@ -2,7 +2,7 @@
spec = Gem::Specification.new do |s|
s.name = 'asin'
- s.version = '0.0.7'
+ s.version = '0.0.8'
s.author = 'Peter Schröder'
s.description = 'Amazon Simple INterface or whatever you want to call this.'
@@ -16,9 +16,8 @@ spec = Gem::Specification.new do |s|
s.files = Dir.glob('lib/*.rb') + %w(README.rdoc)
s.test_files = Dir.glob('test/test_*.rb')
- # trying not to be too restrictive...
- s.add_dependency('crack', '>= 0.1.0')
- s.add_dependency('hashie', '>= 0.2.0')
- s.add_dependency('httpclient', '>= 2.1.0')
+ s.add_dependency('crack', '~> 0.1.7')
+ s.add_dependency('hashie', '~> 0.2.1')
+ s.add_dependency('httpclient', '~> 2.1.5.2')
end
View
12 lib/asin.rb
@@ -25,7 +25,8 @@
#
# configure :secret => 'your-secret', :key => 'your-key'
#
-# After configuring your environment you can call the +lookup+ method to retrieve an +Item+ via the Amazon Standard Identification Number (ASIN):
+# After configuring your environment you can call the +lookup+ method to retrieve an +Item+ via the
+# Amazon Standard Identification Number (ASIN):
#
# item = lookup '1430218150'
# item.title
@@ -38,7 +39,8 @@
#
# ==Further Configuration
#
-# If you need more controll over the request that is sent to the Amazon API (http://docs.amazonwebservices.com/AWSEcommerceService/4-0/),
+# If you need more controll over the request that is sent to the
+# Amazon API (http://docs.amazonwebservices.com/AWSEcommerceService/4-0/),
# you can override some defaults or add additional query-parameters to the REST calls:
#
# configure :host => 'webservices.amazon.de'
@@ -130,12 +132,12 @@ def create_signed_query_string(params)
params[:AWSAccessKeyId] = @options[:key]
# utc timestamp needed for signing
params[:Timestamp] = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
-
+ # signing needs to order the query alphabetically
query = params.map{|key, value| "#{key}=#{CGI.escape(value.to_s)}" }.sort.join('&')
-
+ # yeah, you really need to sign the get-request not the query
request_to_sign = "GET\n#{@options[:host]}\n#{@options[:path]}\n#{query}"
hmac = OpenSSL::HMAC.digest(@options[:digest], @options[:secret], request_to_sign)
-
+ # don't forget to remove the newline from base64
signature = CGI.escape(Base64.encode64(hmac).chomp)
"#{query}&Signature=#{signature}"
end

0 comments on commit 5a960ff

Please sign in to comment.