dpickett-ramazon_advertising 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 0.3.0
@@ -2,7 +2,7 @@ Feature: As a user of the Ramazon Advertising API
2
2
  I want a list of browse nodes
3
3
  So that I have starting points for browse node traversal
4
4
 
5
- Scenario: Retrieving browse nodes
5
+ Scenario: Retrieving root browse nodes
6
6
  Given I want browse nodes to be stored in a temporary file
7
7
  And the browse node temporary file doesn't exist
8
8
  When I retrieve root nodes
@@ -10,3 +10,4 @@ Feature: As a user of the Ramazon Advertising API
10
10
  And I should have a "Books" root node
11
11
  And I should have a "Grocery" root node
12
12
  And I should have a list of root nodes
13
+
@@ -0,0 +1,10 @@
1
+ Feature: As a user of the ramazon advertising api
2
+ I want to get browse node information
3
+ So I can retrieve Amazon product data more effectively
4
+
5
+ Scenario: Fetch "Other Video Games" Node
6
+ Given I want browse node information for the node "294940"
7
+ When I retrieve the browse node
8
+ Then the browse node should have a name
9
+ And the browse node should have "children"
10
+ And the browse node should have a "child_hash"
@@ -7,9 +7,28 @@ Feature: Search for products
7
7
  Given I have a valid access key
8
8
  And I have a valid secret key
9
9
 
10
+ Scenario: Finding dvds
10
11
  Given I am searching with the "search_index" of "DVD"
11
12
  And I am searching with the "browse_node" of "130"
12
13
  When I perform the product search
13
14
  Then I should get a list of products
14
15
  And the list of products should have more than 1 product
15
16
  And each product should have the "product_group" "DVD"
17
+
18
+ Scenario: Finding video games
19
+ Given I am searching with the "search_index" of "VideoGames"
20
+ And I am searching with the "response_group" of "Medium,BrowseNodes"
21
+ And I am searching with the "browse_node" of "294940"
22
+ When I perform the product search
23
+ Then I should get a list of products
24
+ And the list of products should have more than 1 product
25
+ And each product should have the "product_group" "Video Games"
26
+
27
+ Scenario: Finding multiple browse nodes
28
+ Given I am searching with the "search_index" of "VideoGames"
29
+ And I am searching with the "response_group" of "Medium"
30
+ And I am searching with the "browse_node" of "11075221"
31
+ When I perform the product search
32
+ Then I should get a list of products
33
+ And the list of products should have more than 1 product
34
+ And each product should have the "product_group" "Video Games"
@@ -6,6 +6,10 @@ Given /^the browse node temporary file doesn't exist$/ do
6
6
  FileUtils.rm_f @browse_root_filename
7
7
  end
8
8
 
9
+ Given /^I want browse node information for the node "([^\"]*)"$/ do |node_id|
10
+ @node_id = node_id
11
+ end
12
+
9
13
  When /^I retrieve root nodes$/ do
10
14
  if @browse_root_filename
11
15
  Ramazon::BrowseNode.generate_root_nodes @browse_root_filename
@@ -14,6 +18,21 @@ When /^I retrieve root nodes$/ do
14
18
  end
15
19
  end
16
20
 
21
+ When /^I retrieve the browse node$/ do
22
+ @node = Ramazon::BrowseNode.find(@node_id)
23
+ end
24
+
25
+ Then /^the browse node should have a name$/ do
26
+ @node.name.should_not be_nil
27
+ end
28
+
29
+ Then /^the browse node should have (a\s)?"(.*)"$/ do |a, attr|
30
+ @node.send(attr).should_not be_nil
31
+ if @node.send(attr).respond_to?(:empty?)
32
+ @node.send(attr).should_not be_empty
33
+ end
34
+ end
35
+
17
36
  Then /^I should get a temporary file for root nodes$/ do
18
37
  FileTest.exists?(@browse_root_filename).should be_true
19
38
  end
@@ -7,6 +7,7 @@ module Ramazon
7
7
 
8
8
  element :name, String, :tag => "Name"
9
9
  element :node_id, String, :tag => "BrowseNodeId"
10
+ element :children, Ramazon::BrowseNode, :tag => "Children/BrowseNode"
10
11
  element :is_category_root, Boolean, :tag => "IsCategoryRoot"
11
12
 
12
13
  attr_accessor :child
@@ -39,6 +40,28 @@ module Ramazon
39
40
  @root_nodes ||= File.open(file_name) { |yf| YAML::load(yf) }
40
41
  end
41
42
 
43
+ # find a browse node based on its id
44
+ # @param node_id [String] the browse node you're looking for
45
+ # @returns [Ramazon::BrowseNode] the node you're looking for
46
+ def self.find(node_id)
47
+ req = Ramazon::Request.new(:operation => "BrowseNodeLookup", :browse_node_id => node_id)
48
+ res = req.submit
49
+ parse(res.to_s)[0]
50
+ end
51
+
52
+ # get a hash of name -> child browse_nodes
53
+ # @returns [Hash] stringified hash of names => Ramazon::BrowseNode objects
54
+ def child_hash
55
+ if !@child_hash
56
+ @child_hash = {}
57
+ self.children.each do |i|
58
+ @child_hash[i.name] = i
59
+ end
60
+ end
61
+
62
+ @child_hash
63
+ end
64
+
42
65
  def self.parse(xml, options = {})
43
66
  super
44
67
  end
@@ -1,12 +1,15 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{ramazon_advertising}
5
- s.version = "0.2.4"
8
+ s.version = "0.3.0"
6
9
 
7
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
11
  s.authors = ["Dan Pickett"]
9
- s.date = %q{2009-09-12}
12
+ s.date = %q{2009-09-14}
10
13
  s.description = %q{TODO: longer description of your gem}
11
14
  s.email = %q{dpickett@enlightsolutions.com}
12
15
  s.extra_rdoc_files = [
@@ -23,6 +26,7 @@ Gem::Specification.new do |s|
23
26
  "features/friendly_errors.feature",
24
27
  "features/generate_root_browse_nodes.feature",
25
28
  "features/getting_offer_details.feature",
29
+ "features/retrieve_browse_node_information.feature",
26
30
  "features/retrieving_a_product.feature",
27
31
  "features/searching_for_products.feature",
28
32
  "features/step_definitions/auth_steps.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dpickett-ramazon_advertising
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Pickett
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-12 00:00:00 -07:00
12
+ date: 2009-09-14 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -91,6 +91,7 @@ files:
91
91
  - features/friendly_errors.feature
92
92
  - features/generate_root_browse_nodes.feature
93
93
  - features/getting_offer_details.feature
94
+ - features/retrieve_browse_node_information.feature
94
95
  - features/retrieving_a_product.feature
95
96
  - features/searching_for_products.feature
96
97
  - features/step_definitions/auth_steps.rb
@@ -121,6 +122,7 @@ files:
121
122
  - spec/spec_helper.rb
122
123
  has_rdoc: false
123
124
  homepage: http://github.com/dpickett/ramazon_advertising
125
+ licenses:
124
126
  post_install_message:
125
127
  rdoc_options:
126
128
  - --charset=UTF-8
@@ -141,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
143
  requirements: []
142
144
 
143
145
  rubyforge_project:
144
- rubygems_version: 1.2.0
146
+ rubygems_version: 1.3.5
145
147
  signing_key:
146
148
  specification_version: 3
147
149
  summary: "TODO: one-line summary of your gem"