narou 2.9.5 → 3.0.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/.gitignore +7 -0
- data/.reek +34 -0
- data/.rspec +1 -0
- data/.rubocop.yml +9 -1
- data/ChangeLog.md +90 -0
- data/Gemfile +4 -0
- data/README.md +85 -8
- data/lib/command/convert.rb +1 -1
- data/lib/command/list.rb +59 -73
- data/lib/command/list/novel_decorator.rb +107 -0
- data/lib/command/send.rb +23 -13
- data/lib/command/setting.rb +5 -1
- data/lib/command/update.rb +104 -138
- data/lib/command/update/general_lastup_updater.rb +105 -0
- data/lib/command/update/interval.rb +29 -0
- data/lib/command/web.rb +1 -1
- data/lib/commandbase.rb +24 -17
- data/lib/converterbase.rb +10 -5
- data/lib/database.rb +16 -5
- data/lib/device.rb +5 -1
- data/lib/device/library/linux.rb +68 -8
- data/lib/downloader.rb +24 -23
- data/lib/extension.rb +16 -3
- data/lib/helper.rb +26 -3
- data/lib/html.rb +1 -1
- data/lib/inspector.rb +9 -0
- data/lib/inventory.rb +20 -6
- data/lib/logger.rb +8 -2
- data/lib/mailer.rb +2 -1
- data/lib/narou.rb +28 -18
- data/lib/narou/api.rb +62 -31
- data/lib/novelconverter.rb +8 -1
- data/lib/novelinfo.rb +8 -7
- data/lib/novelsetting.rb +1 -0
- data/lib/progressbar.rb +6 -2
- data/lib/sitesetting.rb +2 -1
- data/lib/version.rb +1 -1
- data/lib/web/appserver.rb +72 -9
- data/lib/web/public/resources/narou.library.js +130 -13
- data/lib/web/public/resources/narou.ui.js +96 -9
- data/lib/web/settingmessages.rb +2 -1
- data/lib/web/views/_about.haml +15 -2
- data/lib/web/views/index.haml +12 -3
- data/lib/web/views/layout.haml +2 -1
- data/lib/web/views/style.scss +12 -0
- data/narou.gemspec +88 -11
- data/narou.rb +7 -1
- data/preset/mail_setting.yaml +40 -6
- data/webnovel/kakuyomu.jp.yaml +8 -8
- metadata +95 -139
- data/spec/README.txt +0 -4
- data/spec/convert_spec.rb +0 -119
- data/spec/converterbase_spec.rb +0 -298
- data/spec/data/convert_test/auto_indent/correct_test_auto_indent.txt +0 -28
- data/spec/data/convert_test/auto_indent/test_auto_indent.txt +0 -32
- data/spec/data/convert_test/auto_join_bracket/correct_test_auto_join_bracket.txt +0 -24
- data/spec/data/convert_test/auto_join_bracket/test_auto_join_bracket.txt +0 -28
- data/spec/data/convert_test/auto_join_line/correct_test_auto_join_line.txt +0 -43
- data/spec/data/convert_test/auto_join_line/test_auto_join_line.txt +0 -59
- data/spec/data/convert_test/convert_page_break/correct_test_convert_page_break.txt +0 -22
- data/spec/data/convert_test/convert_page_break/setting.ini +0 -5
- data/spec/data/convert_test/convert_page_break/test_convert_page_break.txt +0 -60
- data/spec/data/convert_test/double_dash_to_image/correct_test_double_dash_to_image.txt +0 -14
- data/spec/data/convert_test/double_dash_to_image/setting.ini +0 -1
- data/spec/data/convert_test/double_dash_to_image/test_double_dash_to_image.txt +0 -12
- data/spec/data/convert_test/english/correct_test_english.txt +0 -27
- data/spec/data/convert_test/english/test_english.txt +0 -27
- data/spec/data/convert_test/force_indent_special_chapter/correct_test_force_indent_special_chapter.txt +0 -64
- data/spec/data/convert_test/force_indent_special_chapter/test_force_indent_special_chapter.txt +0 -61
- data/spec/data/convert_test/horizontal_ellipsis/correct_test_horizontal_ellipsis.txt +0 -53
- data/spec/data/convert_test/horizontal_ellipsis/test_horizontal_ellipsis.txt +0 -57
- data/spec/data/convert_test/insert_separator/correct_test_insert_separator.txt +0 -13
- data/spec/data/convert_test/insert_separator/setting.ini +0 -3
- data/spec/data/convert_test/insert_separator/test_insert_separator.txt +0 -12
- data/spec/data/convert_test/insert_separator_and_replace_txt/correct_test_insert_separator_and_replace_txt.txt +0 -12
- data/spec/data/convert_test/insert_separator_and_replace_txt/setting.ini +0 -3
- data/spec/data/convert_test/insert_separator_and_replace_txt/test_insert_separator_and_replace_txt.txt +0 -11
- data/spec/data/convert_test/kanji_num/correct_test_kanji_num.txt +0 -50
- data/spec/data/convert_test/kanji_num/test_kanji_num.txt +0 -56
- data/spec/data/convert_test/nonokagi/correct_test_nonokagi.txt +0 -30
- data/spec/data/convert_test/nonokagi/test_nonokagi.txt +0 -34
- data/spec/data/convert_test/replace/correct_test_replace.txt +0 -13
- data/spec/data/convert_test/replace/test_replace.txt +0 -14
- data/spec/data/convert_test/ruby/correct_test_ruby.txt +0 -161
- data/spec/data/convert_test/ruby/test_ruby.txt +0 -205
- data/spec/data/convert_test/ruby_youon/correct_test_ruby_youon.txt +0 -13
- data/spec/data/convert_test/ruby_youon/setting.ini +0 -2
- data/spec/data/convert_test/ruby_youon/test_ruby_youon.txt +0 -14
- data/spec/data/convert_test/sesame/correct_test_sesame.txt +0 -41
- data/spec/data/convert_test/sesame/test_sesame.txt +0 -52
- data/spec/data/convert_test/to_odd_leader/correct_test_to_odd_leader.txt +0 -21
- data/spec/data/convert_test/to_odd_leader/test_to_odd_leader.txt +0 -21
- data/spec/data/html_test.html +0 -5
- data/spec/data/html_test.txt +0 -4
- data/spec/data/test.ini +0 -10
- data/spec/device_spec.rb +0 -39
- data/spec/downloader_spec.rb +0 -37
- data/spec/eventable_spec.rb +0 -172
- data/spec/exit_code_spec.rb +0 -67
- data/spec/generator/convert_spec_gen.rb +0 -96
- data/spec/generator/num_to_kanji_test_gen.rb +0 -33
- data/spec/helper_spec.rb +0 -90
- data/spec/html_spec.rb +0 -83
- data/spec/ini_spec.rb +0 -145
- data/spec/input_spec.rb +0 -76
- data/spec/logger_spec.rb +0 -92
- data/spec/novelinfo_spec.rb +0 -15
- data/spec/novelsetting_spec.rb +0 -35
- data/spec/num_to_kanji_spec.rb +0 -2482
- data/spec/spec_helper.rb +0 -16
- data/spec/worker_spec.rb +0 -75
data/spec/exit_code_spec.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
# -*- Encoding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Copyright 2013 whiteleaf. All rights reserved.
|
4
|
-
#
|
5
|
-
|
6
|
-
require_relative "../lib/commandline"
|
7
|
-
require_relative "../lib/logger"
|
8
|
-
|
9
|
-
describe "exit code" do
|
10
|
-
before do
|
11
|
-
$stdout.silent = true
|
12
|
-
$stderr.silent = true
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "download command" do
|
16
|
-
describe "return mistook count" do
|
17
|
-
context "when novel is nothing" do
|
18
|
-
it { expect(CommandLine.run!(%w(download foo))).to eq 1 }
|
19
|
-
it { expect(CommandLine.run!(%w(download foo bar))).to eq 2 }
|
20
|
-
it { expect(CommandLine.run!(%w(download foo bar baz))).to eq 3 }
|
21
|
-
end
|
22
|
-
|
23
|
-
context "when novel is alrady existed" do
|
24
|
-
before do
|
25
|
-
# 事前に最低3つは凍結している小説を用意しておく
|
26
|
-
@ids = `narou l -f nonfrozen`.split
|
27
|
-
end
|
28
|
-
|
29
|
-
it "got 3" do
|
30
|
-
expect(CommandLine.run!(["download"] + @ids[0,3])).to eq 3
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "when novel is alrady frozen" do
|
35
|
-
before do
|
36
|
-
# 事前に最低2つは凍結している小説を用意しておく
|
37
|
-
@ids = `narou l -f frozen`.split
|
38
|
-
end
|
39
|
-
|
40
|
-
it "got 2" do
|
41
|
-
expect(CommandLine.run!(["download"] + @ids[0,2])).to eq 2
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "update command" do
|
48
|
-
describe "return mistook count" do
|
49
|
-
context "when novel is nothing" do
|
50
|
-
it { expect(CommandLine.run!(%w(update foo))).to eq 1 }
|
51
|
-
it { expect(CommandLine.run!(%w(update foo bar))).to eq 2 }
|
52
|
-
it { expect(CommandLine.run!(%w(update foo bar baz))).to eq 3 }
|
53
|
-
end
|
54
|
-
|
55
|
-
context "when novel is alrady frozen" do
|
56
|
-
before do
|
57
|
-
@ids = `narou l -f frozen`.split
|
58
|
-
end
|
59
|
-
|
60
|
-
it "got 2" do
|
61
|
-
expect(CommandLine.run!(["update"] + @ids[0,2])).to eq 2
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
@@ -1,96 +0,0 @@
|
|
1
|
-
# -*- Encoding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Copyright 2013 whiteleaf. All rights reserved.
|
4
|
-
#
|
5
|
-
|
6
|
-
# convert コマンドのテストを自動生成する
|
7
|
-
#
|
8
|
-
# spec/data/convert_test/ 以下に各種テストケースごとにフォルダ分けして、
|
9
|
-
# その中に test_HOGE.txt を用意すると認識する。
|
10
|
-
# そのテストケースごとにreplace.txtやsetting.iniも置ける。
|
11
|
-
# テキストのタイトルは(拡張子を除いた)ファイル名と同じでなければならない。
|
12
|
-
# 想定する出力例は correct_test_HOGE.txt に書く。
|
13
|
-
|
14
|
-
require "erb"
|
15
|
-
|
16
|
-
spec_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
17
|
-
recipe_dir = File.join(spec_dir, "data/convert_test")
|
18
|
-
pwd = Dir.pwd
|
19
|
-
Dir.chdir(recipe_dir)
|
20
|
-
# テストファイルのリストを作成
|
21
|
-
convert_test_text_list = Dir.glob(File.join("*", "test_*.txt")).keep_if { |path|
|
22
|
-
dir = File.dirname(path)
|
23
|
-
basename = File.basename(path)
|
24
|
-
unless File.exist?(File.join(dir, "correct_#{basename}"))
|
25
|
-
puts <<-EOS
|
26
|
-
[Warning]
|
27
|
-
テストケース(#{path})は見つかりましたが、出力例のテキストデータが見つかりません。
|
28
|
-
correct_#{basename} を用意して下さい。
|
29
|
-
|
30
|
-
EOS
|
31
|
-
end
|
32
|
-
true
|
33
|
-
}
|
34
|
-
Dir.chdir(pwd)
|
35
|
-
result = ERB.new(DATA.read, nil, "-").result(binding)
|
36
|
-
output_path = File.join(spec_dir, "convert_spec.rb")
|
37
|
-
File.write(output_path, result)
|
38
|
-
puts "#{output_path} を出力しました"
|
39
|
-
|
40
|
-
__END__
|
41
|
-
# -*- coding: utf-8 -*-
|
42
|
-
#
|
43
|
-
# Copyright 2013 whiteleaf. All rights reserved.
|
44
|
-
#
|
45
|
-
# auto generated at <%= Time.now %>
|
46
|
-
|
47
|
-
Encoding.default_external = Encoding::UTF_8
|
48
|
-
|
49
|
-
require_relative "../lib/commandline"
|
50
|
-
require_relative "../lib/logger"
|
51
|
-
|
52
|
-
AUTHOR = "whiteleaf"
|
53
|
-
$debug = File.exist?(File.expand_path(File.join(File.dirname(__FILE__), "../debug")))
|
54
|
-
|
55
|
-
describe "convert" do
|
56
|
-
before :all do
|
57
|
-
test_text_dir = File.join(File.dirname(__FILE__), "data/convert_test")
|
58
|
-
@pwd = Dir.pwd
|
59
|
-
Dir.chdir(test_text_dir)
|
60
|
-
|
61
|
-
Inventory.load("local_setting")["convert.filename-to-ncode"] = false
|
62
|
-
end
|
63
|
-
|
64
|
-
after :all do
|
65
|
-
# 変換した際に出力される各ファイルを削除
|
66
|
-
unless $debug
|
67
|
-
glob_path = "*/\\[#{AUTHOR}\\]*.txt\0*/{見出しリスト,調査ログ}.txt"
|
68
|
-
glob_path.encode!("Windows-31J") if RbConfig::CONFIG["host_os"] =~ /mswin(?!ce)|mingw|bccwin/i
|
69
|
-
Dir.glob(glob_path) do |path|
|
70
|
-
File.delete(path)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
Dir.chdir(@pwd)
|
74
|
-
end
|
75
|
-
|
76
|
-
def load_file(path)
|
77
|
-
# 行末の空白と改行の違いは無視する
|
78
|
-
File.read(path).gsub("\r", "").rstrip
|
79
|
-
end
|
80
|
-
|
81
|
-
def check_answer(path)
|
82
|
-
dir = File.dirname(path)
|
83
|
-
filename = File.basename(path)
|
84
|
-
$stdout.silence do
|
85
|
-
CommandLine.run(["convert", path, "--no-epub", "--no-open", "--ignore-force", "--ignore-default"])
|
86
|
-
end
|
87
|
-
output_file = File.join(dir, "[#{AUTHOR}] #{filename}")
|
88
|
-
correct_file = File.join(dir, "correct_#{filename}")
|
89
|
-
expect(load_file(output_file)).to eq load_file(correct_file)
|
90
|
-
end
|
91
|
-
<% convert_test_text_list.each do |path| %>
|
92
|
-
it "<%= path %>" do
|
93
|
-
check_answer("<%= path %>")
|
94
|
-
end
|
95
|
-
<% end -%>
|
96
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# -*- Encoding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Copyright 2013 whiteleaf. All rights reserved.
|
4
|
-
#
|
5
|
-
|
6
|
-
#require "pry"
|
7
|
-
|
8
|
-
require_relative "../../lib/converterbase"
|
9
|
-
|
10
|
-
converter = ConverterBase.new(nil, nil, nil)
|
11
|
-
|
12
|
-
11111.times do |i|
|
13
|
-
str = i.to_s
|
14
|
-
converter.num_to_kanji(str)
|
15
|
-
converter.convert_kanji_num_with_unit(str)
|
16
|
-
puts
|
17
|
-
puts " it \"#{str}\" do".encode("sjis")
|
18
|
-
puts " compare_kanji_and_integer(\"#{str}\", #{i})".encode("sjis")
|
19
|
-
puts " end"
|
20
|
-
end
|
21
|
-
|
22
|
-
__END__
|
23
|
-
|
24
|
-
サンプル
|
25
|
-
|
26
|
-
it "百十" do
|
27
|
-
compare_kanji_and_integer("百十", 110)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "二百十" do
|
31
|
-
compare_kanji_and_integer("二百十", 210)
|
32
|
-
end
|
33
|
-
end
|
data/spec/helper_spec.rb
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
# -*- Encoding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Copyright 2013 whiteleaf. All rights reserved.
|
4
|
-
#
|
5
|
-
|
6
|
-
require "tmpdir"
|
7
|
-
require "tempfile"
|
8
|
-
require_relative "../lib/helper"
|
9
|
-
|
10
|
-
describe Helper do
|
11
|
-
describe ".string_cast_to_type" do
|
12
|
-
context "boolean" do
|
13
|
-
it { expect(Helper.string_cast_to_type("true", :boolean)).to eq true }
|
14
|
-
it { expect(Helper.string_cast_to_type("TRUE", :boolean)).to eq true }
|
15
|
-
it { expect(Helper.string_cast_to_type("false", :boolean)).to eq false }
|
16
|
-
it { expect(Helper.string_cast_to_type("FALSE", :boolean)).to eq false }
|
17
|
-
it "should be error" do
|
18
|
-
expect { Helper.string_cast_to_type("1", :boolean) }.to raise_error
|
19
|
-
expect { Helper.string_cast_to_type("abc", :boolean) }.to raise_error
|
20
|
-
expect { Helper.string_cast_to_type("TrueClass", :boolean) }.to raise_error
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context "integer" do
|
25
|
-
it { expect(Helper.string_cast_to_type("100", :integer)).to eq 100 }
|
26
|
-
it { expect(Helper.string_cast_to_type("+100", :integer)).to eq 100 }
|
27
|
-
it { expect(Helper.string_cast_to_type("-100", :integer)).to eq -100 }
|
28
|
-
it { expect(Helper.string_cast_to_type("+10_00", :integer)).to eq +1000 }
|
29
|
-
it "should be error" do
|
30
|
-
expect { Helper.string_cast_to_type("10.0", :integer) }.to raise_error
|
31
|
-
expect { Helper.string_cast_to_type("abc", :integer) }.to raise_error
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context "float" do
|
36
|
-
it { expect(Helper.string_cast_to_type("100", :float)).to eq 100.0 }
|
37
|
-
it { expect(Helper.string_cast_to_type("100.1", :float)).to eq 100.1 }
|
38
|
-
it { expect(Helper.string_cast_to_type("-100.1", :float)).to eq -100.1 }
|
39
|
-
it { expect(Helper.string_cast_to_type("-10.2e3", :float)).to eq -10200.0 }
|
40
|
-
it "should be error" do
|
41
|
-
expect { Helper.string_cast_to_type("abc", :float) }.to raise_error
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context "directory" do
|
46
|
-
it do
|
47
|
-
Dir.mktmpdir do |tmpdir|
|
48
|
-
expect(Helper.string_cast_to_type(tmpdir, :directory)).to eq File.expand_path(tmpdir)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
it "should be error" do
|
52
|
-
expect { Helper.string_cast_to_type("/foobarbazz", :directory) }.to raise_error
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "file" do
|
57
|
-
it do
|
58
|
-
Tempfile.open("temp") do |fp|
|
59
|
-
fp.puts "test"
|
60
|
-
expect(Helper.string_cast_to_type(fp.path, :file)).to eq File.expand_path(fp.path)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
it "should be error" do
|
64
|
-
expect { Helper.string_cast_to_type("/foobarbazz.txt", :file) }.to raise_error
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context "string" do
|
69
|
-
it { expect(Helper.string_cast_to_type("string", :string)).to eq "string" }
|
70
|
-
end
|
71
|
-
|
72
|
-
context "select" do
|
73
|
-
it { expect(Helper.string_cast_to_type("string", :select)).to eq "string" }
|
74
|
-
end
|
75
|
-
|
76
|
-
context "multiple" do
|
77
|
-
it { expect(Helper.string_cast_to_type("string", :multiple)).to eq "string" }
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
describe ".date_string_to_time" do
|
82
|
-
it do
|
83
|
-
expect(Helper.date_string_to_time("2014年03月02日(日) 07:39")).to eq(Time.parse("2014/3/2 07:39"))
|
84
|
-
end
|
85
|
-
|
86
|
-
it do
|
87
|
-
expect(Helper.date_string_to_time("2012年 11月22日 17時00分")).to eq(Time.parse("2012/11/22 17:00"))
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
data/spec/html_spec.rb
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
# -*- Encoding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Copyright 2013 whiteleaf. All rights reserved.
|
4
|
-
#
|
5
|
-
|
6
|
-
require_relative "../lib/html"
|
7
|
-
|
8
|
-
html_test_html_path = File.expand_path(File.dirname(__FILE__) + "/data/html_test.html")
|
9
|
-
html_test_txt_path = File.expand_path(File.dirname(__FILE__) + "/data/html_test.txt")
|
10
|
-
|
11
|
-
describe HTML do
|
12
|
-
before do
|
13
|
-
@html = HTML.new("")
|
14
|
-
end
|
15
|
-
|
16
|
-
it "rubyタグ → 青空ルビ注記" do
|
17
|
-
rubies = [
|
18
|
-
["<ruby>漢字<rt>かんじ</ruby>", "|漢字《かんじ》"],
|
19
|
-
["<ruby><rb>八九三<rp>(<rt>やくざ<rp>)</ruby>", "|八九三《やくざ》"],
|
20
|
-
["<ruby><rb>堪能</rb><rp>(</rp><rt>たんのう</rt><rp>)</rp></ruby>", "|堪能《たんのう》"],
|
21
|
-
["<ruby>漢字</ruby>", "漢字"],
|
22
|
-
["この文章の中にルビはない", "この文章の中にルビはない"],
|
23
|
-
["美食を<ruby><rb>堪能</rb><rp>(</rp><rt>たんのう</rt><rp>)</rp></ruby>した", "美食を|堪能《たんのう》した"],
|
24
|
-
]
|
25
|
-
rubies.each do |ruby|
|
26
|
-
expect(@html.ruby_to_aozora(ruby[0])).to eq(ruby[1])
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it "<b> → 太字" do
|
31
|
-
expect(@html.b_to_aozora("次の文字は<b>太字</b>に")).to eq("次の文字は[#太字]太字[#太字終わり]に")
|
32
|
-
end
|
33
|
-
|
34
|
-
it "<i> → 斜体" do
|
35
|
-
expect(@html.i_to_aozora("次の文字は<i>斜体</i>に")).to eq("次の文字は[#斜体]斜体[#斜体終わり]に")
|
36
|
-
end
|
37
|
-
|
38
|
-
it "<s> → 取消線" do
|
39
|
-
expect(@html.s_to_aozora("次の文字は<s>取消線</s>に")).to eq("次の文字は[#取消線]取消線[#取消線終わり]に")
|
40
|
-
end
|
41
|
-
|
42
|
-
it "<br> → 改行" do
|
43
|
-
expect(@html.br_to_aozora("あいう<br>かきく<br />\nさしす<BR>")).to eq("あいう\nかきく\nさしす\n")
|
44
|
-
end
|
45
|
-
|
46
|
-
it "<img> → 挿絵注記" do
|
47
|
-
expect(@html.img_to_aozora('<img src="./images/100.jpg">')).to eq("[#挿絵(./images/100.jpg)入る]")
|
48
|
-
@html.set_illust_setting(current_url: "http://novel.example.com/10510/")
|
49
|
-
expect(@html.img_to_aozora('<img src="./images/100.jpg">')).to eq(
|
50
|
-
"[#挿絵(http://novel.example.com/10510/images/100.jpg)入る]"
|
51
|
-
)
|
52
|
-
@html.set_illust_setting(current_url: nil)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "HTML#to_aozora" do
|
56
|
-
test_html = File.read(html_test_html_path, encoding: "utf-8")
|
57
|
-
test_txt = File.read(html_test_txt_path, encoding: "utf-8")
|
58
|
-
html = HTML.new(test_html)
|
59
|
-
expect(html.to_aozora).to eq(test_txt)
|
60
|
-
end
|
61
|
-
|
62
|
-
describe "装飾タグの削除" do
|
63
|
-
before do
|
64
|
-
@strip_html = HTML.new
|
65
|
-
@strip_html.strip_decoration_tag = true
|
66
|
-
end
|
67
|
-
|
68
|
-
it do
|
69
|
-
@strip_html.string = "<b>太字</b>"
|
70
|
-
expect(@strip_html.to_aozora).to eq "太字"
|
71
|
-
end
|
72
|
-
|
73
|
-
it do
|
74
|
-
@strip_html.string = "<b>太字<i>斜体</i></b><s>打ち消し</s>"
|
75
|
-
expect(@strip_html.to_aozora).to eq "太字斜体打ち消し"
|
76
|
-
end
|
77
|
-
|
78
|
-
it do
|
79
|
-
@strip_html.string = "<b><ruby>漢字<rt>かんじ</ruby></b>"
|
80
|
-
expect(@strip_html.to_aozora).to eq "|漢字《かんじ》"
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
data/spec/ini_spec.rb
DELETED
@@ -1,145 +0,0 @@
|
|
1
|
-
# -*- Encoding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Copyright 2013 whiteleaf. All rights reserved.
|
4
|
-
#
|
5
|
-
|
6
|
-
require_relative "../lib/ini"
|
7
|
-
|
8
|
-
data_test_ini_path = File.expand_path(File.dirname(__FILE__) + "/data/test.ini")
|
9
|
-
|
10
|
-
describe Ini, "#cast" do
|
11
|
-
before do
|
12
|
-
@ini = Ini.new
|
13
|
-
end
|
14
|
-
|
15
|
-
it "class type should be Fixnum" do
|
16
|
-
expect(@ini.cast("100").class).to eq Fixnum
|
17
|
-
end
|
18
|
-
|
19
|
-
it "return 100" do
|
20
|
-
expect(@ini.cast("100")).to eq 100
|
21
|
-
end
|
22
|
-
|
23
|
-
it "return 100" do
|
24
|
-
expect(@ini.cast("+100")).to eq 100
|
25
|
-
end
|
26
|
-
|
27
|
-
it "return -100" do
|
28
|
-
expect(@ini.cast("-100")).to eq -100
|
29
|
-
end
|
30
|
-
|
31
|
-
it "class type).to be Float" do
|
32
|
-
expect(@ini.cast("10.5").class).to eq Float
|
33
|
-
end
|
34
|
-
|
35
|
-
it "return 10.5" do
|
36
|
-
expect(@ini.cast("10.5")).to eq 10.5
|
37
|
-
end
|
38
|
-
|
39
|
-
it "return +10.5" do
|
40
|
-
expect(@ini.cast("+10.5")).to eq 10.5
|
41
|
-
end
|
42
|
-
|
43
|
-
it "return -10.5" do
|
44
|
-
expect(@ini.cast("-10.5")).to eq -10.5
|
45
|
-
end
|
46
|
-
|
47
|
-
it "return true" do
|
48
|
-
expect(@ini.cast("true")).to eq true
|
49
|
-
end
|
50
|
-
|
51
|
-
it "return false" do
|
52
|
-
expect(@ini.cast("false")).to eq false
|
53
|
-
end
|
54
|
-
|
55
|
-
it "return `string'" do
|
56
|
-
expect(@ini.cast("string")).to eq "string"
|
57
|
-
end
|
58
|
-
|
59
|
-
it "return `string'" do
|
60
|
-
expect(@ini.cast("'string'")).to eq "string"
|
61
|
-
end
|
62
|
-
|
63
|
-
it "return `string'" do
|
64
|
-
expect(@ini.cast('"string"')).to eq "string"
|
65
|
-
end
|
66
|
-
|
67
|
-
it "return nil" do
|
68
|
-
expect(@ini.cast("nil")).to eq nil
|
69
|
-
end
|
70
|
-
|
71
|
-
it "return nil" do
|
72
|
-
expect(@ini.cast("null")).to eq nil
|
73
|
-
end
|
74
|
-
|
75
|
-
it "empty string cast to nil" do
|
76
|
-
expect(@ini.cast("null")).to eq nil
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe Ini, "を初期化した場合:" do
|
81
|
-
describe 'new("") した時' do
|
82
|
-
before do
|
83
|
-
@ini = Ini.new
|
84
|
-
end
|
85
|
-
|
86
|
-
it "は global セクションだけがあること" do
|
87
|
-
expect(@ini.object.count).to eq 1
|
88
|
-
expect(@ini.object.include?("global")).to be_truthy
|
89
|
-
end
|
90
|
-
|
91
|
-
it "の global セクションは空のハッシュだけであること" do
|
92
|
-
expect(@ini.object["global"].empty?).to be_truthy
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "test.ini" do
|
98
|
-
before do
|
99
|
-
@ini_data = Ini.load_file(data_test_ini_path)
|
100
|
-
end
|
101
|
-
|
102
|
-
it "は Hash であること" do
|
103
|
-
expect(@ini_data.class).to eq Hash
|
104
|
-
end
|
105
|
-
|
106
|
-
it "はセクションが2つであること" do
|
107
|
-
expect(@ini_data.count).to eq 2
|
108
|
-
end
|
109
|
-
|
110
|
-
it "はglobalセクションが必ずあること" do
|
111
|
-
expect(@ini_data.include?("global")).to be_truthy
|
112
|
-
end
|
113
|
-
|
114
|
-
it "はsub_sectionがあること" do
|
115
|
-
expect(@ini_data.include?("sub_section")).to be_truthy
|
116
|
-
end
|
117
|
-
|
118
|
-
it "は global_string が 文字列 という文字であること" do
|
119
|
-
expect(@ini_data["global"]["global_string"]).to eq "文字列"
|
120
|
-
end
|
121
|
-
|
122
|
-
it "は true_value が true であること" do
|
123
|
-
expect(@ini_data["sub_section"]["true_value"]).to eq true
|
124
|
-
end
|
125
|
-
|
126
|
-
it "は false_value が false であること" do
|
127
|
-
expect(@ini_data["sub_section"]["false_value"]).to eq false
|
128
|
-
end
|
129
|
-
|
130
|
-
it "は nil_value_1 が nil であること" do
|
131
|
-
expect(@ini_data["sub_section"]["nil_value_1"]).to eq nil
|
132
|
-
end
|
133
|
-
|
134
|
-
it "は nil_value_2 が nil であること" do
|
135
|
-
expect(@ini_data["sub_section"]["nil_value_2"]).to eq nil
|
136
|
-
end
|
137
|
-
|
138
|
-
it "は number が 100 であること" do
|
139
|
-
expect(@ini_data["sub_section"]["number"]).to eq 100
|
140
|
-
end
|
141
|
-
|
142
|
-
it 'は quote_string が 囲まれた文字列 であること' do
|
143
|
-
expect(@ini_data["sub_section"]["quote_string"]).to eq '囲まれた文字列'
|
144
|
-
end
|
145
|
-
end
|