tucano 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -6,8 +6,8 @@ source "http://rubygems.org"
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
 
9
- #I'm not 100% sure on how do to proper HTTP request yet, so I used Vacuum to interact with the API and parsed the results.
10
- gem 'vacuum'
9
+ #I'm not 100% sure on how do to proper HTTP request yet, so I used AmazonECS to interact with the API and parsed the results.
10
+ gem 'amazon-ecs'
11
11
 
12
12
  group :development do
13
13
  gem "rspec", "~> 2.8.0"
@@ -1,12 +1,10 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- addressable (2.2.7)
4
+ amazon-ecs (2.2.4)
5
+ nokogiri (~> 1.4)
6
+ ruby-hmac (~> 0.3)
5
7
  diff-lcs (1.1.3)
6
- faraday (0.7.6)
7
- addressable (~> 2.2)
8
- multipart-post (~> 1.1)
9
- rack (~> 1.1)
10
8
  fuubar (1.0.0)
11
9
  rspec (~> 2.0)
12
10
  rspec-instafail (~> 0.2.0)
@@ -18,9 +16,7 @@ GEM
18
16
  rake
19
17
  rdoc
20
18
  json (1.6.6)
21
- multipart-post (1.1.5)
22
19
  nokogiri (1.5.2)
23
- rack (1.4.1)
24
20
  rake (0.9.2.2)
25
21
  rcov (0.9.11)
26
22
  rdoc (3.12)
@@ -34,20 +30,17 @@ GEM
34
30
  diff-lcs (~> 1.1.2)
35
31
  rspec-instafail (0.2.4)
36
32
  rspec-mocks (2.8.0)
33
+ ruby-hmac (0.4.0)
37
34
  ruby-progressbar (0.0.10)
38
- vacuum (0.2.2)
39
- addressable (~> 2.2)
40
- faraday (~> 0.7.6)
41
- nokogiri (~> 1.5)
42
35
 
43
36
  PLATFORMS
44
37
  ruby
45
38
 
46
39
  DEPENDENCIES
40
+ amazon-ecs
47
41
  bundler
48
42
  fuubar
49
43
  jeweler (~> 1.8.3)
50
44
  rcov (= 0.9.11)
51
45
  rdoc (~> 3.12)
52
46
  rspec (~> 2.8.0)
53
- vacuum
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.2.0
@@ -1,4 +1,4 @@
1
- require 'vacuum'
1
+ require 'amazon/ecs'
2
2
 
3
3
  module Tucano
4
4
  class Item
@@ -7,30 +7,27 @@ module Tucano
7
7
 
8
8
  class ProductSearch
9
9
  def initialize(key, secret, associate_tag)
10
- @request = ::Vacuum.new(:product_advertising)
11
- @request.configure do |config|
12
- config.key = key
13
- config.secret = secret
14
- config.tag = associate_tag
15
- end
10
+ Amazon::Ecs.options = {
11
+ :associate_tag => associate_tag,
12
+ :AWS_access_key_id => key,
13
+ :AWS_secret_key => secret
14
+ }
16
15
  end
17
16
 
18
17
  def convert_to_product(item)
19
18
  i = Item.new
20
- i.name = item["ItemAttributes"]["Title"]
21
- i.category = item["ItemAttributes"]["ProductGroup"]
22
- i.price = item["ItemAttributes"]["ListPrice"]["Amount"].to_i
23
- i.currency = item["ItemAttributes"]["ListPrice"]["CurrencyCode"]
24
- #i.description = item["EditorialReviews"]["EditorialReview"]["Content"]
25
- i.image = item["LargeImage"]["URL"]
26
- i.url = item["DetailPageURL"]
27
-
19
+ i.name = item.get_hash("ItemAttributes")["Title"]
20
+ i.category = item.get_hash("ItemAttributes")["ProductGroup"]
21
+ i.price = item.get_hash("ItemAttributes/ListPrice")["Amount"]
22
+ i.currency = item.get_hash("ItemAttributes/ListPrice")["CurrencyCode"]
23
+ i.description = item.get_hash("EditorialReviews/EditorialReview")["Content"]
24
+ i.image = item.get_hash("LargeImage")["URL"]
28
25
  return i
29
26
  end
30
27
 
31
- def parse_response(response)
28
+ def parse_response
32
29
  products = []
33
- response.find("Item") do |item|
30
+ @response.items.each do |item|
34
31
  product = convert_to_product(item)
35
32
  products << product
36
33
  end
@@ -38,14 +35,9 @@ module Tucano
38
35
  end
39
36
 
40
37
  def search(query)
41
- rg = %W{ItemAttributes EditorialReview Images}
42
- @request.build(:operation => "ItemSearch",
43
- :search_index => "All",
44
- :keywords => query,
45
- :response_group => rg)
38
+ @response = Amazon::Ecs.item_search(query, :search_index => "All", :response_group => "Medium")
46
39
  products = []
47
- response = @request.get
48
- products = parse_response(response)
40
+ products = parse_response
49
41
  products
50
42
  end
51
43
  end
@@ -1,33 +1,34 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Tucano" do
4
- before do
5
- #Note: API keys here are for our testing account. Sign up for a Product Advertising Account to recieve your API Keys. The third attribute is your Associate ID.
6
- @tucano = Tucano::ProductSearch.new('AKIAJ5HO5KJC4OISP7WQ', 'QqaxJ09GZbMZPcETeDOOoSQrdm4llVIf3jg1q8+g', 'voicsear-20')
7
- @products = @tucano.search("Rails")
8
- end
9
- it "should be create a request when given a query string" do
10
- @tucano.should be_an_instance_of Tucano::ProductSearch
11
- end
4
+ before do
5
+ @tucano = Tucano::ProductSearch.new('AKIAJ5HO5KJC4OISP7WQ', 'QqaxJ09GZbMZPcETeDOOoSQrdm4llVIf3jg1q8+g', 'voicsear-20')
6
+ @products = @tucano.search("Rails")
7
+ end
12
8
 
13
- it "should return an array" do
14
- @products.should be_an_instance_of Array
15
- end
9
+ describe "Search" do
10
+ it "should be create a request when given a query string" do
11
+ @tucano.should be_an_instance_of Tucano::ProductSearch
12
+ end
16
13
 
17
- it "should return an array of items" do
18
- @products.first.should be_an_instance_of Tucano::Item
19
- end
14
+ it "should return an array" do
15
+ @products.should be_an_instance_of Array
16
+ end
20
17
 
21
- it "should set the attributes of each item" do
22
- item = @products.first
23
- item.name.length.should be > 0
24
- item.image.length.should be > 0
25
- item.category.length.should be > 0
26
- item.currency.should == "USD"
27
- item.url.should include("amazon.co")
28
- end
18
+ it "should return an array of items" do
19
+ @products.first.should be_an_instance_of Tucano::Item
20
+ end
21
+
22
+ it "should set the attributes of each item" do
23
+ item = @products.first
24
+ item.name.length.should be > 0
25
+ item.image.length.should be > 0
26
+ item.category.length.should be > 0
27
+ item.currency.should == "USD"
28
+ end
29
29
 
30
- it "should return an empty array when no results are found" do
31
- @tucano.search("sofewfbewiofbewofinalskdn fnwlefbkf").should == []
30
+ it "should return an empty array when no results are found" do
31
+ @tucano.search("sofewfbewiofbewofinalskdn fnwlefbkf").should == []
32
+ end
32
33
  end
33
34
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "tucano"
8
- s.version = "0.1.3"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mark Provan"]
12
- s.date = "2012-04-11"
12
+ s.date = "2012-04-12"
13
13
  s.description = "When taking part in a hackathon recently I was looking for a simple gem to pull products from Amazon based on a search string. I found a few but none did exactly what I wanted, so I built this one."
14
14
  s.email = "markgprovan@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -41,7 +41,7 @@ Gem::Specification.new do |s|
41
41
  s.specification_version = 3
42
42
 
43
43
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
- s.add_runtime_dependency(%q<vacuum>, [">= 0"])
44
+ s.add_runtime_dependency(%q<amazon-ecs>, [">= 0"])
45
45
  s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
46
46
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
47
47
  s.add_development_dependency(%q<bundler>, [">= 0"])
@@ -49,7 +49,7 @@ Gem::Specification.new do |s|
49
49
  s.add_development_dependency(%q<rcov>, ["= 0.9.11"])
50
50
  s.add_development_dependency(%q<fuubar>, [">= 0"])
51
51
  else
52
- s.add_dependency(%q<vacuum>, [">= 0"])
52
+ s.add_dependency(%q<amazon-ecs>, [">= 0"])
53
53
  s.add_dependency(%q<rspec>, ["~> 2.8.0"])
54
54
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
55
55
  s.add_dependency(%q<bundler>, [">= 0"])
@@ -58,7 +58,7 @@ Gem::Specification.new do |s|
58
58
  s.add_dependency(%q<fuubar>, [">= 0"])
59
59
  end
60
60
  else
61
- s.add_dependency(%q<vacuum>, [">= 0"])
61
+ s.add_dependency(%q<amazon-ecs>, [">= 0"])
62
62
  s.add_dependency(%q<rspec>, ["~> 2.8.0"])
63
63
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
64
64
  s.add_dependency(%q<bundler>, [">= 0"])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tucano
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-11 00:00:00.000000000 Z
12
+ date: 2012-04-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: vacuum
16
- requirement: &70286142240000 !ruby/object:Gem::Requirement
15
+ name: amazon-ecs
16
+ requirement: &70199840103820 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70286142240000
24
+ version_requirements: *70199840103820
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70286142279560 !ruby/object:Gem::Requirement
27
+ requirement: &70199840102700 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.8.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70286142279560
35
+ version_requirements: *70199840102700
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rdoc
38
- requirement: &70286142278540 !ruby/object:Gem::Requirement
38
+ requirement: &70199840133540 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '3.12'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70286142278540
46
+ version_requirements: *70199840133540
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &70286142276720 !ruby/object:Gem::Requirement
49
+ requirement: &70199840132060 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70286142276720
57
+ version_requirements: *70199840132060
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: jeweler
60
- requirement: &70286142274560 !ruby/object:Gem::Requirement
60
+ requirement: &70199840130560 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.8.3
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70286142274560
68
+ version_requirements: *70199840130560
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rcov
71
- requirement: &70286142267780 !ruby/object:Gem::Requirement
71
+ requirement: &70199840129640 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - =
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.9.11
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70286142267780
79
+ version_requirements: *70199840129640
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: fuubar
82
- requirement: &70286142265560 !ruby/object:Gem::Requirement
82
+ requirement: &70199840128380 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70286142265560
90
+ version_requirements: *70199840128380
91
91
  description: When taking part in a hackathon recently I was looking for a simple gem
92
92
  to pull products from Amazon based on a search string. I found a few but none did
93
93
  exactly what I wanted, so I built this one.
@@ -126,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  segments:
128
128
  - 0
129
- hash: 1651647363753523815
129
+ hash: 3815527294345816950
130
130
  required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  none: false
132
132
  requirements: