narou 3.6.0 → 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of narou might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ChangeLog.md +7 -0
- data/Gemfile.lock +25 -24
- data/README.md +8 -0
- data/lib/command/setting.rb +2 -2
- data/lib/helper.rb +2 -2
- data/lib/narou.rb +276 -270
- data/lib/version.rb +1 -1
- data/lib/web/appserver.rb +1 -1
- data/narou.gemspec +7 -4
- metadata +34 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e7602ba2d969aaf94fd33d0a1ba7f706149861cb90b6d7924cc2c8f66081416
|
4
|
+
data.tar.gz: 5d0dc68095c855a69a3af7837949a2902bd2509cf6febae7d8c9589ea1fef301
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9f48b127ae554760619b1cfdbd61041b3284ee675a9c6a00fb91adfe54968d8c0f5f776eee036bdf8fadb59308169a2732ac0413c3da3223e18c0fbe0bc83fa
|
7
|
+
data.tar.gz: c368440c723fec9af88932da94755d787720bddf393413467ddbcb86c39b41cdb629e980b79f76db6acc8b7715cd55b41a4e20f998a975caf75259434dd8d46a
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
更新履歴 - ChangeLog
|
2
2
|
====================
|
3
3
|
|
4
|
+
3.7.0: 2021/01/23
|
5
|
+
-----------------
|
6
|
+
#### 修正内容
|
7
|
+
- Apple Silicon 搭載 Mac でも動く様にライブラリをアップデート
|
8
|
+
- device を kobo に設定し、_ebook-filename-length-limit でファイル名が制限され
|
9
|
+
た場合に send コマンドが正常に実行できない不具合を修正
|
10
|
+
|
4
11
|
3.6.0: 2021/01/02
|
5
12
|
-----------------
|
6
13
|
#### 修正内容
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
narou (3.
|
5
|
-
activesupport (>=
|
4
|
+
narou (3.7.0)
|
5
|
+
activesupport (>= 6.1, < 8.0)
|
6
6
|
diff-lcs (~> 1.2, >= 1.2.5)
|
7
7
|
erubis (~> 2.7)
|
8
|
+
ffi (>= 1.4.2)
|
8
9
|
haml (>= 5.1.2, < 6)
|
9
10
|
mail (~> 2.6.0, >= 2.6.6)
|
10
11
|
memoist (~> 0.11.0)
|
@@ -23,7 +24,7 @@ PATH
|
|
23
24
|
GEM
|
24
25
|
remote: https://rubygems.org/
|
25
26
|
specs:
|
26
|
-
activesupport (6.1.
|
27
|
+
activesupport (6.1.1)
|
27
28
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
28
29
|
i18n (>= 1.6, < 2)
|
29
30
|
minitest (>= 5.1)
|
@@ -32,16 +33,16 @@ GEM
|
|
32
33
|
awesome_print (1.8.0)
|
33
34
|
byebug (11.1.3)
|
34
35
|
coderay (1.1.3)
|
35
|
-
concurrent-ruby (1.1.
|
36
|
+
concurrent-ruby (1.1.8)
|
36
37
|
diff-lcs (1.4.4)
|
37
|
-
docile (1.3.
|
38
|
+
docile (1.3.5)
|
38
39
|
erubis (2.7.0)
|
39
|
-
ffi (1.
|
40
|
-
ffi (1.
|
40
|
+
ffi (1.14.2)
|
41
|
+
ffi (1.14.2-java)
|
41
42
|
haml (5.2.1)
|
42
43
|
temple (>= 0.8.0)
|
43
44
|
tilt
|
44
|
-
i18n (1.8.
|
45
|
+
i18n (1.8.7)
|
45
46
|
concurrent-ruby (~> 1.0)
|
46
47
|
mail (2.6.6)
|
47
48
|
mime-types (>= 1.16, < 4)
|
@@ -50,7 +51,7 @@ GEM
|
|
50
51
|
mime-types (3.3.1)
|
51
52
|
mime-types-data (~> 3.2015)
|
52
53
|
mime-types-data (3.2020.1104)
|
53
|
-
minitest (5.14.
|
54
|
+
minitest (5.14.3)
|
54
55
|
multi_json (1.15.0)
|
55
56
|
mustermann (1.1.1)
|
56
57
|
ruby2_keywords (~> 0.0.1)
|
@@ -70,28 +71,28 @@ GEM
|
|
70
71
|
rack (2.2.3)
|
71
72
|
rack-protection (2.1.0)
|
72
73
|
rack
|
73
|
-
rspec (3.
|
74
|
-
rspec-core (~> 3.
|
75
|
-
rspec-expectations (~> 3.
|
76
|
-
rspec-mocks (~> 3.
|
77
|
-
rspec-core (3.
|
78
|
-
rspec-support (~> 3.
|
79
|
-
rspec-expectations (3.
|
74
|
+
rspec (3.10.0)
|
75
|
+
rspec-core (~> 3.10.0)
|
76
|
+
rspec-expectations (~> 3.10.0)
|
77
|
+
rspec-mocks (~> 3.10.0)
|
78
|
+
rspec-core (3.10.1)
|
79
|
+
rspec-support (~> 3.10.0)
|
80
|
+
rspec-expectations (3.10.1)
|
80
81
|
diff-lcs (>= 1.2.0, < 2.0)
|
81
|
-
rspec-support (~> 3.
|
82
|
-
rspec-mocks (3.
|
82
|
+
rspec-support (~> 3.10.0)
|
83
|
+
rspec-mocks (3.10.1)
|
83
84
|
diff-lcs (>= 1.2.0, < 2.0)
|
84
|
-
rspec-support (~> 3.
|
85
|
+
rspec-support (~> 3.10.0)
|
85
86
|
rspec-retry (0.6.2)
|
86
87
|
rspec-core (> 3.3)
|
87
|
-
rspec-support (3.
|
88
|
+
rspec-support (3.10.1)
|
88
89
|
rspec_junit_formatter (0.4.1)
|
89
90
|
rspec-core (>= 2, < 4, != 2.12.0)
|
90
|
-
ruby2_keywords (0.0.
|
91
|
+
ruby2_keywords (0.0.4)
|
91
92
|
rubyzip (2.3.0)
|
92
93
|
sassc (2.4.0)
|
93
94
|
ffi (~> 1.9)
|
94
|
-
simplecov (0.
|
95
|
+
simplecov (0.21.2)
|
95
96
|
docile (~> 1.1)
|
96
97
|
simplecov-html (~> 0.11)
|
97
98
|
simplecov_json_formatter (~> 0.1)
|
@@ -114,7 +115,7 @@ GEM
|
|
114
115
|
temple (0.8.2)
|
115
116
|
termcolorlight (1.1.1)
|
116
117
|
tilt (2.0.10)
|
117
|
-
timecop (0.9.
|
118
|
+
timecop (0.9.2)
|
118
119
|
tzinfo (2.0.4)
|
119
120
|
concurrent-ruby (~> 1.0)
|
120
121
|
unicode-display_width (1.7.0)
|
@@ -130,7 +131,7 @@ DEPENDENCIES
|
|
130
131
|
narou!
|
131
132
|
pry (~> 0.12)
|
132
133
|
pry-byebug (~> 3.8)
|
133
|
-
rspec (~> 3.
|
134
|
+
rspec (~> 3.10)
|
134
135
|
rspec-retry (~> 0.6)
|
135
136
|
rspec_junit_formatter (~> 0.4)
|
136
137
|
simplecov (~> 0.20)
|
data/README.md
CHANGED
@@ -34,6 +34,14 @@ Narou.rb - 小説家になろうのダウンローダ&縦書き整形&管理
|
|
34
34
|
更新履歴 - ChangeLog
|
35
35
|
--------------------
|
36
36
|
|
37
|
+
3.7.0: 2021/01/23
|
38
|
+
-----------------
|
39
|
+
#### 修正内容
|
40
|
+
- Apple Silicon 搭載 Mac でも動く様にライブラリをアップデート
|
41
|
+
- device を kobo に設定し、_ebook-filename-length-limit でファイル名が制限され
|
42
|
+
た場合に send コマンドが正常に実行できない不具合を修正
|
43
|
+
|
44
|
+
|
37
45
|
3.6.0: 2021/01/02
|
38
46
|
-----------------
|
39
47
|
#### 修正内容
|
data/lib/command/setting.rb
CHANGED
@@ -537,8 +537,8 @@ module Command
|
|
537
537
|
"webui.theme" => {
|
538
538
|
type: :select, help: "WEB UI 用テーマ選択",
|
539
539
|
invisible: true,
|
540
|
-
select_keys: Narou.
|
541
|
-
select_summaries: Narou.
|
540
|
+
select_keys: Narou.theme_names,
|
541
|
+
select_summaries: Narou.theme_names,
|
542
542
|
tab: :webui
|
543
543
|
},
|
544
544
|
"webui.table.reload-timing" => {
|
data/lib/helper.rb
CHANGED
@@ -350,10 +350,10 @@ module Helper
|
|
350
350
|
# 長過ぎるファイルパスを詰める
|
351
351
|
# ファイル名部分のみを詰める。拡張子は維持する
|
352
352
|
#
|
353
|
-
def truncate_path(path, limit = Inventory.load["filename-length-limit"])
|
353
|
+
def truncate_path(path, limit = Inventory.load["filename-length-limit"], extname: nil)
|
354
354
|
limit ||= FILENAME_LENGTH_LIMIT
|
355
355
|
dirname = File.dirname(path)
|
356
|
-
extname
|
356
|
+
extname ||= File.extname(path)
|
357
357
|
basename = File.basename(path, extname)
|
358
358
|
if basename.length > limit
|
359
359
|
basename = basename[0...limit]
|
data/lib/narou.rb
CHANGED
@@ -38,330 +38,336 @@ module Narou
|
|
38
38
|
|
39
39
|
extend Mixin::Locker
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
class << self
|
42
|
+
extend Memoist
|
43
43
|
|
44
|
-
|
44
|
+
@@is_web = false
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
def last_commit_year
|
47
|
+
2021
|
48
|
+
end
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
50
|
+
def root_dir
|
51
|
+
root = nil
|
52
|
+
path = Dir.pwd
|
53
|
+
drive_letter = ""
|
54
|
+
if Helper.os_windows?
|
55
|
+
path.encode!(Encoding::UTF_8)
|
56
|
+
path.gsub!(/^[a-z]:/i, "")
|
57
|
+
drive_letter = $&
|
58
|
+
end
|
59
|
+
while path != ""
|
60
|
+
if File.directory?("#{drive_letter}#{path}/#{LOCAL_SETTING_DIR_NAME}")
|
61
|
+
root = drive_letter + path
|
62
|
+
break
|
63
|
+
end
|
64
|
+
path.gsub!(%r!/[^/]*$!, "")
|
63
65
|
end
|
64
|
-
|
66
|
+
Pathname(root) if root
|
65
67
|
end
|
66
|
-
|
67
|
-
end
|
68
|
-
memoize :root_dir
|
68
|
+
memoize :root_dir
|
69
69
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
70
|
+
def local_setting_dir
|
71
|
+
root_dir&.join(LOCAL_SETTING_DIR_NAME)
|
72
|
+
end
|
73
|
+
memoize :local_setting_dir
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
75
|
+
def global_setting_dir
|
76
|
+
if root_dir
|
77
|
+
dir = root_dir.join(GLOBAL_SETTING_DIR_NAME)
|
78
|
+
return dir if dir.directory?
|
79
|
+
end
|
80
|
+
dir = Pathname(GLOBAL_SETTING_DIR_NAME).expand_path("~")
|
81
|
+
dir.mkdir unless dir.exist?
|
82
|
+
dir
|
79
83
|
end
|
80
|
-
|
81
|
-
dir.mkdir unless dir.exist?
|
82
|
-
dir
|
83
|
-
end
|
84
|
-
memoize :global_setting_dir
|
84
|
+
memoize :global_setting_dir
|
85
85
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
86
|
+
def script_dir
|
87
|
+
Pathname(__dir__).join("..").expand_path
|
88
|
+
end
|
89
|
+
memoize :script_dir
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
|
91
|
+
def log_dir
|
92
|
+
root_dir&.join(LOG_DIR)
|
93
|
+
end
|
94
94
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
95
|
+
def preset_dir
|
96
|
+
script_dir&.join(PRESET_DIR)
|
97
|
+
end
|
98
|
+
memoize :preset_dir
|
99
99
|
|
100
|
-
|
101
|
-
|
102
|
-
|
100
|
+
def already_init?
|
101
|
+
root_dir.present?
|
102
|
+
end
|
103
103
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
104
|
+
def init
|
105
|
+
return nil if already_init?
|
106
|
+
FileUtils.mkdir(LOCAL_SETTING_DIR_NAME)
|
107
|
+
puts "#{LOCAL_SETTING_DIR_NAME}/ を作成しました"
|
108
|
+
Database.init
|
109
|
+
end
|
110
110
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
111
|
+
#
|
112
|
+
# target が alias だった場合はIDに変換する
|
113
|
+
#
|
114
|
+
# 全てのtarget照合系はこのメソッドを通過するので、ここで小文字にしてしまう
|
115
|
+
#
|
116
|
+
def alias_to_id(target)
|
117
|
+
aliases = Inventory.load("alias")
|
118
|
+
if aliases[target]
|
119
|
+
return aliases[target]
|
120
|
+
end
|
121
|
+
target.is_a?(Numeric) ? target : target.downcase
|
122
|
+
end
|
123
123
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
124
|
+
def novel_frozen?(target)
|
125
|
+
id = Downloader.get_id_by_target(target) or return false
|
126
|
+
Inventory.load("freeze").include?(id)
|
127
|
+
end
|
128
128
|
|
129
|
-
|
130
|
-
|
131
|
-
|
129
|
+
def create_aozoraepub3_jar_path(*paths)
|
130
|
+
Pathname(File.expand_path(File.join(*paths, AOZORAEPUB3_JAR_NAME)))
|
131
|
+
end
|
132
132
|
|
133
|
-
|
134
|
-
|
135
|
-
|
133
|
+
def aozoraepub3_directory?(path)
|
134
|
+
create_aozoraepub3_jar_path(path).exist?
|
135
|
+
end
|
136
136
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
137
|
+
def parse_replace_txt(text)
|
138
|
+
pattern = []
|
139
|
+
text.each_line do |line|
|
140
|
+
line.sub!(/[\r\n]+\z/, "")
|
141
|
+
next if line[0] == ";" # コメント記号
|
142
|
+
pair = line.split("\t", 2)
|
143
|
+
if pair.length == 2 && pair[0]
|
144
|
+
pattern << pair
|
145
|
+
end
|
145
146
|
end
|
147
|
+
pattern
|
146
148
|
end
|
147
|
-
pattern
|
148
|
-
end
|
149
149
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
150
|
+
def write_replace_txt(path, pairs)
|
151
|
+
buffer = pairs.each_with_object("\t").map(&:join).join("\n")
|
152
|
+
File.write(path, buffer)
|
153
|
+
end
|
154
154
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
155
|
+
def load_global_replace_pattern
|
156
|
+
path = root_dir.join(GLOBAL_REPLACE_NAME)
|
157
|
+
pairs =
|
158
|
+
if path.exist?
|
159
|
+
Helper::CacheLoader.memo(path) do |text|
|
160
|
+
parse_replace_txt(text)
|
161
|
+
end
|
162
|
+
else
|
163
|
+
[]
|
161
164
|
end
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
@@global_replace_pattern_pairs = pairs
|
166
|
-
pairs
|
167
|
-
end
|
165
|
+
@@global_replace_pattern_pairs = pairs
|
166
|
+
pairs
|
167
|
+
end
|
168
168
|
|
169
|
-
|
170
|
-
|
171
|
-
|
169
|
+
def global_replace_pattern
|
170
|
+
@@global_replace_pattern_pairs ||= load_global_replace_pattern
|
171
|
+
end
|
172
172
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
173
|
+
def save_global_replace_pattern
|
174
|
+
path = root_dir.join(GLOBAL_REPLACE_NAME)
|
175
|
+
write_replace_txt(path, @@global_replace_pattern_pairs)
|
176
|
+
end
|
177
177
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
178
|
+
#
|
179
|
+
# AozoraEpub3 の実行ファイル(.jar)のフルパス取得
|
180
|
+
# 検索順序
|
181
|
+
# 1. グローバルセッティング (global_setting aozoraepub3dir)
|
182
|
+
# 2. 小説保存ディレクトリ(Narou.root_dir) 直下の AozoraEpub3
|
183
|
+
# 3. スクリプト保存ディレクトリ(Narou.script_dir) 直下の AozoraEpub3
|
184
|
+
#
|
185
|
+
def aozoraepub3_path
|
186
|
+
global_setting_aozora_path = Inventory.load("global_setting", :global)["aozoraepub3dir"]
|
187
|
+
if global_setting_aozora_path
|
188
|
+
aozora_jar_path = create_aozoraepub3_jar_path(global_setting_aozora_path)
|
189
|
+
if aozora_jar_path.exist?
|
190
|
+
return aozora_jar_path
|
191
|
+
end
|
191
192
|
end
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
return aozora_jar_path if aozora_jar_path.exist?
|
196
|
-
end
|
197
|
-
nil
|
198
|
-
end
|
199
|
-
memoize :aozoraepub3_path
|
200
|
-
|
201
|
-
#
|
202
|
-
# 書籍ファイル名を生成する
|
203
|
-
# convert.filename-to-ncode を設定している場合に novel_data に ncode、domain を
|
204
|
-
# 設定しない場合は id カラムが必須
|
205
|
-
#
|
206
|
-
def create_novel_filename(novel_data, ext = "")
|
207
|
-
filename_to_ncode = Inventory.load("local_setting")["convert.filename-to-ncode"]
|
208
|
-
novel_setting =
|
209
|
-
if novel_data["id"]
|
210
|
-
NovelSetting.load(novel_data["id"])
|
211
|
-
else
|
212
|
-
OpenStruct.new
|
193
|
+
[Narou.root_dir, Narou.script_dir].each do |dir|
|
194
|
+
aozora_jar_path = create_aozoraepub3_jar_path(dir, AOZORAEPUB3_DIR)
|
195
|
+
return aozora_jar_path if aozora_jar_path.exist?
|
213
196
|
end
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
197
|
+
nil
|
198
|
+
end
|
199
|
+
memoize :aozoraepub3_path
|
200
|
+
|
201
|
+
#
|
202
|
+
# 書籍ファイル名を生成する
|
203
|
+
# convert.filename-to-ncode を設定している場合に novel_data に ncode、domain を
|
204
|
+
# 設定しない場合は id カラムが必須
|
205
|
+
#
|
206
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
207
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
208
|
+
def create_novel_filename(novel_data, ext = "")
|
209
|
+
filename_to_ncode = Inventory.load("local_setting")["convert.filename-to-ncode"]
|
210
|
+
novel_setting =
|
211
|
+
if novel_data["id"]
|
212
|
+
NovelSetting.load(novel_data["id"])
|
213
|
+
else
|
214
|
+
OpenStruct.new
|
215
|
+
end
|
216
|
+
if novel_setting.output_filename.present?
|
217
|
+
%!#{novel_setting.output_filename}#{ext}!
|
218
|
+
elsif filename_to_ncode
|
219
|
+
ncode = novel_data["ncode"]
|
220
|
+
domain = novel_data["domain"]
|
221
|
+
if !ncode || !domain
|
222
|
+
id = novel_data["id"]
|
223
|
+
unless id
|
224
|
+
raise ArgumentError, %!novel_data["id"] を設定して下さい!
|
225
|
+
end
|
226
|
+
site_setting = Downloader.get_sitesetting_by_target(id)
|
227
|
+
ncode = site_setting["ncode"]
|
228
|
+
domain = site_setting["domain"]
|
222
229
|
end
|
223
|
-
|
224
|
-
ncode
|
225
|
-
|
230
|
+
serialized_domain = domain.to_s.gsub(".", "_")
|
231
|
+
%!#{serialized_domain}_#{ncode}#{ext}!
|
232
|
+
else
|
233
|
+
author = Helper.replace_filename_special_chars(
|
234
|
+
novel_setting.novel_author.presence || novel_data["author"],
|
235
|
+
true
|
236
|
+
)
|
237
|
+
title = Helper.replace_filename_special_chars(
|
238
|
+
novel_setting.novel_title.presence || novel_data["title"],
|
239
|
+
true
|
240
|
+
)
|
241
|
+
filename = "[#{author}] #{title}#{ext}"
|
242
|
+
length_limit = Inventory.load["ebook-filename-length-limit"]
|
243
|
+
length_limit ? Helper.truncate_path(filename, length_limit, extname: ext) : filename
|
226
244
|
end
|
227
|
-
serialized_domain = domain.to_s.gsub(".", "_")
|
228
|
-
%!#{serialized_domain}_#{ncode}#{ext}!
|
229
|
-
else
|
230
|
-
author = Helper.replace_filename_special_chars(
|
231
|
-
novel_setting.novel_author.presence || novel_data["author"],
|
232
|
-
true
|
233
|
-
)
|
234
|
-
title = Helper.replace_filename_special_chars(
|
235
|
-
novel_setting.novel_title.presence || novel_data["title"],
|
236
|
-
true
|
237
|
-
)
|
238
|
-
filename = "[#{author}] #{title}#{ext}"
|
239
|
-
length_limit = Inventory.load["ebook-filename-length-limit"]
|
240
|
-
length_limit ? Helper.truncate_path(filename, length_limit) : filename
|
241
245
|
end
|
242
|
-
|
246
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
247
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
243
248
|
|
244
|
-
|
245
|
-
|
246
|
-
|
249
|
+
def get_mobi_paths(target)
|
250
|
+
get_ebook_file_paths(target, ".mobi")
|
251
|
+
end
|
247
252
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
dir = Downloader.get_novel_data_dir_by_target(target)
|
252
|
-
fname = create_novel_filename(data, ext)
|
253
|
-
base = File.basename(fname, ext)
|
254
|
-
get_ebook_file_paths_from_components(dir, base, ext)
|
255
|
-
end
|
253
|
+
def get_ebook_file_paths(target, ext)
|
254
|
+
data = Downloader.get_data_by_target(target)
|
255
|
+
return nil unless data
|
256
256
|
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
paths.push(Pathname(path))
|
262
|
-
index += 1
|
257
|
+
dir = Downloader.get_novel_data_dir_by_target(target)
|
258
|
+
fname = create_novel_filename(data, ext)
|
259
|
+
base = File.basename(fname, ext)
|
260
|
+
get_ebook_file_paths_from_components(dir, base, ext)
|
263
261
|
end
|
264
|
-
paths
|
265
|
-
end
|
266
262
|
|
267
|
-
|
268
|
-
|
269
|
-
|
263
|
+
def get_ebook_file_paths_from_components(dir, base, ext)
|
264
|
+
paths = [File.join(dir, "#{base}#{ext}")]
|
265
|
+
index = 2
|
266
|
+
while File.exist?(path = File.join(dir, "#{base}_#{index}#{ext}"))
|
267
|
+
paths.push(Pathname(path))
|
268
|
+
index += 1
|
269
|
+
end
|
270
|
+
paths
|
271
|
+
end
|
272
|
+
|
273
|
+
def misc_dir
|
274
|
+
root_dir.join(MISC_DIR)
|
275
|
+
end
|
270
276
|
|
271
|
-
|
277
|
+
require_relative "device"
|
272
278
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
279
|
+
def get_device(device_name = nil)
|
280
|
+
device_name ||= Inventory.load("local_setting")["device"]
|
281
|
+
if device_name && Device.exists?(device_name)
|
282
|
+
return Device.create(device_name)
|
283
|
+
end
|
284
|
+
nil
|
277
285
|
end
|
278
|
-
nil
|
279
|
-
end
|
280
286
|
|
281
|
-
|
282
|
-
|
283
|
-
|
287
|
+
def web=(bool)
|
288
|
+
@@is_web = bool
|
289
|
+
end
|
284
290
|
|
285
|
-
|
286
|
-
|
287
|
-
|
291
|
+
def web?
|
292
|
+
@@is_web
|
293
|
+
end
|
288
294
|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
295
|
+
def update_sort_key_summaries(left_space = 28)
|
296
|
+
summaries = { "KEY" => " 対象" }.merge(UPDATE_SORT_KEYS)
|
297
|
+
key_max_width = summaries.keys.max_by(&:length).length
|
298
|
+
summaries.map do |(key, summary)|
|
299
|
+
"#{" " * left_space}| #{key.center(key_max_width)} | #{summary}"
|
300
|
+
end.join("\n")
|
301
|
+
end
|
296
302
|
|
297
|
-
|
298
|
-
|
299
|
-
|
303
|
+
def theme
|
304
|
+
Inventory.load("local_setting")["webui.theme"]
|
305
|
+
end
|
300
306
|
|
301
|
-
|
302
|
-
|
303
|
-
|
307
|
+
def get_theme_dir(name = nil)
|
308
|
+
Pathname(File.join([script_dir, "lib/web/public/theme", name].compact))
|
309
|
+
end
|
304
310
|
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
311
|
+
def theme_names
|
312
|
+
Dir.glob(get_theme_dir("*")).map do |path|
|
313
|
+
name = File.basename(path)
|
314
|
+
name == "fonts" ? nil : name
|
315
|
+
end.compact
|
316
|
+
end
|
317
|
+
memoize :theme_names
|
312
318
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
319
|
+
def economy?(mode)
|
320
|
+
eco_modes = Inventory.load("local_setting")["economy"].to_s.split(",").map(&:strip)
|
321
|
+
eco_modes.include?(mode)
|
322
|
+
end
|
317
323
|
|
318
|
-
|
319
|
-
|
320
|
-
|
324
|
+
def novel_type_text(type)
|
325
|
+
type == 2 ? "短編" : "連載"
|
326
|
+
end
|
321
327
|
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
328
|
+
#
|
329
|
+
# Narou.rb gem の最新バージョン番号を取得する
|
330
|
+
#
|
331
|
+
# rubygems公式APIによる取得は、WindowsでのSSL証明書問題で取得出来ない
|
332
|
+
# 環境があるため、gemコマンド経由で取得する
|
333
|
+
#
|
334
|
+
def latest_version
|
335
|
+
response = `gem search ^narou$`.split("\n")
|
336
|
+
if response.last =~ /\Anarou \(([0-9.]+).*?\)\z/
|
337
|
+
$1
|
338
|
+
end
|
332
339
|
end
|
333
|
-
end
|
334
340
|
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
341
|
+
def commit_version
|
342
|
+
cv_path = File.expand_path("commitversion", script_dir)
|
343
|
+
File.read(cv_path) if File.exist?(cv_path)
|
344
|
+
end
|
345
|
+
memoize :commit_version
|
340
346
|
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
347
|
+
def kindlegen_path
|
348
|
+
postfix = Helper.os_windows? ? ".exe" : ""
|
349
|
+
aozoraepub3_path.dirname.join("kindlegen#{postfix}")
|
350
|
+
end
|
351
|
+
memoize :kindlegen_path
|
346
352
|
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
353
|
+
def line_height(default: LINE_HEIGHT_DEFAULT)
|
354
|
+
global_setting = Inventory.load("global_setting", :global)
|
355
|
+
global_setting["line-height"] || default
|
356
|
+
end
|
351
357
|
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
358
|
+
def concurrency_enabled?
|
359
|
+
$stdout != $stdout2
|
360
|
+
end
|
361
|
+
memoize :concurrency_enabled?
|
356
362
|
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
363
|
+
# 同時実行が有効ならキューに積んで、無効なら普通に実行する
|
364
|
+
def concurrency_call(&block)
|
365
|
+
if concurrency_enabled?
|
366
|
+
Worker.push(&block)
|
367
|
+
EXIT_SUCCESS
|
368
|
+
else
|
369
|
+
block.call
|
370
|
+
end
|
364
371
|
end
|
365
372
|
end
|
366
|
-
end
|
367
373
|
end
|
data/lib/version.rb
CHANGED
data/lib/web/appserver.rb
CHANGED
data/narou.gemspec
CHANGED
@@ -32,10 +32,12 @@ Gem::Specification.new do |gem|
|
|
32
32
|
install_message = <<-EOS
|
33
33
|
#{"*" * 60}
|
34
34
|
|
35
|
-
3.
|
35
|
+
3.7.0: 2021/01/23
|
36
36
|
-----------------
|
37
37
|
#### 修正内容
|
38
|
-
-
|
38
|
+
- Apple Silicon 搭載 Mac でも動く様にライブラリをアップデート
|
39
|
+
- device を kobo に設定し、_ebook-filename-length-limit でファイル名が制限され
|
40
|
+
た場合に send コマンドが正常に実行できない不具合を修正
|
39
41
|
|
40
42
|
#{"*" * 60}
|
41
43
|
EOS
|
@@ -55,16 +57,17 @@ Gem::Specification.new do |gem|
|
|
55
57
|
gem.add_runtime_dependency 'sinatra-contrib', '~> 2.0', '>= 2.0.8.1'
|
56
58
|
gem.add_runtime_dependency 'tilt', '~> 2.0', '>= 2.0.10'
|
57
59
|
gem.add_runtime_dependency 'sassc', '~> 2.4'
|
60
|
+
gem.add_runtime_dependency 'ffi', '~> 1.4', '>= 1.4.2'
|
58
61
|
gem.add_runtime_dependency 'haml', '>= 5.1.2', '< 6'
|
59
62
|
gem.add_runtime_dependency 'memoist', '~> 0.11.0'
|
60
63
|
gem.add_runtime_dependency 'systemu', '~> 2.6', '>= 2.6.5'
|
61
64
|
gem.add_runtime_dependency 'erubis', '~> 2.7'
|
62
65
|
gem.add_runtime_dependency 'open_uri_redirections', '~> 0.2', '>= 0.2.1'
|
63
|
-
gem.add_runtime_dependency 'activesupport', '>=
|
66
|
+
gem.add_runtime_dependency 'activesupport', '>= 6.1', '< 8.0'
|
64
67
|
gem.add_runtime_dependency 'unicode-display_width', '~> 1.4'
|
65
68
|
gem.add_runtime_dependency 'webrick', '~> 1.7'
|
66
69
|
|
67
|
-
gem.add_development_dependency 'rspec', '~> 3.
|
70
|
+
gem.add_development_dependency 'rspec', '~> 3.10'
|
68
71
|
gem.add_development_dependency 'rspec-retry', '~> 0.6'
|
69
72
|
gem.add_development_dependency 'rspec_junit_formatter', '~> 0.4'
|
70
73
|
gem.add_development_dependency 'timecop', '~> 0.9'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: narou
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- whiteleaf7
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: termcolorlight
|
@@ -184,6 +184,26 @@ dependencies:
|
|
184
184
|
- - "~>"
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: '2.4'
|
187
|
+
- !ruby/object:Gem::Dependency
|
188
|
+
name: ffi
|
189
|
+
requirement: !ruby/object:Gem::Requirement
|
190
|
+
requirements:
|
191
|
+
- - "~>"
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: '1.4'
|
194
|
+
- - ">="
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: 1.4.2
|
197
|
+
type: :runtime
|
198
|
+
prerelease: false
|
199
|
+
version_requirements: !ruby/object:Gem::Requirement
|
200
|
+
requirements:
|
201
|
+
- - "~>"
|
202
|
+
- !ruby/object:Gem::Version
|
203
|
+
version: '1.4'
|
204
|
+
- - ">="
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: 1.4.2
|
187
207
|
- !ruby/object:Gem::Dependency
|
188
208
|
name: haml
|
189
209
|
requirement: !ruby/object:Gem::Requirement
|
@@ -278,20 +298,20 @@ dependencies:
|
|
278
298
|
requirements:
|
279
299
|
- - ">="
|
280
300
|
- !ruby/object:Gem::Version
|
281
|
-
version: '
|
301
|
+
version: '6.1'
|
282
302
|
- - "<"
|
283
303
|
- !ruby/object:Gem::Version
|
284
|
-
version: '
|
304
|
+
version: '8.0'
|
285
305
|
type: :runtime
|
286
306
|
prerelease: false
|
287
307
|
version_requirements: !ruby/object:Gem::Requirement
|
288
308
|
requirements:
|
289
309
|
- - ">="
|
290
310
|
- !ruby/object:Gem::Version
|
291
|
-
version: '
|
311
|
+
version: '6.1'
|
292
312
|
- - "<"
|
293
313
|
- !ruby/object:Gem::Version
|
294
|
-
version: '
|
314
|
+
version: '8.0'
|
295
315
|
- !ruby/object:Gem::Dependency
|
296
316
|
name: unicode-display_width
|
297
317
|
requirement: !ruby/object:Gem::Requirement
|
@@ -326,14 +346,14 @@ dependencies:
|
|
326
346
|
requirements:
|
327
347
|
- - "~>"
|
328
348
|
- !ruby/object:Gem::Version
|
329
|
-
version: '3.
|
349
|
+
version: '3.10'
|
330
350
|
type: :development
|
331
351
|
prerelease: false
|
332
352
|
version_requirements: !ruby/object:Gem::Requirement
|
333
353
|
requirements:
|
334
354
|
- - "~>"
|
335
355
|
- !ruby/object:Gem::Version
|
336
|
-
version: '3.
|
356
|
+
version: '3.10'
|
337
357
|
- !ruby/object:Gem::Dependency
|
338
358
|
name: rspec-retry
|
339
359
|
requirement: !ruby/object:Gem::Requirement
|
@@ -675,10 +695,12 @@ metadata: {}
|
|
675
695
|
post_install_message: |
|
676
696
|
************************************************************
|
677
697
|
|
678
|
-
3.
|
698
|
+
3.7.0: 2021/01/23
|
679
699
|
-----------------
|
680
700
|
#### 修正内容
|
681
|
-
-
|
701
|
+
- Apple Silicon 搭載 Mac でも動く様にライブラリをアップデート
|
702
|
+
- device を kobo に設定し、_ebook-filename-length-limit でファイル名が制限され
|
703
|
+
た場合に send コマンドが正常に実行できない不具合を修正
|
682
704
|
|
683
705
|
************************************************************
|
684
706
|
rdoc_options: []
|
@@ -696,7 +718,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
696
718
|
version: '0'
|
697
719
|
requirements: []
|
698
720
|
rubygems_version: 3.2.3
|
699
|
-
signing_key:
|
721
|
+
signing_key:
|
700
722
|
specification_version: 4
|
701
723
|
summary: Narou.rb ― 小説家になろうダウンローダ&縦書用整形スクリプト
|
702
724
|
test_files: []
|