kindai 2.7.0 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -5
- data/Gemfile +2 -3
- data/Gemfile.lock +23 -21
- data/README.md +7 -4
- data/VERSION +1 -1
- data/kindai.gemspec +10 -10
- data/lib/kindai/book.rb +1 -1
- data/lib/kindai/searcher.rb +3 -3
- data/lib/kindai/spread.rb +1 -1
- data/lib/kindai/util.rb +7 -0
- data/spec/book_spec.rb +21 -0
- data/spec/spread_spec.rb +3 -3
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a54936e0a98b3c7fb26c231f0edd5c54cb96902c
|
4
|
+
data.tar.gz: 7b58e03c66062af64918e186f2568d2d801930c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba93eedc3b58aae9a7e353d8eb7ca722aa8c486628b86815234af493f9fa18357c034c833398cef62fe64c1492dc7a9f12630a9fc2d12ac5d46e8c6c12d91e2a
|
7
|
+
data.tar.gz: 7b170249b7f5c2fb369e897ead0c085a9fa8529e19c6792a9b725efb898ad636e7a09a2efd29f35f7e785bbe58d7ca9e2278334a87c405788f662bb432b9822c
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
addressable (2.
|
4
|
+
addressable (2.5.0)
|
5
|
+
public_suffix (~> 2.0, >= 2.0.2)
|
5
6
|
builder (3.2.2)
|
6
7
|
descendants_tracker (0.0.4)
|
7
8
|
thread_safe (~> 0.3, >= 0.3.1)
|
8
9
|
diff-lcs (1.2.5)
|
9
|
-
faraday (0.9.
|
10
|
+
faraday (0.9.2)
|
10
11
|
multipart-post (>= 1.2, < 3)
|
11
|
-
git (1.
|
12
|
+
git (1.3.0)
|
12
13
|
github_api (0.11.3)
|
13
14
|
addressable (~> 2.3)
|
14
15
|
descendants_tracker (~> 0.0.1)
|
@@ -17,36 +18,36 @@ GEM
|
|
17
18
|
multi_json (>= 1.7.5, < 2.0)
|
18
19
|
nokogiri (~> 1.6.0)
|
19
20
|
oauth2
|
20
|
-
hashie (
|
21
|
-
highline (1.
|
22
|
-
jeweler (2.
|
21
|
+
hashie (3.4.6)
|
22
|
+
highline (1.7.8)
|
23
|
+
jeweler (2.1.2)
|
23
24
|
builder
|
24
25
|
bundler (>= 1.0)
|
25
26
|
git (>= 1.2.5)
|
26
|
-
github_api
|
27
|
+
github_api (~> 0.11.0)
|
27
28
|
highline (>= 1.6.15)
|
28
29
|
nokogiri (>= 1.5.10)
|
29
30
|
rake
|
30
31
|
rdoc
|
32
|
+
semver
|
31
33
|
json (1.8.1)
|
32
|
-
jwt (
|
33
|
-
multi_json (>= 1.5)
|
34
|
+
jwt (1.5.6)
|
34
35
|
mini_portile (0.6.0)
|
35
|
-
multi_json (1.
|
36
|
+
multi_json (1.12.1)
|
36
37
|
multi_xml (0.5.5)
|
37
38
|
multipart-post (2.0.0)
|
38
39
|
nokogiri (1.6.2.1)
|
39
40
|
mini_portile (= 0.6.0)
|
40
|
-
oauth2 (
|
41
|
+
oauth2 (1.2.0)
|
41
42
|
faraday (>= 0.8, < 0.10)
|
42
|
-
jwt (~>
|
43
|
+
jwt (~> 1.0)
|
43
44
|
multi_json (~> 1.3)
|
44
45
|
multi_xml (~> 0.5)
|
45
|
-
rack (
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
rack (>= 1.2, < 3)
|
47
|
+
public_suffix (2.0.3)
|
48
|
+
rack (2.0.1)
|
49
|
+
rake (11.3.0)
|
50
|
+
rdoc (5.0.0)
|
50
51
|
rmagick (2.15.4)
|
51
52
|
rspec (2.14.1)
|
52
53
|
rspec-core (~> 2.14.0)
|
@@ -56,15 +57,16 @@ GEM
|
|
56
57
|
rspec-expectations (2.14.5)
|
57
58
|
diff-lcs (>= 1.1.3, < 2.0)
|
58
59
|
rspec-mocks (2.14.6)
|
59
|
-
|
60
|
+
semver (1.0.1)
|
61
|
+
thread_safe (0.3.5)
|
60
62
|
zipruby (0.3.6)
|
61
63
|
|
62
64
|
PLATFORMS
|
63
65
|
ruby
|
64
66
|
|
65
67
|
DEPENDENCIES
|
66
|
-
bundler (>= 1.6
|
67
|
-
jeweler (>= 2.
|
68
|
+
bundler (>= 1.13.6)
|
69
|
+
jeweler (>= 2.1.2)
|
68
70
|
json (>= 1.4)
|
69
71
|
nokogiri
|
70
72
|
rmagick (>= 2.13.3)
|
@@ -72,4 +74,4 @@ DEPENDENCIES
|
|
72
74
|
zipruby
|
73
75
|
|
74
76
|
BUNDLED WITH
|
75
|
-
1.
|
77
|
+
1.13.6
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# kindai.rb [![Build Status](https://travis-ci.org/hitode909/kindairb.png?branch=master)](https://travis-ci.org/hitode909/kindairb)
|
2
2
|
|
3
|
-
##
|
3
|
+
## 近デジダウンローダー
|
4
4
|
|
5
|
-
|
5
|
+
国立国会図書館デジタルコレクションから画像をダウンロードします.
|
6
6
|
|
7
7
|
## インストール
|
8
8
|
|
@@ -19,7 +19,7 @@ gemをインストールすると,kindai.rbというコマンドがインス
|
|
19
19
|
起動時の引数に,ダウンロードしたい本の URL を指定します.スペース区切りで複数指定できます.
|
20
20
|
|
21
21
|
```
|
22
|
-
kindai.rb http://
|
22
|
+
kindai.rb http://dl.ndl.go.jp/info:ndljp/pid/922693
|
23
23
|
```
|
24
24
|
|
25
25
|
URL の代わりに検索ワードを指定すると,ヒットした本をまとめてダウンロードします.AND検索もできます.
|
@@ -32,7 +32,7 @@ kindai.rb "松茸 調理"
|
|
32
32
|
--output オプションで,保存先を指定できます.指定したディレクトリの下に,書名のディレクトリができます.
|
33
33
|
|
34
34
|
```
|
35
|
-
kindai.rb http://
|
35
|
+
kindai.rb http://dl.ndl.go.jp/info:ndljp/pid/922693 --output ~/Documents/
|
36
36
|
```
|
37
37
|
|
38
38
|
## 本の加工(自動)
|
@@ -91,6 +91,9 @@ kindai.rb publish --position 2905x2510+270+190 "~/Documents/正義熱血社 -
|
|
91
91
|
brew install ruby imagemagick
|
92
92
|
```
|
93
93
|
|
94
|
+
## 歴史
|
95
|
+
|
96
|
+
国立国会図書館デジタルコレクションは,その昔,近代デジタルライブラリーでした.
|
94
97
|
|
95
98
|
## Copyright
|
96
99
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.8.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.
|
5
|
+
# stub: kindai 2.8.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "kindai"
|
9
|
-
s.version = "2.
|
9
|
+
s.version = "2.8.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 = "2016-
|
14
|
+
s.date = "2016-11-06"
|
15
15
|
s.description = "kindai.rb is kindai digital library downloader."
|
16
16
|
s.email = "hitode909@gmail.com"
|
17
17
|
s.executables = ["kindai.rb"]
|
@@ -53,7 +53,7 @@ Gem::Specification.new do |s|
|
|
53
53
|
s.homepage = "http://github.com/hitode909/kindairb"
|
54
54
|
s.licenses = ["MIT"]
|
55
55
|
s.rdoc_options = ["--main", "README.rdoc", "--exclude", "spec"]
|
56
|
-
s.rubygems_version = "2.
|
56
|
+
s.rubygems_version = "2.4.5.1"
|
57
57
|
s.summary = "kindai digital library downloader"
|
58
58
|
|
59
59
|
if s.respond_to? :specification_version then
|
@@ -65,16 +65,16 @@ Gem::Specification.new do |s|
|
|
65
65
|
s.add_runtime_dependency(%q<zipruby>, [">= 0"])
|
66
66
|
s.add_runtime_dependency(%q<json>, [">= 1.4"])
|
67
67
|
s.add_development_dependency(%q<rspec>, [">= 2.13.3"])
|
68
|
-
s.add_development_dependency(%q<bundler>, [">= 1.6
|
69
|
-
s.add_development_dependency(%q<jeweler>, [">= 2.
|
68
|
+
s.add_development_dependency(%q<bundler>, [">= 1.13.6"])
|
69
|
+
s.add_development_dependency(%q<jeweler>, [">= 2.1.2"])
|
70
70
|
else
|
71
71
|
s.add_dependency(%q<nokogiri>, [">= 0"])
|
72
72
|
s.add_dependency(%q<rmagick>, [">= 2.13.3"])
|
73
73
|
s.add_dependency(%q<zipruby>, [">= 0"])
|
74
74
|
s.add_dependency(%q<json>, [">= 1.4"])
|
75
75
|
s.add_dependency(%q<rspec>, [">= 2.13.3"])
|
76
|
-
s.add_dependency(%q<bundler>, [">= 1.6
|
77
|
-
s.add_dependency(%q<jeweler>, [">= 2.
|
76
|
+
s.add_dependency(%q<bundler>, [">= 1.13.6"])
|
77
|
+
s.add_dependency(%q<jeweler>, [">= 2.1.2"])
|
78
78
|
end
|
79
79
|
else
|
80
80
|
s.add_dependency(%q<nokogiri>, [">= 0"])
|
@@ -82,8 +82,8 @@ Gem::Specification.new do |s|
|
|
82
82
|
s.add_dependency(%q<zipruby>, [">= 0"])
|
83
83
|
s.add_dependency(%q<json>, [">= 1.4"])
|
84
84
|
s.add_dependency(%q<rspec>, [">= 2.13.3"])
|
85
|
-
s.add_dependency(%q<bundler>, [">= 1.6
|
86
|
-
s.add_dependency(%q<jeweler>, [">= 2.
|
85
|
+
s.add_dependency(%q<bundler>, [">= 1.13.6"])
|
86
|
+
s.add_dependency(%q<jeweler>, [">= 2.1.2"])
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
data/lib/kindai/book.rb
CHANGED
data/lib/kindai/searcher.rb
CHANGED
@@ -37,14 +37,14 @@ module Kindai
|
|
37
37
|
def result_for keyword, page = 1
|
38
38
|
page = Nokogiri Kindai::Util.fetch_uri(uri_for(keyword, page))
|
39
39
|
page.search('a.item-link').map{ |item|
|
40
|
-
'http://
|
40
|
+
'http://dl.ndl.go.jp' + item.attr('href')
|
41
41
|
}
|
42
42
|
end
|
43
43
|
|
44
44
|
def uri_for keyword, page = 1
|
45
45
|
rows = 100
|
46
|
-
params = { :SID => 'kindai', :searchWord => keyword, :pageNo => page, :rows => rows }
|
47
|
-
root = URI.parse("http://
|
46
|
+
params = { :SID => 'kindai', :viewRestricted => 0, :searchWord => keyword, :pageNo => page, :rows => rows }
|
47
|
+
root = URI.parse("http://dl.ndl.go.jp/search/searchResult")
|
48
48
|
query = '?' + Kindai::Util.expand_params(params)
|
49
49
|
root + query
|
50
50
|
end
|
data/lib/kindai/spread.rb
CHANGED
data/lib/kindai/util.rb
CHANGED
@@ -5,6 +5,7 @@ require 'digest/sha1'
|
|
5
5
|
require 'rmagick'
|
6
6
|
require 'zipruby'
|
7
7
|
require 'net/http'
|
8
|
+
require 'uri'
|
8
9
|
|
9
10
|
module Kindai::Util
|
10
11
|
def self.logger
|
@@ -93,6 +94,12 @@ module Kindai::Util
|
|
93
94
|
Dir.chdir(from)
|
94
95
|
end
|
95
96
|
|
97
|
+
def self.normalize_permalink_uri(uri_string)
|
98
|
+
uri = URI.parse(uri_string)
|
99
|
+
uri.host = 'dl.ndl.go.jp'
|
100
|
+
uri.to_s
|
101
|
+
end
|
102
|
+
|
96
103
|
def self.fetch_uri(uri, rich = false)
|
97
104
|
uri = URI.parse(uri) unless uri.kind_of? URI
|
98
105
|
self.logger.debug "fetch_uri #{uri}"
|
data/spec/book_spec.rb
CHANGED
@@ -30,6 +30,27 @@ describe Kindai::Book do
|
|
30
30
|
@book.spreads.should have_exactly(@book.total_spread).spreads
|
31
31
|
end
|
32
32
|
|
33
|
+
it 'normalizes permalink to canonical uri' do
|
34
|
+
@book.permalink_uri.should == 'http://dl.ndl.go.jp/info:ndljp/pid/922693'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe Kindai::Book, '国会図書館デジタルコレクション' do
|
39
|
+
before do
|
40
|
+
@book = Kindai::Book.new_from_permalink('http://dl.ndl.go.jp/info:ndljp/pid/922693')
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'has static permalink_uri' do
|
44
|
+
@book.permalink_uri.should == 'http://dl.ndl.go.jp/info:ndljp/pid/922693'
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'has key' do
|
48
|
+
@book.key.should == "922693"
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'has title' do
|
52
|
+
@book.title.should == '正義の叫'
|
53
|
+
end
|
33
54
|
end
|
34
55
|
|
35
56
|
describe Kindai::Book, 'with series' do
|
data/spec/spread_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
3
3
|
|
4
4
|
describe Kindai::Spread do
|
5
5
|
before do
|
6
|
-
@book = Kindai::Book.new_from_permalink('http://
|
6
|
+
@book = Kindai::Book.new_from_permalink('http://dl.ndl.go.jp/info:ndljp/pid/922693')
|
7
7
|
@spread = @book.spreads[4]
|
8
8
|
end
|
9
9
|
|
@@ -16,11 +16,11 @@ describe Kindai::Spread do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'has uri' do
|
19
|
-
@spread.uri.should == 'http://
|
19
|
+
@spread.uri.should == 'http://dl.ndl.go.jp/info:ndljp/pid/922693/5'
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'has image_uri' do
|
23
|
-
@spread.image_uri.should == "http://
|
23
|
+
@spread.image_uri.should == "http://dl.ndl.go.jp/view/jpegOutput?itemId=info%3Andljp%2Fpid%2F922693&contentNo=5&outputScale=1"
|
24
24
|
end
|
25
25
|
|
26
26
|
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.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hitode909
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -86,28 +86,28 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.6
|
89
|
+
version: 1.13.6
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.6
|
96
|
+
version: 1.13.6
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: jeweler
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 2.
|
103
|
+
version: 2.1.2
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 2.
|
110
|
+
version: 2.1.2
|
111
111
|
description: kindai.rb is kindai digital library downloader.
|
112
112
|
email: hitode909@gmail.com
|
113
113
|
executables:
|
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
170
|
version: '0'
|
171
171
|
requirements: []
|
172
172
|
rubyforge_project:
|
173
|
-
rubygems_version: 2.
|
173
|
+
rubygems_version: 2.4.5.1
|
174
174
|
signing_key:
|
175
175
|
specification_version: 4
|
176
176
|
summary: kindai digital library downloader
|