link_oracle 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/link_oracle/extractor/og.rb +10 -1
- data/lib/link_oracle/version.rb +1 -1
- data/spec/link_oracle/extractor/og_spec.rb +20 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3be685ce4c88a7b4bb145386e83a7abe75182002
|
4
|
+
data.tar.gz: 8f9f0067936d8d8b330c8d44d2bd302fa18ec10e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4b7e2c94808c71a5140aa96b57046f58d6cc4b04be79acb27f7ba7a718034b81ccaa60755d7c0ff391feaca4d88968e349b89fa19620a5f688a395aa1bc4f9d
|
7
|
+
data.tar.gz: ac2fafb2410fc9c2cb0b979f27b0f2f3b2d3e7a55ca24a53b8700b725039b0c4b1b2e8cc9bf4d1f5db7bdaa67d85133151ffadeda95f26d62de457a602ccbdbb
|
@@ -10,12 +10,21 @@ class LinkOracle
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def image
|
13
|
-
|
13
|
+
return image_data if !image_data.first
|
14
|
+
image_is_path? ? [] : image_data
|
14
15
|
end
|
15
16
|
|
16
17
|
def description
|
17
18
|
get_content("//meta[@property='og:description']")
|
18
19
|
end
|
20
|
+
|
21
|
+
def image_is_path?
|
22
|
+
!!(image_data.first.match(/\A\//))
|
23
|
+
end
|
24
|
+
|
25
|
+
def image_data
|
26
|
+
get_content("//meta[@property='og:image']")
|
27
|
+
end
|
19
28
|
end
|
20
29
|
end
|
21
30
|
end
|
data/lib/link_oracle/version.rb
CHANGED
@@ -57,12 +57,11 @@ describe LinkOracle::Extractor::OG do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'should set image to nil' do
|
60
|
-
link_data.image_url.should == nil
|
60
|
+
link_data.image_url.should == nil
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
context 'there is og_data' do
|
65
|
-
|
66
65
|
it 'should populate link_data title' do
|
67
66
|
link_data.title.should == 'This is a title'
|
68
67
|
end
|
@@ -75,5 +74,24 @@ describe LinkOracle::Extractor::OG do
|
|
75
74
|
link_data.description.should == 'A description for your face'
|
76
75
|
end
|
77
76
|
end
|
77
|
+
|
78
|
+
context 'the og image content is a path' do
|
79
|
+
let(:body) {
|
80
|
+
"<html>
|
81
|
+
<head>
|
82
|
+
<meta property=\"og:title\" content=\"This is a title\">
|
83
|
+
<meta property=\"og:description\" content=\"A description for your face\">
|
84
|
+
<meta property=\"og:image\" content=\"/sites/default/files/go_og.jpg\">
|
85
|
+
<meta name=\"Description\" content=\" \tHere is a description not for facebook\t\">
|
86
|
+
<meta name=\"KEYWORDS\" content=\" \tKeywords, Keywords everywhere \t\">
|
87
|
+
<title>TITLE!</title>
|
88
|
+
</head>
|
89
|
+
</html>"
|
90
|
+
}
|
91
|
+
|
92
|
+
it 'should set image to nil' do
|
93
|
+
link_data.image_url.should == nil
|
94
|
+
end
|
95
|
+
end
|
78
96
|
end
|
79
97
|
end
|