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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/web_stat/config/web_stat.yml +5 -1
- data/lib/web_stat/fetch.rb +1 -7
- data/lib/web_stat/version.rb +1 -1
- data/spec/web_stat/configure_spec.rb +17 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2893819d947835e7cc92b35361c487ede791e0bd87ac7aa94bb0d0c3e28780a0
|
4
|
+
data.tar.gz: 35d90e33f07dc24fabeabca7aef669519053781ff71ddeec12ca85ee52521c3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f576937d619990b2ccb72bf016975521065e052605c7c4835f233f0f58da866836cb961ea8bd8d213bebee84671717d73b35cc82a0a49dcef9ad04f276cacd3
|
7
|
+
data.tar.gz: 87711062737c14f00523ea51a91de50f5e9a00364c4df73a61bd49fcfa5559ae7b995718168b2fa48346d0f3e25af16aa98df16e56b4c6f1dea7ebf74a629664
|
data/Gemfile.lock
CHANGED
@@ -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:
|
data/lib/web_stat/fetch.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/web_stat/version.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2020-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|