ficon 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ficon/version.rb +1 -1
- data/lib/ficon.rb +4 -2
- data/test/ficon_test.rb +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 983278b3457ed0fb97538fbea8c9c245c6431d29
|
4
|
+
data.tar.gz: 9c3425714495448a15b641264bee8fb1dd95220d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48326e26ddeb8ee13f09d60ba5aa6fb5298700a153ebf872fd2f19e6329025db80b39dd876b37eaba31b9c8c938daa003e90e26d3eb30d4635a3357a0b08fae0
|
7
|
+
data.tar.gz: 58b8a3f1d77a1ad0e5af439a15fd718aa12d9b81dc4463f096f81d51bef5db428a01447b4182159881767a888901bfdcd01b36c564100ea91342f9ba4841058b
|
data/lib/ficon/version.rb
CHANGED
data/lib/ficon.rb
CHANGED
@@ -80,11 +80,13 @@ module Ficon
|
|
80
80
|
raise ArgumentError
|
81
81
|
end
|
82
82
|
|
83
|
-
doc.xpath("//meta[@property='og:image']|//meta[@name='msapplication-TileImage']|//link[@type='image/ico' or @type='image/vnd.microsoft.icon']|//link[@rel='icon' or @rel='shortcut icon' or @rel='apple-touch-icon-precomposed' or @rel='apple-touch-icon']").
|
84
|
-
|
83
|
+
doc.xpath("//meta[@property='og:image']|//meta[@name='msapplication-TileImage']|//link[@type='image/ico' or @type='image/vnd.microsoft.icon']|//link[@rel='icon' or @rel='shortcut icon' or @rel='apple-touch-icon-precomposed' or @rel='apple-touch-icon']").
|
84
|
+
collect {|e| e.values.select {|v| v =~ /\.png$|\.jpg$|\.gif$|\.ico$|\.svg$/ }}.
|
85
|
+
flatten.collect {|v| v[/^http/] || v[/^\//] ? v : '/' + v }
|
85
86
|
end
|
86
87
|
|
87
88
|
def self.normalise(base, candidate)
|
89
|
+
#candidate = '/' + candidate unless candidate[/^\//]
|
88
90
|
parsed_candidate = URI(candidate);
|
89
91
|
|
90
92
|
parsed_candidate.host = base.host if parsed_candidate.host.nil? # Set relative URLs to absolute
|
data/test/ficon_test.rb
CHANGED
@@ -17,6 +17,7 @@ require 'ficon'
|
|
17
17
|
Tests << { html: %Q{<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/wp-content/themes/torrentfreakredux/assets/img/icons/72.png">}, value: '/wp-content/themes/torrentfreakredux/assets/img/icons/72.png' }
|
18
18
|
Tests << { html: %Q{<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/wp-content/themes/torrentfreakredux/assets/img/icons/144.png">}, value: '/wp-content/themes/torrentfreakredux/assets/img/icons/144.png' }
|
19
19
|
Tests << { html: %Q{<link rel="shortcut icon" href="/favicon.png">}, value: '/favicon.png' }
|
20
|
+
Tests << { html: %Q{<link rel="shortcut icon" href="favicon.ico" />}, value: '/favicon.ico' }
|
20
21
|
Tests << { html: %Q{<link rel="apple-touch-icon" href="/apple-touch-icon.png">}, value: '/apple-touch-icon.png' }
|
21
22
|
Tests << { html: %Q{<link rel="shortcut icon" href="http://example.com/myicon.ico" />}, value: 'http://example.com/myicon.ico' }
|
22
23
|
Tests << { html: %Q{<link rel="icon" href="http://example.com/image.ico" />}, value: 'http://example.com/image.ico' }
|
@@ -31,7 +32,8 @@ require 'ficon'
|
|
31
32
|
class FiconTest < Test::Unit::TestCase
|
32
33
|
def test_html_chunks
|
33
34
|
Tests.each do |t|
|
34
|
-
|
35
|
+
result = Ficon.from_page( t[:html] )[0]
|
36
|
+
assert result == t[:value], "Seaching |#{t[:html]}| expected #{t[:value]}, got #{result}"
|
35
37
|
end
|
36
38
|
end
|
37
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ficon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Milne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|