Permalink
Browse files

Upgraded to ecs 0.5.6 to enable authenticating calls

  • Loading branch information...
scottned committed Jul 21, 2009
1 parent dc3161f commit a082c3204d3477202bd8579c0b1f7a9b21bf85ae
Showing with 43 additions and 63 deletions.
  1. +8 −0 CHANGELOG
  2. +1 −38 Rakefile
  3. +1 −1 VERSION
  4. +3 −3 acts_as_amazon_product.gemspec
  5. +11 −5 lib/acts_as_amazon_product.rb
  6. +19 −16 test/acts_as_amazon_product_test.rb
View
@@ -1,3 +1,11 @@
+= 2.1
+=== 20th July, 2009
+* Support for authenticated calls to Amazon
+
+= 2.0
+=== 18th June, 2009
+* Setup with Jeweler for packaging and deployment
+
= 1.4
=== 11th October, 2008
* Added load_from_amazon and load_from_amazon! methods to load up Amazon attributes into a local object directly (see the README for usage)
View
@@ -8,9 +8,6 @@ require 'fileutils'
include FileUtils
NAME = "acts_as_amazon_product"
-# REV = File.read(".svn/entries")[/committed-rev="(\d+)"/, 1] rescue nil
-# VERS = ENV['VERSION'] || ("1.1" + (REV ? ".#{REV}" : ""))
-VERS = ENV['VERSION'] || "1.4.1"
CLEAN.include ['**/.*.sw?', '*.gem', '.config', 'test/test.log']
desc 'Default: run unit tests.'
@@ -26,40 +23,6 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_files.include('lib/**/*.rb')
end
-# Gem::manage_gems
-# require 'rake/gempackagetask'
-# spec = Gem::Specification.new do |s|
-# s.platform = Gem::Platform::RUBY
-# s.name = NAME
-# s.version = VERS
-# s.author = "Scott Nedderman"
-# s.email = "scott@netphase.com"
-# s.homepage = "http://netphase.com"
-# s.summary = "A package for simplifying use of the Amazon/ECS API"
-# s.files = FileList['lib/*.rb', 'test/*'].to_a.reject {|f| f.match /config\.yml/ }
-# s.require_path = "lib"
-# # s.autorequire = "acts_as_amazon_product"
-# s.test_files = Dir.glob('tests/*.rb')
-# s.has_rdoc = true
-# s.extra_rdoc_files = ["README"]
-# s.add_dependency("amazon-ecs", ">=0.5.1")
-# end
-# Rake::GemPackageTask.new(spec) do |pkg|
-# pkg.need_tar = true
-# end
-# task :default => "pkg/#{spec.name}-#{spec.version}.gem" do
-# puts "generated latest version"
-# end
-#
-# task :install do
-# sh %{rake package}
-# sh %{sudo gem install pkg/#{NAME}-#{VERS}}
-# end
-#
-# task :uninstall => [:clean] do
-# sh %{sudo gem uninstall #{NAME}}
-# end
-
desc 'Test the acts_as_amazon_product plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
@@ -75,7 +38,7 @@ begin
gemspec.email = "scott@netphase.com"
gemspec.homepage = "http://github.com/netphase/aaap"
gemspec.authors = ["Scott Nedderman","Chris Beck"]
- gemspec.add_dependency("amazon-ecs", ">=0.5.1")
+ gemspec.add_dependency("amazon-ecs", ">=0.5.6")
gemspec.files.exclude 'test/config.yml'
end
View
@@ -1 +1 @@
-2.0.0
+2.1.0
@@ -47,11 +47,11 @@ Gem::Specification.new do |s|
s.specification_version = 2
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<amazon-ecs>, [">= 0.5.1"])
+ s.add_runtime_dependency(%q<amazon-ecs>, [">= 0.5.6"])
else
- s.add_dependency(%q<amazon-ecs>, [">= 0.5.1"])
+ s.add_dependency(%q<amazon-ecs>, [">= 0.5.6"])
end
else
- s.add_dependency(%q<amazon-ecs>, [">= 0.5.1"])
+ s.add_dependency(%q<amazon-ecs>, [">= 0.5.6"])
end
end
@@ -17,6 +17,7 @@ def acts_as_amazon_product(options = {})
:asin => 'asin',
:name => 'name',
:access_key => ENV['AMAZON_ACCESS_KEY_ID'],
+ :secret_key => ENV['AMAZON_SECRET_KEY'],
:associate_tag => ENV['AMAZON_ASSOCIATE_TAG'],
:search_index => 'Books',
:response_group => 'Medium',
@@ -29,17 +30,22 @@ def acts_as_amazon_product(options = {})
}
options = defaults.merge options
- Amazon::Ecs.options = {:aWS_access_key_id => options[:access_key],
- :associate_tag => options[:associate_tag], :response_group => options[:response_group]}
+ Amazon::Ecs.options = {
+ :aWS_access_key_id => options[:access_key],
+ :aWS_secret_key => options[:secret_key],
+ :associate_tag => options[:associate_tag],
+ :response_group => options[:response_group]
+ }
write_inheritable_attribute(:amazon_asin, options[:asin])
write_inheritable_attribute(:amazon_name, options[:name])
- write_inheritable_attribute(:amazon_search_index, options[:search_index])
- write_inheritable_attribute(:amazon_associate_key, options[:associate_key])
+ write_inheritable_attribute(:amazon_search_index, options[:search_index])
+ write_inheritable_attribute(:amazon_associate_tag, options[:associate_tag])
write_inheritable_attribute(:auto_load_fields, options[:auto_load_fields])
write_inheritable_attribute(:ignore_fields, options[:ignore_fields])
write_inheritable_attribute(:auto_delete_amazon, options[:auto_delete_amazon])
- class_inheritable_reader :amazon_asin, :amazon_name, :amazon_search_index, :amazon_associate_key
+ class_inheritable_reader :amazon_asin, :amazon_name, :amazon_search_index
+ class_inheritable_reader :amazon_associate_tag
class_inheritable_reader :auto_load_fields, :ignore_fields, :auto_delete_amazon
has_one :amazon_product, :as => :amazonable #, :dependent => :delete
@@ -2,15 +2,14 @@
require 'yaml'
require File.expand_path(File.dirname(__FILE__) + "/../lib/acts_as_amazon_product")
-
require File.expand_path(File.dirname(__FILE__) + "/../init")
-config = open(File.dirname(__FILE__) + "/../test/config.yml") { |f| YAML.load(f.read)}
-ActiveRecord::Base.establish_connection(config["database"])
+@@config = open(File.dirname(__FILE__) + "/../test/config.yml") { |f| YAML.load(f.read)}
+ActiveRecord::Base.establish_connection(@@config["database"])
-#Amazon::Ecs.options = {:aWS_access_key_id => config['amazon']['access_key']}
-@@access_key = config['amazon']['access_key']
-@@associate_tag = config['amazon']['associate_tag']
+ENV['AMAZON_ACCESS_KEY_ID'] = @@config['amazon']['access_key']
+ENV['AMAZON_SECRET_KEY'] = @@config['amazon']['secret_key']
+ENV['AMAZON_ASSOCIATE_TAG'] = @@config['amazon']['associate_tag']
ActiveRecord::Base.connection.drop_table :amazon_products rescue nil
ActiveRecord::Base.connection.drop_table :books rescue nil
@@ -54,31 +53,31 @@
t.column :amazonable_type, :string, :limit => 15, :default => "", :null => false
end
+
+
class Book < ActiveRecord::Base
- acts_as_amazon_product(
- :asin => 'isbn', :name => 'title',
- :access_key => @@access_key, :associate_tag => @@associate_tag)
+ acts_as_amazon_product(:asin => 'isbn', :name => 'title')
end
class EANBook < Book
- acts_as_amazon_product(
- :asin => 'ean', :name => 'title',
- :access_key => @@access_key, :associate_tag => @@associate_tag)
+ acts_as_amazon_product(:asin => 'ean', :name => 'title' )
end
class Movie < ActiveRecord::Base
- acts_as_amazon_product :access_key => @@access_key, :associate_tag => @@associate_tag
+ acts_as_amazon_product
end
class Magazine < ActiveRecord::Base
- acts_as_amazon_product :search_index => 'Magazines', :access_key => @@access_key,
- :associate_tag => @@associate_tag
+ acts_as_amazon_product :search_index => 'Magazines'
end
class LocalBook < ActiveRecord::Base
acts_as_amazon_product(
+ :access_key => @@config['amazon']['access_key'],
+ :secret_key => @@config['amazon']['secret_key'],
+ :associate_tag => @@config['amazon']['associate_tag'],
:asin => 'isbn', :name => 'title',
- :access_key => @@access_key, :associate_tag => @@associate_tag, :ignore_fields => [:small_image_url, :medium_image_url]
+ :ignore_fields => [:small_image_url, :medium_image_url]
)
end
@@ -99,6 +98,10 @@ def setup
@local_roots = LocalBook.load_from_amazon!('Roots', true)
end
+ def test_associate_tag
+ assert_equal(@@config['amazon']['associate_tag'], Book.amazon_associate_tag)
+ end
+
def test_isbn
assert_not_nil(@book_gtd.amazon)
assert_equal("0142000280", @book_gtd.amazon.isbn)

0 comments on commit a082c32

Please sign in to comment.