netphase-acts_as_amazon_product 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +8 -0
- data/Rakefile +1 -38
- data/VERSION +1 -1
- data/acts_as_amazon_product.gemspec +7 -8
- data/lib/acts_as_amazon_product.rb +12 -6
- data/test/acts_as_amazon_product_test.rb +19 -16
- metadata +5 -5
data/CHANGELOG
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
= 2.1
|
2
|
+
=== 20th July, 2009
|
3
|
+
* Support for authenticated calls to Amazon
|
4
|
+
|
5
|
+
= 2.0
|
6
|
+
=== 18th June, 2009
|
7
|
+
* Setup with Jeweler for packaging and deployment
|
8
|
+
|
1
9
|
= 1.4
|
2
10
|
=== 11th October, 2008
|
3
11
|
* Added load_from_amazon and load_from_amazon! methods to load up Amazon attributes into a local object directly (see the README for usage)
|
data/Rakefile
CHANGED
@@ -8,9 +8,6 @@ require 'fileutils'
|
|
8
8
|
include FileUtils
|
9
9
|
|
10
10
|
NAME = "acts_as_amazon_product"
|
11
|
-
# REV = File.read(".svn/entries")[/committed-rev="(\d+)"/, 1] rescue nil
|
12
|
-
# VERS = ENV['VERSION'] || ("1.1" + (REV ? ".#{REV}" : ""))
|
13
|
-
VERS = ENV['VERSION'] || "1.4"
|
14
11
|
CLEAN.include ['**/.*.sw?', '*.gem', '.config', 'test/test.log']
|
15
12
|
|
16
13
|
desc 'Default: run unit tests.'
|
@@ -26,40 +23,6 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
26
23
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
27
24
|
end
|
28
25
|
|
29
|
-
# Gem::manage_gems
|
30
|
-
# require 'rake/gempackagetask'
|
31
|
-
# spec = Gem::Specification.new do |s|
|
32
|
-
# s.platform = Gem::Platform::RUBY
|
33
|
-
# s.name = NAME
|
34
|
-
# s.version = VERS
|
35
|
-
# s.author = "Scott Nedderman"
|
36
|
-
# s.email = "scott@netphase.com"
|
37
|
-
# s.homepage = "http://netphase.com"
|
38
|
-
# s.summary = "A package for simplifying use of the Amazon/ECS API"
|
39
|
-
# s.files = FileList['lib/*.rb', 'test/*'].to_a.reject {|f| f.match /config\.yml/ }
|
40
|
-
# s.require_path = "lib"
|
41
|
-
# # s.autorequire = "acts_as_amazon_product"
|
42
|
-
# s.test_files = Dir.glob('tests/*.rb')
|
43
|
-
# s.has_rdoc = true
|
44
|
-
# s.extra_rdoc_files = ["README"]
|
45
|
-
# s.add_dependency("amazon-ecs", ">=0.5.1")
|
46
|
-
# end
|
47
|
-
# Rake::GemPackageTask.new(spec) do |pkg|
|
48
|
-
# pkg.need_tar = true
|
49
|
-
# end
|
50
|
-
# task :default => "pkg/#{spec.name}-#{spec.version}.gem" do
|
51
|
-
# puts "generated latest version"
|
52
|
-
# end
|
53
|
-
#
|
54
|
-
# task :install do
|
55
|
-
# sh %{rake package}
|
56
|
-
# sh %{sudo gem install pkg/#{NAME}-#{VERS}}
|
57
|
-
# end
|
58
|
-
#
|
59
|
-
# task :uninstall => [:clean] do
|
60
|
-
# sh %{sudo gem uninstall #{NAME}}
|
61
|
-
# end
|
62
|
-
|
63
26
|
desc 'Test the acts_as_amazon_product plugin.'
|
64
27
|
Rake::TestTask.new(:test) do |t|
|
65
28
|
t.libs << 'lib'
|
@@ -75,7 +38,7 @@ begin
|
|
75
38
|
gemspec.email = "scott@netphase.com"
|
76
39
|
gemspec.homepage = "http://github.com/netphase/aaap"
|
77
40
|
gemspec.authors = ["Scott Nedderman","Chris Beck"]
|
78
|
-
gemspec.add_dependency("amazon-ecs", ">=0.5.
|
41
|
+
gemspec.add_dependency("amazon-ecs", ">=0.5.6")
|
79
42
|
gemspec.files.exclude 'test/config.yml'
|
80
43
|
|
81
44
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.1.0
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{acts_as_amazon_product}
|
5
|
-
s.version = "2.
|
5
|
+
s.version = "2.1.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Scott Nedderman", "Chris Beck"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-07-20}
|
10
10
|
s.email = %q{scott@netphase.com}
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"README"
|
@@ -31,11 +31,10 @@ Gem::Specification.new do |s|
|
|
31
31
|
"test/example.rb",
|
32
32
|
"uninstall.rb"
|
33
33
|
]
|
34
|
-
s.has_rdoc = true
|
35
34
|
s.homepage = %q{http://github.com/netphase/aaap}
|
36
35
|
s.rdoc_options = ["--charset=UTF-8"]
|
37
36
|
s.require_paths = ["lib"]
|
38
|
-
s.rubygems_version = %q{1.3.
|
37
|
+
s.rubygems_version = %q{1.3.3}
|
39
38
|
s.summary = %q{A package for simplifying use of the Amazon/ECS API}
|
40
39
|
s.test_files = [
|
41
40
|
"test/acts_as_amazon_product_test.rb",
|
@@ -44,14 +43,14 @@ Gem::Specification.new do |s|
|
|
44
43
|
|
45
44
|
if s.respond_to? :specification_version then
|
46
45
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
47
|
-
s.specification_version =
|
46
|
+
s.specification_version = 3
|
48
47
|
|
49
48
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
50
|
-
s.add_runtime_dependency(%q<amazon-ecs>, [">= 0.5.
|
49
|
+
s.add_runtime_dependency(%q<amazon-ecs>, [">= 0.5.6"])
|
51
50
|
else
|
52
|
-
s.add_dependency(%q<amazon-ecs>, [">= 0.5.
|
51
|
+
s.add_dependency(%q<amazon-ecs>, [">= 0.5.6"])
|
53
52
|
end
|
54
53
|
else
|
55
|
-
s.add_dependency(%q<amazon-ecs>, [">= 0.5.
|
54
|
+
s.add_dependency(%q<amazon-ecs>, [">= 0.5.6"])
|
56
55
|
end
|
57
56
|
end
|
@@ -17,6 +17,7 @@ module Netphase
|
|
17
17
|
:asin => 'asin',
|
18
18
|
:name => 'name',
|
19
19
|
:access_key => ENV['AMAZON_ACCESS_KEY_ID'],
|
20
|
+
:secret_key => ENV['AMAZON_SECRET_KEY'],
|
20
21
|
:associate_tag => ENV['AMAZON_ASSOCIATE_TAG'],
|
21
22
|
:search_index => 'Books',
|
22
23
|
:response_group => 'Medium',
|
@@ -29,17 +30,22 @@ module Netphase
|
|
29
30
|
}
|
30
31
|
options = defaults.merge options
|
31
32
|
|
32
|
-
Amazon::Ecs.options = {
|
33
|
-
:
|
33
|
+
Amazon::Ecs.options = {
|
34
|
+
:aWS_access_key_id => options[:access_key],
|
35
|
+
:aWS_secret_key => options[:secret_key],
|
36
|
+
:associate_tag => options[:associate_tag],
|
37
|
+
:response_group => options[:response_group]
|
38
|
+
}
|
34
39
|
|
35
40
|
write_inheritable_attribute(:amazon_asin, options[:asin])
|
36
41
|
write_inheritable_attribute(:amazon_name, options[:name])
|
37
|
-
write_inheritable_attribute(:amazon_search_index, options[:search_index])
|
38
|
-
write_inheritable_attribute(:
|
42
|
+
write_inheritable_attribute(:amazon_search_index, options[:search_index])
|
43
|
+
write_inheritable_attribute(:amazon_associate_tag, options[:associate_tag])
|
39
44
|
write_inheritable_attribute(:auto_load_fields, options[:auto_load_fields])
|
40
45
|
write_inheritable_attribute(:ignore_fields, options[:ignore_fields])
|
41
46
|
write_inheritable_attribute(:auto_delete_amazon, options[:auto_delete_amazon])
|
42
|
-
class_inheritable_reader :amazon_asin, :amazon_name, :amazon_search_index
|
47
|
+
class_inheritable_reader :amazon_asin, :amazon_name, :amazon_search_index
|
48
|
+
class_inheritable_reader :amazon_associate_tag
|
43
49
|
class_inheritable_reader :auto_load_fields, :ignore_fields, :auto_delete_amazon
|
44
50
|
|
45
51
|
has_one :amazon_product, :as => :amazonable #, :dependent => :delete
|
@@ -77,7 +83,7 @@ module Netphase
|
|
77
83
|
newbie = self.new
|
78
84
|
self.auto_load_fields.each do |key, value|
|
79
85
|
if newbie.respond_to?(key.to_s) && !self.ignore_fields.include?(key)
|
80
|
-
newbie.send key.to_s + '=', item.get(value)
|
86
|
+
newbie.send key.to_s + '=', CGI.unescapeHTML(item.get(value))
|
81
87
|
end
|
82
88
|
end
|
83
89
|
return newbie
|
@@ -2,15 +2,14 @@ require 'test/unit'
|
|
2
2
|
require 'yaml'
|
3
3
|
|
4
4
|
require File.expand_path(File.dirname(__FILE__) + "/../lib/acts_as_amazon_product")
|
5
|
-
|
6
5
|
require File.expand_path(File.dirname(__FILE__) + "/../init")
|
7
6
|
|
8
|
-
config = open(File.dirname(__FILE__) + "/../test/config.yml") { |f| YAML.load(f.read)}
|
9
|
-
ActiveRecord::Base.establish_connection(config["database"])
|
7
|
+
@@config = open(File.dirname(__FILE__) + "/../test/config.yml") { |f| YAML.load(f.read)}
|
8
|
+
ActiveRecord::Base.establish_connection(@@config["database"])
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
ENV['AMAZON_ACCESS_KEY_ID'] = @@config['amazon']['access_key']
|
11
|
+
ENV['AMAZON_SECRET_KEY'] = @@config['amazon']['secret_key']
|
12
|
+
ENV['AMAZON_ASSOCIATE_TAG'] = @@config['amazon']['associate_tag']
|
14
13
|
|
15
14
|
ActiveRecord::Base.connection.drop_table :amazon_products rescue nil
|
16
15
|
ActiveRecord::Base.connection.drop_table :books rescue nil
|
@@ -54,31 +53,31 @@ ActiveRecord::Base.connection.create_table :amazon_products do |t| # , :id => f
|
|
54
53
|
t.column :amazonable_type, :string, :limit => 15, :default => "", :null => false
|
55
54
|
end
|
56
55
|
|
56
|
+
|
57
|
+
|
57
58
|
class Book < ActiveRecord::Base
|
58
|
-
acts_as_amazon_product(
|
59
|
-
:asin => 'isbn', :name => 'title',
|
60
|
-
:access_key => @@access_key, :associate_tag => @@associate_tag)
|
59
|
+
acts_as_amazon_product(:asin => 'isbn', :name => 'title')
|
61
60
|
end
|
62
61
|
|
63
62
|
class EANBook < Book
|
64
|
-
acts_as_amazon_product(
|
65
|
-
:asin => 'ean', :name => 'title',
|
66
|
-
:access_key => @@access_key, :associate_tag => @@associate_tag)
|
63
|
+
acts_as_amazon_product(:asin => 'ean', :name => 'title' )
|
67
64
|
end
|
68
65
|
|
69
66
|
class Movie < ActiveRecord::Base
|
70
|
-
acts_as_amazon_product
|
67
|
+
acts_as_amazon_product
|
71
68
|
end
|
72
69
|
|
73
70
|
class Magazine < ActiveRecord::Base
|
74
|
-
acts_as_amazon_product :search_index => 'Magazines'
|
75
|
-
:associate_tag => @@associate_tag
|
71
|
+
acts_as_amazon_product :search_index => 'Magazines'
|
76
72
|
end
|
77
73
|
|
78
74
|
class LocalBook < ActiveRecord::Base
|
79
75
|
acts_as_amazon_product(
|
76
|
+
:access_key => @@config['amazon']['access_key'],
|
77
|
+
:secret_key => @@config['amazon']['secret_key'],
|
78
|
+
:associate_tag => @@config['amazon']['associate_tag'],
|
80
79
|
:asin => 'isbn', :name => 'title',
|
81
|
-
:
|
80
|
+
:ignore_fields => [:small_image_url, :medium_image_url]
|
82
81
|
)
|
83
82
|
end
|
84
83
|
|
@@ -99,6 +98,10 @@ class ActAsAmazonProductTest < Test::Unit::TestCase
|
|
99
98
|
@local_roots = LocalBook.load_from_amazon!('Roots', true)
|
100
99
|
end
|
101
100
|
|
101
|
+
def test_associate_tag
|
102
|
+
assert_equal(@@config['amazon']['associate_tag'], Book.amazon_associate_tag)
|
103
|
+
end
|
104
|
+
|
102
105
|
def test_isbn
|
103
106
|
assert_not_nil(@book_gtd.amazon)
|
104
107
|
assert_equal("0142000280", @book_gtd.amazon.isbn)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netphase-acts_as_amazon_product
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Nedderman
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-07-20 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
requirements:
|
22
22
|
- - ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 0.5.
|
24
|
+
version: 0.5.6
|
25
25
|
version:
|
26
26
|
description:
|
27
27
|
email: scott@netphase.com
|
@@ -50,7 +50,7 @@ files:
|
|
50
50
|
- test/config-example.yml
|
51
51
|
- test/example.rb
|
52
52
|
- uninstall.rb
|
53
|
-
has_rdoc:
|
53
|
+
has_rdoc: false
|
54
54
|
homepage: http://github.com/netphase/aaap
|
55
55
|
post_install_message:
|
56
56
|
rdoc_options:
|
@@ -74,7 +74,7 @@ requirements: []
|
|
74
74
|
rubyforge_project:
|
75
75
|
rubygems_version: 1.2.0
|
76
76
|
signing_key:
|
77
|
-
specification_version:
|
77
|
+
specification_version: 3
|
78
78
|
summary: A package for simplifying use of the Amazon/ECS API
|
79
79
|
test_files:
|
80
80
|
- test/acts_as_amazon_product_test.rb
|