web_stat 0.3.18 → 0.3.19

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
  SHA256:
3
- metadata.gz: a1577e388af881db0fb90000e62a9768711d6098fb256235a7976ac317a2f2f2
4
- data.tar.gz: 06d1a79f46b436e20fc0730232ff4997eec11eccd939a1d7d28311780f496273
3
+ metadata.gz: 2893819d947835e7cc92b35361c487ede791e0bd87ac7aa94bb0d0c3e28780a0
4
+ data.tar.gz: 35d90e33f07dc24fabeabca7aef669519053781ff71ddeec12ca85ee52521c3b
5
5
  SHA512:
6
- metadata.gz: 15f4eca65d1fdc2d3c4bc5d1e06817e78896774abfe384419b8416a0ff73ff6b423c15b029632e28708e58e868f0c126e86f56295b618cc4ea4d93ac6cc7d26d
7
- data.tar.gz: e15ee2f11d221b1d6997a6f7aad45571c6bf9456b813e95465f5c029617b701e4f18e3b4b7ec35246d0fddefca1f7648d07bff5a585eaf18cc9859362ceb5ca9
6
+ metadata.gz: 6f576937d619990b2ccb72bf016975521065e052605c7c4835f233f0f58da866836cb961ea8bd8d213bebee84671717d73b35cc82a0a49dcef9ad04f276cacd3
7
+ data.tar.gz: 87711062737c14f00523ea51a91de50f5e9a00364c4df73a61bd49fcfa5559ae7b995718168b2fa48346d0f3e25af16aa98df16e56b4c6f1dea7ebf74a629664
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- web_stat (0.3.18)
4
+ web_stat (0.3.19)
5
5
  bundler (>= 2.0.2)
6
6
  cld (>= 0.8.0)
7
7
  mechanize (>= 2.7)
@@ -1,7 +1,7 @@
1
1
  development: &development
2
2
  # Minimum number of characters to detect meta title
3
3
  min_length_of_meta_title: 10
4
- # Split regular expression for titles
4
+ # Split regular expression for titles
5
5
  regex_to_sprit_title: '\||-|:|||:|〜|\~| – '
6
6
  # User Agent
7
7
  user_agent: "web_stat gem agent"
@@ -14,6 +14,10 @@ development: &development
14
14
  - '//img/@src'
15
15
  userdic: ""
16
16
  use_chromedirver: false
17
+ thumbnail_regex:
18
+ youtube:
19
+ - '%r{^https://www.youtube.com/watch\?v=([^&]+)}'
20
+ - 'http://img.youtube.com/vi/\1/default.jpg'
17
21
  test:
18
22
  <<: *development
19
23
  production:
@@ -1,11 +1,5 @@
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
- }
9
3
  attr_accessor :url, :html, :nokogiri, :userdic, :status
10
4
  # Get title
11
5
  # @return [String] title
@@ -54,7 +48,7 @@ module WebStat
54
48
  end
55
49
  end
56
50
  # If there is a thumbnail rule, apply it.
57
- THUMBNAIL_REGEXS.each do |provider, v|
51
+ WebStat::Configure.get["thumbnail_regex"].each do |provider, v|
58
52
  if @url.match(v[0])
59
53
  return @url.gsub(v[0], v[1])
60
54
  end
@@ -1,3 +1,3 @@
1
1
  module WebStat
2
- VERSION = "0.3.18"
2
+ VERSION = "0.3.19"
3
3
  end
@@ -3,11 +3,26 @@ RSpec.describe WebStat::Configure do
3
3
  configure = WebStat::Configure.get
4
4
  expect(configure).not_to eq nil
5
5
  end
6
-
6
+
7
7
  it "Readable Config" do
8
8
  config = WebStat::Configure.get
9
-
9
+
10
10
  expect(config["min_length_of_meta_title"]).to eq 10
11
11
  expect(config["regex_to_sprit_title"]).to eq '\||-|:|||:|〜|\~| – '
12
12
  end
13
+
14
+ it "Get thumbnail_regex.youtube." do
15
+ config = WebStat::Configure.get
16
+ expect(config["thumbnail_regex"]["yotube"].nil?).to eq true
17
+ expect(config["thumbnail_regex"]["youtube"].count).to eq 2
18
+ end
19
+
20
+ it "Match youtube url." do
21
+ sample_url = "https://www.youtube.com/watch?v=aChpsuUffUM"
22
+ WebStat::Configure.get["thumbnail_regex"].each do |provider, v|
23
+ if sample_url.match(v[0])
24
+ expect(sample_url.gsub(v[0], v[1])).to eq 'http://img.youtube.com/vi/aChpsuUffUM/default.jpg'
25
+ end
26
+ end
27
+ end
13
28
  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.18
4
+ version: 0.3.19
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-10-11 00:00:00.000000000 Z
11
+ date: 2020-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler