kindai 1.6.2 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.2
1
+ 1.7.0
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.2"
8
+ s.version = "1.7.0"
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-05-19}
12
+ s.date = %q{2011-05-24}
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}
@@ -51,7 +51,7 @@ Gem::Specification.new do |s|
51
51
  s.licenses = ["MIT"]
52
52
  s.rdoc_options = ["--main", "README.rdoc", "--exclude", "spec"]
53
53
  s.require_paths = ["lib"]
54
- s.rubygems_version = %q{1.3.7}
54
+ s.rubygems_version = %q{1.5.2}
55
55
  s.summary = %q{kindai digital library downloader}
56
56
  s.test_files = [
57
57
  "spec/book_downloader_spec.rb",
@@ -63,7 +63,6 @@ Gem::Specification.new do |s|
63
63
  ]
64
64
 
65
65
  if s.respond_to? :specification_version then
66
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
67
66
  s.specification_version = 3
68
67
 
69
68
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
data/lib/kindai/book.rb CHANGED
@@ -20,6 +20,11 @@ module Kindai
20
20
  end
21
21
 
22
22
  # ----- metadata -----
23
+
24
+ def key
25
+ permalink_uri.match(/\d+$/)[0]
26
+ end
27
+
23
28
  def title
24
29
  title_container = control_page.at('.titlehead')
25
30
  subtitle_container = control_page.at('.headmenu')
@@ -7,6 +7,7 @@ require 'ostruct'
7
7
  module Kindai::Util::Database
8
8
  ENDPOINT = URI.parse 'http://gigaschema.appspot.com/hitode909/kindai.json'
9
9
 
10
+ # XXX: deprecated, page 1 only
10
11
  def self.items
