narou 1.5.11 → 1.6.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.

Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/ChangeLog.md +619 -432
  4. data/Gemfile +9 -0
  5. data/README.md +101 -76
  6. data/lib/color.rb +62 -22
  7. data/lib/command.rb +21 -19
  8. data/lib/command/alias.rb +9 -9
  9. data/lib/command/backup.rb +11 -4
  10. data/lib/command/browser.rb +8 -7
  11. data/lib/command/convert.rb +25 -77
  12. data/lib/command/diff.rb +67 -36
  13. data/lib/command/download.rb +5 -4
  14. data/lib/command/flag.rb +32 -6
  15. data/lib/command/folder.rb +7 -5
  16. data/lib/command/freeze.rb +21 -11
  17. data/lib/command/help.rb +29 -17
  18. data/lib/command/init.rb +7 -7
  19. data/lib/command/inspect.rb +6 -5
  20. data/lib/command/list.rb +106 -25
  21. data/lib/command/mail.rb +6 -7
  22. data/lib/command/remove.rb +9 -7
  23. data/lib/command/send.rb +6 -5
  24. data/lib/command/setting.rb +51 -16
  25. data/lib/command/tag.rb +179 -0
  26. data/lib/command/update.rb +9 -8
  27. data/lib/command/version.rb +4 -4
  28. data/lib/commandbase.rb +79 -8
  29. data/lib/commandline.rb +14 -8
  30. data/lib/converterbase.rb +78 -28
  31. data/lib/database.rb +3 -3
  32. data/lib/device.rb +26 -13
  33. data/lib/device/ibooks.rb +116 -0
  34. data/lib/device/ibunko.rb +45 -0
  35. data/lib/device/kindle.rb +4 -0
  36. data/lib/device/kobo.rb +4 -0
  37. data/lib/device/library/windows.rb +12 -4
  38. data/lib/device/reader.rb +9 -0
  39. data/lib/diffviewer.rb +147 -0
  40. data/lib/downloader.rb +195 -80
  41. data/lib/extensions/jruby.rb +33 -0
  42. data/lib/extensions/windows.rb +8 -9
  43. data/lib/helper.rb +79 -37
  44. data/lib/illustration.rb +1 -1
  45. data/lib/inspector.rb +2 -2
  46. data/lib/inventory.rb +48 -0
  47. data/lib/logger.rb +28 -4
  48. data/lib/narou.rb +9 -7
  49. data/lib/narou/api.rb +7 -2
  50. data/lib/novelconverter.rb +46 -19
  51. data/lib/novelinfo.rb +13 -3
  52. data/lib/novelsetting.rb +17 -9
  53. data/lib/version.rb +1 -1
  54. data/narou.gemspec +106 -27
  55. data/narou.rb +2 -2
  56. data/spec/convert_spec.rb +102 -0
  57. data/spec/data/convert_test/auto_indent/correct_test_auto_indent.txt +18 -0
  58. data/spec/data/convert_test/auto_indent/test_auto_indent.txt +21 -0
  59. data/spec/data/convert_test/auto_join_bracket/correct_test_auto_join_bracket.txt +12 -0
  60. data/spec/data/convert_test/auto_join_bracket/test_auto_join_bracket.txt +16 -0
  61. data/spec/data/convert_test/auto_join_line/correct_test_auto_join_line.txt +36 -0
  62. data/spec/data/convert_test/auto_join_line/test_auto_join_line.txt +51 -0
  63. data/spec/data/convert_test/convert_page_break/correct_test_convert_page_break.txt +21 -0
  64. data/spec/data/convert_test/convert_page_break/setting.ini +5 -0
  65. data/spec/data/convert_test/convert_page_break/test_convert_page_break.txt +60 -0
  66. data/spec/data/convert_test/force_indent_special_chapter/correct_test_force_indent_special_chapter.txt +64 -0
  67. data/spec/data/convert_test/force_indent_special_chapter/test_force_indent_special_chapter.txt +61 -0
  68. data/spec/data/convert_test/horizontal_ellipsis/correct_test_horizontal_ellipsis.txt +52 -0
  69. data/spec/data/convert_test/horizontal_ellipsis/test_horizontal_ellipsis.txt +57 -0
  70. data/spec/data/convert_test/kanji_num/correct_test_kanji_num.txt +49 -0
  71. data/spec/data/convert_test/kanji_num/test_kanji_num.txt +56 -0
  72. data/spec/data/convert_test/nonokagi/correct_test_nonokagi.txt +29 -0
  73. data/spec/data/convert_test/nonokagi/test_nonokagi.txt +34 -0
  74. data/spec/data/convert_test/replace/correct_test_replace.txt +12 -0
  75. data/spec/data/convert_test/replace/replace.txt +7 -0
  76. data/spec/data/convert_test/replace/test_replace.txt +14 -0
  77. data/spec/data/convert_test/ruby/correct_test_ruby.txt +131 -0
  78. data/spec/data/convert_test/ruby/test_ruby.txt +170 -0
  79. data/spec/data/convert_test/ruby_youon/correct_test_ruby_youon.txt +12 -0
  80. data/spec/data/convert_test/ruby_youon/setting.ini +2 -0
  81. data/spec/data/convert_test/ruby_youon/test_ruby_youon.txt +14 -0
  82. data/spec/data/convert_test/sesame/correct_test_sesame.txt +40 -0
  83. data/spec/data/convert_test/sesame/test_sesame.txt +52 -0
  84. data/spec/data/convert_test/to_odd_leader/correct_test_to_odd_leader.txt +20 -0
  85. data/spec/data/convert_test/to_odd_leader/test_to_odd_leader.txt +21 -0
  86. data/spec/device_spec.rb +3 -3
  87. data/spec/generator/convert_spec_gen.rb +95 -0
  88. data/spec/html_spec.rb +9 -8
  89. data/spec/ini_spec.rb +31 -31
  90. data/spec/novelinfo_spec.rb +2 -2
  91. data/spec/num_to_kanji_spec.rb +2 -2
  92. data/template/diff.txt.erb +5 -2
  93. data/template/ibunko_novel.txt.erb +2 -1
  94. data/template/novel.txt.erb +16 -3
  95. data/template/setting.ini.erb +1 -1
  96. data/webnovel/ncode.syosetu.com.yaml +7 -7
  97. data/webnovel/novel18.syosetu.com.yaml +7 -7
  98. data/webnovel/syosetu.org.yaml +8 -11
  99. metadata +193 -23
  100. data/lib/globalsetting.rb +0 -64
  101. data/lib/localsetting.rb +0 -63
data/lib/narou/api.rb CHANGED
@@ -34,12 +34,17 @@ module Narou
34
34
  gzip_opt = RUBY_VERSION >= "2.0.0" ? "gzip=#{gzip}&" : ""
35
35
  url = "#{@api_url}?#{gzip_opt}ncode=#{@ncode}&of=#{of}"
36
36
  open(url) do |fp|
37
- result = YAML.load(fp.read)
37
+ result = YAML.load(fp.read.force_encoding(Encoding::UTF_8))
38
38
  if result[0]["allcount"] == 1
39
39
  @api_result = result[1]
40
40
  if of.length > 0
41
41
  @api_result["novel_type"] = @api_result["noveltype"]
42
- @api_result["writer"] = @api_result["writer"].to_s # なろうAPIが返すデータが数値の場合があるため強制変換
42
+ # なろうAPIが返すデータが数値の場合があるため強制変換
43
+ @api_result["writer"] = @api_result["writer"].to_s
44
+ stat_end = @api_result["end"]
45
+ if stat_end
46
+ @api_result["end"] = stat_end == 0
47
+ end
43
48
  end
44
49
  else
45
50
  # なろうAPIからデータを取得出来なかった
@@ -13,7 +13,7 @@ require_relative "downloader"
13
13
  require_relative "template"
14
14
  require_relative "progressbar"
15
15
  require_relative "helper"
16
- require_relative "localsetting"
16
+ require_relative "inventory"
17
17
  require_relative "html"
18
18
 
19
19
  class NovelConverter
@@ -29,10 +29,14 @@ class NovelConverter
29
29
  #
30
30
  # 指定の小説を整形・変換する
31
31
  #
32
- def self.convert(target, output_filename = nil, display_inspector = false)
33
- setting = NovelSetting.load(target)
32
+ def self.convert(target, options = {})
33
+ options = {
34
+ # default paraeters
35
+ output_filename: nil, display_inspector: false, ignore_force: false,
36
+ }.merge(options)
37
+ setting = NovelSetting.load(target, options[:ignore_force])
34
38
  if setting
35
- novel_converter = new(setting, output_filename, display_inspector)
39
+ novel_converter = new(setting, options[:output_filename], options[:display_inspector])
36
40
  return {
37
41
  converted_txt_path: novel_converter.convert_main,
38
42
  use_dakuten_font: novel_converter.use_dakuten_font
@@ -44,19 +48,24 @@ class NovelConverter
44
48
  #
45
49
  # テキストファイルを整形・変換する
46
50
  #
47
- def self.convert_file(filename, encoding = nil, output_filename = nil, display_inspector = false)
51
+ def self.convert_file(filename, options = {})
52
+ options = {
53
+ # default parameters
54
+ encoding: nil, output_filename: nil, display_inspector: false, ignore_force: false,
55
+ }.merge(options)
56
+ output_filename = options[:output_filename]
48
57
  if output_filename
49
58
  archive_path = File.dirname(output_filename) + "/"
50
59
  else
51
60
  archive_path = File.dirname(filename) + "/"
52
61
  end
53
- setting = NovelSetting.new(archive_path)
62
+ setting = NovelSetting.new(archive_path, options[:ignore_force])
54
63
  setting.author = ""
55
64
  setting.title = File.basename(filename)
56
- novel_converter = new(setting, output_filename, display_inspector)
57
- text = open(filename, "r:BOM|UTF-8") { |fp| fp.read }
58
- if encoding
59
- text.force_encoding(encoding).encode!(Encoding::UTF_8)
65
+ novel_converter = new(setting, output_filename, options[:display_inspector])
66
+ text = open(filename, "r:BOM|UTF-8") { |fp| fp.read }.gsub("\r", "")
67
+ if options[:encoding]
68
+ text.force_encoding(options[:encoding]).encode!(Encoding::UTF_8)
60
69
  end
61
70
  {
62
71
  converted_txt_path: novel_converter.convert_main(text),
@@ -137,14 +146,27 @@ class NovelConverter
137
146
  end
138
147
  stash_aozora_fonts_directory unless use_dakuten_font
139
148
  print "AozoraEpub3でEPUBに変換しています"
140
- res = Helper::AsyncCommand.exec(command) do
141
- print "."
149
+ begin
150
+ res = Helper::AsyncCommand.exec(command) do
151
+ print "."
152
+ end
153
+ ensure
154
+ visible_aozora_fonts_directory unless use_dakuten_font
155
+ Dir.chdir(pwd)
142
156
  end
143
- visible_aozora_fonts_directory unless use_dakuten_font
144
- Dir.chdir(pwd)
145
157
 
146
158
  stdout_capture = res[0]
147
159
 
160
+ # Javaの実行環境に由来するであろうエラー
161
+ if stdout_capture =~ /Error occurred during initialization of VM/
162
+ puts
163
+ warn stdout_capture.strip
164
+ warn "-" * 70
165
+ error "Javaの実行エラーが発生しました。EPUBを作成出来ませんでした\n" \
166
+ "Hint: 複数のJava環境が混じっていると起きやすいエラーのようです"
167
+ return :error
168
+ end
169
+
148
170
  if verbose
149
171
  puts
150
172
  puts "==== AozoraEpub3 stdout capture " + "=" * 47
@@ -260,11 +282,14 @@ class NovelConverter
260
282
  end
261
283
  # タイトルに完結したかどうかを付加する
262
284
  flags = data["flags"] || {}
285
+ tags = data["tags"] || []
286
+ flags["end"] ||= tags.include?("end")
263
287
  if flags["end"]
264
288
  processed_title += " (完結)"
265
289
  end
266
290
  # タイトルがルビ化されてしまうのを抑制
267
- toc["title"] = toc["title"].gsub("《", "※[#始め二重山括弧]").gsub("》", "※[#終わり二重山括弧]")
291
+ processed_title = processed_title.gsub("《", "※[#始め二重山括弧]")
292
+ .gsub("》", "※[#終わり二重山括弧]")
268
293
  tempalte_name = (device && device.ibunko? ? NOVEL_TEXT_TEMPLATE_NAME_FOR_IBUNKO : NOVEL_TEXT_TEMPLATE_NAME)
269
294
  Template.get(tempalte_name, binding)
270
295
  end
@@ -323,8 +348,8 @@ class NovelConverter
323
348
  @toc["story"] = conv.convert(@toc["story"], "story")
324
349
  html = HTML.new
325
350
  site_setting = find_site_setting
326
- html.set_illust_setting(current_url: site_setting["illust_current_url"],
327
- grep_pattern: site_setting["illust_grep_pattern"])
351
+ html.set_illust_setting({current_url: site_setting["illust_current_url"],
352
+ grep_pattern: site_setting["illust_grep_pattern"]})
328
353
  progressbar = ProgressBar.new(@toc["subtitles"].count)
329
354
  @toc["subtitles"].each_with_index do |subinfo, i|
330
355
  progressbar.output(i)
@@ -438,7 +463,9 @@ class NovelConverter
438
463
  #
439
464
  def update_latest_convert_novel
440
465
  id = Downloader.get_id_by_target(@novel_title)
441
- LocalSetting.get["latest_convert"]["id"] = id
442
- LocalSetting.get.save_settings
466
+ Inventory.load("latest_convert", :local).tap { |inv|
467
+ inv["id"] = id
468
+ inv.save
469
+ }
443
470
  end
444
471
  end
data/lib/novelinfo.rb CHANGED
@@ -25,15 +25,25 @@ class NovelInfo
25
25
  info_url = @setting["novel_info_url"] or return nil
26
26
  result = @@novel_info_parameters[@setting["name"]][@ncode] ||= {}
27
27
  return result unless result.empty?
28
- of = "nt-s-gf-nu-gl-w"
28
+ of = "t-nt-ga-s-gf-nu-gl-w"
29
29
  request_output_parameters = of.split("-")
30
30
  info_source = ""
31
31
  open(info_url) do |fp|
32
32
  info_source = Helper.pretreatment_source(fp.read, @setting["encoding"])
33
33
  end
34
34
  @setting.multi_match(info_source, *request_output_parameters)
35
- result["novel_type"] = @setting["novel_type_string"][@setting["novel_type"]] || 1
36
- result["story"] = @setting["story"]
35
+ result["title"] = @setting["title"]
36
+ novel_status = @setting["novel_type_string"][@setting["novel_type"]] || 1
37
+ result["end"] = novel_status == 3
38
+ result["novel_type"] = case novel_status
39
+ when 1, 3 # 連載
40
+ 1
41
+ when 2 # 短編
42
+ ga = @setting["general_all_no"]
43
+ # ハーメルンで短編なのに連載形式のがあるため
44
+ ga && ga > "1" ? 1 : 2
45
+ end
46
+ result["story"] = HTML.new(@setting["story"]).to_aozora
37
47
  result["writer"] = @setting["writer"]
38
48
  %w(general_firstup novelupdated_at general_lastup).each do |elm|
39
49
  result[elm] = date_string_to_time(@setting[elm])
data/lib/novelsetting.rb CHANGED
@@ -12,10 +12,10 @@ class NovelSetting
12
12
 
13
13
  attr_accessor :id, :author, :title, :archive_path, :replace_pattern
14
14
 
15
- def self.load(target)
15
+ def self.load(target, ignore_force)
16
16
  archive_path = Downloader.get_novel_data_dir_by_target(target)
17
17
  if archive_path
18
- setting = new(archive_path)
18
+ setting = new(archive_path, ignore_force)
19
19
  data = Downloader.get_data_by_target(target)
20
20
  setting.id = data["id"]
21
21
  setting.author = data["author"]
@@ -26,8 +26,9 @@ class NovelSetting
26
26
  end
27
27
  end
28
28
 
29
- def initialize(archive_path)
29
+ def initialize(archive_path, ignore_force)
30
30
  @archive_path = File.expand_path(archive_path)
31
+ @ignore_force = ignore_force
31
32
  load_settings
32
33
  set_attribute
33
34
  load_replace_pattern
@@ -47,11 +48,13 @@ class NovelSetting
47
48
  ini = Ini.load_file(ini_path) rescue Ini.load("")
48
49
  force_settings = {}
49
50
  # 設定値を強制的に上書きするデータの読込
50
- LocalSetting.get["local_setting"].each { |name, value|
51
- if name =~ /^force\.(.+)$/
52
- force_settings[$1] = value
53
- end
54
- }
51
+ unless @ignore_force
52
+ Inventory.load("local_setting", :local).each { |name, value|
53
+ if name =~ /^force\.(.+)$/
54
+ force_settings[$1] = value
55
+ end
56
+ }
57
+ end
55
58
  DEFAULT_SETTINGS.each do |element|
56
59
  name, value = element[:name], element[:value]
57
60
  if force_settings.include?(name)
@@ -96,7 +99,7 @@ class NovelSetting
96
99
  if File.exists?(replace_txt_path)
97
100
  open(replace_txt_path, "r:BOM|UTF-8") do |fp|
98
101
  fp.each do |line|
99
- line.sub!(/\n\z/, "")
102
+ line.sub!(/[\r\n]+\z/, "")
100
103
  next if line[0] == ";" # コメント記号
101
104
  pattern = line.split("\t", 2)
102
105
  if pattern.length == 2 && pattern[0]
@@ -246,5 +249,10 @@ class NovelSetting
246
249
  value: false,
247
250
  help: "ルビの拗音(ぁ、ぃ等)を商業書籍のように大きくするかどうか"
248
251
  },
252
+ {
253
+ name: "enable_pack_blank_line",
254
+ value: true,
255
+ help: "縦書きで読みやすいように空行を減らすかどうか"
256
+ },
249
257
  ]
250
258
  end
data/lib/version.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # Copyright 2013 whiteleaf. All rights reserved.
4
4
  #
5
5
 
6
- Version = "1.5.11"
6
+ Version = "1.6.0"
7
7
 
8
8
  cv_path = File.expand_path(File.join(File.dirname(__FILE__), "../commitversion"))
9
9
  if File.exists?(cv_path)
data/narou.gemspec CHANGED
@@ -2,26 +2,20 @@
2
2
  # -*- coding: utf-8 -*-
3
3
  lib = File.expand_path("../lib", __FILE__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
-
6
5
  require "version"
7
-
8
6
  require "fileutils"
9
-
10
7
  module Narou
11
8
  def self.create_git_commit_version
12
9
  File.write("commitversion", `git describe --always`.strip)
13
10
  "commitversion"
14
11
  end
15
12
  end
16
-
17
13
  at_exit do
18
14
  if File.exists?("commitversion")
19
15
  FileUtils.rm("commitversion")
20
16
  end
21
17
  end
22
-
23
18
  Encoding.default_external = Encoding::UTF_8
24
-
25
19
  Gem::Specification.new do |gem|
26
20
  gem.name = "narou"
27
21
  gem.version = Version
@@ -35,10 +29,113 @@ Gem::Specification.new do |gem|
35
29
  変換を支援します。縦書用に特化されており、横書き用に特化されたWEB小説
36
30
  を違和感なく縦書で読むことが出来るようになります。
37
31
  }.split("\n").join
38
-
39
32
  install_message = <<-EOS
40
33
  #{"*" * 79}
41
34
 
35
+ 1.6.0 : 2014/08/28
36
+ ------------------
37
+ #### 追加機能
38
+ - **iBooks** での管理に対応しました
39
+ + Mac OS X Mavericks以上が対象です
40
+ + `narou s device=ibooks` で変更できます
41
+ + 初回登録時はiBooksでEPUBファイルを開くので、ウィンドウが大量に開くことに
42
+ ご注意ください。次回以降はiBooksの管理フォルダを直接更新してウィンドウが
43
+ 開くことはありません
44
+ - **JRuby** での実行に対応しました(Windowsでは環境変数JAVA_OPTSに
45
+ -Dfile.encoding=UTF8を設定して下さい)
46
+ - `diff` コマンドで外部ツールがなくても更新された部分の差分を表示できるように
47
+ なりました
48
+ + `difftool` が設定されていない場合、独自の差分表示処理を行います。
49
+ 小説用なので一文字単位の修正がわかりやすいように調整してあります
50
+
51
+ ![diff使用時のイメージ](https://raw.github.com/wiki/whiteleaf7/narou/images/diff_cap.png)
52
+ - `tag` コマンドが追加されました
53
+ + 小説に自由にタグを付けることができ、絞り込み等で使用出来ます
54
+ + タグを追加: `narou tag -a akatsuki 0`
55
+ + タグが付いた小説を表示: `narou tag akatsuki`
56
+ + コマンドの対象小説をタグで指定: `narou update akatsuki`
57
+ + その他詳細な説明は `narou tag -h` を参照して下さい
58
+ - `list` コマンドが拡張されます
59
+ + `--site` オプション(短縮: -s)が追加されました。掲載小説サイト名を合わせて
60
+ 表示します
61
+ + `--author` オプション(短縮:-a)が追加されました。作者名を合わせて表示します
62
+ + `--tag` オプション(短縮: -t)が追加されました。タグで小説を検索出来ます
63
+ * `narou l -t tagname` 、 `narou l -t "tag1 tag2"`
64
+ * `narou l -t` と引数を省略すると全ての小説をタグつきで表示
65
+ + `--grep` オプション(短縮: -g)が追加されました。リストの中から指定された
66
+ 文字列で検索します。最終的に表示される内容から検索するため、作者名やサイト
67
+ 名等そのままでは表示されない要素から検索したい場合、それぞれを表示するオプ
68
+ ションも合わせて指定して下さい
69
+ * 例1: リストから作者名に“紫炎”が含まれる小説を探したい場合
70
+ - `narou list --author --grep 紫炎` 或いは `narou l -ag 紫炎`
71
+ * 例2: 小説家になろう以外の小説を表示したい場合
72
+ - `narou list --site --grep "-小説家になろう"` 或いは
73
+ `narou l -sg "-小説家になろう"` (-をつけることでNOT検索)
74
+ * 例3: ハーメルンの小説からSAOを含む小説を探す
75
+ - `narou l -sg "ハーメルン SAO"` (スペース区切りによるAND検索)
76
+ + listコマンドの結果をパイプで他のコマンドに接続できるようになりました
77
+ * 例1: ハーメルに掲載されている小説にhamelnタグを付けたい
78
+ - `narou l -sg ハーメルン | narou t -a hameln`
79
+ * 例2: 短編を全て凍結したい
80
+ - `narou l -f ss | narou freeze --on`
81
+ * 注意点として、パイプでつないだ場合は remove コマンドは確認メッセージを
82
+ 出さずに削除します
83
+ - `convert` コマンドに `--ignore-force` オプションが追加されました。
84
+ `narou s force.設定名=値` として強制上書きされる設定を一時的に無効にします
85
+ - 空改行の削除処理を制御する `enable_pack_blank_line` オプションが追加されました
86
+ + デフォルトでは有効です。無効にするには各小説の setting.ini に
87
+ `enable_pack_blank_line=false` を追加するか、
88
+ `narou s force.enable_pack_blank_line=false` を実行して下さい
89
+ - `freeze` コマンドに強制凍結及び解除する `--on` 及び `--off` オプションが追加
90
+ されました
91
+
92
+ #### 仕様変更
93
+ - `update.strong` の挙動を、「当日分は必ずDLする」から「当日分は内容を見て更新
94
+ されているか確認する」に変更しました。またタイムスタンプを記録するようにし、
95
+ アップデート時のパフォーマンスを向上させました
96
+ - デバイス設定時に最低限必要な関連項目を設定変更するようになりました
97
+ - 空改行の間引き具合を若干弱くしました
98
+ - `list` コマンドの `--type` オプションを `--kind` (短縮:-k)に変更しました
99
+ - 差分オブジェクトの書式を `20YY.MM.DD@hh;mm;ss` から `20YY.MM.DD@hh.mm.ss` に
100
+ 変更します
101
+ + このバージョンから反映。以前のバージョンで作成された差分は旧書式のままです
102
+ - 新着のみの更新の場合差分データを作成しないように変更しました
103
+ - `backup` コマンドで作成するZIPファイルの内部ファイルパス文字エンコーディング
104
+ をOS毎に変更するようにしました
105
+ + Windows = Windows-31J、その他OS = UTF-8
106
+ - `flag` コマンドは非推奨になり、tagコマンドに統一されます。今後完結フラグを立
107
+ てる場合、 `narou tag -a end 0` として下さい。flagコマンドは1.7.0で廃止される
108
+ 予定です
109
+ + flagデータをtagデータに移行する場合は `narou flag --convert-tag` を実行
110
+ して下さい
111
+ - 完結の情報を自動で付与するようになりました。完結を検知したら end タグを追加
112
+ します
113
+ + 現在は小説家になろう関連サイトとハーメルンのみ自動検知します
114
+ - 選択肢を選ぶときエンターを押す必要がなくなりました
115
+ - このバージョンからセマンティックバージョニングに移行します
116
+ + Major.Minor.Teen という形式で、特別なアップデートでMajor、追加機能を含む
117
+ アップデートでMinor、バグ修正のみのアップデートでTeenの番号を増やします
118
+
119
+ #### Bug Fix
120
+ - 小説が掲載サイトから削除されていない時(500や503)にも自動凍結していたのを修正
121
+ - iBooksで閲覧時章タイトルページのレイアウトが崩れていたのを修正
122
+ - iBooksで閲覧時Arcadiaの掲載アドレスがあるページでエラーがでていたのを修正 #47
123
+ - ハーメルンで作者名が正常に取得できない場合があったのを修正 #48
124
+ - ハーメルンで連載形式の短編が1話目しか取得できていなかったのを修正 #49
125
+ - 自動字下げの判定処理が正常に動作していなかったのを修正
126
+ - `diff` コマンドの差分表示時に更新日が挿入されない場合があったのを修正
127
+ - `diff` コマンドで小説家になろう以外の小説の差分がHTMLタグ付きのまま表示されて
128
+ いたのを修正
129
+
130
+ - 未対応のURLを入力した場合にエラーが出るようになっていたのを修正
131
+ - 小説家になろうの短編のあらすじで改行が無視されていたのを修正
132
+ - 小説家になろうの短編のあらすじで先頭に縦棒(|)が入ってしまう問題に対応 #46
133
+ - 小説家になろうの挿絵を認識出来ない場合があったのを修正
134
+ - 前書き・後書き内にある挿絵を単ページ化出来なかったのを修正 #8
135
+ - 漢数字変換で対応桁数以上を変換しようとしてクラッシュしていたのを修正
136
+ - その他ヘルプ文の訂正や無駄な処理削減等多数の細かい調整
137
+
138
+
42
139
  narou コマンドのインストール or アップデートが完了しました。
43
140
  詳しい説明は `narou help' コマンドをご覧下さい。
44
141
 
@@ -46,28 +143,9 @@ narou コマンドのインストール or アップデートが完了しまし
46
143
  初めてこのアプリケーションを使う場合、小説管理用のフォルダを初期化する必要があります。
47
144
  任意のフォルダで `narou init' を実行して下さい。
48
145
 
49
- 2014/07/24 : **1.5.11**
50
- * 追加機能もしくは仕様変更
51
- - 改稿の更新漏れ対策として、 `update.strong` オプションが追加されました
52
- + `narou s update.strong=true` として設定して下さい
53
- + 改稿日の更新は必ずダウンロードされるようになります(当日はアップデートする度にDLします)。
54
- 何度も改稿された小説では、更新のタイミングによっては改稿内容を取りこぼす可能性があるため、
55
- このオプションを有効にすることで必ず拾えるようにします
56
- + ファイルのタイムスタンプをチェックするので、更新動作が多少遅くなります
57
- - 指定の話数ごとにウェイトを入れられる `download.wait-steps` オプションが追加されました
58
- + `narou s download.wait-steps=10` として設定して下さい
59
- + 小説家になろうの場合は11話以上を指定しても10話ごとにウェイトが入ります
60
- - `backup` コマンドを追加しました
61
- + 使用例: `narou backup 0` 、 `narou ba 0`
62
- + 小説保存フォルダ直下の backup フォルダに、バックアップ以外の全てのファイルをZIPで固めて保存します
63
- - ダイジェスト化検出時の処理項目に「バックアップの作成」と「保存フォルダを開く」を追加しました
64
- * Bug Fix
65
- - まのわ(n3730bn)のプリセット変換スクリプトの挙動を調整
66
- - 暁で一部あらすじが正常に取れていない小説があったので修正
67
-
68
146
  #{"*" * 79}
69
147
  EOS
70
- gem.post_install_message = install_message.gsub("\t", " ")
148
+ gem.post_install_message = install_message.gsub("\t", " ")
71
149
 
72
150
  gem.required_ruby_version = ">=1.9.3"
73
151
 
@@ -77,4 +155,5 @@ narou コマンドのインストール or アップデートが完了しまし
77
155
  gem.add_runtime_dependency 'termcolor', '~> 1.2', '>= 1.2.2'
78
156
  gem.add_runtime_dependency 'rubyzip', '~> 1.1', '>= 1.1.0'
79
157
  gem.add_runtime_dependency 'pony', '~> 1.8'
158
+ gem.add_runtime_dependency 'diff-lcs', '~> 1.2', '>= 1.2.5'
80
159
  end
data/narou.rb CHANGED
@@ -16,11 +16,11 @@ if ARGV.delete("--time")
16
16
  end
17
17
  end
18
18
 
19
- require_relative "lib/globalsetting"
19
+ require_relative "lib/inventory"
20
20
  display_backtrace = ARGV.delete("--backtrace")
21
21
  display_backtrace ||= $debug
22
22
  $disable_color = ARGV.delete("--no-color")
23
- $disable_color ||= GlobalSetting.get["global_setting"]["no-color"]
23
+ $disable_color ||= Inventory.load("global_setting", :global)["no-color"]
24
24
 
25
25
  require_relative "lib/logger"
26
26
  require_relative "lib/version"
@@ -0,0 +1,102 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright 2013 whiteleaf. All rights reserved.
4
+ #
5
+ # auto generated at 2014-08-28 00:35:38 +0900
6
+
7
+ Encoding.default_external = Encoding::UTF_8
8
+
9
+ require "termcolor"
10
+ require_relative "../lib/commandline"
11
+ require_relative "../lib/logger"
12
+
13
+ AUTHOR = "whiteleaf"
14
+ $debug = File.exists?(File.expand_path(File.join(File.dirname(__FILE__), "../debug")))
15
+
16
+ describe "convert" do
17
+ before :all do
18
+ test_text_dir = File.join(File.dirname(__FILE__), "data/convert_test")
19
+ @pwd = Dir.pwd
20
+ Dir.chdir(test_text_dir)
21
+ end
22
+
23
+ after :all do
24
+ # 変換した際に出力される各ファイルを削除
25
+ unless $debug
26
+ glob_path = "*/\\[#{AUTHOR}\\]*.txt\0*/{見出しリスト,調査ログ}.txt"
27
+ glob_path.encode!("Windows-31J") if RbConfig::CONFIG["host_os"] =~ /mswin(?!ce)|mingw|bccwin/i
28
+ Dir.glob(glob_path) do |path|
29
+ File.delete(path)
30
+ end
31
+ end
32
+ Dir.chdir(@pwd)
33
+ end
34
+
35
+ def load_file(path)
36
+ # 行末の空白と改行の違いは無視する
37
+ File.read(path).gsub("\r", "").rstrip
38
+ end
39
+
40
+ def check_answer(path)
41
+ dir = File.dirname(path)
42
+ filename = File.basename(path)
43
+ $stdout.silence do
44
+ CommandLine.run(["convert", path, "--no-epub", "--no-open", "--ignore-force"])
45
+ end
46
+ output_file = File.join(dir, "[#{AUTHOR}] #{filename}")
47
+ correct_file = File.join(dir, "correct_#{filename}")
48
+ expect(load_file(output_file)).to eq load_file(correct_file)
49
+ end
50
+
51
+ it "auto_indent/test_auto_indent.txt" do
52
+ check_answer("auto_indent/test_auto_indent.txt")
53
+ end
54
+
55
+ it "auto_join_bracket/test_auto_join_bracket.txt" do
56
+ check_answer("auto_join_bracket/test_auto_join_bracket.txt")
57
+ end
58
+
59
+ it "auto_join_line/test_auto_join_line.txt" do
60
+ check_answer("auto_join_line/test_auto_join_line.txt")
61
+ end
62
+
63
+ it "convert_page_break/test_convert_page_break.txt" do
64
+ check_answer("convert_page_break/test_convert_page_break.txt")
65
+ end
66
+
67
+ it "force_indent_special_chapter/test_force_indent_special_chapter.txt" do
68
+ check_answer("force_indent_special_chapter/test_force_indent_special_chapter.txt")
69
+ end
70
+
71
+ it "horizontal_ellipsis/test_horizontal_ellipsis.txt" do
72
+ check_answer("horizontal_ellipsis/test_horizontal_ellipsis.txt")
73
+ end
74
+
75
+ it "kanji_num/test_kanji_num.txt" do
76
+ check_answer("kanji_num/test_kanji_num.txt")
77
+ end
78
+
79
+ it "nonokagi/test_nonokagi.txt" do
80
+ check_answer("nonokagi/test_nonokagi.txt")
81
+ end
82
+
83
+ it "replace/test_replace.txt" do
84
+ check_answer("replace/test_replace.txt")
85
+ end
86
+
87
+ it "ruby/test_ruby.txt" do
88
+ check_answer("ruby/test_ruby.txt")
89
+ end
90
+
91
+ it "ruby_youon/test_ruby_youon.txt" do
92
+ check_answer("ruby_youon/test_ruby_youon.txt")
93
+ end
94
+
95
+ it "sesame/test_sesame.txt" do
96
+ check_answer("sesame/test_sesame.txt")
97
+ end
98
+
99
+ it "to_odd_leader/test_to_odd_leader.txt" do
100
+ check_answer("to_odd_leader/test_to_odd_leader.txt")
101
+ end
102
+ end