narou 1.4.2.rc2 → 1.4.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 106a0cab3c8db068920d8345df963ba43b088771
4
- data.tar.gz: e379a8e63f7df81e51b08d565131ea60300560c9
3
+ metadata.gz: 7e357d2d3541349dcd9c101577f46371b4dcad85
4
+ data.tar.gz: 842dcfd45f32421a67eff684de2be212a0955441
5
5
  SHA512:
6
- metadata.gz: 4678086165e0a898a5b0ab82da4d84c8981a52ce4e6ed990b7dca6d5dae7b5e7e01b12ac92ee8b3d06a45908b717c873e7f9482daa031117c32d852f88090ded
7
- data.tar.gz: 568f57a6281ee6bfe8dad434a578af8616d3c63cf4683aece71408a2e3e38602be9792417867da72bd20be12699faa2447561ce012a66cd7cacc6698daeed4b4
6
+ metadata.gz: 1704c6770acaa3edf92561ef6b1633ce228f1b88898a85a481201058e66c03a6eed5d3b2ba068ee59bc6d0114822bd70cc66ab5f64fca404acaaad22c9d86827
7
+ data.tar.gz: 7e4767c4235c59ba90ab7bd21f7402228415037d99858e825720d2dbbf0a9c9b50e77e4fa588f5e56a89ad40b267f28e728ddfd3b236ca964582f9cde9f5bcc9
@@ -2,6 +2,21 @@
2
2
  更新履歴 - ChangeLog
3
3
  --------------------
4
4
 
5
+ 2014/02/24 : **1.4.3**
6
+ * 追加機能もしくは仕様変更
7
+ - **i文庫** に対応しました。専用のzipアーカイブを生成出来るようになります(txtと表紙、挿絵をzipで固めたもの)
8
+ + `narou s device=ibunko` で切り替えることが出来ます
9
+ + Drobbox等と連携をするために、 `narou s convert.copy_to=フォルダのパス` を設定することで、
10
+ zipファイルがコピーされるようになります
11
+ + i文庫専用レイアウトテンプレート、ibunko_novel.txt.erb が追加されました
12
+ + `narou convert` コマンドに `--no-zip` オプションが追加されました
13
+ - `setting.ini` に濁点フォントの埋め込みを制御できる `enable_dakuten_font` が追加されました
14
+ - あらすじ及び章も変換処理を施すように変更しました
15
+ + `converter#before` 及び `after` メソッドの text_type に、 `story` `chapter` が渡されるようになりました
16
+ * Bug Fix
17
+ - Windowsにおいて、タイトル及び作者名にCP392外の文字が使われていた場合に変換がエラーになる問題を修正
18
+ - 章タイトルが※で終わる小説をEPUB変換時に警告が出ていたのを修正
19
+
5
20
  2014/02/20 : **1.4.1.1**
6
21
  * Bug Fix
7
22
  - `narou init` 時にエラーが出るようになっていたのを修正
@@ -37,7 +52,7 @@
37
52
 
38
53
  2013/10/30 : **1.3.3**
39
54
  * 追加機能もしくは仕様変更
40
- - 送信対応端末に SonyReader(PRS-T2) を追加
55
+ - 送信対応端末に **SonyReader(PRS-T2)** を追加
41
56
  + `narou setting device=reader` で切り替えることが出来ます
42
57
 
43
58
  2013/10/29 : **1.3.2**
data/README.md CHANGED
@@ -21,6 +21,21 @@ Narou.rb ― 「小説家になろう」「小説を読もう!」ダウンロ
21
21
  更新履歴 - ChangeLog
22
22
  --------------------
23
23
 
24
+ 2014/02/24 : **1.4.3**
25
+ * 追加機能もしくは仕様変更
26
+ - **i文庫** に対応しました。専用のzipアーカイブを生成出来るようになります(txtと表紙、挿絵をzipで固めたもの)
27
+ + `narou s device=ibunko` で切り替えることが出来ます
28
+ + Drobbox等と連携をするために、 `narou s convert.copy_to=フォルダのパス` を設定することで、
29
+ zipファイルがコピーされるようになります
30
+ + i文庫専用レイアウトテンプレート、ibunko_novel.txt.erb が追加されました
31
+ + `narou convert` コマンドに `--no-zip` オプションが追加されました
32
+ - `setting.ini` に濁点フォントの埋め込みを制御できる `enable_dakuten_font` が追加されました
33
+ - あらすじ及び章も変換処理を施すように変更しました
34
+ + `converter#before` 及び `after` メソッドの text_type に、 `story` `chapter` が渡されるようになりました
35
+ * Bug Fix
36
+ - Windowsにおいて、タイトル及び作者名にCP392外の文字が使われていた場合に変換がエラーになる問題を修正
37
+ - 章タイトルが※で終わる小説をEPUB変換時に警告が出ていたのを修正
38
+
24
39
  2014/02/20 : **1.4.1.1**
25
40
  * Bug Fix
26
41
  - `narou init` 時にエラーが出るようになっていたのを修正
@@ -50,21 +65,6 @@ Narou.rb ― 「小説家になろう」「小説を読もう!」ダウンロ
50
65
  - Mac上での動作改善コードの取り込み(https://github.com/yossoy/narou)
51
66
  + java の動作不良対応、Kindle 対応
52
67
 
53
- 2013/12/25 : **1.3.4**
54
- * Bug Fix
55
- - `narou init` 時に "" で囲まれたパスを認識できない不具合を修正
56
-
57
- 2013/10/30 : **1.3.3**
58
- * 追加機能もしくは仕様変更
59
- - 送信対応端末に SonyReader(PRS-T2) を追加
60
- + `narou setting device=reader` で切り替えることが出来ます
61
-
62
- 2013/10/29 : **1.3.2**
63
- * 追加機能もしくは仕様変更
64
- - `default_args.*` の設定が使われるのは、各コマンドの引数が省略された時だけに変更
65
- - 各端末のボリュームラベルを大文字小文字区別しないで認識するように変更(Windowsのみ)
66
- - ダイジェスト化の自動検知機能を搭載。更新するかしないか、凍結してしまうかを選択可能に
67
-
68
68
  ----
69
69
 
70
70
  「小説家になろう」は株式会社ヒナプロジェクトの登録商標です
@@ -230,10 +230,11 @@ module Command
230
230
  SETTING_VARIABLES = {
231
231
  local: {
232
232
  # 変数名 => [受け付ける型, 説明(, 不可視化フラグ)]
233
- "convert.no-epub" => [:boolean, "EPUB変換を無効にするかどうか"],
234
- "convert.no-mobi" => [:boolean, "MOBI変換を無効にするかどうか"],
235
- "convert.no-strip" => [:boolean, "MOBIのstripを無効にするかどうか\n" +
233
+ "convert.no-epub" => [:boolean, "EPUB変換を無効にする"],
234
+ "convert.no-mobi" => [:boolean, "MOBI変換を無効にする"],
235
+ "convert.no-strip" => [:boolean, "MOBIのstripを無効にする\n" +
236
236
  " " * 6 + "※注意:KDP用のMOBIはstripしないでください"],
237
+ "convert.no-zip" => [:boolean, "i文庫用のzipファイルを作らない"],
237
238
  "convert.no-open" => [:boolean, "変換終了時に保存フォルダを開かない"],
238
239
  "convert.copy_to" => [:directory, "変換したらこのフォルダにコピーする\n" +
239
240
  " " * 6 + "※注意:存在しないフォルダだとエラーになる"],
@@ -16,8 +16,10 @@ class ConverterBase
16
16
  def before(io, text_type)
17
17
  data = io.string
18
18
  convert_page_break(data) if @text_type == "body"
19
- data.gsub!("\n\n", "\n")
20
- data.gsub!("\n\n\n", "\n\n")
19
+ if @text_type != "story"
20
+ data.gsub!("\n\n", "\n")
21
+ data.gsub!("\n\n\n", "\n\n")
22
+ end
21
23
  io
22
24
  end
23
25
 
@@ -72,7 +74,8 @@ class ConverterBase
72
74
  def convert_numbers(data)
73
75
  # 小数点を・に
74
76
  data.gsub!(/([\d0-9#{KANJI_NUM}]+?)[\..]([\d0-9#{KANJI_NUM}]+?)/, "\\1・\\2")
75
- if @setting.enable_convert_num_to_kanji && @text_type != "subtitle"
77
+ if @setting.enable_convert_num_to_kanji &&
78
+ @text_type != "subtitle" && @text_type != "chapter" && @text_type != "story"
76
79
  num_to_kanji(data)
77
80
  else
78
81
  hankaku_num_to_zenkaku_num(data)
@@ -93,10 +93,16 @@ class Device
93
93
  dst_path = File.join(documents_path, File.basename(src_file))
94
94
  case Helper.determine_os
95
95
  when :windows
96
- cmd = "copy /B " + %!"#{src_file}" "#{dst_path}"!.gsub("/", "\\").encode(Encoding::Windows_31J)
97
- capture = `#{cmd}`
98
- if $?.exitstatus > 0
99
- raise capture.force_encoding(Encoding::Windows_31J).rstrip
96
+ begin
97
+ # Rubyでコピーするのは遅いのでOSのコマンドを叩く
98
+ cmd = "copy /B " + %!"#{src_file}" "#{dst_path}"!.gsub("/", "\\").encode(Encoding::Windows_31J)
99
+ capture = `#{cmd}`
100
+ if $?.exitstatus > 0
101
+ raise capture.force_encoding(Encoding::Windows_31J).rstrip
102
+ end
103
+ rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError => e
104
+ # Windows-31J に変換できない文字をファイル名に含むものはRubyでコピーする
105
+ FileUtils.cp(src_file, dst_path)
100
106
  end
101
107
  else
102
108
  FileUtils.cp(src_file, dst_path)
@@ -482,7 +482,7 @@ class Downloader
482
482
  end
483
483
  @setting.multi_match(toc_source, "title", "author", "story", "tcode")
484
484
  @title = @setting["title"]
485
- @file_title = Helper.replace_filename_special_chars(@title).strip
485
+ @file_title = Helper.replace_filename_special_chars(@title, invalid_replace: true).strip
486
486
  @setting["story"] = @setting["story"].gsub("<br />", "")
487
487
  toc_objects = {
488
488
  "title" => @title,
@@ -84,8 +84,14 @@ module Helper
84
84
  puts "―" * 35
85
85
  end
86
86
 
87
- def self.replace_filename_special_chars(str)
88
- str.tr("/:*?\"<>|.", "/:*?”〈〉|.").gsub("\\", "¥")
87
+ def self.replace_filename_special_chars(str, invalid_replace: false)
88
+ result = str.tr("/:*?\"<>|.", "/:*?”〈〉|.").gsub("\\", "¥")
89
+ if invalid_replace
90
+ org_encoding = result.encoding
91
+ result = result.encode(Encoding::Windows_31J, invalid: :replace, undef: :replace, replace: "_")
92
+ .encode(org_encoding)
93
+ end
94
+ result
89
95
  end
90
96
 
91
97
  #
@@ -9,6 +9,7 @@ require_relative "helper"
9
9
  BlankConverter = Class.new(ConverterBase) {}
10
10
 
11
11
  $converter_container = {}
12
+ $converter_load_once = {}
12
13
 
13
14
  def converter(title, &block)
14
15
  $converter_container[title] = Class.new(ConverterBase, &block)
@@ -30,6 +31,8 @@ end
30
31
  # また、返却する IO オブジェクトはファイル先頭に seek しておく必要はない。
31
32
  # text_type は渡されるテキストがタイトルなのか、前書きなのか等の種別を判断する文字列が渡される。
32
33
  # 渡される文字列と意味:
34
+ # story あらすじ
35
+ # chapter 章のタイトル
33
36
  # subtitle 節のタイトル
34
37
  # introduction 前書き
35
38
  # body 本文
@@ -61,7 +64,10 @@ def load_converter(title, archive_path)
61
64
  if File.exists?(converter_path)
62
65
  if Helper.os_windows?
63
66
  # TODO: RubyのバグでUTF-8なパスをrequireが見えてない。修正されたら消す
64
- require converter_path.encode(Encoding::Windows_31J)
67
+ unless $converter_load_once[archive_path]
68
+ eval(File.read(converter_path, encoding: Encoding::UTF_8))
69
+ $converter_load_once[archive_path] = true
70
+ end
65
71
  else
66
72
  require converter_path
67
73
  end
@@ -131,7 +131,7 @@ module Narou
131
131
 
132
132
  def self.create_novel_filename(novel_data, ext = "")
133
133
  author, title = %w(author title).map { |k|
134
- Helper.replace_filename_special_chars(novel_data[k])
134
+ Helper.replace_filename_special_chars(novel_data[k], invalid_replace: true)
135
135
  }
136
136
  "[#{author}] #{title}#{ext}"
137
137
  end
@@ -83,10 +83,12 @@ class NovelConverter
83
83
  #
84
84
  def self.txt_to_epub(filename, use_dakuten_font = false, dst_dir = nil, device = nil, verbose = false)
85
85
  abs_srcpath = File.expand_path(filename)
86
+ src_dir = File.dirname(abs_srcpath)
86
87
 
87
88
  cover_option = ""
88
89
  # MEMO: 外部実行からだと -c FILENAME, -c 1 オプションはぬるぽが出て動かない
89
- if get_cover_filename(File.dirname(abs_srcpath))
90
+ cover_filename = get_cover_filename(src_dir)
91
+ if cover_filename
90
92
  cover_option = "-c 0" # 先頭の挿絵を表紙として利用
91
93
  end
92
94
 
@@ -117,7 +119,7 @@ class NovelConverter
117
119
  aozoraepub3_basename = File.basename(aozoraepub3_path)
118
120
  aozoraepub3_dir = File.dirname(aozoraepub3_path)
119
121
 
120
- java_encoding = Helper.os_mac? ? "-Dfile.encoding=UTF-8" : ""
122
+ java_encoding = "-Dfile.encoding=UTF-8"
121
123
 
122
124
  Dir.chdir(aozoraepub3_dir)
123
125
  command = %!java #{java_encoding} -cp #{aozoraepub3_basename} AozoraEpub3 -enc UTF-8 -of #{device_option} ! +
@@ -131,15 +133,9 @@ class NovelConverter
131
133
  print "."
132
134
  end
133
135
  visible_aozora_fonts_directory unless use_dakuten_font
136
+ Dir.chdir(pwd)
134
137
 
135
138
  stdout_capture = res[0]
136
- if Helper.os_windows?
137
- stdout_capture = stdout_capture.force_encoding(Encoding::Shift_JIS).encode(Encoding::UTF_8)
138
- else
139
- stdout_capture.force_encoding(Encoding::UTF_8)
140
- end
141
-
142
- Dir.chdir(pwd)
143
139
 
144
140
  if verbose
145
141
  puts
@@ -180,10 +176,10 @@ class NovelConverter
180
176
  return :error
181
177
  end
182
178
 
179
+ command = %!"#{kindlegen_path}" -locale ja "#{epub_path}"!
183
180
  if Helper.os_windows?
184
- epub_path.encode!(Encoding::Windows_31J)
181
+ command.encode!(Encoding::Windows_31J)
185
182
  end
186
- command = %!"#{kindlegen_path}" -locale ja "#{epub_path}"!
187
183
  print "kindlegen実行中"
188
184
  res = Helper::AsyncCommand.exec(command) do
189
185
  print "."
@@ -289,10 +285,14 @@ class NovelConverter
289
285
  else
290
286
  @section_save_dir = Downloader.get_novel_section_save_dir(@setting.archive_path)
291
287
  @toc = Downloader.get_toc_data(@setting.archive_path)
288
+ @toc["story"] = conv.convert(@toc["story"], "story")
292
289
  progressbar = ProgressBar.new(@toc["subtitles"].count)
293
290
  @toc["subtitles"].each_with_index do |subinfo, i|
294
291
  progressbar.output(i)
295
292
  section = load_novel_section(subinfo)
293
+ if section["chapter"].length > 0
294
+ section["chapter"] = conv.convert(section["chapter"], "chapter")
295
+ end
296
296
  @inspector.subtitle = section["subtitle"]
297
297
  element = section["element"]
298
298
  element.each do |text_type, elm_text|
@@ -3,7 +3,7 @@
3
3
  # Copyright 2013 whiteleaf. All rights reserved.
4
4
  #
5
5
 
6
- Version = "1.4.2.rc2"
6
+ Version = "1.4.3"
7
7
 
8
8
  cv_path = File.expand_path(File.join(File.dirname(__FILE__), "../commitversion"))
9
9
  if File.exists?(cv_path)
@@ -46,20 +46,34 @@ narou コマンドのインストール or アップデートが完了しまし
46
46
  初めてこのアプリケーションを使う場合、小説管理用のフォルダを初期化する必要があります。
47
47
  任意のフォルダで `narou init' を実行して下さい。
48
48
 
49
- 更新内容
49
+ 2014/02/24 : **1.4.3**
50
+ * 追加機能もしくは仕様変更
51
+ - **i文庫** に対応しました。専用のzipアーカイブを生成出来るようになります(txtと表紙、挿絵をzipで固めたもの)
52
+ + `narou s device=ibunko` で切り替えることが出来ます
53
+ + Drobbox等と連携をするために、 `narou s convert.copy_to=フォルダのパス` を設定することで、
54
+ zipファイルがコピーされるようになります
55
+ + i文庫専用レイアウトテンプレート、ibunko_novel.txt.erb が追加されました
56
+ + `narou convert` コマンドに `--no-zip` オプションが追加されました
57
+ - `setting.ini` に濁点フォントの埋め込みを制御できる `enable_dakuten_font` が追加されました
58
+ - あらすじ及び章も変換処理を施すように変更しました
59
+ + `converter#before` 及び `after` メソッドの text_type に、 `story` `chapter` が渡されるようになりました
60
+ * Bug Fix
61
+ - Windowsにおいて、タイトル及び作者名にCP392外の文字が使われていた場合に変換がエラーになる問題を修正
62
+ - 章タイトルが※で終わる小説をEPUB変換時に警告が出ていたのを修正
63
+
50
64
  2014/02/20 : **1.4.0**
51
65
  * 重要な修正
52
66
  - 小説家になろうのレイアウト変更によって更新処理ができなくなっていたものを修正しました
53
67
 
54
68
  #{"*" * 79}
55
69
  EOS
56
- gem.post_install_message = install_message.gsub("\t", " ")
70
+ gem.post_install_message = install_message.gsub("\t", " ")
57
71
 
58
72
  gem.required_ruby_version = ">=1.9.3"
59
73
 
60
74
  gem.files = `git ls-files`.split("\n") << Narou.create_git_commit_version
61
75
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
62
76
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
63
- gem.add_dependency "termcolor", ">=1.2.2"
64
- gem.add_dependency "rubyzip", "~> 1.1.0"
77
+ gem.add_runtime_dependency 'termcolor', '~> 1.2', '>= 1.2.2'
78
+ gem.add_runtime_dependency 'rubyzip', '~> 1.1', '>= 1.1.0'
65
79
  end
metadata CHANGED
@@ -1,19 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: narou
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2.rc2
4
+ version: 1.4.3
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-22 00:00:00.000000000 Z
11
+ date: 2014-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: termcolor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
17
20
  - - '>='
18
21
  - !ruby/object:Gem::Version
19
22
  version: 1.2.2
@@ -21,6 +24,9 @@ dependencies:
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.2'
24
30
  - - '>='
25
31
  - !ruby/object:Gem::Version
26
32
  version: 1.2.2
@@ -29,6 +35,9 @@ dependencies:
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ~>
38
+ - !ruby/object:Gem::Version
39
+ version: '1.1'
40
+ - - '>='
32
41
  - !ruby/object:Gem::Version
33
42
  version: 1.1.0
34
43
  type: :runtime
@@ -36,6 +45,9 @@ dependencies:
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
47
  - - ~>
48
+ - !ruby/object:Gem::Version
49
+ version: '1.1'
50
+ - - '>='
39
51
  - !ruby/object:Gem::Version
40
52
  version: 1.1.0
41
53
  description: 小説家になろうで公開されている小説の管理、及び電子書籍データへの変換を支援します。縦書用に特化されており、横書き用に特化されたWEB小説を違和感なく縦書で読むことが出来るようになります。
@@ -149,10 +161,24 @@ post_install_message: |
149
161
  初めてこのアプリケーションを使う場合、小説管理用のフォルダを初期化する必要があります。
150
162
  任意のフォルダで `narou init' を実行して下さい。
151
163
 
152
- 更新内容
164
+ 2014/02/24 : **1.4.3**
165
+ * 追加機能もしくは仕様変更
166
+ - **i文庫** に対応しました。専用のzipアーカイブを生成出来るようになります(txtと表紙、挿絵をzipで固めたもの)
167
+ + `narou s device=ibunko` で切り替えることが出来ます
168
+ + Drobbox等と連携をするために、 `narou s convert.copy_to=フォルダのパス` を設定することで、
169
+ zipファイルがコピーされるようになります
170
+ + i文庫専用レイアウトテンプレート、ibunko_novel.txt.erb が追加されました
171
+ + `narou convert` コマンドに `--no-zip` オプションが追加されました
172
+ - `setting.ini` に濁点フォントの埋め込みを制御できる `enable_dakuten_font` が追加されました
173
+ - あらすじ及び章も変換処理を施すように変更しました
174
+ + `converter#before` 及び `after` メソッドの text_type に、 `story` `chapter` が渡されるようになりました
175
+ * Bug Fix
176
+ - Windowsにおいて、タイトル及び作者名にCP392外の文字が使われていた場合に変換がエラーになる問題を修正
177
+ - 章タイトルが※で終わる小説をEPUB変換時に警告が出ていたのを修正
178
+
153
179
  2014/02/20 : **1.4.0**
154
180
  * 重要な修正
155
- - 小説家になろうのレイアウト変更によって更新処理ができなくなっていたものを修正しました
181
+ - 小説家になろうのレイアウト変更によって更新処理ができなくなっていたものを修正しました
156
182
 
157
183
  *******************************************************************************
158
184
  rdoc_options: []
@@ -165,9 +191,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
165
191
  version: 1.9.3
166
192
  required_rubygems_version: !ruby/object:Gem::Requirement
167
193
  requirements:
168
- - - '>'
194
+ - - '>='
169
195
  - !ruby/object:Gem::Version
170
- version: 1.3.1
196
+ version: '0'
171
197
  requirements: []
172
198
  rubyforge_project:
173
199
  rubygems_version: 2.2.2