aozoragen 0.0.3 → 0.0.4
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.
- data/aozoragen.gemspec +1 -1
- data/bin/aozora2pdf +1 -1
- data/lib/aozoragen/renzaburo.rb +1 -0
- data/lib/aozoragen/sai-zen-sen.rb +52 -9
- data/lib/aozoragen/version.rb +1 -1
- metadata +5 -5
data/aozoragen.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = Aozoragen::VERSION
|
8
8
|
s.authors = ["TADA Tadashi"]
|
9
9
|
s.email = ["t@tdtds.jp"]
|
10
|
-
s.homepage = ""
|
10
|
+
s.homepage = "https://github.com/tdtds/aozoragen"
|
11
11
|
s.summary = "Generating AOZORA format text of eBook novels via some Web sites."
|
12
12
|
s.description = "Scraping some Ebook web site and generating AOZORA format text files."
|
13
13
|
|
data/bin/aozora2pdf
CHANGED
data/lib/aozoragen/renzaburo.rb
CHANGED
@@ -8,21 +8,23 @@ require 'pathname'
|
|
8
8
|
|
9
9
|
class SaiZenSen
|
10
10
|
def initialize( index_uri )
|
11
|
-
|
12
|
-
|
11
|
+
if index_uri.path == '/sa/fate-zero/works/'
|
12
|
+
@entity = SaiZenSenFateZero::new( index_uri )
|
13
|
+
else
|
14
|
+
@entity = SaiZenSenRegular::new( index_uri )
|
15
|
+
end
|
13
16
|
end
|
14
17
|
|
15
18
|
def metainfo
|
16
|
-
|
17
|
-
info[:title] = (@index_html / '#page-content-heading h1')[0].text
|
18
|
-
(@index_html / '#authors h3').each do |author|
|
19
|
-
info[:author] = (info[:author] || [] ) << author.text.sub( /.*? /, '' )
|
20
|
-
end
|
21
|
-
info
|
19
|
+
@entity.metainfo
|
22
20
|
end
|
23
21
|
|
24
22
|
def each_chapter
|
25
|
-
|
23
|
+
@entity.each_chapter{|c| yield c}
|
24
|
+
end
|
25
|
+
|
26
|
+
def each_chapter_local( selector )
|
27
|
+
(@index_html / selector).each do |a|
|
26
28
|
uri = @index_uri + a.attr('href')
|
27
29
|
chapter = Nokogiri( open( uri, 'r:utf-8', &:read ) )
|
28
30
|
text = ''
|
@@ -69,3 +71,44 @@ class SaiZenSen
|
|
69
71
|
elem.to_html.gsub( /<.*?>/, '' ).strip
|
70
72
|
end
|
71
73
|
end
|
74
|
+
|
75
|
+
class SaiZenSenRegular < SaiZenSen
|
76
|
+
def initialize( index_uri )
|
77
|
+
@index_uri = index_uri
|
78
|
+
@index_html = Nokogiri( open( @index_uri, 'r:utf-8', &:read ) )
|
79
|
+
end
|
80
|
+
|
81
|
+
def metainfo
|
82
|
+
info = {:id => Pathname( @index_uri.path ).basename.to_s, :author => []}
|
83
|
+
info[:title] = (@index_html / '#page-content-heading h1')[0].text
|
84
|
+
(@index_html / '#authors h3').each do |author|
|
85
|
+
info[:author] << author.text.sub( /.*? /, '' )
|
86
|
+
end
|
87
|
+
info
|
88
|
+
end
|
89
|
+
|
90
|
+
def each_chapter
|
91
|
+
each_chapter_local( '#back-numbers li a' ){|c| yield c}
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
class SaiZenSenFateZero < SaiZenSen
|
96
|
+
def initialize( index_uri )
|
97
|
+
@index_uri = index_uri
|
98
|
+
@index_html = Nokogiri( open( @index_uri, 'r:utf-8', &:read ) )
|
99
|
+
end
|
100
|
+
|
101
|
+
def metainfo
|
102
|
+
info = {
|
103
|
+
:id => Pathname( @index_uri.path ).basename.to_s,
|
104
|
+
:author => ['虚淵玄']
|
105
|
+
}
|
106
|
+
info[:title] = (@index_html / 'h1 img')[0].attr( 'alt' )
|
107
|
+
info
|
108
|
+
end
|
109
|
+
|
110
|
+
def each_chapter
|
111
|
+
each_chapter_local( 'article a' ){|c| yield c}
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
data/lib/aozoragen/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aozoragen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
16
|
-
requirement: &
|
16
|
+
requirement: &85482890 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *85482890
|
25
25
|
description: Scraping some Ebook web site and generating AOZORA format text files.
|
26
26
|
email:
|
27
27
|
- t@tdtds.jp
|
@@ -42,7 +42,7 @@ files:
|
|
42
42
|
- lib/aozoragen/renzaburo.rb
|
43
43
|
- lib/aozoragen/sai-zen-sen.rb
|
44
44
|
- lib/aozoragen/version.rb
|
45
|
-
homepage:
|
45
|
+
homepage: https://github.com/tdtds/aozoragen
|
46
46
|
licenses: []
|
47
47
|
post_install_message:
|
48
48
|
rdoc_options: []
|