onebox 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a7bb8f501bd1571f0ebb6d05de268c7a25bfaf4
4
- data.tar.gz: a9d916c58f10fd69906578734bc50ade5fedf9b3
3
+ metadata.gz: 977d0987e9df9956d13b5fd9b4ea2836970950cc
4
+ data.tar.gz: a41dccd090afb43672b7569a9fc6d0b9cb514839
5
5
  SHA512:
6
- metadata.gz: 76f0c2bbcf0aa381da8b934f12b00397d56eda73460409fd6837def9df358849f75ec1e257a21509cca5868a8b2415507a62dbb5ba5164668eb978ee4b302895
7
- data.tar.gz: c407ceea8eb7cec34d382469f708310862784264bf42793b502e8818dc4e5c689e0bc78df3cb29fec9ee583bc00b062d440c065a0cb4144baf799eb2cae2c185
6
+ metadata.gz: 95c60583f27f77785ebcd5727a73d374383bded0639dfeb51812ef08a04733aaa720737ca589be7c36f23075a705b56bf9220d797b2a3c3f218b335fa7b18b07
7
+ data.tar.gz: f5ab7b01db74e545f60623e964344a52a68c8574a7b6aa7962ad3b44edd0716bf9c7f2b2e23e10ace38ab86157fca8b8c48fd14ecf9ab32669e9be179cdd1c98
@@ -6,13 +6,17 @@ module Onebox
6
6
  include HTML
7
7
 
8
8
 
9
- matches_regexp(/^http:\/\/(?:www)\.amazon\.(com|ca)/)
9
+ matches_regexp(/^http:\/\/(?:www)\.amazon\.(?<tld>com|ca|de|it|es|fr|co\.jp|co\.uk|cn|in|com\.br)\//)
10
10
 
11
11
  def url
12
- return "http://www.amazon.com/gp/aw/d/" + URI::encode(match[:id]) if match && match[:id]
12
+ return "http://www.amazon.#{tld}/gp/aw/d/" + URI::encode(match[:id]) if match && match[:id]
13
13
  @url
14
14
  end
15
15
 
16
+ def tld
17
+ @tld || @@matcher.match(@url)["tld"]
18
+ end
19
+
16
20
  def http_params
17
21
  {'User-Agent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3'}
18
22
  end
@@ -32,7 +32,7 @@ module Onebox
32
32
  private
33
33
 
34
34
  def parse_open_graph(html, url)
35
- og = Struct.new(:url, :type, :title, :description, :images, :metadata).new
35
+ og = Struct.new(:url, :type, :title, :description, :images, :metadata, :html).new
36
36
  og.url = url
37
37
  og.images = []
38
38
  og.metadata = {}
@@ -69,6 +69,7 @@ module Onebox
69
69
  liveleak.com
70
70
  lessonplanet.com
71
71
  mashable.com
72
+ meetup.com
72
73
  mlb.com
73
74
  myspace.com
74
75
  nba.com
@@ -30,7 +30,7 @@ module Onebox
30
30
  html = "<iframe width=\"480\" height=\"270\" src=\"https://www.youtube.com/embed/#{video_id}?feature=oembed\" frameborder=\"0\" allowfullscreen></iframe>"
31
31
  else
32
32
  # Fall back to making HTTP requests.
33
- html = raw[:html]
33
+ html = raw[:html] || ""
34
34
  end
35
35
 
36
36
  rewrite_agnostic(append_params(html))
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.3.2"
2
+ VERSION = "1.3.3"
3
3
  end
@@ -9,6 +9,57 @@ describe Onebox::Engine::AmazonOnebox do
9
9
  include_context "engines"
10
10
  it_behaves_like "an engine"
11
11
 
12
+ describe "works with international domains" do
13
+
14
+ def check_link(tdl, link)
15
+ onebox_cls = Onebox::Matcher.new(link).oneboxed
16
+ expect(onebox_cls).to_not be(nil)
17
+ expect(onebox_cls.new(link).url).to include("http://www.amazon.#{tdl}")
18
+ end
19
+
20
+ it "matches canadian domains" do
21
+ resp = check_link("ca", "http://www.amazon.ca/Too-Much-Happiness-Alice-Munro-ebook/dp/B0031TZ98K/")
22
+
23
+ end
24
+
25
+ it "matches german domains" do
26
+ check_link("de", "http://www.amazon.de/Buddenbrooks-Verfall-einer-Familie-Roman/dp/3596294312/")
27
+ end
28
+
29
+ it "matches uk domains" do
30
+ check_link("co.uk", "http://www.amazon.co.uk/Pygmalion-George-Bernard-Shaw/dp/1420925237/")
31
+ end
32
+
33
+ it "matches japanese domains" do
34
+ check_link("co.jp", "http://www.amazon.co.jp/%E9%9B%AA%E5%9B%BD-%E6%96%B0%E6%BD%AE%E6%96%87%E5%BA%AB-%E3%81%8B-1-1-%E5%B7%9D%E7%AB%AF-%E5%BA%B7%E6%88%90/dp/4101001014/")
35
+ end
36
+
37
+ it "matches chinese domains" do
38
+ check_link("cn", "http://www.amazon.cn/%E5%AD%99%E5%AD%90%E5%85%B5%E6%B3%95-%E5%AD%99%E8%86%91%E5%85%B5%E6%B3%95-%E5%AD%99%E6%AD%A6/dp/B0011C40FC/")
39
+ end
40
+
41
+ it "matches french domains" do
42
+ check_link("fr", "http://www.amazon.fr/Les-Mots-autres-%C3%A9crits-autobiographiques/dp/2070114147/")
43
+ end
44
+
45
+ it "matches italian domains" do
46
+ check_link("it", "http://www.amazon.it/Tutte-poesie-Salvatore-Quasimodo/dp/8804520477/")
47
+ end
48
+
49
+ it "matches spanish domains" do
50
+ check_link("es", "http://www.amazon.es/familia-Pascual-Duarte-Camilo-Jos%C3%A9-ebook/dp/B00EJRTKTW/")
51
+ end
52
+
53
+ it "matches brasilian domains" do
54
+ check_link("com.br", "http://www.amazon.com.br/A-p%C3%A1tria-chuteiras-Nelson-Rodrigues-ebook/dp/B00J2B414Y/")
55
+ end
56
+
57
+ it "matches indian domains" do
58
+ check_link("in", "http://www.amazon.in/Fireflies-Rabindranath-Tagore/dp/9381523169/")
59
+ end
60
+
61
+ end
62
+
12
63
  describe "#to_html" do
13
64
  it "includes image" do
14
65
  expect(html).to include("img")
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,3 @@
1
- require "coveralls"
2
- Coveralls.wear! do
3
- add_filter "/spec/"
4
- end
5
-
6
1
  require "rspec"
7
2
  require "pry"
8
3
  require "fakeweb"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onebox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joanna Zeta
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-04-25 00:00:00.000000000 Z
13
+ date: 2014-05-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json