enju_oai 0.1.0.pre18 → 0.1.0.pre19
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6f952547e6fb1fd17016917dd03c4a2ccb18ca6
|
4
|
+
data.tar.gz: 6ff27008468b09fea1e0358866575f7980764ca7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa6f72a07db0b9e60668c673d875e26c23c396661bbcc4bbb269c1939ce7dda5f109d7dc8cfa2d6d4723792f9db65ee277593ab59ac4d1400dedac0b3f1ad6a2
|
7
|
+
data.tar.gz: b30081617dc9f6017d7ab4c91632200ef7f0e77b40021ca57f46ff590983c2d9226543c44ba91d521a508f9150b284c0b13ca955d7768fbd6dd5fb643ef7af7c
|
@@ -1,9 +1,9 @@
|
|
1
|
-
xml.instruct! :xml, :version=>"1.0"
|
1
|
+
xml.instruct! :xml, :version => "1.0"
|
2
2
|
xml.tag! "OAI-PMH", :xmlns => "http://www.openarchives.org/OAI/2.0/",
|
3
3
|
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
|
4
4
|
"xsi:schemaLocation" => "http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd" do
|
5
5
|
xml.responseDate Time.zone.now.utc.iso8601
|
6
|
-
xml.request manifestations_url(format: :oai),
|
6
|
+
xml.request manifestations_url(format: :oai), request_attr(@from_time, @until_time, @oai[:metadataPrefix])
|
7
7
|
@oai[:errors].each do |error|
|
8
8
|
xml.error :code => error
|
9
9
|
end
|
@@ -20,9 +20,12 @@ xml.tag! "OAI-PMH", :xmlns => "http://www.openarchives.org/OAI/2.0/",
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
if @resumption.present?
|
23
|
-
if @resumption[:cursor].to_i + @manifestations.limit_value
|
24
|
-
|
23
|
+
if @resumption[:cursor].to_i + @manifestations.limit_value <= @count[:query_result]
|
24
|
+
token = @resumption[:token]
|
25
|
+
else
|
26
|
+
token = nil
|
25
27
|
end
|
28
|
+
xml.resumptionToken token, completeListSize: @count[:query_result], cursor: @cursor.to_i
|
26
29
|
end
|
27
30
|
end
|
28
31
|
end
|
@@ -1,18 +1,9 @@
|
|
1
|
-
|
2
|
-
from_time = @from_time.utc.iso8601 if @from_time
|
3
|
-
until_time = @until_time.utc.iso8601 if @until_time
|
4
|
-
attribute = {:metadataPrefix => prefix, :verb => 'ListRecords'}
|
5
|
-
attribute.merge(:from => from_time) if from_time
|
6
|
-
attribute.merge(:until => until_time) if until_time
|
7
|
-
attribute
|
8
|
-
end
|
9
|
-
|
10
|
-
xml.instruct! :xml, :version=>"1.0"
|
1
|
+
xml.instruct! :xml, :version => "1.0"
|
11
2
|
xml.tag! "OAI-PMH", :xmlns => "http://www.openarchives.org/OAI/2.0/",
|
12
3
|
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
|
13
4
|
"xsi:schemaLocation" => "http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd" do
|
14
5
|
xml.responseDate Time.zone.now.utc.iso8601
|
15
|
-
xml.request manifestations_url(format: :oai), request_attr(@oai[:metadataPrefix])
|
6
|
+
xml.request manifestations_url(format: :oai), request_attr(@from_time, @until_time, @oai[:metadataPrefix])
|
16
7
|
@oai[:errors].each do |error|
|
17
8
|
xml.error code: error
|
18
9
|
end
|
@@ -36,9 +27,12 @@ xml.tag! "OAI-PMH", :xmlns => "http://www.openarchives.org/OAI/2.0/",
|
|
36
27
|
end
|
37
28
|
end
|
38
29
|
if @resumption.present?
|
39
|
-
if @resumption[:cursor].to_i + @manifestations.limit_value
|
40
|
-
|
30
|
+
if @resumption[:cursor].to_i + @manifestations.limit_value <= @count[:query_result]
|
31
|
+
token = @resumption[:token]
|
32
|
+
else
|
33
|
+
token = nil
|
41
34
|
end
|
35
|
+
xml.resumptionToken token, completeListSize: @count[:query_result], cursor: @cursor.to_i
|
42
36
|
end
|
43
37
|
end
|
44
38
|
end
|
@@ -1,43 +1,11 @@
|
|
1
1
|
module EnjuOai
|
2
2
|
module OaiController
|
3
3
|
def self.included(base)
|
4
|
-
base.send :include,
|
4
|
+
base.send :include, ClassMethods
|
5
|
+
base.helper_method :request_attr
|
5
6
|
end
|
6
7
|
|
7
|
-
module
|
8
|
-
def render_oai(oai, params)
|
9
|
-
if params[:format] == 'oai'
|
10
|
-
oai_search = true
|
11
|
-
from_and_until_times = set_from_and_until(Manifestation, params[:from], params[:until])
|
12
|
-
from_time = @from_time = from_and_until_times[:from]
|
13
|
-
until_time = @until_time = from_and_until_times[:until]
|
14
|
-
# OAI-PMHのデフォルトの件数
|
15
|
-
per_page = 200
|
16
|
-
if params[:resumptionToken]
|
17
|
-
current_token = get_resumption_token(params[:resumptionToken])
|
18
|
-
if current_token
|
19
|
-
page = (current_token[:cursor].to_i + per_page).div(per_page) + 1
|
20
|
-
else
|
21
|
-
@oai[:errors] << 'badResumptionToken'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
page ||= 1
|
25
|
-
|
26
|
-
if params[:verb] == 'GetRecord' and params[:identifier]
|
27
|
-
begin
|
28
|
-
@manifestation = Manifestation.find_by_oai_identifier(params[:identifier])
|
29
|
-
rescue ActiveRecord::RecordNotFound
|
30
|
-
@oai[:errors] << "idDoesNotExist"
|
31
|
-
render :formats => :oai, :layout => false
|
32
|
-
return
|
33
|
-
end
|
34
|
-
render :template => 'manifestations/show', :formats => :oai, :layout => false
|
35
|
-
return
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
8
|
+
module ClassMethods
|
41
9
|
def check_oai_params(params)
|
42
10
|
oai = {}
|
43
11
|
if params[:format] == 'oai'
|
@@ -86,57 +54,50 @@ module EnjuOai
|
|
86
54
|
true
|
87
55
|
end
|
88
56
|
end
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
57
|
+
|
58
|
+
def request_attr(from_time, until_time, prefix = 'oai_dc')
|
59
|
+
attribute = {metadataPrefix: prefix, verb: 'ListRecords'}
|
60
|
+
attribute.merge(from: from_time.utc.iso8601) if from_time
|
61
|
+
attribute.merge(:until => until_time.utc.iso8601) if until_time
|
62
|
+
attribute
|
94
63
|
end
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
if token.present?
|
102
|
-
latest_resumption = Rails.cache.read(token)
|
103
|
-
if latest_resumption
|
104
|
-
cursor = latest_resumption[:cursor] + per_page
|
64
|
+
|
65
|
+
def set_resumption_token(token, from_time, until_time, per_page = 200)
|
66
|
+
if token
|
67
|
+
cursor = token.split(',').reverse.first.to_i + per_page
|
68
|
+
else
|
69
|
+
cursor = per_page
|
105
70
|
end
|
71
|
+
{
|
72
|
+
token: "f(#{from_time.utc.iso8601.to_s}),u(#{until_time.utc.iso8601.to_s}),#{cursor}",
|
73
|
+
cursor: cursor
|
74
|
+
}
|
106
75
|
end
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
times[:from]
|
129
|
-
|
130
|
-
times
|
131
|
-
end
|
132
|
-
if /^[12]\d{3}-(0?[1-9]|1[0-2])-(0?[1-9]|[12]\d|3[01])$/ =~ until_t
|
133
|
-
times[:until] = Time.zone.parse(until_t).beginning_of_day
|
134
|
-
else
|
135
|
-
times[:until] = Time.zone.parse(until_t)
|
76
|
+
|
77
|
+
def set_from_and_until(klass, from_t, until_t)
|
78
|
+
if klass.first and klass.last
|
79
|
+
from_t ||= klass.order(:updated_at).first.updated_at.to_s
|
80
|
+
until_t ||= klass.order(:updated_at).last.updated_at.to_s
|
81
|
+
else
|
82
|
+
from_t ||= Time.zone.now.to_s
|
83
|
+
until_t ||= Time.zone.now.to_s
|
84
|
+
end
|
85
|
+
|
86
|
+
times = {}
|
87
|
+
if /^[12]\d{3}-(0?[1-9]|1[0-2])-(0?[1-9]|[12]\d|3[01])$/ =~ from_t
|
88
|
+
times[:from] = Time.zone.parse(from_t).beginning_of_day
|
89
|
+
else
|
90
|
+
times[:from] = Time.zone.parse(from_t)
|
91
|
+
end
|
92
|
+
if /^[12]\d{3}-(0?[1-9]|1[0-2])-(0?[1-9]|[12]\d|3[01])$/ =~ until_t
|
93
|
+
times[:until] = Time.zone.parse(until_t).beginning_of_day
|
94
|
+
else
|
95
|
+
times[:until] = Time.zone.parse(until_t)
|
96
|
+
end
|
97
|
+
times[:from] ||= Time.zone.parse(from_t)
|
98
|
+
times[:until] ||= Time.zone.parse(until_t)
|
99
|
+
times
|
136
100
|
end
|
137
|
-
times[:from] ||= Time.zone.parse(from_t)
|
138
|
-
times[:until] ||= Time.zone.parse(until_t)
|
139
|
-
times
|
140
101
|
end
|
141
102
|
end
|
142
103
|
end
|
data/lib/enju_oai/version.rb
CHANGED
data/lib/enju_oai.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enju_oai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.pre19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kosuke Tanabe
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.1.0.
|
19
|
+
version: 0.1.0.pre69
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.1.0.
|
26
|
+
version: 0.1.0.pre69
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: enju_subject
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|