kindai 2.6.0 → 2.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b895015c470172f22ceb220245b023e35b810d5d
4
- data.tar.gz: 874f045e55b6606d1d01609985ce25b9ead0c930
3
+ metadata.gz: 8cf9e500aa2a37a7d5f47beb679c48a7d453f34a
4
+ data.tar.gz: 3918213cea5033faddd958e39b3dbc6e438a5f0a
5
5
  SHA512:
6
- metadata.gz: 9932aad701113ffad984ff3f33d1c4c14699196ae2dda95aca18541026fd282587deef167b6e47261bbead14c5729abe86e448cf2b8724a22460b3b1360edfad
7
- data.tar.gz: 752f010a0c184ed229564149f9b7ee5a8144b6833684d681525d2704f0649cc771fbcc783334cedacca59997e61cb269fa90837e075144dc7b582758ac64c46c
6
+ metadata.gz: 17c2f6379ab404154c112fd9d134146641eb8b4b732ca54ad99156ad97df2842ae41706d8e0c26fd0ae710ebee84daed55a156f448b0331820b53400cf65466a
7
+ data.tar.gz: a88dd14f6ece1e8c8f2e581bc40dc885f7681d06be0c427f2a863eb148651666fc54e201bb12012e21f06c37b3e6c859b1081d6035ab630fbdb51a367820f1d6
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.6.0
1
+ 2.7.0
data/kindai.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: kindai 2.6.0 ruby lib
5
+ # stub: kindai 2.7.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "kindai"
9
- s.version = "2.6.0"
9
+ s.version = "2.7.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["hitode909"]
14
- s.date = "2015-10-19"
14
+ s.date = "2016-02-15"
15
15
  s.description = "kindai.rb is kindai digital library downloader."
16
16
  s.email = "hitode909@gmail.com"
17
17
  s.executables = ["kindai.rb"]
@@ -43,6 +43,7 @@ Gem::Specification.new do |s|
43
43
  "lib/kindai/util/database.rb",
44
44
  "publish.rb",
45
45
  "spec/book_downloader_spec.rb",
46
+ "spec/book_downloader_with_book_with_slash_spec.rb",
46
47
  "spec/book_spec.rb",
47
48
  "spec/searcher_spec.rb",
48
49
  "spec/spec_helper.rb",
data/lib/kindai/book.rb CHANGED
@@ -29,10 +29,35 @@ module Kindai
29
29
  end
30
30
 
31
31
  def title
32
- main = metadata_like 'title'
32
+ base = "#{metadata_like 'title'}#{volume_number}"
33
33
 
34
- sub = metadata_like('volumeTranscription').to_i.to_s rescue nil
35
- sub ? main + sub : main
34
+ if edition
35
+ base += "(#{edition})"
36
+ end
37
+
38
+ base
39
+ end
40
+
41
+ def volume_number
42
+ # 0036 とか
43
+ begin
44
+ return metadata_like('volumeTranscription').to_i
45
+ rescue
46
+ end
47
+
48
+ # 第36巻 とか
49
+ begin
50
+ return metadata_like('volume').scan(/\d+/).first.to_i
51
+ rescue
52
+ end
53
+
54
+ nil
55
+ end
56
+
57
+ def edition
58
+ return metadata_like('edition')
59
+ rescue
60
+ nil
36
61
  end
37
62
 
38
63
  def author
@@ -40,7 +65,7 @@ module Kindai
40
65
  rescue
41
66
  alt_author
42
67
  end
43
-
68
+
44
69
  def alt_author
45
70
  metadata_like 'creator'
46
71
  rescue
@@ -22,8 +22,12 @@ module Kindai
22
22
  return true
23
23
  end
24
24
 
25
+ def safe_filename filename
26
+ filename.gsub(File::SEPARATOR, '_')
27
+ end
28
+
25
29
  def book_path
26
- path = File.join(self.base_path, [@book.author, @book.title].compact.join(' - '))
30
+ path = File.join(self.base_path, safe_filename([@book.author, @book.title].compact.join(' - ')))
27
31
  File.expand_path path
28
32
  end
29
33
 
@@ -0,0 +1,24 @@
1
+ # -*- coding: utf-8 -*-
2
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
+
4
+ describe Kindai::BookDownloader, 'with book which contains slash in title' do
5
+ before do
6
+ @book = Kindai::Book.new_from_permalink('http://kindai.ndl.go.jp/info:ndljp/pid/1057420')
7
+ @downloader = Kindai::BookDownloader.new_from_book(@book)
8
+ end
9
+
10
+ describe 'safe_filename' do
11
+ it 'convert path separator to _' do
12
+ @downloader.safe_filename('a/b').should == 'a_b'
13
+ @downloader.safe_filename('a/b/c/d').should == 'a_b_c_d'
14
+ end
15
+ end
16
+
17
+ it 'has base path' do
18
+ @downloader.base_path = "/path/to/library"
19
+ @downloader.book_path.should == "/path/to/library/BMW航空発動機会社 [著]三菱商事株式会社機械部 訳編 - BMW132Dc_1型発動機部品表"
20
+ end
21
+ end
22
+
23
+
24
+
data/spec/book_spec.rb CHANGED
@@ -14,6 +14,10 @@ describe Kindai::Book do
14
14
  @book.title.should == '正義の叫'
15
15
  end
16
16
 
17
+ it "doesn't have volume number" do
18
+ @book.volume_number.should be_nil
19
+ end
20
+
17
21
  it 'has total spread' do
18
22
  @book.total_spread.should == 20
19
23
  end
@@ -33,7 +37,46 @@ describe Kindai::Book, 'with series' do
33
37
  @book = Kindai::Book.new_from_permalink('http://kindai.da.ndl.go.jp/info:ndljp/pid/890078')
34
38
  end
35
39
 
40
+ it 'has volume number' do
41
+ @book.volume_number.should == 3
42
+ end
43
+
36
44
  it 'has title' do
37
45
  @book.title.should == '講談日露戦争記3'
38
46
  end
39
47
  end
48
+
49
+ describe Kindai::Book, 'with volume' do
50
+ before do
51
+ @book = Kindai::Book.new_from_permalink('http://kindai.ndl.go.jp/info:ndljp/pid/941439')
52
+ end
53
+
54
+ it 'has volume number' do
55
+ @book.volume_number.should == 36
56
+ end
57
+
58
+ it 'has title' do
59
+ @book.title.should == '漢籍国字解全書 : 先哲遺著追補36'
60
+ end
61
+ end
62
+
63
+ describe Kindai::Book, 'with edition' do
64
+ before do
65
+ @book1 = Kindai::Book.new_from_permalink('http://kindai.ndl.go.jp/info:ndljp/pid/951217')
66
+ @book2 = Kindai::Book.new_from_permalink('http://kindai.ndl.go.jp/info:ndljp/pid/951218')
67
+ @book3 = Kindai::Book.new_from_permalink('http://kindai.ndl.go.jp/info:ndljp/pid/951219')
68
+ end
69
+
70
+ it 'has edition' do
71
+ @book1.edition.should == nil
72
+ @book2.edition.should == '補再版'
73
+ @book3.edition.should == '補3版'
74
+ end
75
+
76
+ it 'appends edition to title' do
77
+ @book1.title.should == '千山万岳'
78
+ @book2.title.should == '千山万岳(補再版)'
79
+ @book3.title.should == '千山万岳(補3版)'
80
+ end
81
+
82
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kindai
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - hitode909
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-19 00:00:00.000000000 Z
11
+ date: 2016-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -140,6 +140,7 @@ files:
140
140
  - lib/kindai/util/database.rb
141
141
  - publish.rb
142
142
  - spec/book_downloader_spec.rb
143
+ - spec/book_downloader_with_book_with_slash_spec.rb
143
144
  - spec/book_spec.rb
144
145
  - spec/searcher_spec.rb
145
146
  - spec/spec_helper.rb