ficon 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 983278b3457ed0fb97538fbea8c9c245c6431d29
4
- data.tar.gz: 9c3425714495448a15b641264bee8fb1dd95220d
3
+ metadata.gz: f93ff5282fbdea68fba20fef8ec680122f0fc127
4
+ data.tar.gz: 0501155e4a2b1cff104176f78e617ef3c5f13a3a
5
5
  SHA512:
6
- metadata.gz: 48326e26ddeb8ee13f09d60ba5aa6fb5298700a153ebf872fd2f19e6329025db80b39dd876b37eaba31b9c8c938daa003e90e26d3eb30d4635a3357a0b08fae0
7
- data.tar.gz: 58b8a3f1d77a1ad0e5af439a15fd718aa12d9b81dc4463f096f81d51bef5db428a01447b4182159881767a888901bfdcd01b36c564100ea91342f9ba4841058b
6
+ metadata.gz: d71449d493421e4f1068c263e74a8d5f4a6ee61b12dfe95977963e3e426737cf2a72b9edaff61ad6a1fb82f277cb53e388f14470775f623302fcc21ff9825b6d
7
+ data.tar.gz: 44889ee60225766e370e6ab4ce1946a253bdfad07738cbcba2d56e1622907dee437054c23c8cc44a0b9013eeb7576d11316fb663e82934e25fb2507be48b6a59
data/README.md CHANGED
@@ -21,15 +21,13 @@ Or install it yourself as:
21
21
  irb(main)> Ficon.from_uri "https://facebook.com"
22
22
  => ["https://www.facebook.com/images/fb_icon_325x325.png", "https://fbstatic-a.akamaihd.net/rsrc.php/yV/r/hzMapiNYYpW.ico", "https://www.facebook.com/favicon.ico"]
23
23
 
24
- ## Todo
25
-
26
- When returning a win8-tile, should probably test if there's a colour assocaited with it. EG, twitter returns:
27
-
28
- ````html
29
- <meta name="msapplication-TileImage" content="//abs.twimg.com/favicons/win8-tile-144.png"/>
30
- <meta name="msapplication-TileColor" content="#00aced"/>
31
- ````
24
+ Or form the shell:
32
25
 
26
+ $ ficon https://facebook.com
27
+ https://www.facebook.com/images/fb_icon_325x325.png
28
+ https://fbstatic-a.akamaihd.net/rsrc.php/yV/r/hzMapiNYYpW.ico
29
+ https://www.facebook.com/favicon.ico
30
+
33
31
 
34
32
  ## Contributing
35
33
 
data/lib/ficon.rb CHANGED
@@ -53,8 +53,11 @@ module Ficon
53
53
 
54
54
  probe = Net::HTTP.new(uri.host).request_head("/")
55
55
  if probe.code == "301" || probe.code == "302"
56
- uri = URI(probe.header["Location"])
57
- uri.path = ""
56
+ new_uri = URI(probe.header["Location"])
57
+ if ! new_uri.host.nil?
58
+ uri = new_uri
59
+ uri.path = ""
60
+ end
58
61
  end
59
62
 
60
63
  results = []
@@ -81,12 +84,11 @@ module Ficon
81
84
  end
82
85
 
83
86
  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 }
