amazon_seller_central 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # amazon\_seller\_central
2
2
 
3
- This gem is intended to wrap Amazon's SellerCentral pages with a Ruby
4
- API. Currently this gem supports accessing buyer feedback, accessing
3
+ This gem wraps Amazon's SellerCentral pages with a Ruby API.
4
+ Currently this gem supports accessing buyer feedback, accessing
5
5
  current inventory listings, and simple updates to those listings.
6
6
 
7
7
  ## Setup
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{amazon_seller_central}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["optoro"]
12
- s.date = %q{2011-09-01}
12
+ s.date = %q{2011-09-08}
13
13
  s.description = %q{This gem is intended to wrap Amazon's SellerCentral pages with a Ruby API. Currently this gem supports accessing buyer feedback only.}
14
14
  s.email = %q{dev@optoro.com}
15
15
  s.extra_rdoc_files = [
@@ -18,6 +18,6 @@ module AmazonSellerCentral
18
18
  end
19
19
 
20
20
  def self.mechanizer
21
- AmazonSellerCentral::Mechanizer.instance
21
+ AmazonSellerCentral::Mechanizer.new
22
22
  end
23
23
  end
@@ -9,8 +9,8 @@ module AmazonSellerCentral
9
9
  def next_page
10
10
  @next_page ||= begin
11
11
  raise NoNextPageAvailableError unless has_next?
12
- page = AmazonSellerCentral.mechanizer.follow_link_with(:text => 'Next')
13
- FeedbackPage.new(:page => page)
12
+ page = @agent.follow_link_with(:text => 'Next')
13
+ FeedbackPage.new(:page => page, :agent => @agent)
14
14
  end
15
15
  end
16
16
 
@@ -25,10 +25,11 @@ module AmazonSellerCentral
25
25
  module ClassMethods
26
26
 
27
27
  def load_first_page
28
- AmazonSellerCentral.mechanizer.login_to_seller_central
29
- feedback_home = AmazonSellerCentral.mechanizer.follow_link_with(:text => "Feedback")
30
- feedback_page = AmazonSellerCentral.mechanizer.follow_link_with(:text => "View all your feedback")
31
- FeedbackPage.new(:page => feedback_page)
28
+ mech = AmazonSellerCentral.mechanizer
29
+ mech.login_to_seller_central
30
+ feedback_home = mech.follow_link_with(:text => "Feedback")
31
+ feedback_page = mech.follow_link_with(:text => "View all your feedback")
32
+ FeedbackPage.new(:page => feedback_page, :agent => mech)
32
33
  end
33
34
 
34
35
  def load_all_pages
@@ -2,9 +2,10 @@ module AmazonSellerCentral
2
2
  class Inventory
3
3
  module ClassMethods
4
4
  def load_first_page
5
- AmazonSellerCentral.mechanizer.login_to_seller_central
6
- manage_inventory = AmazonSellerCentral.mechanizer.follow_link_with(:text => "Manage Inventory")
7
- InventoryPage.new( :page => manage_inventory, :page_no => 1, :uri_base => manage_inventory.uri.to_s )
5
+ mech = AmazonSellerCentral.mechanizer
6
+ mech.login_to_seller_central
7
+ manage_inventory = mech.follow_link_with(:text => "Manage Inventory")
8
+ InventoryPage.new( :page => manage_inventory, :page_no => 1, :uri_base => manage_inventory.uri.to_s, :agent => mech )
8
9
  end
9
10
 
10
11
  def load_all_pages
@@ -15,11 +15,12 @@ module AmazonSellerCentral
15
15
  @next_page ||= begin
16
16
  raise NoNextPageAvailableError unless has_next?
17
17
 
18
- next_page = AmazonSellerCentral.mechanizer.agent.get("#{@uri_base}&searchPageOffset=#{@page_no + 1}")
18
+ next_page = @agent.agent.get("#{@uri_base}&searchPageOffset=#{@page_no + 1}")
19
19
  InventoryPage.new(
20
20
  :page => next_page,
21
21
  :page_no => (@page_no + 1),
22
- :uri_base => @uri_base
22
+ :uri_base => @uri_base,
23
+ :agent => @agent
23
24
  )
24
25
  end
25
26
  end
@@ -1,8 +1,6 @@
1
1
  require 'mechanize'
2
- require 'singleton'
3
2
  module AmazonSellerCentral
4
3
  class Mechanizer
5
- include Singleton
6
4
  MASQUERADE_AGENTS = ['Mac Safari', 'Mac FireFox', 'Linux Firefox']
7
5
 
8
6
  attr_reader :agent
@@ -3,8 +3,9 @@ module AmazonSellerCentral
3
3
  attr_accessor :body
4
4
 
5
5
  def initialize(options={})
6
- @page = options.delete(:page)
7
- @body = @page ? @page.body : ""
6
+ @page = options.delete(:page)
7
+ @agent = options.delete(:agent)
8
+ @body = @page ? @page.body : ""
8
9
  end
9
10
 
10
11
  def has_next?
@@ -26,7 +26,7 @@ describe "AmazonSellerCentral" do
26
26
  AmazonSellerCentral.configuration.login_password.should == @password
27
27
  end
28
28
 
29
- it "allows access to a singleton mechanizer" do
29
+ it "allows access to a mechanizer" do
30
30
  mech = AmazonSellerCentral.mechanizer
31
31
  mech.should be_instance_of(AmazonSellerCentral::Mechanizer)
32
32
  end
@@ -2,7 +2,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe "FeedbackPage" do
4
4
  before :all do
5
- #AmazonSellerCentral.mechanizer.reset!
6
5
  @first_page_test_regex = FEEDBACK_FIRST_PAGE_TEST_REGEX
7
6
  @second_page_test_regex = FEEDBACK_SECOND_PAGE_TEST_REGEX
8
7
  @last_page_test_regex = FEEDBACK_LAST_PAGE_TEST_REGEX
@@ -22,14 +21,12 @@ describe "FeedbackPage" do
22
21
 
23
22
  describe "ClassMethods" do
24
23
  it "loads the first page of feedback data" do
25
- AmazonSellerCentral.mechanizer.reset!
26
24
  page = AmazonSellerCentral::FeedbackPage.load_first_page
27
25
  page.should be_kind_of(AmazonSellerCentral::FeedbackPage)
28
26
  page.body.should =~ @first_page_test_regex
29
27
  end
30
28
 
31
29
  it "loads all feedback pages" do
32
- AmazonSellerCentral.mechanizer.reset!
33
30
  pages = AmazonSellerCentral::FeedbackPage.load_all_pages
34
31
  pages.size.should == 3
35
32
  pages.first.body.should =~ @first_page_test_regex
@@ -87,7 +87,7 @@ describe "InventoryPage" do
87
87
 
88
88
  @first_page.apply_listings(listings).should be_true
89
89
 
90
- (AmazonSellerCentral.mechanizer.last_page.parser.css('div#msg_saveSuccess')[0]['style'] !~ /display: none/).should be_true
90
+ (@first_page.instance_variable_get('@agent').last_page.parser.css('div#msg_saveSuccess')[0]['style'] !~ /display: none/).should be_true
91
91
 
92
92
  FakeWeb.register_uri(:get, 'https://sellercentral.amazon.com/gp/ezdpc-gui/inventory-status/status.html/ref=ag_invmgr_mmap_home', :response => mock_pages[:update_inventory_result_from_page_1])
93
93
  listing = AmazonSellerCentral::Inventory.load_first_page.listings[0]
@@ -30,7 +30,7 @@ describe "Mechanizer" do
30
30
 
31
31
  mech = AmazonSellerCentral.mechanizer
32
32
  mech.login_to_seller_central
33
- AmazonSellerCentral.mechanizer.reset!
33
+ mech.reset!
34
34
  lambda {
35
35
  mech.follow_link_with(:text => "Feedback")
36
36
  }.should raise_exception(AmazonSellerCentral::Mechanizer::AgentResetError)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amazon_seller_central
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - optoro
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-01 00:00:00 -04:00
18
+ date: 2011-09-08 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency