narou 1.4.1.1 → 1.4.2.rc1
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/lib/command/convert.rb +69 -2
- data/lib/command/send.rb +8 -2
- data/lib/converterbase.rb +1 -1
- data/lib/device.rb +14 -6
- data/lib/device/ibunko.rb +13 -0
- data/lib/device/kindle.rb +3 -0
- data/lib/device/kobo.rb +3 -0
- data/lib/device/reader.rb +3 -0
- data/lib/novelconverter.rb +3 -1
- data/lib/novelsetting.rb +5 -0
- data/lib/template.rb +3 -1
- data/lib/version.rb +1 -1
- data/narou.gemspec +1 -0
- data/template/ibunko_novel.txt.erb +41 -0
- metadata +22 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a1797a6b3e930caf7864207b026e7bcfcc495f4
|
4
|
+
data.tar.gz: 0841fe186112b837b3c9b2c76ea1f720568a9d4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37f1f5ac7a3b3597d42e706c26746bbe965734147af4b84f817083f1a331b4a1a34692bdfc0375ab4860f37e6e5c84831e61cd31da28dd880ac0028487ff6654
|
7
|
+
data.tar.gz: f99e88ddd9ba24bd6160d52ed0a63838d606bc7b08674cfcaf23d18c83ecea31597e9873a0f0deb7fb6a1169a031c3512d62f7f6388c0017ffdcebc07b41515e
|
data/lib/command/convert.rb
CHANGED
@@ -59,6 +59,9 @@ module Command
|
|
59
59
|
@opt.on("--no-strip", "MOBIをstripしない") {
|
60
60
|
@options["no-strip"] = true
|
61
61
|
}
|
62
|
+
@opt.on("--no-zip", "i文庫用のzipファイルを作らない") {
|
63
|
+
@options["no-zip"] = true
|
64
|
+
}
|
62
65
|
@opt.on("--no-open", "出力時に保存フォルダを開かない") {
|
63
66
|
@options["no-open"] = true
|
64
67
|
}
|
@@ -109,6 +112,9 @@ module Command
|
|
109
112
|
end
|
110
113
|
end
|
111
114
|
@device = Narou.get_device
|
115
|
+
if @device && @device.ibunko?
|
116
|
+
change_settings_for_ibunko
|
117
|
+
end
|
112
118
|
convert_novels(argv)
|
113
119
|
end
|
114
120
|
|
@@ -135,14 +141,19 @@ module Command
|
|
135
141
|
@converted_txt_path = res[:converted_txt_path]
|
136
142
|
@use_dakuten_font = res[:use_dakuten_font]
|
137
143
|
|
138
|
-
|
144
|
+
if @device && @device.ibunko?
|
145
|
+
ebook_file = archive_ibunko_zipfile
|
146
|
+
else
|
147
|
+
ebook_file = convert_txt_to_ebook_file
|
148
|
+
end
|
139
149
|
next if ebook_file.nil?
|
140
150
|
if ebook_file
|
141
151
|
copied_file_path = copy_to_converted_file(ebook_file)
|
142
152
|
if copied_file_path
|
143
153
|
puts copied_file_path.encode(Encoding::UTF_8) + " へコピーしました"
|
144
154
|
end
|
145
|
-
if @device && @device.
|
155
|
+
if @device && @device.physical_support? &&
|
156
|
+
@device.connecting? && File.extname(ebook_file) == @device.ebook_file_ext
|
146
157
|
if @argument_target_type == :novel
|
147
158
|
Send.execute_and_rescue_exit([@device.name, target])
|
148
159
|
else
|
@@ -167,6 +178,9 @@ module Command
|
|
167
178
|
exit 1
|
168
179
|
end
|
169
180
|
|
181
|
+
#
|
182
|
+
# 直接指定されたテキストファイルを変換する
|
183
|
+
#
|
170
184
|
def convert_txt(target)
|
171
185
|
return NovelConverter.convert_file(target, @enc, @output_filename, @options["inspect"])
|
172
186
|
rescue ArgumentError => e
|
@@ -185,6 +199,9 @@ module Command
|
|
185
199
|
return nil
|
186
200
|
end
|
187
201
|
|
202
|
+
#
|
203
|
+
# 変換された整形済みテキストファイルをデバイスに対応した書籍データに変換する
|
204
|
+
#
|
188
205
|
def convert_txt_to_ebook_file
|
189
206
|
return false if @options["no-epub"]
|
190
207
|
# epub
|
@@ -223,6 +240,56 @@ module Command
|
|
223
240
|
return mobi_path
|
224
241
|
end
|
225
242
|
|
243
|
+
#
|
244
|
+
# i文庫用にテキストと挿絵ファイルをzipアーカイブ化する
|
245
|
+
#
|
246
|
+
def archive_ibunko_zipfile
|
247
|
+
return false if @options["no-zip"]
|
248
|
+
require "zip"
|
249
|
+
Zip.unicode_names = true
|
250
|
+
dirpath = File.dirname(@converted_txt_path)
|
251
|
+
zipfile_path = @converted_txt_path.sub(/.txt$/, @device.ebook_file_ext)
|
252
|
+
File.delete(zipfile_path) if File.exists?(zipfile_path)
|
253
|
+
Zip::File.open(zipfile_path, Zip::File::CREATE) do |zip|
|
254
|
+
zip.add(File.basename(@converted_txt_path), @converted_txt_path)
|
255
|
+
illust_dirpath = File.join(dirpath, Illustration::ILLUST_DIR)
|
256
|
+
# 挿絵
|
257
|
+
if File.exists?(illust_dirpath)
|
258
|
+
Dir.glob(File.join(illust_dirpath, "*")) do |img_path|
|
259
|
+
zip.add(File.join(Illustration::ILLUST_DIR, File.basename(img_path)), img_path)
|
260
|
+
end
|
261
|
+
end
|
262
|
+
# 表紙画像
|
263
|
+
cover_name = NovelConverter.get_cover_filename(dirpath)
|
264
|
+
if cover_name
|
265
|
+
zip.add(cover_name, File.join(dirpath, cover_name))
|
266
|
+
end
|
267
|
+
end
|
268
|
+
puts File.basename(zipfile_path) + " を出力しました"
|
269
|
+
puts "<bold><green>#{@device.display_name}用ファイルを出力しました</green></bold>".termcolor
|
270
|
+
return zipfile_path
|
271
|
+
end
|
272
|
+
|
273
|
+
#
|
274
|
+
# i文庫用に設定を強制設定する
|
275
|
+
#
|
276
|
+
def change_settings_for_ibunko
|
277
|
+
settings = LocalSetting.get["local_setting"]
|
278
|
+
modified = false
|
279
|
+
%w(enable_half_indent_bracket enable_dakuten_font).each do |word|
|
280
|
+
name = "force.#{word}"
|
281
|
+
if settings[name].nil? || settings[name] == true
|
282
|
+
settings[name] = false
|
283
|
+
puts "#{name} を#{@device.display_name}用に false に強制変更しました"
|
284
|
+
modified = true
|
285
|
+
end
|
286
|
+
end
|
287
|
+
LocalSetting.get.save_settings("local_setting") if modified
|
288
|
+
end
|
289
|
+
|
290
|
+
#
|
291
|
+
# convert.copy_to で指定されたディレクトリに書籍データをコピーする
|
292
|
+
#
|
226
293
|
def copy_to_converted_file(src_path)
|
227
294
|
copy_to_dir = @options["copy_to"]
|
228
295
|
return nil unless copy_to_dir
|
data/lib/command/send.rb
CHANGED
@@ -46,11 +46,17 @@ module Command
|
|
46
46
|
super
|
47
47
|
device = get_device(argv)
|
48
48
|
unless device
|
49
|
-
error "
|
49
|
+
error "デバイス名が指定されていないか、間違っています。\n" +
|
50
|
+
"narou setting device=デバイス名 で指定出来ます。\n" +
|
51
|
+
"指定出来るデバイス名:" + Device::DEVICES.keys.join(", ")
|
52
|
+
exit 1
|
53
|
+
end
|
54
|
+
unless device.physical_support?
|
55
|
+
error "#{device.display_name} への直接送信は対応していません"
|
50
56
|
exit 1
|
51
57
|
end
|
52
58
|
unless device.connecting?
|
53
|
-
error "#{device.
|
59
|
+
error "#{device.display_name} が接続されていません"
|
54
60
|
exit 1
|
55
61
|
end
|
56
62
|
send_all = false
|
data/lib/converterbase.rb
CHANGED
data/lib/device.rb
CHANGED
@@ -19,12 +19,15 @@ class Device
|
|
19
19
|
extend Device::Library::Linux
|
20
20
|
end
|
21
21
|
|
22
|
-
attr_reader :name, :ebook_file_ext
|
22
|
+
attr_reader :name, :ebook_file_ext, :display_name
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
DEVICES = {}.tap do |h|
|
25
|
+
Dir.glob(File.join(File.dirname(__FILE__), "device", "*.rb")).each do |name|
|
26
|
+
name = File.basename(name, ".rb")
|
27
|
+
require_relative "device/#{name}"
|
28
|
+
h[name] = eval(name.capitalize)
|
29
|
+
end
|
30
|
+
end
|
28
31
|
|
29
32
|
class UnknownDevice < StandardError; end
|
30
33
|
|
@@ -45,7 +48,8 @@ class Device
|
|
45
48
|
raise UnknownDevice, "#{device_name} は存在しません"
|
46
49
|
end
|
47
50
|
@device = DEVICES[device_name.downcase]
|
48
|
-
@name =
|
51
|
+
@name = @device::NAME
|
52
|
+
@display_name = @device::DISPLAY_NAME
|
49
53
|
@ebook_file_ext = @device::EBOOK_FILE_EXT
|
50
54
|
create_device_check_methods
|
51
55
|
end
|
@@ -107,6 +111,10 @@ class Device
|
|
107
111
|
exit 1
|
108
112
|
end
|
109
113
|
|
114
|
+
def physical_support?
|
115
|
+
@device::PHYSICAL_SUPPORT
|
116
|
+
end
|
117
|
+
|
110
118
|
private
|
111
119
|
|
112
120
|
def create_device_check_methods
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2013 whiteleaf. All rights reserved.
|
4
|
+
#
|
5
|
+
|
6
|
+
module Device::Ibunko
|
7
|
+
PHYSICAL_SUPPORT = false
|
8
|
+
VOLUME_NAME = nil
|
9
|
+
DOCUMENTS_PATH_LIST = nil
|
10
|
+
EBOOK_FILE_EXT = ".zip"
|
11
|
+
NAME = "iBunko"
|
12
|
+
DISPLAY_NAME = "i文庫"
|
13
|
+
end
|
data/lib/device/kindle.rb
CHANGED
data/lib/device/kobo.rb
CHANGED
data/lib/device/reader.rb
CHANGED
data/lib/novelconverter.rb
CHANGED
@@ -17,6 +17,7 @@ require_relative "localsetting"
|
|
17
17
|
|
18
18
|
class NovelConverter
|
19
19
|
NOVEL_TEXT_TEMPLATE_NAME = "novel.txt"
|
20
|
+
NOVEL_TEXT_TEMPLATE_NAME_FOR_IBUNKO = "ibunko_novel.txt"
|
20
21
|
|
21
22
|
attr_reader :use_dakuten_font
|
22
23
|
|
@@ -237,7 +238,8 @@ class NovelConverter
|
|
237
238
|
toc = @toc
|
238
239
|
cover_chuki = @cover_chuki
|
239
240
|
device = Narou.get_device
|
240
|
-
|
241
|
+
tempalte_name = (device && device.ibunko? ? NOVEL_TEXT_TEMPLATE_NAME_FOR_IBUNKO : NOVEL_TEXT_TEMPLATE_NAME)
|
242
|
+
Template.get(tempalte_name, binding)
|
241
243
|
end
|
242
244
|
|
243
245
|
#
|
data/lib/novelsetting.rb
CHANGED
data/lib/template.rb
CHANGED
@@ -9,6 +9,8 @@ require_relative "narou"
|
|
9
9
|
class Template
|
10
10
|
TEMPLATE_DIR = "template/"
|
11
11
|
|
12
|
+
class LoadError < StandardError; end
|
13
|
+
|
12
14
|
#
|
13
15
|
# テンプレートを元にファイルを作成
|
14
16
|
#
|
@@ -49,7 +51,7 @@ class Template
|
|
49
51
|
result = ERB.new(src, nil, "-").result(_binding)
|
50
52
|
return result
|
51
53
|
end
|
52
|
-
|
54
|
+
raise LoadError, "テンプレートファイルが見つかりません。(#{src_filename}.erb)"
|
53
55
|
end
|
54
56
|
|
55
57
|
def self.invalid_templace_version?
|
data/lib/version.rb
CHANGED
data/narou.gemspec
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
<%# -*- coding: utf-8 -*- -%>
|
2
|
+
<% Template.target_binary_version(1.0) -%>
|
3
|
+
<%= toc["title"] %>
|
4
|
+
<%= toc["author"] %>
|
5
|
+
<%= cover_chuki %>
|
6
|
+
――――――――――――――――――――――――
|
7
|
+
あらすじ:
|
8
|
+
<%= toc["story"] %>
|
9
|
+
|
10
|
+
掲載ページ: <%= toc["toc_url"] %>
|
11
|
+
――――――――――――――――――――――――
|
12
|
+
|
13
|
+
<% sections.each_with_index do |section, i| -%>
|
14
|
+
[#改ページ]
|
15
|
+
<% if section["chapter"] != "" -%>
|
16
|
+
[#ページの左右中央]
|
17
|
+
|
18
|
+
|
19
|
+
[#3字下げ][#ここから大見出し]<%= section["chapter"] %>[#ここで大見出し終わり]
|
20
|
+
|
21
|
+
|
22
|
+
[#改ページ]
|
23
|
+
<% end -%>
|
24
|
+
|
25
|
+
[#3字下げ][#ここから中見出し]<%= section["subtitle"].rstrip %>[#ここで中見出し終わり]
|
26
|
+
|
27
|
+
<% if section["element"]["introduction"] != "" -%>
|
28
|
+
[#ここから6字下げ]
|
29
|
+
<%= section["element"]["introduction"] %>
|
30
|
+
[#ここで字下げ終わり]
|
31
|
+
<% end -%>
|
32
|
+
|
33
|
+
|
34
|
+
<%= section["element"]["body"] %>
|
35
|
+
|
36
|
+
<% if section["element"]["postscript"] != "" -%>
|
37
|
+
[#ここから6字下げ]
|
38
|
+
<%= section["element"]["postscript"] %>
|
39
|
+
[#ここで字下げ終わり]
|
40
|
+
<% end -%>
|
41
|
+
<% end -%>
|
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: 1.4.
|
4
|
+
version: 1.4.2.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- whiteleaf7
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: termcolor
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.2.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubyzip
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.1.0
|
27
41
|
description: 小説家になろうで公開されている小説の管理、及び電子書籍データへの変換を支援します。縦書用に特化されており、横書き用に特化されたWEB小説を違和感なく縦書で読むことが出来るようになります。
|
28
42
|
email:
|
29
43
|
- 2nd.leaf@gmail.com
|
@@ -40,6 +54,7 @@ files:
|
|
40
54
|
- README.md
|
41
55
|
- Rakefile
|
42
56
|
- bin/narou
|
57
|
+
- commitversion
|
43
58
|
- lib/color.rb
|
44
59
|
- lib/command.rb
|
45
60
|
- lib/command/alias.rb
|
@@ -63,6 +78,7 @@ files:
|
|
63
78
|
- lib/converterbase.rb
|
64
79
|
- lib/database.rb
|
65
80
|
- lib/device.rb
|
81
|
+
- lib/device/ibunko.rb
|
66
82
|
- lib/device/kindle.rb
|
67
83
|
- lib/device/kobo.rb
|
68
84
|
- lib/device/library/linux.rb
|
@@ -108,6 +124,7 @@ files:
|
|
108
124
|
- preset/vertical_font.css
|
109
125
|
- template/converter.rb.erb
|
110
126
|
- template/diff.txt.erb
|
127
|
+
- template/ibunko_novel.txt.erb
|
111
128
|
- template/novel.txt.erb
|
112
129
|
- template/replace.txt.erb
|
113
130
|
- template/setting.ini.erb
|
@@ -118,7 +135,6 @@ files:
|
|
118
135
|
- test/num_to_kanji.rb
|
119
136
|
- webnovel/ncode.syosetu.com.yaml
|
120
137
|
- webnovel/novel18.syosetu.com.yaml
|
121
|
-
- commitversion
|
122
138
|
homepage: http://whiteleaf.hatenablog.com/
|
123
139
|
licenses:
|
124
140
|
- MIT
|
@@ -149,12 +165,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
165
|
version: 1.9.3
|
150
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
167
|
requirements:
|
152
|
-
- - '
|
168
|
+
- - '>'
|
153
169
|
- !ruby/object:Gem::Version
|
154
|
-
version:
|
170
|
+
version: 1.3.1
|
155
171
|
requirements: []
|
156
172
|
rubyforge_project:
|
157
|
-
rubygems_version: 2.
|
173
|
+
rubygems_version: 2.2.2
|
158
174
|
signing_key:
|
159
175
|
specification_version: 4
|
160
176
|
summary: Narou.rb ― 小説家になろうダウンローダ&縦書用整形スクリプト
|