urifetch 0.1.1.rc5 → 0.1.1.rc6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/urifetch.rb +6 -6
- data/lib/urifetch/strategy.rb +2 -2
- data/lib/urifetch/strategy/base.rb +6 -4
- data/lib/urifetch/version.rb +1 -1
- data/urifetch.gemspec +1 -1
- metadata +2 -2
data/lib/urifetch.rb
CHANGED
@@ -14,12 +14,12 @@ include ActionView::Helpers::NumberHelper
|
|
14
14
|
|
15
15
|
module Urifetch
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
require "#{File.expand_path(File.dirname(__FILE__))}/urifetch/response"
|
18
|
+
require "#{File.expand_path(File.dirname(__FILE__))}/urifetch/strategy"
|
19
|
+
require "#{File.expand_path(File.dirname(__FILE__))}/urifetch/router"
|
20
|
+
require "#{File.expand_path(File.dirname(__FILE__))}/urifetch/version"
|
21
|
+
|
22
|
+
require "#{File.expand_path(File.dirname(__FILE__))}/urifetch/ext/opengraph"
|
23
23
|
|
24
24
|
@@router = Router.new()
|
25
25
|
|
data/lib/urifetch/strategy.rb
CHANGED
@@ -2,8 +2,8 @@ module Urifetch
|
|
2
2
|
|
3
3
|
module Strategy
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
require "#{File.expand_path(File.dirname(__FILE__))}/strategy/base"
|
6
|
+
require "#{File.expand_path(File.dirname(__FILE__))}/strategy/image"
|
7
7
|
|
8
8
|
end
|
9
9
|
|
@@ -49,8 +49,8 @@ module Urifetch
|
|
49
49
|
# Start by setting the URI
|
50
50
|
set :url, uri.to_s.sub(/\/$/,"")
|
51
51
|
|
52
|
-
doc = Nokogiri::HTML.parse(@request
|
53
|
-
|
52
|
+
doc = Nokogiri::HTML.parse(@request)
|
53
|
+
|
54
54
|
# Image
|
55
55
|
image = doc.css('img').first
|
56
56
|
image = image.nil? ? nil : image['src'].try(:strip)
|
@@ -62,7 +62,7 @@ module Urifetch
|
|
62
62
|
end
|
63
63
|
|
64
64
|
# Open Auth data
|
65
|
-
if og = OpenGraph.parse(doc)
|
65
|
+
if og = OpenGraph.parse(doc,false)
|
66
66
|
set :url, og.url.to_s.sub(/\/$/,""), override: true
|
67
67
|
set :title, og.title, override: true
|
68
68
|
set :image, og.image, override: true
|
@@ -97,7 +97,9 @@ module Urifetch
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def set(key,value,args={})
|
100
|
-
|
100
|
+
if value.present?
|
101
|
+
response.data[key.to_s] = value if (args[:override] || !response.data[key.to_s].present?)
|
102
|
+
end
|
101
103
|
end
|
102
104
|
|
103
105
|
def set?(key)
|
data/lib/urifetch/version.rb
CHANGED
data/urifetch.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: urifetch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.1.
|
4
|
+
version: 0.1.1.rc6
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -249,7 +249,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
249
249
|
version: '0'
|
250
250
|
segments:
|
251
251
|
- 0
|
252
|
-
hash:
|
252
|
+
hash: 460218162848213799
|
253
253
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
254
254
|
none: false
|
255
255
|
requirements:
|