11
12
  @items ||= JSON.parse(open(ENDPOINT).read)['data'].map{|item|
12
13
  begin
@@ -21,7 +22,17 @@ module Kindai::Util::Database
21
22
  end
22
23
 
23
24
  def self.item_for_book(book)
24
- self.items.find{|item| item.uri == book.permalink_uri}
25
+ path = ENDPOINT + "?group=#{book.key}"
26
+ JSON.parse(open(path).read)['data'].map{|item|
27
+ begin
28
+ hash = JSON.parse(item['value'])
29
+ self.validate(hash)
30
+ OpenStruct.new(hash)
31
+ rescue => error
32
+ Kindai::Util.logger.warn error
33
+ nil
34
+ end
35
+ }.compact.first
25
36
  end
26
37
 
27
38
  def self.save_item(book, info)
@@ -45,7 +56,7 @@ module Kindai::Util::Database
45
56
 
46
57
  res = Net::HTTP.start(ENDPOINT.host, ENDPOINT.port){|http|
47
58
  request = Net::HTTP::Post.new(ENDPOINT.path)
48
- request.set_form_data({:value => send_data.to_json})
59
+ request.set_form_data({:value => send_data.to_json, :group => book.key})
49
60
  http.request(request)
50
61
  }
51
62
  case res.code
data/spec/book_spec.rb CHANGED
@@ -6,6 +6,10 @@ describe Kindai::Book do
6
6
  @book = Kindai::Book.new_from_permalink('http://kindai.ndl.go.jp/info:ndljp/pid/922693')
7
7
  end
8
8
 
9
+ it 'has key' do
10
+ @book.key.should == "922693"
11
+ end
12
+
9
13
  it 'has title' do
10
14
  @book.title.should == '正義の叫'
11
15
  end
metadata CHANGED
@@ -1,152 +1,114 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: kindai
3
- version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease: false
6
- segments:
7
- - 1
8
- - 6
9
- - 2
10
- version: 1.6.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.7.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - hitode909
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-05-19 00:00:00 +09:00
12
+ date: 2011-05-24 00:00:00.000000000 +09:00
19
13
  default_executable: kindai.rb
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- type: :runtime
23
- prerelease: false
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
24
16
  name: nokogiri
25
- version_requirements: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &2156017080 !ruby/object:Gem::Requirement
26
18
  none: false
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- hash: 3
31
- segments:
32
- - 0
33
- version: "0"
34
- requirement: *id001
35
- - !ruby/object:Gem::Dependency
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
36
23
  type: :runtime
37
24
  prerelease: false
25
+ version_requirements: *2156017080
26
+ - !ruby/object:Gem::Dependency
38
27
  name: rmagick
39
- version_requirements: &id002 !ruby/object:Gem::Requirement
28
+ requirement: &2156014800 !ruby/object:Gem::Requirement
40
29
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- version: "0"
48
- requirement: *id002
49
- - !ruby/object:Gem::Dependency
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
50
34
  type: :runtime
51
35
  prerelease: false
36
+ version_requirements: *2156014800
37
+ - !ruby/object:Gem::Dependency
52
38
  name: zipruby
53
- version_requirements: &id003 !ruby/object:Gem::Requirement
39
+ requirement: &2156013420 !ruby/object:Gem::Requirement
54
40
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
62
- requirement: *id003
63
- - !ruby/object:Gem::Dependency
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
64
45
  type: :runtime
65
46
  prerelease: false
47
+ version_requirements: *2156013420
48
+ - !ruby/object:Gem::Dependency
66
49
  name: json
67
- version_requirements: &id004 !ruby/object:Gem::Requirement
50
+ requirement: &2156012280 !ruby/object:Gem::Requirement
68
51
  none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 7
73
- segments:
74
- - 1
75
- - 4
76
- version: "1.4"
77
- requirement: *id004
78
- - !ruby/object:Gem::Dependency
79
- type: :development
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '1.4'
56
+ type: :runtime
80
57
  prerelease: false
58
+ version_requirements: *2156012280
59
+ - !ruby/object:Gem::Dependency
81
60
  name: rspec
82
- version_requirements: &id005 !ruby/object:Gem::Requirement
61
+ requirement: &2156011420 !ruby/object:Gem::Requirement
83
62
  none: false
84
- requirements:
63
+ requirements:
85
64
  - - ~>
86
- - !ruby/object:Gem::Version
87
- hash: 3
88
- segments:
89
- - 2
90
- - 3
91
- - 0
65
+ - !ruby/object:Gem::Version
92
66
  version: 2.3.0
93
- requirement: *id005
94
- - !ruby/object:Gem::Dependency
95
67
  type: :development
96
68
  prerelease: false
69
+ version_requirements: *2156011420
70
+ - !ruby/object:Gem::Dependency
97
71
  name: bundler
98
- version_requirements: &id006 !ruby/object:Gem::Requirement
72
+ requirement: &2156010180 !ruby/object:Gem::Requirement
99
73
  none: false
100
- requirements:
74
+ requirements:
101
75
  - - ~>
102
- - !ruby/object:Gem::Version
103
- hash: 23
104
- segments:
105
- - 1
106
- - 0
107
- - 0
76
+ - !ruby/object:Gem::Version
108
77
  version: 1.0.0
109
- requirement: *id006
110
- - !ruby/object:Gem::Dependency
111
78
  type: :development
112
79
  prerelease: false
80
+ version_requirements: *2156010180
81
+ - !ruby/object:Gem::Dependency
113
82
  name: jeweler
114
- version_requirements: &id007 !ruby/object:Gem::Requirement
83
+ requirement: &2156008360 !ruby/object:Gem::Requirement
115
84
  none: false
116
- requirements:
85
+ requirements:
117
86
  - - ~>
118
- - !ruby/object:Gem::Version
119
- hash: 7
120
- segments:
121
- - 1
122
- - 5
123
- - 2
87
+ - !ruby/object:Gem::Version
124
88
  version: 1.5.2
125
- requirement: *id007
126
- - !ruby/object:Gem::Dependency
127
89
  type: :development
128
90
  prerelease: false
91
+ version_requirements: *2156008360
92
+ - !ruby/object:Gem::Dependency
129
93
  name: rcov
130
- version_requirements: &id008 !ruby/object:Gem::Requirement
94
+ requirement: &2156004900 !ruby/object:Gem::Requirement
131
95
  none: false
132
- requirements:
133
- - - ">="
134
- - !ruby/object:Gem::Version
135
- hash: 3
136
- segments:
137
- - 0
138
- version: "0"
139
- requirement: *id008
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ type: :development
101
+ prerelease: false
102
+ version_requirements: *2156004900
140
103
  description: kindai.rb is kindai digital library downloader.
141
104
  email: hitode909@gmail.com
142
- executables:
105
+ executables:
143
106
  - kindai.rb
144
107
  extensions: []
145
-
146
- extra_rdoc_files:
108
+ extra_rdoc_files:
147
109
  - LICENSE.txt
148
110
  - README.rdoc
149
- files:
111
+ files:
150
112
  - Gemfile
151
113
  - Gemfile.lock
152
114
  - LICENSE.txt
@@ -176,42 +138,38 @@ files:
176
138
  - spec/spread_spec.rb
177
139
  has_rdoc: true
178
140
  homepage: http://github.com/hitode909/kindairb
179
- licenses:
141
+ licenses:
180
142
  - MIT
181
143
  post_install_message:
182
- rdoc_options:
144
+ rdoc_options:
183
145
  - --main
184
146
  - README.rdoc
185
147
  - --exclude
186
148
  - spec
187
- require_paths:
149
+ require_paths:
188
150
  - lib
189
- required_ruby_version: !ruby/object:Gem::Requirement
151
+ required_ruby_version: !ruby/object:Gem::Requirement
190
152
  none: false
191
- requirements:
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- hash: 3
195
- segments:
153
+ requirements:
154
+ - - ! '>='
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ segments:
196
158
  - 0
197
- version: "0"
198
- required_rubygems_version: !ruby/object:Gem::Requirement
159
+ hash: 4261753351778255770
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
199
161
  none: false
200
- requirements:
201
- - - ">="
202
- - !ruby/object:Gem::Version
203
- hash: 3
204
- segments:
205
- - 0
206
- version: "0"
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
207
166
  requirements: []
208
-
209
167
  rubyforge_project:
210
- rubygems_version: 1.3.7
168
+ rubygems_version: 1.5.2
211
169
  signing_key:
212
170
  specification_version: 3
213
171
  summary: kindai digital library downloader
214
- test_files:
172
+ test_files:
215
173
  - spec/book_downloader_spec.rb
216
174
  - spec/book_spec.rb
217
175
  - spec/searcher_spec.rb