aozora2html 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +12 -0
- data/bin/aozora2html +37 -13
- data/lib/aozora2html/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d5866db44c93055109ebd1523d14adbc54430b4
|
4
|
+
data.tar.gz: 024cf855007a18c9b4592fa1576cc50394b52f3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d022e52edd4ad4d8d329e6b9aa3421505e60942bdc80b558bf2691a1e871b7053b10fae60b1b6493d5d6670ff4554822f2996056e86de695e4cb0430a01b4d60
|
7
|
+
data.tar.gz: 67f47a64d1df309ffcef401e9faef8b466a56fbb00a26d8b17afcac0bdc78d95264167af01b6d249f58f3661279262fe3ab849bc4b8e47c88277d29762c8204e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -39,6 +39,18 @@ $ aozora2html foo.txt foo.html
|
|
39
39
|
$ aozora2html foo.zip foo.html
|
40
40
|
```
|
41
41
|
|
42
|
+
第1引数にURLを指定すると、そのURLのファイルをダウンロードして変換します。
|
43
|
+
|
44
|
+
```
|
45
|
+
$ aozora2html http://example.jp/foo/bar.zip foo.html
|
46
|
+
```
|
47
|
+
|
48
|
+
第2引数を省略すると、ファイルではなく標準出力に変換結果を出力します。
|
49
|
+
|
50
|
+
```
|
51
|
+
$ aozora2html foo.txt
|
52
|
+
```
|
53
|
+
|
42
54
|
コマンドラインオプションとして`--gaiji-dir`と`--use-jisx0213`があります。
|
43
55
|
`--gaiji-dir`は外字画像のパスを指定します。
|
44
56
|
`--use-jisx0213`はJIS X 0213の外字画像を使わず、数値実体参照として表示します。
|
data/bin/aozora2html
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'aozora2html'
|
4
4
|
require 'optparse'
|
5
|
+
require "tempfile"
|
5
6
|
|
6
7
|
# override Aozora2Html#push_chars
|
7
8
|
#
|
@@ -27,7 +28,7 @@ class Aozora2Html
|
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
30
|
-
opt = OptionParser.new("Usage: aozora2html [options] <text file> <html file
|
31
|
+
opt = OptionParser.new("Usage: aozora2html [options] <text file> [<html file>]\n")
|
31
32
|
opt.on('--gaiji-dir DIR', 'setting gaiji directory')
|
32
33
|
opt.on('--use-jisx0213', 'setting gaiji directory')
|
33
34
|
opt.version = Aozora2Html::VERSION
|
@@ -41,24 +42,47 @@ if options["use-jisx0213"]
|
|
41
42
|
Embed_Gaiji_tag.use_jisx0213 = true
|
42
43
|
end
|
43
44
|
|
44
|
-
if ARGV.size
|
45
|
+
if ARGV.size < 1 || ARGV.size > 2
|
45
46
|
$stderr.print opt.banner
|
46
47
|
exit 1
|
47
48
|
end
|
48
49
|
|
49
|
-
|
50
|
-
$stderr.print "file not found: #{ARGV[0]}\n"
|
51
|
-
exit 1
|
52
|
-
end
|
50
|
+
src_file, dest_file = ARGV[0], ARGV[1]
|
53
51
|
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
Dir.mktmpdir do |dir|
|
53
|
+
if dest_file.nil?
|
54
|
+
dest_file = File.join(dir, "output.html")
|
55
|
+
end
|
56
|
+
if src_file =~ /\Ahttps?:/
|
57
|
+
require 'open-uri'
|
58
|
+
down_file = File.join(dir, File.basename(src_file))
|
59
|
+
begin
|
60
|
+
open(down_file, "wb") do |f0|
|
61
|
+
open(src_file){|f1| f0.write(f1.read)}
|
62
|
+
end
|
63
|
+
src_file = down_file
|
64
|
+
rescue
|
65
|
+
$stderr.print "file not found: #{src_file}\n"
|
66
|
+
$stderr.print "Download Error: #{$!}\n"
|
67
|
+
exit 1
|
68
|
+
end
|
69
|
+
else
|
70
|
+
if !File.exists?(src_file)
|
71
|
+
$stderr.print "file not found: #{src_file}\n"
|
72
|
+
exit 1
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
if File.extname(src_file) == ".zip"
|
57
77
|
tmpfile = File.join(dir, "aozora.txt")
|
58
|
-
Aozora2Html::Zip.unzip(
|
59
|
-
Aozora2Html.new(tmpfile,
|
78
|
+
Aozora2Html::Zip.unzip(src_file, tmpfile)
|
79
|
+
Aozora2Html.new(tmpfile, dest_file).process
|
80
|
+
else
|
81
|
+
Aozora2Html.new(src_file, dest_file).process
|
82
|
+
end
|
83
|
+
if !ARGV[1]
|
84
|
+
output = File.read(dest_file)
|
85
|
+
print output
|
60
86
|
end
|
61
|
-
else
|
62
|
-
Aozora2Html.new(ARGV[0], ARGV[1]).process
|
63
87
|
end
|
64
88
|
|
data/lib/aozora2html/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aozora2html
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aozorahack team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|