aozora2html 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: edf21d2f7a57981dd8804564940a39eb9bd3f892
4
- data.tar.gz: 677bcf4c4c1eb6db14f807e95ac2e46af9e3f75f
3
+ metadata.gz: ebbb4e466f94aeb389fe6a7764c1e13e7b28bce1
4
+ data.tar.gz: 0f67eec7dac026fe4c352638e75719468dcb3673
5
5
  SHA512:
6
- metadata.gz: 458e1fc1eaa839e90cb894a4d6f5d1bc23940b8b25737504b0838324957fd61f699488f988ea0e6cf7c85b78dce70b499a23270244b87b344ae7845b4c1e63ee
7
- data.tar.gz: 4b739ed45adb2061e27e5cb4719814d84b1797b79020e20a63e7da8055cd6f2e3a903a030374ef351d4e3f992eb4c385a7c84ad9678b3b7e9a7dbb50fe117073
6
+ metadata.gz: 4553e567889b845b5e34f1be83ec83c56b94558309efe337338e9cbf66d83417d3005554257a9b90bb15e80cb9ffb324f3b7c3f1c4b085bc4ad9c199bbd17ba4
7
+ data.tar.gz: 7c6478d6ca814b9c42b30333d8c0fb1dfcefc78f3a0af4a4a2aa0a72ec5bfc18d7b1316efa090aa35bfd75e3ef32561c22ac8dbaea373bfb7ece23dd85290e8d
@@ -0,0 +1,15 @@
1
+ <a name="0.2.0"></a>
2
+ ## 0.2.0
3
+
4
+ ### Features
5
+
6
+ * 入力ファイルとして www.aozora.gr.jp で配布しているzipファイルも直接読み込めるようにした
7
+ * `--gaiji-dir`オプションで外字ディレクトリを指定できるようにした
8
+ * `-v` (`--version`)オプションと`-h` (`--help`)オプションを追加した
9
+
10
+ <a name="0.1.0"></a>
11
+ ## 0.1.0 (2015-10-26)
12
+
13
+ ### Features
14
+
15
+ * 最初のリリース
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Aozora2Html
2
2
 
3
- [![Build Status](https://travis-ci.org/aozorahack/aozora2html.svg?branch=master)](https://travis-ci.org/aozorahack/aozora2html)
3
+ [![Build Status](https://travis-ci.org/aozorahack/aozora2html.svg?branch=master)](https://travis-ci.org/aozorahack/aozora2html) [![Gem Version](https://badge.fury.io/rb/aozora2html.svg)](https://badge.fury.io/rb/aozora2html)
4
4
 
5
5
  青空文庫の「組版案内」( http://kumihan.aozora.gr.jp/ )で配布されているtxt2html内にあるt2hs.rbを改造するプロジェクトです。
6
6
 
@@ -33,6 +33,13 @@ $ aozora2html foo.txt foo.html
33
33
 
34
34
  こうすると、青空文庫記法で書かれたfoo.txtをfoo.htmlに変換します。
35
35
 
36
+ また、青空文庫サイトで配布している、中にテキストファイルが同梱されているzip形式のファイルも変換できます。
37
+
38
+ ```
39
+ $ aozora2html foo.zip foo.html
40
+ ```
41
+
42
+
36
43
  ## テスト
37
44
 
38
45
  テストも追加しています。テストは以下のように実行します。
@@ -42,6 +49,10 @@ $ bundle install
42
49
  $ rake test
43
50
  ```
44
51
 
52
+ ## 更新履歴
53
+
54
+ 主な更新履歴は[CHANGELOG.md](CHANGELOG.md)にあります。
55
+
45
56
  ## License
46
57
 
47
58
  CC0
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
+ spec.add_dependency "rubyzip"
24
25
  spec.add_development_dependency "bundler"
25
26
  spec.add_development_dependency "rake", "~> 10.0"
26
27
  spec.add_development_dependency "test-unit"
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'aozora2html'
4
+ require 'optparse'
4
5
 
5
6
  # override Aozora2Html#push_chars
6
7
  #
@@ -26,12 +27,17 @@ class Aozora2Html
26
27
  end
27
28
  end
28
29
 
29
- def usage
30
- $stderr.print "usage: aozora2html <text file> <html file>\n"
30
+ opt = OptionParser.new("Usage: aozora2html [options] <text file> <html file>\n")
31
+ opt.on('--gaiji-dir DIR', 'setting gaiji directory')
32
+ opt.version = Aozora2Html::VERSION
33
+ options = opt.getopts
34
+
35
+ if options["gaiji-dir"]
36
+ $gaiji_dir = options["gaiji-dir"]
31
37
  end
32
38
 
33
39
  if ARGV.size != 2
34
- usage
40
+ $stderr.print opt.banner
35
41
  exit 1
36
42
  end
37
43
 
@@ -40,5 +46,14 @@ if !File.exists?(ARGV[0])
40
46
  exit 1
41
47
  end
42
48
 
43
- Aozora2Html.new(ARGV[0],ARGV[1]).process
49
+ if File.extname(ARGV[0]) == ".zip"
50
+ require "tempfile"
51
+ Dir.mktmpdir do |dir|
52
+ tmpfile = File.join(dir, "aozora.txt")
53
+ Aozora2Html::Zip.unzip(ARGV[0], tmpfile)
54
+ Aozora2Html.new(tmpfile, ARGV[1]).process
55
+ end
56
+ else
57
+ Aozora2Html.new(ARGV[0], ARGV[1]).process
58
+ end
44
59
 
@@ -1,4 +1,5 @@
1
1
  require "aozora2html/version"
2
+ require "aozora2html/zip"
2
3
  require 't2hs.rb'
3
4
 
4
5
  ## already defined in t2hs.rb
@@ -1,3 +1,3 @@
1
1
  class Aozora2Html
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,11 @@
1
+ require 'zip'
2
+ class Aozora2Html
3
+ class Zip
4
+ def self.unzip(zipfilename, textfilename)
5
+ ::Zip::File.open(zipfilename) do |zip_file|
6
+ entry = zip_file.glob('*.txt').first
7
+ entry.extract(textfilename)
8
+ end
9
+ end
10
+ end
11
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aozora2html
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.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-10-26 00:00:00.000000000 Z
11
+ date: 2015-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubyzip
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -105,6 +119,7 @@ extra_rdoc_files: []
105
119
  files:
106
120
  - ".gitignore"
107
121
  - ".travis.yml"
122
+ - CHANGELOG.md
108
123
  - Gemfile
109
124
  - Guardfile
110
125
  - README.md
@@ -113,6 +128,7 @@ files:
113
128
  - bin/aozora2html
114
129
  - lib/aozora2html.rb
115
130
  - lib/aozora2html/version.rb
131
+ - lib/aozora2html/zip.rb
116
132
  - lib/t2hs.rb
117
133
  - sample/chukiichiran_kinyurei.html
118
134
  - sample/chukiichiran_kinyurei.txt