urifetch 0.1.1.rc4 → 0.1.1.rc5

Sign up to get free protection for your applications and to get access to all the features.
@@ -50,13 +50,23 @@ module Urifetch
50
50
  set :url, uri.to_s.sub(/\/$/,"")
51
51
 
52
52
  doc = Nokogiri::HTML.parse(@request,false)
53
+
54
+ # Image
55
+ image = doc.css('img').first
56
+ image = image.nil? ? nil : image['src'].try(:strip)
57
+ if image
58
+ if image.match(/^https?:\/\//i).nil?
59
+ image = uri.scheme + "://" + uri.host.sub(/\/$/,"") + "/" + image.sub(/^\//,"")
60
+ end
61
+ set :image, image
62
+ end
53
63
 
54
64
  # Open Auth data
55
65
  if og = OpenGraph.parse(doc)
56
- set :url, og.url.to_s.sub(/\/$/,""), override: true if og.url
57
- set :title, og.title if og.title
58
- set :image, og.image if og.image
59
- set :description, og.description if og.description
66
+ set :url, og.url.to_s.sub(/\/$/,""), override: true
67
+ set :title, og.title, override: true
68
+ set :image, og.image, override: true
69
+ set :description, og.description, override: true
60
70
  end
61
71
 
62
72
  # Custom CSS data
@@ -74,16 +84,6 @@ module Urifetch
74
84
  set :favicon, favicon
75
85
  end
76
86
 
77
- # Fallback Image
78
- image = doc.css('img').first
79
- image = image.nil? ? nil : image['src'].try(:strip)
80
- if image
81
- if image.match(/^https?:\/\//i).nil?
82
- image = uri.scheme + "://" + uri.host.sub(/\/$/,"") + "/" + image.sub(/^\//,"")
83
- end
84
- set(:image, image) unless get(:image)
85
- end
86
-
87
87
  end
88
88
 
89
89
  private
@@ -5,7 +5,7 @@ module Urifetch
5
5
  MAJOR = 0
6
6
  MINOR = 1
7
7
  PATCH = 1
8
- BUILD = 'rc4'
8
+ BUILD = 'rc5'
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
11
11
 
data/urifetch.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "urifetch"
8
- s.version = "0.1.1.rc4"
8
+ s.version = "0.1.1.rc5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Philip Vieira"]
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.rc4
4
+ version: 0.1.1.rc5
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: 176922821966614000
252
+ hash: -1453431270534021920
253
253
  required_rubygems_version: !ruby/object:Gem::Requirement
254
254
  none: false
255
255
  requirements: