ncode-syosetu 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5125304dda2035078544374652de492c43972cd5
4
- data.tar.gz: 5a9b7d21fa880d25d66e43319bf1be1a8918b840
3
+ metadata.gz: 3b4409dedee26d5a6c495b2850eaaa8a4f7f5487
4
+ data.tar.gz: 93028f52ca2e51e9a0d6c90c612402b1a51d56bb
5
5
  SHA512:
6
- metadata.gz: f237cdbdb2402eb882c5b0fb0762352c0bc040a78f3c614a6b65bb0b124d76b35aa13c5c0f8d7dd302f5889a83daa156df8d1e54a320a6d3e33f25d16f9fafc5
7
- data.tar.gz: 9c6d70005e58c61577619b9598fe6ee5ecb5fd0760034382cc1374d151bdb053b826b04f772987d2ca2ba1fc83d48d88196448d86eaa16edff88a34910063a0a
6
+ metadata.gz: 30586a35d4c450f54424da1f092639820371a260f74409a56831b412561b5a8de9e10ab0a73f96431b39122d24f9f0742538e5b7242de71f0cc25a4a942d206f
7
+ data.tar.gz: 920a2b5b017935de0732a81727e16458d89e7e681432a907573fac0631f44deab780d7a64f09beaaeb92ba9b35bc6fc03e59e7de6f0201531567971c4aa5e687
@@ -15,7 +15,7 @@ module NcodeSyosetu
15
15
  date Time.now.to_s
16
16
 
17
17
  resources(workdir: tmpdir) do
18
- toc_html = novel.toc.html.gsub(%r[<a href="/[^/]+/(\d+)/?">], '<a href="\1.html">')
18
+ toc_html = novel.toc.html.gsub(%r[<a href="/[^/]+/(\d+)/?">], '<a href="\1.html">').gsub(/<br>/, '<br />')
19
19
  File.write("toc.html", toc_html)
20
20
  nav "toc.html"
21
21
 
@@ -25,8 +25,9 @@ module NcodeSyosetu
25
25
  if episode.is_a?(NcodeSyosetu::Model::Heading)
26
26
  next_heading = episode.title
27
27
  else
28
+ episode_html = episode.html.gsub(/<br>/, '<br />')
28
29
  html_path = "#{episode.number}.html"
29
- File.write(html_path, episode.html)
30
+ File.write(html_path, episode_html)
30
31
  file html_path
31
32
  if next_heading
32
33
  heading next_heading
@@ -10,7 +10,8 @@ module NcodeSyosetu
10
10
  @abstract = page.search(".novel_ex").text.chomp
11
11
 
12
12
  @episodes = []
13
- page.search(".novel_sublist2 dd").each do |sub_item|
13
+ page.at(".index_box").children.each do |sub_item|
14
+ next unless sub_item.matches?('.chapter_title, .novel_sublist2')
14
15
  episode = { text: sub_item.text.gsub(/\s+/, " ").chomp }
15
16
  link = sub_item.search("a")
16
17
  unless link.empty?
@@ -24,7 +25,7 @@ module NcodeSyosetu
24
25
  @body_html =
25
26
  page.search(".novel_writername").to_html <<
26
27
  page.search(".novel_ex").to_html <<
27
- page.search(".novel_sublist").to_html
28
+ page.search(".index_box").to_html
28
29
  end
29
30
 
30
31
  def html
@@ -1,3 +1,3 @@
1
1
  module NcodeSyosetu
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
+ <title>たいとる</title>
7
+ </head>
8
+ <body>
9
+
10
+ <div class="novel_subtitle"><div class="chapter_title">第1章</div>第一話</div>
11
+ <div class="novel_view" id="novel_view">
12
+  本文<br />
13
+  <ruby><rb>漢字</rb><rt>かんじ</rt></ruby>
14
+ </div>
15
+
16
+ </body>
17
+ </html>
@@ -9,14 +9,17 @@
9
9
 
10
10
  <div class="novel_writername">作者:<a href="http://mypage.syosetu.com/00000/">さくしゃ</a></div>
11
11
  <div class="novel_ex">あらすじ</div>
12
- <div class="novel_sublist">
13
- <table>
14
- <tr><td class="chapter">第1章</td></tr>
15
- <tr>
16
- <td class="period_subtitle"><a href="/n00000/1/">第一話</a></td>
17
- <td class="long_update">2014年 1月 31日</td>
18
- </tr>
19
- </table>
12
+ <div class="index_box">
13
+ <div class="chapter_title">第1章</div>
14
+ <dl class="novel_sublist2">
15
+ <dd class="subtitle"><a href="/n00000/1/">第一話</a></dd>
16
+ <dt class="long_update">2014年 1月 31日</dt>
17
+ </dl>
18
+ <div class="chapter_title">第2章</div>
19
+ <dl class="novel_sublist2">
20
+ <dd class="subtitle"><a href="/n00000/2/">第二話</a></dd>
21
+ <dt class="long_update">2014年 2月 31日</dt>
22
+ </dl>
20
23
  </div>
21
24
 
22
25
  </body>
@@ -11,10 +11,13 @@ describe NcodeSyosetu::Client do
11
11
 
12
12
  it "scrapes ncode novel" do
13
13
  expect(subject.toc.title).to eq("たいとる")
14
- expect(subject.episodes.size).to eq(2)
14
+ expect(subject.episodes.size).to eq(4)
15
15
  expect(subject.episodes[0]).to be_a(NcodeSyosetu::Model::Heading)
16
16
  expect(subject.episodes[1]).to be_a(NcodeSyosetu::Model::Episode)
17
17
  expect(subject.episodes[1].number).to eq(1)
18
+ expect(subject.episodes[2]).to be_a(NcodeSyosetu::Model::Heading)
19
+ expect(subject.episodes[3]).to be_a(NcodeSyosetu::Model::Episode)
20
+ expect(subject.episodes[3].number).to eq(2)
18
21
  end
19
22
  end
20
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ncode-syosetu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - hogelog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-21 00:00:00.000000000 Z
11
+ date: 2014-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize
@@ -196,6 +196,7 @@ files:
196
196
  - lib/ncode_syosetu/version.rb
197
197
  - ncode_syosetu.gemspec
198
198
  - spec/data/n00000/1.html
199
+ - spec/data/n00000/2.html
199
200
  - spec/data/n00000/index.html
200
201
  - spec/ncode_syosetu/builder/epub3_spec.rb
201
202
  - spec/ncode_syosetu/builder/mobi_spec.rb
@@ -228,6 +229,7 @@ specification_version: 4
228
229
  summary: Ncode syosetu scraper
229
230
  test_files:
230
231
  - spec/data/n00000/1.html
232
+ - spec/data/n00000/2.html
231
233
  - spec/data/n00000/index.html
232
234
  - spec/ncode_syosetu/builder/epub3_spec.rb
233
235
  - spec/ncode_syosetu/builder/mobi_spec.rb