87
+ collect {|e| e.values.select {|v| v =~ /\.png$|\.jpg$|\.gif$|\.ico$|\.svg$|\.ico\?\d*$/ }}.flatten.
88
+ collect {|v| v[/^http/] || v[/^\//] ? v : '/' + v }
86
89
  end
87
90
 
88
91
  def self.normalise(base, candidate)
89
- #candidate = '/' + candidate unless candidate[/^\//]
90
92
  parsed_candidate = URI(candidate);
91
93
 
92
94
  parsed_candidate.host = base.host if parsed_candidate.host.nil? # Set relative URLs to absolute
data/lib/ficon/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ficon
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/test/ficon_test.rb CHANGED
@@ -16,17 +16,19 @@ require 'ficon'
16
16
  Tests << { html: %Q{<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/wp-content/themes/torrentfreakredux/assets/img/icons/114.png">}, value: '/wp-content/themes/torrentfreakredux/assets/img/icons/114.png' }
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
- 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' }
21
- Tests << { html: %Q{<link rel="apple-touch-icon" href="/apple-touch-icon.png">}, value: '/apple-touch-icon.png' }
22
- Tests << { html: %Q{<link rel="shortcut icon" href="http://example.com/myicon.ico" />}, value: 'http://example.com/myicon.ico' }
23
- Tests << { html: %Q{<link rel="icon" href="http://example.com/image.ico" />}, value: 'http://example.com/image.ico' }
24
- Tests << { html: %Q{<link rel="icon" type="image/vnd.microsoft.icon" href="http://example.com/image.ico" />}, value: 'http://example.com/image.ico' }
25
- Tests << { html: %Q{<link rel="icon" type="image/png" href="http://example.com/image.png" />}, value: 'http://example.com/image.png' }
26
- Tests << { html: %Q{<link rel="icon" type="image/gif" href="http://example.com/image.gif" />}, value: 'http://example.com/image.gif' }
27
- Tests << { html: %Q{<link rel="icon" type="image/x-icon" href="http://example.com/image.ico"/>}, value: 'http://example.com/image.ico' }
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' }
21
+ Tests << { html: %Q{<link rel="apple-touch-icon" href="/apple-touch-icon.png">}, value: '/apple-touch-icon.png' }
22
+ Tests << { html: %Q{<link rel="shortcut icon" href="http://example.com/myicon.ico" />}, value: 'http://example.com/myicon.ico'}
23
+ Tests << { html: %Q{<link rel="icon" href="http://example.com/image.ico" />}, value: 'http://example.com/image.ico' }
24
+ Tests << { html: %Q{<link rel="icon" type="image/vnd.microsoft.icon" href="http://example.com/image.ico" />}, value: 'http://example.com/image.ico' }
25
+ Tests << { html: %Q{<link rel="icon" type="image/png" href="http://example.com/image.png" />}, value: 'http://example.com/image.png' }
26
+ Tests << { html: %Q{<link rel="icon" type="image/gif" href="http://example.com/image.gif" />}, value: 'http://example.com/image.gif' }
27
+ Tests << { html: %Q{<link rel="icon" type="image/x-icon" href="http://example.com/image.ico"/>}, value: 'http://example.com/image.ico' }
28
28
  Tests << { html: %Q{<link rel="shortcut icon" href="https://fbstatic-a.akamaihd.net/rsrc.php/yl/r/H3nktOa7ZMg.ico" />}, value: 'https://fbstatic-a.akamaihd.net/rsrc.php/yl/r/H3nktOa7ZMg.ico' }
29
- Tests << { html: %Q{<meta property="og:image" content="https://www.facebook.com/images/fb_icon_325x325.png" />}, value: 'https://www.facebook.com/images/fb_icon_325x325.png' }
29
+ Tests << { html: %Q{<meta property="og:image" content="https://www.facebook.com/images/fb_icon_325x325.png" />}, value: 'https://www.facebook.com/images/fb_icon_325x325.png' }
30
+ Tests << { html: %Q{<link rel="icon" type="image/vnd.microsoft.icon" href="/viconline/img/favicon.ico?1393375504" />}, value: '/viconline/img/favicon.ico?1393375504' }
31
+ Tests << { html: %Q{<link rel="shortcut icon" type="image/x-icon" href="/viconline/img/favicon.ico?1393375504" />}, value: '/viconline/img/favicon.ico?1393375504' }
30
32
 
31
33
 
32
34
  class FiconTest < Test::Unit::TestCase
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.3
4
+ version: 0.0.4
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-12-07 00:00:00.000000000 Z
11
+ date: 2014-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri