kindai 1.6.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/kindai.gemspec +2 -2
- data/lib/kindai/book.rb +9 -2
- data/lib/kindai/util/database.rb +1 -0
- data/spec/book_spec.rb +27 -0
- metadata +17 -17
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.6.
|
1
|
+
1.6.1
|
data/kindai.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{kindai}
|
8
|
-
s.version = "1.6.
|
8
|
+
s.version = "1.6.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["hitode909"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-04-28}
|
13
13
|
s.default_executable = %q{kindai.rb}
|
14
14
|
s.description = %q{kindai.rb is kindai digital library downloader.}
|
15
15
|
s.email = %q{hitode909@gmail.com}
|
data/lib/kindai/book.rb
CHANGED
@@ -2,12 +2,14 @@
|
|
2
2
|
module Kindai
|
3
3
|
class Book
|
4
4
|
attr_accessor :permalink_uri
|
5
|
+
attr_accessor :trimming
|
5
6
|
|
6
7
|
# ----- constructor -----
|
7
|
-
def self.new_from_permalink(permalink_uri)
|
8
|
+
def self.new_from_permalink(permalink_uri, trimming = {})
|
8
9
|
raise "not info:ndljp" unless permalink_uri.match(/info\:ndljp/)
|
9
10
|
me = new
|
10
11
|
me.permalink_uri = permalink_uri
|
12
|
+
me.trimming = trimming
|
11
13
|
return me
|
12
14
|
end
|
13
15
|
|
@@ -46,7 +48,12 @@ module Kindai
|
|
46
48
|
|
47
49
|
page_file = Kindai::Util.fetch_uri page_uri.to_s
|
48
50
|
uri = page_file.base_uri.to_s + '&vs=10000,10000,0,0,0,0,0,0'
|
49
|
-
|
51
|
+
unless self.trimming.keys.empty?
|
52
|
+
%w{x y w h resize_w resize_h}.map(&:to_sym).each{ |key|
|
53
|
+
self.trimming[key] ||= 0
|
54
|
+
}
|
55
|
+
uri += "&ref=" + [self.trimming[:x], self.trimming[:y], self.trimming[:w], self.trimming[:h], self.trimming[:resize_w], self.trimming[:resize_h], 0, 0].join(',')
|
56
|
+
end
|
50
57
|
uri
|
51
58
|
end
|
52
59
|
end
|
data/lib/kindai/util/database.rb
CHANGED
data/spec/book_spec.rb
CHANGED
@@ -37,3 +37,30 @@ describe Kindai::Book, 'with series' do
|
|
37
37
|
@book.title.should == '講談日露戦争記[第3冊]第3編'
|
38
38
|
end
|
39
39
|
end
|
40
|
+
|
41
|
+
describe Kindai::Book, 'with trimming' do
|
42
|
+
before do
|
43
|
+
|
44
|
+
@trimming = {:x => 342, :y => 190, :w => 2829, :h => 2485, :resize_w => 900, :resize_h => 900}
|
45
|
+
@book = Kindai::Book.new_from_permalink('http://kindai.ndl.go.jp/info:ndljp/pid/922693', @trimming)
|
46
|
+
@book_normal = Kindai::Book.new_from_permalink('http://kindai.ndl.go.jp/info:ndljp/pid/922693')
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'has trimming' do
|
50
|
+
@book.trimming.should be_kind_of Hash
|
51
|
+
@book.trimming.should == @trimming
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'has base uri including trimming info' do
|
55
|
+
@book.base_uri.should match(/2485/)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'has different image uri' do
|
59
|
+
@book.spreads.first.uri.should_not == @book_normal.spreads.first.uri
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kindai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-04-28 00:00:00.000000000 +09:00
|
13
13
|
default_executable: kindai.rb
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
17
|
-
requirement: &
|
17
|
+
requirement: &2153140460 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2153140460
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rmagick
|
28
|
-
requirement: &
|
28
|
+
requirement: &2153138480 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2153138480
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: zipruby
|
39
|
-
requirement: &
|
39
|
+
requirement: &2153136680 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2153136680
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rspec
|
50
|
-
requirement: &
|
50
|
+
requirement: &2153134480 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: 2.3.0
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2153134480
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: bundler
|
61
|
-
requirement: &
|
61
|
+
requirement: &2153130260 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ~>
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: 1.0.0
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *2153130260
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: jeweler
|
72
|
-
requirement: &
|
72
|
+
requirement: &2153129020 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: 1.5.2
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *2153129020
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: rcov
|
83
|
-
requirement: &
|
83
|
+
requirement: &2153128220 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ! '>='
|
@@ -88,7 +88,7 @@ dependencies:
|
|
88
88
|
version: '0'
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *2153128220
|
92
92
|
description: kindai.rb is kindai digital library downloader.
|
93
93
|
email: hitode909@gmail.com
|
94
94
|
executables:
|
@@ -145,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
145
|
version: '0'
|
146
146
|
segments:
|
147
147
|
- 0
|
148
|
-
hash:
|
148
|
+
hash: 437047170026144001
|
149
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
150
|
none: false
|
151
151
|
requirements:
|