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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc5fc123c0eb33e93cad52763281c7d245e1548e
4
- data.tar.gz: 81ac25d42620a9d589ef675880172f9551a7395b
3
+ metadata.gz: 3be685ce4c88a7b4bb145386e83a7abe75182002
4
+ data.tar.gz: 8f9f0067936d8d8b330c8d44d2bd302fa18ec10e
5
5
  SHA512:
6
- metadata.gz: 1e333fe7849786162ad9855e0652e301f825054ac322bfa1ab89ccddec8af2fff57bba32f35a43e6247f3de0a248a565f9db703c46e77f9304a7dc1ba9f6dc7a
7
- data.tar.gz: 4597a6b9fa3787eda0c8239db48bb758f336841d4529572a53b4478877f07a74ce0d56594c83930b48504144a9beec04e3e8109168fb497dc63458efbb5ee75d
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
- get_content("//meta[@property='og:image']")
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
@@ -1,3 +1,3 @@
1
1
  class LinkOracle
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: link_oracle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Cooper