nhkore 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -2
- data/Gemfile +0 -18
- data/Gemfile.lock +32 -29
- data/README.md +19 -19
- data/Rakefile +38 -52
- data/bin/nhkore +4 -15
- data/lib/nhkore.rb +8 -20
- data/lib/nhkore/app.rb +229 -234
- data/lib/nhkore/article.rb +39 -53
- data/lib/nhkore/article_scraper.rb +293 -285
- data/lib/nhkore/cleaner.rb +20 -32
- data/lib/nhkore/cli/fx_cmd.rb +41 -53
- data/lib/nhkore/cli/get_cmd.rb +59 -70
- data/lib/nhkore/cli/news_cmd.rb +143 -153
- data/lib/nhkore/cli/search_cmd.rb +108 -118
- data/lib/nhkore/cli/sift_cmd.rb +109 -120
- data/lib/nhkore/datetime_parser.rb +88 -104
- data/lib/nhkore/defn.rb +48 -55
- data/lib/nhkore/dict.rb +26 -38
- data/lib/nhkore/dict_scraper.rb +31 -40
- data/lib/nhkore/entry.rb +43 -55
- data/lib/nhkore/error.rb +16 -21
- data/lib/nhkore/fileable.rb +10 -21
- data/lib/nhkore/lib.rb +5 -17
- data/lib/nhkore/missingno.rb +21 -33
- data/lib/nhkore/news.rb +58 -72
- data/lib/nhkore/polisher.rb +22 -34
- data/lib/nhkore/scraper.rb +74 -83
- data/lib/nhkore/search_link.rb +62 -76
- data/lib/nhkore/search_scraper.rb +81 -92
- data/lib/nhkore/sifter.rb +157 -171
- data/lib/nhkore/splitter.rb +19 -31
- data/lib/nhkore/user_agents.rb +28 -32
- data/lib/nhkore/util.rb +72 -84
- data/lib/nhkore/variator.rb +20 -32
- data/lib/nhkore/version.rb +4 -16
- data/lib/nhkore/word.rb +99 -97
- data/nhkore.gemspec +30 -51
- data/samples/looper.rb +18 -29
- data/test/nhkore/test_helper.rb +3 -15
- data/test/nhkore_test.rb +6 -18
- metadata +33 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c63efbc2f65cfe83c7b55e53a0dfca329c2aded4c22ae05c2fb50583876452b4
|
4
|
+
data.tar.gz: 87c5116e11cb7e2dd4a5cdb86d6fc1a80ea58dd4efa7bc27ad448c25c4fad724
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68eb93da6d8f5c8ba3c4c58e0a9a71803dd4eefc6063df4ead9f0d06c0f1ba59892f5ddb43a9735c30ceaf85db63ed80c1b155bac1d5f0daf73f9cebbc7f6c6e
|
7
|
+
data.tar.gz: 33e9f4f770bceb2c0eb5d6d62781af400bc2b66f4ba4d4092b01b224bc365edef98cc47032f4b2389e04664f6cabcd2c02024139971bee207a121570805a6015
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,30 @@
|
|
1
1
|
# Changelog | NHKore
|
2
2
|
|
3
|
-
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
Format is based on [Keep a Changelog v1.0.0](https://keepachangelog.com/en/1.0.0),
|
6
|
+
and this project adheres to [Semantic Versioning v2.0.0](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [[Unreleased]](https://github.com/esotericpig/nhkore/compare/v0.3.8...HEAD)
|
9
|
+
-
|
10
|
+
|
11
|
+
|
12
|
+
## [v0.3.8] - 2021-06-26
|
13
|
+
|
14
|
+
### Fixed
|
15
|
+
- Fixed `App#refresh_cmd()` to also copy Cri's `default_proc` to the new Hash for the command options.
|
16
|
+
- Fixed to check for non-strings for JSON & URI.
|
17
|
+
- For JSON, convert `StringIO` to string in `DictScraper.scrape()`.
|
18
|
+
- For URL, convert URL using `URI()` because `URI.parse()` will crash with a non-string (URI object) in `Scraper.open_url()`.
|
19
|
+
- Fixed to scrape multiple HTML Ruby tag words (instead of just 1).
|
20
|
+
- I thought multiple Ruby bases/texts (`<rb>`/`<rt>`) were invalid, but after running into the article below and checking the HTML with a validator, it's actually valid HTML:
|
21
|
+
- https://www3.nhk.or.jp/news/easy/k10012759201000/k10012759201000.html
|
22
|
+
- No previous articles/URLs ran into this problem (would have raised an error), so it should only be a problem with this specific, new article.
|
23
|
+
|
24
|
+
### Changed
|
25
|
+
- Formatted/Linted all code using RuboCop.
|
26
|
+
- Updated Gems.
|
4
27
|
|
5
|
-
## [[Unreleased]](https://github.com/esotericpig/nhkore/compare/v0.3.7...HEAD)
|
6
28
|
|
7
29
|
## [v0.3.7] - 2020-11-07
|
8
30
|
|
@@ -20,6 +42,7 @@ Format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
20
42
|
- https://www3.nhk.or.jp/news/easy/k10012639271000/k10012639271000.html
|
21
43
|
- `第3のビール` should have HTML ruby tags around *第*
|
22
44
|
|
45
|
+
|
23
46
|
## [v0.3.6] - 2020-08-18
|
24
47
|
|
25
48
|
### Added
|
@@ -35,6 +58,7 @@ Format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
35
58
|
- Ignored `/cgi2.*enqform/` URLs from SearchScraper (Bing)
|
36
59
|
- Added more detail to dictionary error in ArticleScraper
|
37
60
|
|
61
|
+
|
38
62
|
## [v0.3.5] - 2020-05-04
|
39
63
|
|
40
64
|
### Added
|
@@ -45,6 +69,7 @@ Format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
45
69
|
- Fixed URLs stored in YAML data to always be of type String (not URI)
|
46
70
|
- This initially caused a problem in DictScraper.parse_url() from ArticleScraper, but fixed it for all data
|
47
71
|
|
72
|
+
|
48
73
|
## [v0.3.4] - 2020-04-25
|
49
74
|
|
50
75
|
### Added
|
@@ -66,12 +91,14 @@ Format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
66
91
|
- `-d '3-3'`
|
67
92
|
- `-d '3'`
|
68
93
|
|
94
|
+
|
69
95
|
## [v0.3.3] - 2020-04-23
|
70
96
|
|
71
97
|
### Added
|
72
98
|
- Added JSON support to Sifter & SiftCmd.
|
73
99
|
- Added use of `attr_bool` Gem for `attr_accessor?` & `attr_reader?`.
|
74
100
|
|
101
|
+
|
75
102
|
## [v0.3.2] - 2020-04-22
|
76
103
|
|
77
104
|
### Added
|
@@ -95,6 +122,7 @@ Format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
95
122
|
- ArticleScraper
|
96
123
|
- Renamed `mode` param to `strict`. `mode` was overshadowing File.open()'s in Scraper.
|
97
124
|
|
125
|
+
|
98
126
|
## [v0.3.1] - 2020-04-20
|
99
127
|
|
100
128
|
### Changed
|
@@ -112,6 +140,7 @@ Format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
112
140
|
- BingScraper
|
113
141
|
- Fixed possible RSS infinite loop.
|
114
142
|
|
143
|
+
|
115
144
|
## [v0.3.0] - 2020-04-12
|
116
145
|
|
117
146
|
### Added
|
@@ -146,7 +175,9 @@ Format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
146
175
|
- ignore empty filenames in the Zip for safety.
|
147
176
|
- ask to overwrite files instead of erroring.
|
148
177
|
|
178
|
+
|
149
179
|
## [v0.2.0] - 2020-04-01
|
180
|
+
|
150
181
|
First working version.
|
151
182
|
|
152
183
|
### Added
|
@@ -182,7 +213,9 @@ First working version.
|
|
182
213
|
- test/nhkore_tester.rb
|
183
214
|
- Renamed to `test/nhkore/test_helper.rb`
|
184
215
|
|
216
|
+
|
185
217
|
## [v0.1.0] - 2020-02-24
|
218
|
+
|
186
219
|
### Added
|
187
220
|
- .gitignore
|
188
221
|
- CHANGELOG.md
|
data/Gemfile
CHANGED
@@ -1,24 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
#--
|
5
|
-
# This file is part of NHKore.
|
6
|
-
# Copyright (c) 2020 Jonathan Bradley Whited (@esotericpig)
|
7
|
-
#
|
8
|
-
# NHKore is free software: you can redistribute it and/or modify
|
9
|
-
# it under the terms of the GNU Lesser General Public License as published by
|
10
|
-
# the Free Software Foundation, either version 3 of the License, or
|
11
|
-
# (at your option) any later version.
|
12
|
-
#
|
13
|
-
# NHKore is distributed in the hope that it will be useful,
|
14
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
-
# GNU Lesser General Public License for more details.
|
17
|
-
#
|
18
|
-
# You should have received a copy of the GNU Lesser General Public License
|
19
|
-
# along with NHKore. If not, see <https://www.gnu.org/licenses/>.
|
20
|
-
#++
|
21
|
-
|
22
4
|
|
23
5
|
source 'https://rubygems.org'
|
24
6
|
|
data/Gemfile.lock
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nhkore (0.3.
|
4
|
+
nhkore (0.3.8)
|
5
5
|
attr_bool (~> 0.2)
|
6
6
|
bimyou_segmenter (~> 1.2)
|
7
7
|
cri (~> 2.15)
|
8
|
-
down (~> 5.
|
8
|
+
down (~> 5.2)
|
9
9
|
highline (~> 2.0)
|
10
10
|
http-cookie (~> 1.0)
|
11
11
|
japanese_deinflector (~> 0.0)
|
12
|
-
nokogiri (~> 1.
|
12
|
+
nokogiri (~> 1.11)
|
13
13
|
psychgus (~> 1.3)
|
14
14
|
public_suffix (~> 4.0)
|
15
15
|
rainbow (~> 3.0)
|
16
16
|
rubyzip (~> 2.3)
|
17
17
|
tiny_segmenter (~> 0.0)
|
18
|
-
tty-progressbar (~> 0.
|
18
|
+
tty-progressbar (~> 0.18)
|
19
19
|
tty-spinner (~> 0.9)
|
20
20
|
|
21
21
|
GEM
|
@@ -23,64 +23,67 @@ GEM
|
|
23
23
|
specs:
|
24
24
|
addressable (2.7.0)
|
25
25
|
public_suffix (>= 2.0.2, < 5.0)
|
26
|
-
attr_bool (0.2.
|
26
|
+
attr_bool (0.2.2)
|
27
27
|
bimyou_segmenter (1.2.0)
|
28
|
-
cri (2.15.
|
28
|
+
cri (2.15.11)
|
29
29
|
domain_name (0.5.20190701)
|
30
30
|
unf (>= 0.0.5, < 1.0.0)
|
31
|
-
down (5.2.
|
31
|
+
down (5.2.2)
|
32
32
|
addressable (~> 2.5)
|
33
33
|
highline (2.0.3)
|
34
|
-
http-cookie (1.0.
|
34
|
+
http-cookie (1.0.4)
|
35
35
|
domain_name (~> 0.5)
|
36
36
|
japanese_deinflector (0.0.2)
|
37
|
-
mini_portile2 (2.
|
38
|
-
minitest (5.14.
|
39
|
-
nokogiri (1.
|
40
|
-
mini_portile2 (~> 2.
|
41
|
-
|
42
|
-
|
37
|
+
mini_portile2 (2.5.3)
|
38
|
+
minitest (5.14.4)
|
39
|
+
nokogiri (1.11.7)
|
40
|
+
mini_portile2 (~> 2.5.0)
|
41
|
+
racc (~> 1.4)
|
42
|
+
psych (4.0.1)
|
43
|
+
psychgus (1.3.4)
|
43
44
|
psych (>= 3.0)
|
44
45
|
public_suffix (4.0.6)
|
46
|
+
racc (1.5.2)
|
45
47
|
rainbow (3.0.0)
|
46
|
-
rake (13.0.
|
47
|
-
raketeer (0.2.
|
48
|
+
rake (13.0.3)
|
49
|
+
raketeer (0.2.13)
|
48
50
|
rake
|
49
|
-
rdoc (6.
|
50
|
-
redcarpet (3.5.
|
51
|
+
rdoc (6.3.1)
|
52
|
+
redcarpet (3.5.1)
|
51
53
|
rubyzip (2.3.0)
|
52
|
-
strings-ansi (0.
|
54
|
+
strings-ansi (0.2.0)
|
53
55
|
tiny_segmenter (0.0.6)
|
54
56
|
tty-cursor (0.7.1)
|
55
|
-
tty-progressbar (0.
|
56
|
-
strings-ansi (~> 0.
|
57
|
+
tty-progressbar (0.18.2)
|
58
|
+
strings-ansi (~> 0.2)
|
57
59
|
tty-cursor (~> 0.7)
|
58
|
-
tty-screen (~> 0.
|
59
|
-
unicode-display_width (
|
60
|
+
tty-screen (~> 0.8)
|
61
|
+
unicode-display_width (>= 1.6, < 3.0)
|
60
62
|
tty-screen (0.8.1)
|
61
63
|
tty-spinner (0.9.3)
|
62
64
|
tty-cursor (~> 0.7)
|
63
65
|
unf (0.1.4)
|
64
66
|
unf_ext
|
65
67
|
unf_ext (0.0.7.7)
|
66
|
-
unicode-display_width (
|
67
|
-
yard (0.9.
|
68
|
-
yard_ghurt (1.2.
|
68
|
+
unicode-display_width (2.0.0)
|
69
|
+
yard (0.9.26)
|
70
|
+
yard_ghurt (1.2.1)
|
69
71
|
rake
|
72
|
+
yard
|
70
73
|
|
71
74
|
PLATFORMS
|
72
75
|
ruby
|
73
76
|
|
74
77
|
DEPENDENCIES
|
75
|
-
bundler (~> 2.
|
78
|
+
bundler (~> 2.2)
|
76
79
|
minitest (~> 5.14)
|
77
80
|
nhkore!
|
78
81
|
rake (~> 13.0)
|
79
82
|
raketeer (~> 0.2)
|
80
|
-
rdoc (~> 6.
|
83
|
+
rdoc (~> 6.3)
|
81
84
|
redcarpet (~> 3.5)
|
82
85
|
yard (~> 0.9)
|
83
86
|
yard_ghurt (~> 1.2)
|
84
87
|
|
85
88
|
BUNDLED WITH
|
86
|
-
2.
|
89
|
+
2.2.20
|
data/README.md
CHANGED
@@ -435,18 +435,18 @@ require 'nhkore/scraper'
|
|
435
435
|
s = NHKore::Scraper.new('https://www3.nhk.or.jp/news/easy/',
|
436
436
|
open_timeout: 300, # Open timeout in seconds (default: nil)
|
437
437
|
read_timeout: 300, # Read timeout in seconds (default: nil)
|
438
|
-
|
438
|
+
|
439
439
|
# Maximum number of times to retry the URL
|
440
440
|
# - default: 3
|
441
441
|
# - Open/connect will fail a couple of times on a bad/slow internet connection.
|
442
442
|
max_retries: 10,
|
443
|
-
|
443
|
+
|
444
444
|
# Maximum number of redirects allowed.
|
445
445
|
# - default: 3
|
446
446
|
# - You can set this to nil or -1, but I recommend using a number
|
447
447
|
# for safety (infinite-loop attack).
|
448
448
|
max_redirects: 1,
|
449
|
-
|
449
|
+
|
450
450
|
# How to check redirect URLs for safety.
|
451
451
|
# - default: :strict
|
452
452
|
# - nil => do not check
|
@@ -455,7 +455,7 @@ s = NHKore::Scraper.new('https://www3.nhk.or.jp/news/easy/',
|
|
455
455
|
# - :strict => check the scheme and domain
|
456
456
|
# (i.e., if https://bing.com, redirect URL must be https://bing.com)
|
457
457
|
redirect_rule: :lenient,
|
458
|
-
|
458
|
+
|
459
459
|
# Set the HTTP header field 'cookie' from the 'set-cookie' response.
|
460
460
|
# - default: false
|
461
461
|
# - Currently uses the 'http-cookie' Gem.
|
@@ -463,7 +463,7 @@ s = NHKore::Scraper.new('https://www3.nhk.or.jp/news/easy/',
|
|
463
463
|
# - Necessary for Search Engines or other sites that require cookies
|
464
464
|
# in order to block bots.
|
465
465
|
eat_cookie: true,
|
466
|
-
|
466
|
+
|
467
467
|
# Set HTTP header fields.
|
468
468
|
# - default: nil
|
469
469
|
# - Necessary for Search Engines or other sites that try to block bots.
|
@@ -526,9 +526,9 @@ doc = ss.html_doc()
|
|
526
526
|
|
527
527
|
doc.css('a').each() do |anchor|
|
528
528
|
link = anchor['href']
|
529
|
-
|
529
|
+
|
530
530
|
next if ss.ignore_link?(link,cleaned: false)
|
531
|
-
|
531
|
+
|
532
532
|
if link.include?('https://www3.nhk')
|
533
533
|
puts link
|
534
534
|
end
|
@@ -549,9 +549,9 @@ page_num = 1
|
|
549
549
|
|
550
550
|
while !next_page.empty?()
|
551
551
|
puts "Page #{page_num += 1}: #{next_page.count}"
|
552
|
-
|
552
|
+
|
553
553
|
bs = NHKore::BingScraper.new(:yasashii,url: next_page.url)
|
554
|
-
|
554
|
+
|
555
555
|
next_page = bs.scrape(slinks,next_page)
|
556
556
|
end
|
557
557
|
|
@@ -570,24 +570,24 @@ require 'time'
|
|
570
570
|
|
571
571
|
as = NHKore::ArticleScraper.new(
|
572
572
|
'https://www3.nhk.or.jp/news/easy/k10011862381000/k10011862381000.html',
|
573
|
-
|
573
|
+
|
574
574
|
# If false, scrape the article leniently (for older articles which
|
575
575
|
# may not have certain tags, etc.).
|
576
576
|
# - default: true
|
577
577
|
strict: false,
|
578
|
-
|
578
|
+
|
579
579
|
# {Dict} to use as the dictionary for words (Easy articles).
|
580
580
|
# - default: :scrape
|
581
581
|
# - nil => don't scrape/use it (necessary for Regular articles)
|
582
582
|
# - :scrape => auto-scrape it using {DictScraper}
|
583
583
|
# - {Dict} => your own {Dict}
|
584
584
|
dict: nil,
|
585
|
-
|
585
|
+
|
586
586
|
# Date time to use as a fallback if the article doesn't have one
|
587
587
|
# (for older articles).
|
588
588
|
# - default: nil
|
589
589
|
datetime: Time.new(2020,2,2),
|
590
|
-
|
590
|
+
|
591
591
|
# Year to use as a fallback if the article doesn't have one
|
592
592
|
# (for older articles).
|
593
593
|
# - default: nil
|
@@ -624,7 +624,7 @@ require 'nhkore/dict_scraper'
|
|
624
624
|
url = 'https://www3.nhk.or.jp/news/easy/k10011862381000/k10011862381000.html'
|
625
625
|
ds = NHKore::DictScraper.new(
|
626
626
|
url,
|
627
|
-
|
627
|
+
|
628
628
|
# Change the URL appropriately to the dictionary URL.
|
629
629
|
# - default: true
|
630
630
|
parse_url: true,
|
@@ -637,13 +637,13 @@ dict = ds.scrape()
|
|
637
637
|
|
638
638
|
dict.entries.each() do |key,entry|
|
639
639
|
entry.id
|
640
|
-
|
640
|
+
|
641
641
|
entry.defns.each() do |defn|
|
642
642
|
defn.hyoukis.each() {|hyouki| }
|
643
643
|
defn.text
|
644
644
|
defn.words.each() {|word| }
|
645
645
|
end
|
646
|
-
|
646
|
+
|
647
647
|
puts entry.build_hyouki()
|
648
648
|
puts entry.build_defn()
|
649
649
|
puts '---'
|
@@ -789,13 +789,13 @@ JPN = ['桜','ぶ','ブ']
|
|
789
789
|
|
790
790
|
def fmt_jpn()
|
791
791
|
fmt = []
|
792
|
-
|
792
|
+
|
793
793
|
JPN.each() do |x|
|
794
794
|
x = yield(x)
|
795
795
|
x = x ? "\u2B55" : Util::JPN_SPACE unless x.is_a?(String)
|
796
796
|
fmt << x
|
797
797
|
end
|
798
|
-
|
798
|
+
|
799
799
|
return "[ #{fmt.join(' | ')} ]"
|
800
800
|
end
|
801
801
|
|
@@ -879,7 +879,7 @@ Releasing new HTML file for website:
|
|
879
879
|
[GNU LGPL v3+](LICENSE.txt)
|
880
880
|
|
881
881
|
> NHKore (<https://github.com/esotericpig/nhkore>)
|
882
|
-
> Copyright (c) 2020 Jonathan Bradley Whited
|
882
|
+
> Copyright (c) 2020-2021 Jonathan Bradley Whited
|
883
883
|
>
|
884
884
|
> NHKore is free software: you can redistribute it and/or modify
|
885
885
|
> it under the terms of the GNU Lesser General Public License as published by
|
data/Rakefile
CHANGED
@@ -1,24 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
#--
|
5
|
-
# This file is part of NHKore.
|
6
|
-
# Copyright (c) 2020 Jonathan Bradley Whited (@esotericpig)
|
7
|
-
#
|
8
|
-
# NHKore is free software: you can redistribute it and/or modify
|
9
|
-
# it under the terms of the GNU Lesser General Public License as published by
|
10
|
-
# the Free Software Foundation, either version 3 of the License, or
|
11
|
-
# (at your option) any later version.
|
12
|
-
#
|
13
|
-
# NHKore is distributed in the hope that it will be useful,
|
14
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
-
# GNU Lesser General Public License for more details.
|
17
|
-
#
|
18
|
-
# You should have received a copy of the GNU Lesser General Public License
|
19
|
-
# along with NHKore. If not, see <https://www.gnu.org/licenses/>.
|
20
|
-
#++
|
21
|
-
|
22
4
|
|
23
5
|
require 'bundler/gem_tasks'
|
24
6
|
|
@@ -42,20 +24,20 @@ CLOBBER.include('doc/',File.join(PKG_DIR,''))
|
|
42
24
|
task default: [:test]
|
43
25
|
|
44
26
|
desc 'Generate documentation (YARDoc)'
|
45
|
-
task :
|
27
|
+
task doc: %i[yard yard_gfm_fix] do |task|
|
46
28
|
end
|
47
29
|
|
48
30
|
desc "Package '#{File.join(NHKore::Util::CORE_DIR,'')}' data as a Zip file into '#{File.join(PKG_DIR,'')}'"
|
49
31
|
task :pkg_core do |task|
|
50
32
|
mkdir_p PKG_DIR
|
51
|
-
|
33
|
+
|
52
34
|
pattern = File.join(NHKore::Util::CORE_DIR,'*.{csv,html,json,yml}')
|
53
35
|
zip_file = File.join(PKG_DIR,'nhkore-core.zip')
|
54
|
-
|
55
|
-
sh 'zip','-9rv',zip_file,*Dir.glob(pattern).sort
|
36
|
+
|
37
|
+
sh 'zip','-9rv',zip_file,*Dir.glob(pattern).sort
|
56
38
|
end
|
57
39
|
|
58
|
-
Rake::TestTask.new
|
40
|
+
Rake::TestTask.new do |task|
|
59
41
|
task.libs = ['lib','test']
|
60
42
|
task.pattern = File.join('test','**','*_test.rb')
|
61
43
|
task.description += ": '#{task.pattern}'"
|
@@ -68,73 +50,77 @@ end
|
|
68
50
|
desc "Update '#{File.join(NHKore::Util::CORE_DIR,'')}' files for release"
|
69
51
|
task :update_core do |task|
|
70
52
|
require 'highline'
|
71
|
-
|
72
|
-
|
73
|
-
|
53
|
+
|
54
|
+
continue_msg = "\nContinue (y/n)? "
|
55
|
+
|
74
56
|
cmd = ['ruby','-w','./lib/nhkore.rb','-t','300','-m','10']
|
75
|
-
hl = HighLine.new
|
76
|
-
|
57
|
+
hl = HighLine.new
|
58
|
+
|
77
59
|
next unless sh(*cmd,'se','ez','bing')
|
78
|
-
next unless hl.agree(
|
60
|
+
next unless hl.agree(continue_msg)
|
79
61
|
puts
|
80
|
-
|
81
|
-
next unless sh(*cmd,'news','-s','
|
82
|
-
next unless hl.agree(
|
62
|
+
|
63
|
+
next unless sh(*cmd,'news','-s','500','ez')
|
64
|
+
next unless hl.agree(continue_msg)
|
83
65
|
puts
|
84
|
-
|
66
|
+
|
85
67
|
next unless sh(*cmd,'sift','-e','csv' ,'ez')
|
68
|
+
puts
|
86
69
|
next unless sh(*cmd,'sift','-e','html','ez')
|
70
|
+
puts
|
87
71
|
next unless sh(*cmd,'sift','-e','json','ez')
|
72
|
+
puts
|
88
73
|
next unless sh(*cmd,'sift','-e','yml' ,'ez')
|
74
|
+
puts
|
89
75
|
end
|
90
76
|
|
91
77
|
# @since 0.3.6
|
92
78
|
desc 'Update showcase file for release'
|
93
79
|
task :update_showcase do |task|
|
94
80
|
require 'highline'
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
hl = HighLine.new
|
99
|
-
|
81
|
+
|
82
|
+
showcase_file = File.join('.','nhkore-ez.html')
|
83
|
+
|
84
|
+
hl = HighLine.new
|
85
|
+
|
100
86
|
next unless sh('ruby','-w','./lib/nhkore.rb',
|
101
87
|
'sift','ez','--no-eng',
|
102
|
-
'--out',
|
88
|
+
'--out',showcase_file,
|
103
89
|
)
|
104
|
-
|
90
|
+
|
105
91
|
next unless hl.agree("\nMove the file (y/n)? ")
|
106
92
|
puts
|
107
|
-
next unless sh('mv','-iv',
|
93
|
+
next unless sh('mv','-iv',showcase_file,
|
108
94
|
File.join('..','esotericpig.github.io','showcase',''),
|
109
95
|
)
|
110
96
|
end
|
111
97
|
|
112
|
-
YARD::Rake::YardocTask.new
|
98
|
+
YARD::Rake::YardocTask.new do |task|
|
113
99
|
task.options += ['--template-path',File.join('yard','templates')]
|
114
100
|
task.options += ['--title',"NHKore v#{NHKore::VERSION} Doc"]
|
115
101
|
end
|
116
102
|
|
117
103
|
# Execute "rake yard_gfm_fix" for production.
|
118
104
|
# Execute "rake yard_gfm_fix[true]" for testing locally.
|
119
|
-
YardGhurt::GFMFixTask.new
|
105
|
+
YardGhurt::GFMFixTask.new do |task|
|
120
106
|
task.arg_names = [:dev]
|
121
107
|
task.dry_run = false
|
122
108
|
task.fix_code_langs = true
|
123
109
|
task.md_files = ['index.html']
|
124
|
-
|
125
|
-
task.before =
|
110
|
+
|
111
|
+
task.before = proc do |t,args|
|
126
112
|
# Delete this file as it's never used (index.html is an exact copy).
|
127
|
-
YardGhurt::Util.rm_exist(File.join(
|
128
|
-
|
113
|
+
YardGhurt::Util.rm_exist(File.join(t.doc_dir,'file.README.html'))
|
114
|
+
|
129
115
|
# Root dir of my GitHub Page for CSS/JS.
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
116
|
+
ghp_root = YardGhurt::Util.to_bool(args.dev) ? '../../esotericpig.github.io' : '../../..'
|
117
|
+
|
118
|
+
t.css_styles << %Q(<link rel="stylesheet" type="text/css" href="#{ghp_root}/css/prism.css" />)
|
119
|
+
t.js_scripts << %Q(<script src="#{ghp_root}/js/prism.js"></script>)
|
134
120
|
end
|
135
121
|
end
|
136
122
|
|
137
123
|
# Probably not useful for others.
|
138
|
-
YardGhurt::GHPSyncTask.new
|
124
|
+
YardGhurt::GHPSyncTask.new do |task|
|
139
125
|
task.ghp_dir = '../esotericpig.github.io/docs/nhkore/yardoc'
|
140
126
|
end
|