website_information 0.5.9 → 0.6.0

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: 1e9b92b3d30227c97666ea9fe32c8fc9507bdaa5
4
- data.tar.gz: 4a7072b38298108edb69ce6482e953b35a67562d
3
+ metadata.gz: 34a9a5e4512000c12c0486a1d7f943439fdfa547
4
+ data.tar.gz: 30ca352dbd771d8a8a53ec232e0eb17e85812d55
5
5
  SHA512:
6
- metadata.gz: 6a4e435558b6a08df1f47292548b26f3693830d0348d5a1edb1e6690bfca7e8d73e2a0d77daf189e273e1587c411d912f5a1688bc9f371e78b34b61c841f7108
7
- data.tar.gz: fdc22080a8dc907e50ae84e247d607d641bd03b39c5b03d58fde320e1e0261ea5bb1db1a877ec17bd499082581642c96087edaccd92f050b4b6672db7fd76e7c
6
+ metadata.gz: 5d56538148e498c2b612ae61ab900fd38ee6b8d3f252f6f2ff3bf72d93c89101d3eed4abe6b6e71f0f28696dcd41716b866416c682d3344e9a0d65ebc4dae786
7
+ data.tar.gz: de1f16c637b0f366f1a8f3be8cb1d00272c1ade19e5ef340468adc7ebdeab0408d1c0160b34816662504ab92ea10f16aa46b912d4530908838c496cd92f0cd12
@@ -3,7 +3,7 @@ require 'selenium-webdriver'
3
3
  module WebsiteInformation
4
4
  module Params
5
5
  class Site
6
- attr_accessor :url, :title, :capture, :feed
6
+ attr_accessor :url, :title, :capture, :feed, :favicon
7
7
 
8
8
  def initialize(url)
9
9
  @url = url
@@ -1,3 +1,3 @@
1
1
  module WebsiteInformation
2
- VERSION = "0.5.9"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -24,10 +24,26 @@ module WebsiteInformation
24
24
  @params.og.url = doc.css('//meta[property="og:url"]/@content').to_s
25
25
  @params.og.type = doc.css('//meta[property="og:type"]/@content').to_s
26
26
  @params.og.image = doc.css('//meta[property="og:image"]/@content').to_s
27
+ favicon(doc, url)
27
28
  feed(doc)
28
29
  sns(doc)
29
30
  end
30
31
 
32
+ def favicon(doc, url)
33
+ favicon = doc.css('//link[@rel="shortcut icon"]/@href').to_s
34
+ favicon = doc.css('//link[@type="image/x-icon"]/@href').to_s if favicon.empty?
35
+ favicon = '/favicon.ico' if favicon.empty?
36
+
37
+ require 'uri'
38
+ uri = URI.parse(favicon)
39
+ if uri.host.nil?
40
+ uri = URI.parse(url)
41
+ @params.favicon = "#{uri.scheme}://#{uri.host}#{favicon}"
42
+ else
43
+ @params.favicon = favicon
44
+ end
45
+ end
46
+
31
47
  def feed(doc)
32
48
  @params.feed = doc.css('//link[@rel="alternate"][@type="application/atom+xml"]/@href')[0].to_s
33
49
  @params.feed = doc.css('//link[@rel="alternate"][@type="application/rss+xml"]/@href')[0].to_s if @params.feed.empty?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: website_information
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.9
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - miraoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-03 00:00:00.000000000 Z
11
+ date: 2017-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri