aozoragen 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aozoragen/syosetu.rb +9 -3
- data/lib/aozoragen/util.rb +2 -2
- data/lib/aozoragen/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: 728ce3bb7e29455d9964d2cc3445c116d82a6692
|
4
|
+
data.tar.gz: f746800df12be4f7ea5112ec22d8fd60ba3639df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28261bd866b7c4b13014ec9321c3cf32c219f4ee5739400239cdaa2ec5340659d95445f83120a2ac8c07e908d5a95c95b01d1134e68d75b4e050dba8ecd8d5bc
|
7
|
+
data.tar.gz: 8a125587bfa5d63b951c8b047b0823cc7c0104751c9c2e719b5a1ea7b2427cac72a039637b972d3441f90736884ffbd4d07fac99ddf33f3b92ca45cf7e11609e
|
data/lib/aozoragen/syosetu.rb
CHANGED
@@ -6,6 +6,12 @@ require 'aozoragen/util'
|
|
6
6
|
require 'open-uri'
|
7
7
|
require 'pathname'
|
8
8
|
|
9
|
+
class String
|
10
|
+
def fix_aozora_notation
|
11
|
+
self.gsub(/[||](.+?)『(.+?)』/){"|#$1《#$2》"}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
9
15
|
module Aozoragen
|
10
16
|
class Syosetu
|
11
17
|
include Util
|
@@ -26,13 +32,13 @@ module Aozoragen
|
|
26
32
|
(@index_html / '.subtitle a').each do |a|
|
27
33
|
uri = @index_uri + a.attr('href')
|
28
34
|
|
29
|
-
chapter = Nokogiri(open(uri, 'r:utf-8', &:read).tr('
|
35
|
+
chapter = Nokogiri(open(uri, 'r:utf-8', &:read).tr('《》.|', '『』・|'))
|
30
36
|
text = get_chapter_text(chapter)
|
31
37
|
chapter_id = '%03d' % Pathname(uri.path).basename.to_s.to_i
|
32
38
|
yield({id: chapter_id, uri: uri, text: text})
|
33
39
|
end
|
34
40
|
end
|
35
|
-
|
41
|
+
|
36
42
|
def get_chapter_text(chapter)
|
37
43
|
text = ''
|
38
44
|
text << (chapter / '.novel_subtitle')[0].text.subhead
|
@@ -40,7 +46,7 @@ module Aozoragen
|
|
40
46
|
text << detag(page).gsub(/\n{2,5}/, "\n").gsub(/^ *◆$/, '[#10字下げ]◆')
|
41
47
|
text << "[#改ページ]\n"
|
42
48
|
end
|
43
|
-
text.han2zen.for_tategaki
|
49
|
+
text.han2zen.for_tategaki.fix_aozora_notation
|
44
50
|
end
|
45
51
|
end
|
46
52
|
end
|
data/lib/aozoragen/util.rb
CHANGED
@@ -12,8 +12,8 @@ class String
|
|
12
12
|
# Half width of Alphabet and Digit to Full width.
|
13
13
|
#
|
14
14
|
def han2zen
|
15
|
-
self.tr( 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
|
16
|
-
'
|
15
|
+
self.tr( 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,/?',
|
16
|
+
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,/?' )
|
17
17
|
end
|
18
18
|
|
19
19
|
##
|
data/lib/aozoragen/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aozoragen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TADA Tadashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|