nhkore 0.3.3 → 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/.yardopts +3 -0
- data/CHANGELOG.md +97 -2
- data/Gemfile +0 -18
- data/Gemfile.lock +89 -0
- data/README.md +58 -30
- data/Rakefile +68 -42
- data/bin/nhkore +4 -15
- data/lib/nhkore.rb +8 -20
- data/lib/nhkore/app.rb +231 -236
- data/lib/nhkore/article.rb +56 -53
- data/lib/nhkore/article_scraper.rb +308 -289
- 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 +145 -154
- data/lib/nhkore/cli/search_cmd.rb +110 -120
- data/lib/nhkore/cli/sift_cmd.rb +111 -227
- data/lib/nhkore/datetime_parser.rb +328 -0
- 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 +6 -17
- data/lib/nhkore/missingno.rb +21 -33
- data/lib/nhkore/news.rb +61 -66
- data/lib/nhkore/polisher.rb +22 -34
- data/lib/nhkore/scraper.rb +75 -82
- data/lib/nhkore/search_link.rb +85 -78
- data/lib/nhkore/search_scraper.rb +89 -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 -101
- data/lib/nhkore/variator.rb +20 -32
- data/lib/nhkore/version.rb +4 -16
- data/lib/nhkore/word.rb +105 -99
- data/nhkore.gemspec +58 -65
- data/samples/looper.rb +71 -0
- data/test/nhkore/test_helper.rb +3 -15
- data/test/nhkore_test.rb +6 -18
- metadata +53 -30
data/lib/nhkore/variator.rb
CHANGED
@@ -1,46 +1,34 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
1
|
# encoding: UTF-8
|
3
2
|
# frozen_string_literal: true
|
4
3
|
|
5
4
|
#--
|
6
5
|
# This file is part of NHKore.
|
7
|
-
# Copyright (c) 2020 Jonathan Bradley Whited
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# it under the terms of the GNU Lesser General Public License as published by
|
11
|
-
# the Free Software Foundation, either version 3 of the License, or
|
12
|
-
# (at your option) any later version.
|
13
|
-
#
|
14
|
-
# NHKore is distributed in the hope that it will be useful,
|
15
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
-
# GNU Lesser General Public License for more details.
|
18
|
-
#
|
19
|
-
# You should have received a copy of the GNU Lesser General Public License
|
20
|
-
# along with NHKore. If not, see <https://www.gnu.org/licenses/>.
|
6
|
+
# Copyright (c) 2020-2021 Jonathan Bradley Whited
|
7
|
+
#
|
8
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
21
9
|
#++
|
22
10
|
|
23
11
|
|
24
12
|
module NHKore
|
25
13
|
###
|
26
|
-
# @author Jonathan Bradley Whited
|
14
|
+
# @author Jonathan Bradley Whited
|
27
15
|
# @since 0.2.0
|
28
16
|
###
|
29
17
|
class Variator
|
30
18
|
def begin_variate(str)
|
31
19
|
return str
|
32
20
|
end
|
33
|
-
|
21
|
+
|
34
22
|
def variate(str)
|
35
23
|
str = begin_variate(str)
|
36
24
|
str = end_variate(str)
|
37
|
-
|
25
|
+
|
38
26
|
return str
|
39
27
|
end
|
40
28
|
end
|
41
|
-
|
29
|
+
|
42
30
|
###
|
43
|
-
# @author Jonathan Bradley Whited
|
31
|
+
# @author Jonathan Bradley Whited
|
44
32
|
# @since 0.2.0
|
45
33
|
###
|
46
34
|
class BasicVariator < Variator
|
@@ -48,38 +36,38 @@ module NHKore
|
|
48
36
|
return [] # No variations; don't return nil
|
49
37
|
end
|
50
38
|
end
|
51
|
-
|
39
|
+
|
52
40
|
###
|
53
41
|
# Guesses a word's dictionary/plain form (辞書形).
|
54
|
-
#
|
42
|
+
#
|
55
43
|
# It doesn't work very well,but better than nothing...
|
56
|
-
#
|
44
|
+
#
|
57
45
|
# @since 0.2.0
|
58
46
|
###
|
59
47
|
class DictFormVariator < Variator
|
60
48
|
attr_accessor :deinflector
|
61
|
-
|
49
|
+
|
62
50
|
def initialize(*)
|
63
51
|
require 'set' # Must require manually because JapaneseDeinflector is old
|
64
52
|
require 'japanese_deinflector'
|
65
|
-
|
53
|
+
|
66
54
|
super
|
67
|
-
|
68
|
-
@deinflector = JapaneseDeinflector.new
|
55
|
+
|
56
|
+
@deinflector = JapaneseDeinflector.new
|
69
57
|
end
|
70
|
-
|
58
|
+
|
71
59
|
def end_variate(str)
|
72
60
|
guess = @deinflector.deinflect(str)
|
73
|
-
|
61
|
+
|
74
62
|
return [] if guess.length < 1
|
75
63
|
return [] if (guess = guess[0])[:weight] < 0.5
|
76
|
-
|
64
|
+
|
77
65
|
return [guess[:word]]
|
78
66
|
end
|
79
67
|
end
|
80
|
-
|
68
|
+
|
81
69
|
###
|
82
|
-
# @author Jonathan Bradley Whited
|
70
|
+
# @author Jonathan Bradley Whited
|
83
71
|
# @since 0.2.0
|
84
72
|
###
|
85
73
|
class BestVariator < DictFormVariator
|
data/lib/nhkore/version.rb
CHANGED
@@ -1,26 +1,14 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
1
|
# encoding: UTF-8
|
3
2
|
# frozen_string_literal: true
|
4
3
|
|
5
4
|
#--
|
6
5
|
# This file is part of NHKore.
|
7
|
-
# Copyright (c) 2020 Jonathan Bradley Whited
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# it under the terms of the GNU Lesser General Public License as published by
|
11
|
-
# the Free Software Foundation, either version 3 of the License, or
|
12
|
-
# (at your option) any later version.
|
13
|
-
#
|
14
|
-
# NHKore is distributed in the hope that it will be useful,
|
15
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
-
# GNU Lesser General Public License for more details.
|
18
|
-
#
|
19
|
-
# You should have received a copy of the GNU Lesser General Public License
|
20
|
-
# along with NHKore. If not, see <https://www.gnu.org/licenses/>.
|
6
|
+
# Copyright (c) 2020-2021 Jonathan Bradley Whited
|
7
|
+
#
|
8
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
21
9
|
#++
|
22
10
|
|
23
11
|
|
24
12
|
module NHKore
|
25
|
-
VERSION = '0.3.
|
13
|
+
VERSION = '0.3.8'
|
26
14
|
end
|
data/lib/nhkore/word.rb
CHANGED
@@ -1,23 +1,11 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
1
|
# encoding: UTF-8
|
3
2
|
# frozen_string_literal: true
|
4
3
|
|
5
4
|
#--
|
6
5
|
# This file is part of NHKore.
|
7
|
-
# Copyright (c) 2020 Jonathan Bradley Whited
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# it under the terms of the GNU Lesser General Public License as published by
|
11
|
-
# the Free Software Foundation, either version 3 of the License, or
|
12
|
-
# (at your option) any later version.
|
13
|
-
#
|
14
|
-
# NHKore is distributed in the hope that it will be useful,
|
15
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
-
# GNU Lesser General Public License for more details.
|
18
|
-
#
|
19
|
-
# You should have received a copy of the GNU Lesser General Public License
|
20
|
-
# along with NHKore. If not, see <https://www.gnu.org/licenses/>.
|
6
|
+
# Copyright (c) 2020-2021 Jonathan Bradley Whited
|
7
|
+
#
|
8
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
21
9
|
#++
|
22
10
|
|
23
11
|
|
@@ -29,7 +17,7 @@ require 'nhkore/util'
|
|
29
17
|
|
30
18
|
module NHKore
|
31
19
|
###
|
32
|
-
# @author Jonathan Bradley Whited
|
20
|
+
# @author Jonathan Bradley Whited
|
33
21
|
# @since 0.1.0
|
34
22
|
###
|
35
23
|
class Word
|
@@ -39,38 +27,42 @@ module NHKore
|
|
39
27
|
attr_reader :kana
|
40
28
|
attr_reader :kanji
|
41
29
|
attr_reader :key
|
42
|
-
|
30
|
+
|
43
31
|
def initialize(defn: nil,eng: nil,freq: 1,kana: nil,kanji: nil,unknown: nil,word: nil,**kargs)
|
44
32
|
super()
|
45
|
-
|
46
|
-
if !word.nil?
|
47
|
-
defn = word.defn if defn.nil?
|
48
|
-
eng = word.eng if eng.nil?
|
49
|
-
freq = word.freq if freq.nil?
|
50
|
-
kana = word.kana if kana.nil?
|
51
|
-
kanji = word.kanji if kanji.nil?
|
33
|
+
|
34
|
+
if !word.nil?
|
35
|
+
defn = word.defn if defn.nil?
|
36
|
+
eng = word.eng if eng.nil?
|
37
|
+
freq = word.freq if freq.nil?
|
38
|
+
kana = word.kana if kana.nil?
|
39
|
+
kanji = word.kanji if kanji.nil?
|
52
40
|
end
|
53
|
-
|
41
|
+
|
54
42
|
raise ArgumentError,"freq[#{freq}] cannot be < 1" if freq < 1
|
55
|
-
|
56
|
-
if !unknown.nil?
|
43
|
+
|
44
|
+
if !unknown.nil?
|
57
45
|
# kanji?() only tests if it contains kanji, so don't use kana?().
|
58
46
|
if Util.kanji?(unknown)
|
59
|
-
|
60
|
-
|
47
|
+
if !Util.empty_web_str?(kanji)
|
48
|
+
raise ArgumentError,"unknown[#{unknown}] will overwrite kanji[#{kanji}]"
|
49
|
+
end
|
50
|
+
|
61
51
|
kanji = unknown
|
62
52
|
else
|
63
|
-
|
64
|
-
|
53
|
+
if !Util.empty_web_str?(kana)
|
54
|
+
raise ArgumentError,"unknown[#{unknown}] will overwrite kana[#{kana}]"
|
55
|
+
end
|
56
|
+
|
65
57
|
kana = unknown
|
66
58
|
end
|
67
59
|
end
|
68
|
-
|
60
|
+
|
69
61
|
kana = nil if Util.empty_web_str?(kana)
|
70
62
|
kanji = nil if Util.empty_web_str?(kanji)
|
71
|
-
|
72
|
-
raise ArgumentError,'kanji and kana cannot both be empty' if kana.nil?
|
73
|
-
|
63
|
+
|
64
|
+
raise ArgumentError,'kanji and kana cannot both be empty' if kana.nil? && kanji.nil?
|
65
|
+
|
74
66
|
@defn = defn
|
75
67
|
@eng = eng
|
76
68
|
@freq = freq
|
@@ -78,118 +70,132 @@ module NHKore
|
|
78
70
|
@kanji = kanji
|
79
71
|
@key = "#{kanji}=#{kana}" # nil.to_s() is ''
|
80
72
|
end
|
81
|
-
|
73
|
+
|
82
74
|
def encode_with(coder)
|
83
75
|
# Ignore @key because it will be the key in the YAML/Hash.
|
84
76
|
# Order matters.
|
85
|
-
|
77
|
+
|
86
78
|
coder[:kanji] = @kanji
|
87
79
|
coder[:kana] = @kana
|
88
80
|
coder[:freq] = @freq
|
89
81
|
coder[:defn] = @defn
|
90
82
|
coder[:eng] = @eng
|
91
83
|
end
|
92
|
-
|
84
|
+
|
93
85
|
def self.load_data(key,hash)
|
94
|
-
key = key.to_s
|
95
|
-
|
86
|
+
key = key.to_s # Change from a symbol
|
87
|
+
|
96
88
|
word = Word.new(
|
97
89
|
defn: hash[:defn],
|
98
90
|
eng: hash[:eng],
|
99
91
|
kana: hash[:kana],
|
100
92
|
kanji: hash[:kanji]
|
101
93
|
)
|
102
|
-
|
94
|
+
|
103
95
|
if key != word.key
|
104
96
|
raise ArgumentError,"the key from the hash[#{key}] does not match the generated key[#{word.key}]"
|
105
97
|
end
|
106
|
-
|
107
|
-
freq = hash[:freq].to_i
|
98
|
+
|
99
|
+
freq = hash[:freq].to_i # nil.to_i() is 0
|
108
100
|
word.freq = freq if freq > 0
|
109
|
-
|
101
|
+
|
110
102
|
return word
|
111
103
|
end
|
112
|
-
|
104
|
+
|
113
105
|
# Do not clean and/or strip spaces, as the raw text is important for
|
114
|
-
#
|
106
|
+
# Defn and ArticleScraper.
|
107
|
+
#
|
108
|
+
# This originally only scraped 1 word, but multiple words were added
|
109
|
+
# after seeing this link for 産業能率大学, which is valid HTML:
|
110
|
+
# https://www3.nhk.or.jp/news/easy/k10012759201000/k10012759201000.html
|
111
|
+
#
|
112
|
+
# @return [Array<Word>] the scraped {Word}(s)
|
115
113
|
def self.scrape_ruby_tag(tag,missingno: nil,url: nil)
|
116
114
|
# First, try <rb> tags.
|
117
|
-
|
115
|
+
kanjis = tag.css('rb')
|
118
116
|
# Second, try text nodes.
|
119
|
-
|
117
|
+
kanjis = tag.search('./text()') if kanjis.length < 1
|
120
118
|
# Third, try non-<rt> tags, in case of being surrounded by <span>, <b>, etc.
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
Util.
|
119
|
+
kanjis = tag.search("./*[not(name()='rt')]") if kanjis.length < 1
|
120
|
+
|
121
|
+
kanas = tag.css('rt')
|
122
|
+
|
123
|
+
raise ScrapeError,"no kanji at URL[#{url}] in tag[#{tag}]" if kanjis.length < 1
|
124
|
+
raise ScrapeError,"no kana at URL[#{url}] in tag[#{tag}]" if kanas.length < 1
|
125
|
+
|
126
|
+
if kanjis.length != kanas.length
|
127
|
+
raise ScrapeError,"number of kanji & kana mismatch at URL[#{url}] in tag[#{tag}]"
|
128
|
+
end
|
129
|
+
|
130
|
+
words = []
|
131
|
+
|
132
|
+
(0...kanjis.length).each do |i|
|
133
|
+
kanji = kanjis[i].text
|
134
|
+
kana = kanas[i].text
|
135
|
+
|
136
|
+
# Uncomment for debugging; really need a logger.
|
137
|
+
#puts "Word[#{i}]: #{kanji} => #{kana}"
|
138
|
+
|
139
|
+
if !missingno.nil?
|
140
|
+
# Check kana first, since this is the typical scenario.
|
141
|
+
# - https://www3.nhk.or.jp/news/easy/k10012331311000/k10012331311000.html
|
142
|
+
# - '窓' in '(8)窓を開けて外の空気を入れましょう'
|
143
|
+
if Util.empty_web_str?(kana)
|
144
|
+
kana = missingno.kana_from_kanji(kanji)
|
145
|
+
|
146
|
+
if !Util.empty_web_str?(kana)
|
147
|
+
Util.warn("using missingno for kana[#{kana}] from kanji[#{kanji}]")
|
148
|
+
end
|
149
|
+
elsif Util.empty_web_str?(kanji)
|
150
|
+
kanji = missingno.kanji_from_kana(kana)
|
151
|
+
|
152
|
+
if !Util.empty_web_str?(kanji)
|
153
|
+
Util.warn("using missingno for kanji[#{kanji}] from kana[#{kana}]")
|
154
|
+
end
|
149
155
|
end
|
150
156
|
end
|
157
|
+
|
158
|
+
raise ScrapeError,"empty kanji at URL[#{url}] in tag[#{tag}]" if Util.empty_web_str?(kanji)
|
159
|
+
raise ScrapeError,"empty kana at URL[#{url}] in tag[#{tag}]" if Util.empty_web_str?(kana)
|
160
|
+
|
161
|
+
words << Word.new(kanji: kanji,kana: kana)
|
151
162
|
end
|
152
|
-
|
153
|
-
|
154
|
-
raise ScrapeError,"empty kana at URL[#{url}] in tag[#{tag}]" if Util.empty_web_str?(kana)
|
155
|
-
|
156
|
-
word = Word.new(kana: kana,kanji: kanji)
|
157
|
-
|
158
|
-
return word
|
163
|
+
|
164
|
+
return words
|
159
165
|
end
|
160
|
-
|
166
|
+
|
161
167
|
# Do not clean and/or strip spaces, as the raw text is important for
|
162
|
-
#
|
168
|
+
# Defn and ArticleScraper.
|
163
169
|
def self.scrape_text_node(tag,url: nil)
|
164
170
|
text = tag.text
|
165
|
-
|
171
|
+
|
166
172
|
# No error; empty text is fine (not strictly kanji/kana only).
|
167
173
|
return nil if Util.empty_web_str?(text)
|
168
|
-
|
174
|
+
|
169
175
|
word = Word.new(unknown: text)
|
170
|
-
|
176
|
+
|
171
177
|
return word
|
172
178
|
end
|
173
|
-
|
174
|
-
def kanji?
|
179
|
+
|
180
|
+
def kanji?
|
175
181
|
return !Util.empty_web_str?(@kanji)
|
176
182
|
end
|
177
|
-
|
178
|
-
def word
|
179
|
-
return kanji?
|
183
|
+
|
184
|
+
def word
|
185
|
+
return kanji? ? @kanji : @kana
|
180
186
|
end
|
181
|
-
|
182
|
-
def to_s
|
183
|
-
s = ''.dup
|
184
|
-
|
187
|
+
|
188
|
+
def to_s
|
189
|
+
s = ''.dup
|
190
|
+
|
185
191
|
s << "'#{@key}': "
|
186
192
|
s << "{ kanji=>'#{@kanji}'"
|
187
193
|
s << ", kana=>'#{@kana}'"
|
188
194
|
s << ", freq=>#{@freq}"
|
189
|
-
s << ", defn=>'#{@defn.to_s
|
195
|
+
s << ", defn=>'#{@defn.to_s.gsub("\n",'\\n')}'"
|
190
196
|
s << ", eng=>'#{@eng}'"
|
191
197
|
s << ' }'
|
192
|
-
|
198
|
+
|
193
199
|
return s
|
194
200
|
end
|
195
201
|
end
|
data/nhkore.gemspec
CHANGED
@@ -1,100 +1,93 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
23
|
-
lib = File.expand_path(File.join('..','lib'),__FILE__)
|
24
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
25
|
-
|
26
|
-
require 'nhkore/version'
|
27
|
-
|
28
|
-
|
29
|
-
Gem::Specification.new() do |spec|
|
4
|
+
|
5
|
+
require_relative 'lib/nhkore/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
30
8
|
spec.name = 'nhkore'
|
31
9
|
spec.version = NHKore::VERSION
|
32
|
-
spec.authors = ['Jonathan Bradley Whited
|
33
|
-
spec.email = ['
|
10
|
+
spec.authors = ['Jonathan Bradley Whited']
|
11
|
+
spec.email = ['code@esotericpig.com']
|
34
12
|
spec.licenses = ['LGPL-3.0-or-later']
|
35
13
|
spec.homepage = 'https://github.com/esotericpig/nhkore'
|
36
14
|
spec.summary = 'NHK News Web (Easy) word frequency (core) scraper for Japanese language learners.'
|
37
15
|
spec.description =
|
38
16
|
'Scrapes NHK News Web (Easy) for the word frequency (core list) for Japanese language learners.' \
|
39
17
|
' Includes a CLI app and a scraper library.'
|
40
|
-
|
18
|
+
|
41
19
|
spec.metadata = {
|
42
|
-
'
|
43
|
-
'
|
44
|
-
'
|
45
|
-
'
|
20
|
+
'homepage_uri' => 'https://github.com/esotericpig/nhkore',
|
21
|
+
'source_code_uri' => 'https://github.com/esotericpig/nhkore',
|
22
|
+
'bug_tracker_uri' => 'https://github.com/esotericpig/nhkore/issues',
|
23
|
+
'changelog_uri' => 'https://github.com/esotericpig/nhkore/blob/master/CHANGELOG.md',
|
24
|
+
#'documentation_uri' => '',
|
25
|
+
#'wiki_uri' => '',
|
26
|
+
#'mailing_list_uri' => '',
|
46
27
|
}
|
47
|
-
|
48
|
-
spec.
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
spec.
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
28
|
+
|
29
|
+
spec.requirements = [
|
30
|
+
'Nokogiri: https://www.nokogiri.org/tutorials/installing_nokogiri.html',
|
31
|
+
]
|
32
|
+
|
33
|
+
spec.required_ruby_version = '>= 2.5'
|
34
|
+
spec.require_paths = ['lib']
|
35
|
+
spec.bindir = 'bin'
|
36
|
+
spec.executables = [spec.name]
|
37
|
+
|
38
|
+
spec.files = [
|
39
|
+
Dir.glob(File.join("{#{spec.require_paths.join(',')}}",'**','*.{erb,rb}')),
|
40
|
+
Dir.glob(File.join(spec.bindir,'*')),
|
41
|
+
Dir.glob(File.join('{samples,test,yard}','**','*.{erb,rb}')),
|
42
|
+
%W[ Gemfile Gemfile.lock #{spec.name}.gemspec Rakefile .yardopts ],
|
43
|
+
%w[ CHANGELOG.md LICENSE.txt README.md ],
|
44
|
+
].flatten
|
45
|
+
|
46
|
+
spec.add_runtime_dependency 'attr_bool' ,'~> 0.2' # For attr_accessor?/attr_reader?
|
63
47
|
spec.add_runtime_dependency 'bimyou_segmenter' ,'~> 1.2' # For splitting Japanese sentences into words
|
64
48
|
spec.add_runtime_dependency 'cri' ,'~> 2.15' # For CLI commands/options
|
65
|
-
spec.add_runtime_dependency 'down' ,'~> 5.
|
49
|
+
spec.add_runtime_dependency 'down' ,'~> 5.2' # For downloading files (GetCmd)
|
66
50
|
spec.add_runtime_dependency 'highline' ,'~> 2.0' # For CLI input/output
|
67
51
|
spec.add_runtime_dependency 'http-cookie' ,'~> 1.0' # For parsing/setting cookies (BingScraper/Scraper)
|
68
52
|
spec.add_runtime_dependency 'japanese_deinflector' ,'~> 0.0' # For unconjugating Japanese words (plain/dictionary form)
|
69
|
-
spec.add_runtime_dependency 'nokogiri' ,'~> 1.
|
70
|
-
spec.add_runtime_dependency 'psychgus' ,'~> 1.
|
53
|
+
spec.add_runtime_dependency 'nokogiri' ,'~> 1.11' # For scraping/hacking
|
54
|
+
spec.add_runtime_dependency 'psychgus' ,'~> 1.3' # For styling Psych YAML
|
71
55
|
spec.add_runtime_dependency 'public_suffix' ,'~> 4.0' # For parsing URL domain names
|
72
56
|
spec.add_runtime_dependency 'rainbow' ,'~> 3.0' # For CLI color output
|
73
57
|
spec.add_runtime_dependency 'rubyzip' ,'~> 2.3' # For extracting Zip files (GetCmd)
|
74
58
|
spec.add_runtime_dependency 'tiny_segmenter' ,'~> 0.0' # For splitting Japanese sentences into words
|
75
|
-
spec.add_runtime_dependency 'tty-progressbar' ,'~> 0.
|
59
|
+
spec.add_runtime_dependency 'tty-progressbar' ,'~> 0.18' # For CLI progress bars
|
76
60
|
spec.add_runtime_dependency 'tty-spinner' ,'~> 0.9' # For CLI spinning progress
|
77
|
-
|
78
|
-
spec.add_development_dependency 'bundler' ,'~> 2.
|
61
|
+
|
62
|
+
spec.add_development_dependency 'bundler' ,'~> 2.2'
|
79
63
|
spec.add_development_dependency 'minitest' ,'~> 5.14'
|
80
64
|
spec.add_development_dependency 'rake' ,'~> 13.0'
|
81
65
|
spec.add_development_dependency 'raketeer' ,'~> 0.2' # For extra Rake tasks
|
82
|
-
spec.add_development_dependency 'rdoc' ,'~> 6.
|
66
|
+
spec.add_development_dependency 'rdoc' ,'~> 6.3' # For YARDoc RDoc (*.rb)
|
83
67
|
spec.add_development_dependency 'redcarpet' ,'~> 3.5' # For YARDoc Markdown (*.md)
|
84
68
|
spec.add_development_dependency 'yard' ,'~> 0.9' # For documentation
|
85
69
|
spec.add_development_dependency 'yard_ghurt','~> 1.2' # For extra YARDoc Rake tasks
|
86
|
-
|
87
|
-
spec.post_install_message = <<-
|
88
|
-
|
70
|
+
|
71
|
+
spec.post_install_message = <<-MSG
|
72
|
+
|
89
73
|
NHKore v#{NHKore::VERSION}
|
90
|
-
|
74
|
+
|
91
75
|
You can now use [#{spec.executables.join(', ')}] on the command line.
|
92
|
-
|
76
|
+
|
93
77
|
Homepage: #{spec.homepage}
|
94
|
-
|
78
|
+
|
95
79
|
Code: #{spec.metadata['source_code_uri']}
|
96
|
-
Changelog: #{spec.metadata['changelog_uri']}
|
97
80
|
Bugs: #{spec.metadata['bug_tracker_uri']}
|
98
|
-
|
99
|
-
|
81
|
+
|
82
|
+
Changelog: #{spec.metadata['changelog_uri']}
|
83
|
+
|
84
|
+
MSG
|
85
|
+
|
86
|
+
spec.extra_rdoc_files = %w[ CHANGELOG.md LICENSE.txt README.md ]
|
87
|
+
|
88
|
+
spec.rdoc_options = [
|
89
|
+
'--hyperlink-all','--show-hash',
|
90
|
+
'--title',"NHKore v#{NHKore::VERSION} Doc",
|
91
|
+
'--main','README.md',
|
92
|
+
]
|
100
93
|
end
|