web_stat 0.3.15 → 0.3.16

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
  SHA256:
3
- metadata.gz: 82732f779004a5a2ef1f7259ce40126de8f51dfb07e46cd4972aafd3ab386ac3
4
- data.tar.gz: 17c2b99bdeb5db8c134d107fc9d4957dab985c7e680b1c92060bf7090315477b
3
+ metadata.gz: c332bb9cf67262c2b5d8e3c30c861107bd6ac8e3d86136730864e49b10dabcce
4
+ data.tar.gz: 712f39109989e917e8af6b84fe40b64ce84009a9de4b3647c03177ecb69bc58d
5
5
  SHA512:
6
- metadata.gz: d6691a57b0498fcfbb609042cdb7e12b4ac453b5cedaf6dd39671090c97fc19958a4162ba50947392116320ba78c9a21491acab27be2a41287825d3d4d2194d1
7
- data.tar.gz: 1e2e3d33f5c232532f442bbd16540c47810c93caef436a351124165b5294ddc7354d766ea66aa24ebc052c69432a639a6d5ef7b61a7cde896f6dc4676f95650d
6
+ metadata.gz: 3607fbe1e76018e3e523ed26a2777837c539a80f5c68da195996616d3566f6034125f0d49e96db9338ae40aeda5dac000968f6e089a7d96c19a412f14d2acbd2
7
+ data.tar.gz: 027d3b911cbee0dfdd7a8f85b32d24e4b8c9e2f916a47a2d3ea31b34fe0e2f07b452e00372d2028d511d39fba7df8f26347789fd795103422711d0e979b1d8a2
@@ -1,7 +1,12 @@
1
1
  module WebStat
2
2
  class Fetch
3
+ THUMBNAIL_REGEXS = {
4
+ :youtube => [
5
+ %r{^https://www.youtube.com/watch\?v=([^&]+)},
6
+ 'http://img.youtube.com/vi/\1/default.jpg'
7
+ ]
8
+ }
3
9
  attr_accessor :url, :html, :nokogiri, :userdic, :status
4
-
5
10
  # Get title
6
11
  # @return [String] title
7
12
  def title
@@ -19,7 +24,8 @@ module WebStat
19
24
  title.strip
20
25
  end
21
26
  end
22
- # Get name of domain
27
+
28
+ # Get name of domain
23
29
  def site_name
24
30
  begin
25
31
  site_name = @nokogiri.title.split(/#{WebStat::Configure.get["regex_to_sprit_title"]}/, 2).last
@@ -36,7 +42,7 @@ module WebStat
36
42
  def content
37
43
  Sanitize.clean(Readability::Document.new(@nokogiri.at('body')).content)
38
44
  end
39
-
45
+
40
46
  # Get temporary path of image
41
47
  def eyecatch_image_path
42
48
  # Reuse `path` in this method
@@ -47,9 +53,15 @@ module WebStat
47
53
  break
48
54
  end
49
55
  end
56
+ # If there is a thumbnail rule, apply it.
57
+ THUMBNAIL_REGEXS.each do |provider, v|
58
+ if @url.match(v[0])
59
+ return @url.gsub(v[0], v[1])
60
+ end
61
+ end
50
62
  readability_content = ::Nokogiri::HTML(Readability::Document.new(@nokogiri.at('body')).content)
51
63
  if (path.nil? || path.empty?) && readability_content.xpath('//img').first
52
- path = readability_content.xpath('//img').first.attr('src')
64
+ path = readability_content.xpath('//img').first.attr('src')
53
65
  end
54
66
  if (path.nil? || path.empty?) && @nokogiri.xpath('//img').first
55
67
  path = @nokogiri.xpath('//img').first.attr('src')
@@ -60,7 +72,7 @@ module WebStat
60
72
  path
61
73
  end
62
74
  end
63
-
75
+
64
76
  # Get local path to save url
65
77
  # @param [String] url
66
78
  def save_local_path(url)
@@ -77,7 +89,7 @@ module WebStat
77
89
  end
78
90
  tmp_file
79
91
  end
80
-
92
+
81
93
  # Get url
82
94
  # @param [String] url
83
95
  # @param [String] body
@@ -107,7 +119,7 @@ module WebStat
107
119
  end
108
120
  body
109
121
  end
110
-
122
+
111
123
  # Get the informations of @url
112
124
  # @param [Hash] Specify a dictionary for each language code. example ) {"ja": /***/**.dic, "other": /***/***.dic}
113
125
  def stat(userdics: nil)
@@ -1,3 +1,3 @@
1
1
  module WebStat
2
- VERSION = "0.3.15"
2
+ VERSION = "0.3.16"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web_stat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.15
4
+ version: 0.3.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - yusuke abe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-03 00:00:00.000000000 Z
11
+ date: 2020-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler