forked from lovehandle/agent_cooper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
General cleanup and add EM::Synchrony support
- Loading branch information
Ryan Closner
committed
Jul 23, 2011
1 parent
152c04e
commit 9121112
Showing
62 changed files
with
4,399 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
.bundle | ||
Gemfile.lock | ||
pkg/* | ||
*.yml | ||
ebay.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
require 'vcr' | ||
|
||
def ebay | ||
@ebay ||= YAML::load_file(File.dirname(__FILE__) + "/../../spec/fixtures/ebay.yml") | ||
end | ||
|
||
def ebay_app_id | ||
ebay['app_id'] | ||
end | ||
|
||
|
||
VCR.config do |c| | ||
c.cassette_library_dir = File.dirname(__FILE__) + '/../../spec/fixtures/cassettes' | ||
c.default_cassette_options = { | ||
:record => :none, | ||
:match_requests_on => [:host] } | ||
c.stub_with :webmock | ||
c.filter_sensitive_data('YOUR-APP-ID') { ebay_app_id } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
# Utilities | ||
require 'agent_cooper/config' | ||
require 'agent_cooper/request' | ||
require 'agent_cooper/response' | ||
require 'agent_cooper/finder' | ||
require 'agent_cooper/shopper' | ||
require 'agent_cooper/merchandiser' | ||
require 'agent_cooper/request' | ||
|
||
require 'agent_cooper/nokogiri_decorator' | ||
|
||
# Requests | ||
require 'agent_cooper/requests/finder' | ||
require 'agent_cooper/requests/shopper' | ||
require 'agent_cooper/requests/merchandiser' | ||
|
||
#Version | ||
require "agent_cooper/version" | ||
|
||
module AgentCooper | ||
class << self | ||
def configure(&block) | ||
yield Config | ||
Config.configure(&block) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
module AgentCooper | ||
|
||
# Based on https://gist.github.com/335286 | ||
|
||
class Nokogiri::XML::Document | ||
def to_hash | ||
root.to_hash | ||
end | ||
end | ||
|
||
class Nokogiri::XML::Element | ||
def to_hash | ||
({}).tap do |hash| | ||
|
||
attributes.each_pair do |key, attribute| | ||
hash[key] = attribute.value | ||
end | ||
|
||
children.each do |child| | ||
result = child.to_hash | ||
|
||
if child.name == 'text' | ||
if hash.empty? | ||
return result | ||
else | ||
hash['__content__'] = result | ||
end | ||
elsif hash[child.name] | ||
if hash[child.name].is_a?(Array) | ||
hash[child.name] << result | ||
else | ||
hash[child.name] = [hash[child.name]] << result | ||
end | ||
else | ||
hash[child.name] = result | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
class Nokogiri::XML::Text | ||
def to_hash | ||
content.to_s | ||
end | ||
end | ||
end |
Oops, something went wrong.