remote_book 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/remote_book/amazon.rb +2 -2
- data/lib/remote_book/barnes_and_noble.rb +5 -1
- data/spec/lib/barnes_and_noble_spec.rb +20 -4
- metadata +30 -52
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/remote_book/amazon.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module RemoteBook
|
2
2
|
class Amazon < RemoteBook::Base
|
3
|
-
attr_accessor :large_image, :medium_image, :small_image, :authors, :title, :isbn, :digital_link
|
4
|
-
|
5
3
|
# FIXME: failed digest support should raise exception.
|
6
4
|
# mac os 10.5 does not ship with SHA256 support built into ruby, 10.6 does.
|
7
5
|
DIGEST_SUPPORT = ::OpenSSL::Digest.constants.include?('SHA256') || ::OpenSSL::Digest.constants.include?(:SHA256)
|
8
6
|
DIGEST = ::OpenSSL::Digest::Digest.new('sha256') if DIGEST_SUPPORT
|
9
7
|
|
8
|
+
attr_accessor :large_image, :medium_image, :small_image, :authors, :title
|
9
|
+
|
10
10
|
def self.find(options)
|
11
11
|
a = new
|
12
12
|
# unless DIGEST_SUPPORT raise "no digest sup"
|
@@ -4,13 +4,17 @@ module RemoteBook
|
|
4
4
|
LINK_SHARE_DEEP_LINK_BASE = "http://getdeeplink.linksynergy.com/createcustomlink.shtml"
|
5
5
|
BN_LINK_SHARE_MID = "36889"
|
6
6
|
|
7
|
+
attr_accessor :raw_link, :affiliate_link
|
8
|
+
|
7
9
|
def self.find(options)
|
8
10
|
b = new
|
9
11
|
if options[:isbn]
|
10
12
|
bn_page = barnes_and_noble_page_link_for(options[:isbn])
|
11
13
|
return nil unless bn_page
|
14
|
+
b.raw_link = bn_page
|
15
|
+
b.affiliate_link = link_share_deep_link_for(bn_page)
|
12
16
|
|
13
|
-
b.link =
|
17
|
+
b.link = b.affiliate_link.nil? ? b.raw_link : b.affiliate_link
|
14
18
|
end
|
15
19
|
b
|
16
20
|
end
|
@@ -5,12 +5,28 @@ describe RemoteBook::BarnesAndNoble do
|
|
5
5
|
RemoteBook::BarnesAndNoble.associate_keys = {:web_service_token => 'doesntmatterfortest'}
|
6
6
|
end
|
7
7
|
it "should set link on successful get" do
|
8
|
-
|
8
|
+
affiliate_link = "http://click.linksynergy.com/fs-bin/some_ugly_path"
|
9
|
+
raw_link = "http://search.barnesandnoble.com/bookpath/"
|
9
10
|
FakeWeb.register_uri(:get, RemoteBook::BarnesAndNoble::ISBN_SEARCH_BASE_URI+"1433506254",
|
10
11
|
:body => "redirect",
|
11
|
-
:location =>
|
12
|
-
FakeWeb.register_uri(:get, %r|http://getdeeplink\.linksynergy\.com/(.*)|, :body =>
|
12
|
+
:location => raw_link)
|
13
|
+
FakeWeb.register_uri(:get, %r|http://getdeeplink\.linksynergy\.com/(.*)|, :body => affiliate_link)
|
13
14
|
a = RemoteBook::BarnesAndNoble.find_by_isbn("1433506254")
|
14
|
-
a.link.should ==
|
15
|
+
a.link.should == affiliate_link
|
16
|
+
a.affiliate_link.should == affiliate_link
|
17
|
+
a.raw_link.should == raw_link
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should set link to raw link when affiliate lookup fails" do
|
21
|
+
affiliate_link = "http://click.linksynergy.com/fs-bin/some_ugly_path"
|
22
|
+
raw_link = "http://search.barnesandnoble.com/bookpath/"
|
23
|
+
FakeWeb.register_uri(:get, RemoteBook::BarnesAndNoble::ISBN_SEARCH_BASE_URI+"1433506254",
|
24
|
+
:body => "redirect",
|
25
|
+
:location => raw_link)
|
26
|
+
FakeWeb.register_uri(:get, %r|http://getdeeplink\.linksynergy\.com/(.*)|, :body => "err", :status => ["404", "Not Found"])
|
27
|
+
a = RemoteBook::BarnesAndNoble.find_by_isbn("1433506254")
|
28
|
+
a.link.should == raw_link
|
29
|
+
a.affiliate_link.should be_nil
|
30
|
+
a.raw_link.should == raw_link
|
15
31
|
end
|
16
32
|
end
|
metadata
CHANGED
@@ -1,47 +1,35 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: remote_book
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 1
|
10
|
-
version: 0.1.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Seth Faxon
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-08-22 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: nokogiri
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70143972705560 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :runtime
|
34
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70143972705560
|
35
25
|
description: Pull book affiliate links and images from Amazon, Barns & Noble
|
36
|
-
email:
|
26
|
+
email:
|
37
27
|
- seth.faxon@gmail.com
|
38
28
|
executables: []
|
39
|
-
|
40
29
|
extensions: []
|
41
|
-
|
42
|
-
extra_rdoc_files:
|
30
|
+
extra_rdoc_files:
|
43
31
|
- README.rdoc
|
44
|
-
files:
|
32
|
+
files:
|
45
33
|
- .gitignore
|
46
34
|
- Gemfile
|
47
35
|
- README.rdoc
|
@@ -57,41 +45,31 @@ files:
|
|
57
45
|
- spec/lib/barnes_and_noble_spec.rb
|
58
46
|
- spec/spec_helper.rb
|
59
47
|
- tasks/spec.rake
|
60
|
-
has_rdoc: true
|
61
48
|
homepage: https://github.com/sfaxon/remote_book
|
62
49
|
licenses: []
|
63
|
-
|
64
50
|
post_install_message:
|
65
51
|
rdoc_options: []
|
66
|
-
|
67
|
-
require_paths:
|
52
|
+
require_paths:
|
68
53
|
- lib
|
69
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
55
|
none: false
|
71
|
-
requirements:
|
72
|
-
- -
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
|
75
|
-
|
76
|
-
- 0
|
77
|
-
version: "0"
|
78
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
61
|
none: false
|
80
|
-
requirements:
|
81
|
-
- -
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
|
84
|
-
segments:
|
85
|
-
- 0
|
86
|
-
version: "0"
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
87
66
|
requirements: []
|
88
|
-
|
89
67
|
rubyforge_project: remote_book
|
90
|
-
rubygems_version: 1.6
|
68
|
+
rubygems_version: 1.8.6
|
91
69
|
signing_key:
|
92
70
|
specification_version: 3
|
93
71
|
summary: Pull book affiliate links and images from Amazon, Barns & Noble
|
94
|
-
test_files:
|
72
|
+
test_files:
|
95
73
|
- spec/fixtures/amazon_1433506254.xml
|
96
74
|
- spec/lib/amazon_spec.rb
|
97
75
|
- spec/lib/barnes_and_noble_spec.rb
|