rif-cs 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +33 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +9 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/lib/rif-cs.rb +167 -0
- data/lib/rif-cs/activity.rb +45 -0
- data/lib/rif-cs/collection.rb +74 -0
- data/lib/rif-cs/party.rb +45 -0
- data/lib/rif-cs/service.rb +40 -0
- data/rif-cs.gemspec +75 -0
- data/spec/files/activity.xml +59 -0
- data/spec/files/collection.xml +73 -0
- data/spec/files/party.xml +61 -0
- data/spec/files/service.xml +63 -0
- data/spec/rif-cs_activity_spec.rb +217 -0
- data/spec/rif-cs_collection_spec.rb +270 -0
- data/spec/rif-cs_party_spec.rb +228 -0
- data/spec/rif-cs_service_spec.rb +223 -0
- data/spec/rif-cs_spec.rb +388 -0
- data/spec/spec_helper.rb +12 -0
- metadata +129 -0
@@ -0,0 +1,270 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "RIFCS::Collection" do
|
4
|
+
class CollectionExample
|
5
|
+
require 'date'
|
6
|
+
include RIFCS::Collection
|
7
|
+
|
8
|
+
attr_reader :collection_key
|
9
|
+
|
10
|
+
def initialize(key='a key')
|
11
|
+
@collection_key = key
|
12
|
+
end
|
13
|
+
|
14
|
+
def collection_date_accessioned
|
15
|
+
Time.new(2012, 6, 14).utc
|
16
|
+
end
|
17
|
+
|
18
|
+
def collection_group
|
19
|
+
'test group'
|
20
|
+
end
|
21
|
+
|
22
|
+
def collection_originating_source
|
23
|
+
'tomato'
|
24
|
+
end
|
25
|
+
|
26
|
+
def collection_type
|
27
|
+
'dataset'
|
28
|
+
end
|
29
|
+
|
30
|
+
def collection_date_modified
|
31
|
+
Time.new(2012, 6, 14).utc
|
32
|
+
end
|
33
|
+
|
34
|
+
def collection_identifiers
|
35
|
+
[
|
36
|
+
{ value: 'http://example.com', type: 'uri' },
|
37
|
+
{ value: '123', type: 'local' }
|
38
|
+
]
|
39
|
+
end
|
40
|
+
|
41
|
+
def collection_names
|
42
|
+
[
|
43
|
+
{
|
44
|
+
type: 'primary',
|
45
|
+
name_parts: [
|
46
|
+
{ type: 'title', value: 'Dr' },
|
47
|
+
{ type: 'given', value: 'John' },
|
48
|
+
{ type: 'family', value: 'Doe' }
|
49
|
+
]
|
50
|
+
},
|
51
|
+
]
|
52
|
+
end
|
53
|
+
|
54
|
+
def collection_related_info
|
55
|
+
[
|
56
|
+
{
|
57
|
+
type: 'website',
|
58
|
+
identifier: {
|
59
|
+
value: 'http://example.com/personalsites/foo',
|
60
|
+
type: 'uri'
|
61
|
+
},
|
62
|
+
title: 'This person\'s blog',
|
63
|
+
notes: 'Another blog'
|
64
|
+
},
|
65
|
+
{
|
66
|
+
type: 'publication',
|
67
|
+
identifier: {
|
68
|
+
value: '111',
|
69
|
+
type: 'isbn'
|
70
|
+
},
|
71
|
+
title: 'The Ordering of Things',
|
72
|
+
notes: 'Not available'
|
73
|
+
}
|
74
|
+
]
|
75
|
+
end
|
76
|
+
|
77
|
+
def collection_related_objects
|
78
|
+
{
|
79
|
+
has_association_with: [
|
80
|
+
{
|
81
|
+
key: 'b party',
|
82
|
+
relation: {
|
83
|
+
description: 'owner'
|
84
|
+
}
|
85
|
+
}
|
86
|
+
],
|
87
|
+
is_member_of: [
|
88
|
+
{
|
89
|
+
key: 'some group'
|
90
|
+
}
|
91
|
+
]
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
def collection_locations
|
96
|
+
[
|
97
|
+
{
|
98
|
+
date_from: Time.new(2012, 6, 14).utc,
|
99
|
+
addresses: [
|
100
|
+
{
|
101
|
+
electronic: [
|
102
|
+
{
|
103
|
+
type: 'email',
|
104
|
+
value: 'joe@example.com'
|
105
|
+
},
|
106
|
+
{
|
107
|
+
type: 'uri',
|
108
|
+
value: "http://example.com/people/#{@collection_key}",
|
109
|
+
args: [
|
110
|
+
{ value: 'placeholder', required: 'false' }
|
111
|
+
]
|
112
|
+
}
|
113
|
+
],
|
114
|
+
physical: [
|
115
|
+
{
|
116
|
+
type: 'postalAddress',
|
117
|
+
address_parts: [
|
118
|
+
{
|
119
|
+
type: 'country',
|
120
|
+
value: 'Austrlia'
|
121
|
+
},
|
122
|
+
]
|
123
|
+
},
|
124
|
+
{
|
125
|
+
address_parts: [
|
126
|
+
{
|
127
|
+
type: 'telephoneNumber',
|
128
|
+
value: '+61 2 9123 4567'
|
129
|
+
}
|
130
|
+
]
|
131
|
+
}
|
132
|
+
]
|
133
|
+
}
|
134
|
+
]
|
135
|
+
}
|
136
|
+
]
|
137
|
+
end
|
138
|
+
|
139
|
+
def collection_coverage
|
140
|
+
[
|
141
|
+
{
|
142
|
+
spatials: [
|
143
|
+
{
|
144
|
+
value: '<gmlPoint gmlid="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"><gmlcoordinates>45.67, 88.56</gmlcoordinates></gmlPoint>',
|
145
|
+
type: 'gml'
|
146
|
+
}
|
147
|
+
],
|
148
|
+
temporals: [
|
149
|
+
{
|
150
|
+
dates: [
|
151
|
+
{
|
152
|
+
value: Time.new(2012, 6, 14).utc,
|
153
|
+
date_format: 'UTC',
|
154
|
+
type: 'dateFrom'
|
155
|
+
},
|
156
|
+
{
|
157
|
+
value: Time.new(2013, 6, 14).utc,
|
158
|
+
date_format: 'UTC',
|
159
|
+
type: 'dateTo'
|
160
|
+
},
|
161
|
+
],
|
162
|
+
text: ['Self destructs in 1 year']
|
163
|
+
}
|
164
|
+
]
|
165
|
+
}
|
166
|
+
]
|
167
|
+
end
|
168
|
+
|
169
|
+
def collection_descriptions
|
170
|
+
[
|
171
|
+
{
|
172
|
+
value: 'A researcher',
|
173
|
+
type: 'brief',
|
174
|
+
'xmllang' => nil
|
175
|
+
},
|
176
|
+
{
|
177
|
+
value: 'Not just any researcher',
|
178
|
+
type: 'full'
|
179
|
+
}
|
180
|
+
]
|
181
|
+
end
|
182
|
+
|
183
|
+
def collection_existence_dates
|
184
|
+
[
|
185
|
+
{
|
186
|
+
start_date: {
|
187
|
+
value: Time.new(2012, 6, 14).utc,
|
188
|
+
date_format: 'UTC'
|
189
|
+
},
|
190
|
+
end_date: {
|
191
|
+
}
|
192
|
+
}
|
193
|
+
]
|
194
|
+
end
|
195
|
+
|
196
|
+
def collection_rights
|
197
|
+
[
|
198
|
+
{
|
199
|
+
rights_statement: {
|
200
|
+
rights_uri: 'http://www.intersect.org.au/policies',
|
201
|
+
value: 'Copyright 2012 Intersect Australia Ltd.'
|
202
|
+
},
|
203
|
+
licence: {
|
204
|
+
value: 'Attribution (CC BY)',
|
205
|
+
rights_uri: 'http://creativecommons.org/licenses/by/3.0',
|
206
|
+
type: ''
|
207
|
+
},
|
208
|
+
access_rights: {
|
209
|
+
value: 'Available to all without restriction'
|
210
|
+
}
|
211
|
+
}
|
212
|
+
]
|
213
|
+
end
|
214
|
+
|
215
|
+
def collection_subjects
|
216
|
+
[
|
217
|
+
{
|
218
|
+
value: '123456',
|
219
|
+
type: 'anzsrc-for'
|
220
|
+
}
|
221
|
+
]
|
222
|
+
end
|
223
|
+
|
224
|
+
def collection_citation_info
|
225
|
+
[
|
226
|
+
{
|
227
|
+
full_citation: {
|
228
|
+
style: 'Harvard',
|
229
|
+
value: 'Australian Bureau of Agricultural and Resource Economics 2001, Aquaculture development in Australia: a review of key economic issues, ABARE, Canberra.'
|
230
|
+
},
|
231
|
+
citation_metadata: {
|
232
|
+
identifier: {
|
233
|
+
type: 'isbn',
|
234
|
+
value: '1234'
|
235
|
+
},
|
236
|
+
contributor: [
|
237
|
+
{
|
238
|
+
name_parts: [
|
239
|
+
{ type: 'title', value: 'Dr' },
|
240
|
+
{ type: 'given', value: 'Jane' },
|
241
|
+
{ type: 'family', value: 'Doe' }
|
242
|
+
]
|
243
|
+
}
|
244
|
+
],
|
245
|
+
title: 'Aquaculture development in Australia: a review of key economic issues',
|
246
|
+
edition: '1st',
|
247
|
+
publisher: 'ABARE',
|
248
|
+
place_published: 'Canberra',
|
249
|
+
date: [
|
250
|
+
{
|
251
|
+
value: '2012-06-14',
|
252
|
+
type: 'publicationDate'
|
253
|
+
}
|
254
|
+
],
|
255
|
+
url: 'http://example.com',
|
256
|
+
context: 'local'
|
257
|
+
}
|
258
|
+
}
|
259
|
+
]
|
260
|
+
end
|
261
|
+
|
262
|
+
end
|
263
|
+
|
264
|
+
it "should give a RIF-CS XML Collection record for a model" do
|
265
|
+
expected = IO.read(File.join(File.dirname(__FILE__), 'files', 'collection.xml'))
|
266
|
+
collection = CollectionExample.new
|
267
|
+
collection.to_rifcs.to_xml.should eq(expected)
|
268
|
+
end
|
269
|
+
|
270
|
+
end
|
@@ -0,0 +1,228 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "RIFCS::Party" do
|
4
|
+
class PartyExample
|
5
|
+
require 'date'
|
6
|
+
include RIFCS::Party
|
7
|
+
|
8
|
+
attr_reader :party_key
|
9
|
+
|
10
|
+
def initialize(key='a key')
|
11
|
+
@party_key = key
|
12
|
+
end
|
13
|
+
|
14
|
+
def party_group
|
15
|
+
'test group'
|
16
|
+
end
|
17
|
+
|
18
|
+
def party_originating_source
|
19
|
+
'tomato'
|
20
|
+
end
|
21
|
+
|
22
|
+
def party_type
|
23
|
+
'person'
|
24
|
+
end
|
25
|
+
|
26
|
+
def party_date_modified
|
27
|
+
Time.new(2012, 6, 14).utc
|
28
|
+
end
|
29
|
+
|
30
|
+
def party_identifiers
|
31
|
+
[
|
32
|
+
{ value: 'http://example.com', type: 'uri' },
|
33
|
+
{ value: '123', type: 'local' }
|
34
|
+
]
|
35
|
+
end
|
36
|
+
|
37
|
+
def party_names
|
38
|
+
[
|
39
|
+
{
|
40
|
+
type: 'primary',
|
41
|
+
name_parts: [
|
42
|
+
{ type: 'title', value: 'Dr' },
|
43
|
+
{ type: 'given', value: 'John' },
|
44
|
+
{ type: 'family', value: 'Doe' }
|
45
|
+
]
|
46
|
+
},
|
47
|
+
]
|
48
|
+
end
|
49
|
+
|
50
|
+
def party_related_info
|
51
|
+
[
|
52
|
+
{
|
53
|
+
type: 'website',
|
54
|
+
identifier: {
|
55
|
+
value: 'http://example.com/personalsites/foo',
|
56
|
+
type: 'uri'
|
57
|
+
},
|
58
|
+
title: 'This person\'s blog',
|
59
|
+
notes: 'Another blog'
|
60
|
+
},
|
61
|
+
{
|
62
|
+
type: 'publication',
|
63
|
+
identifier: {
|
64
|
+
value: '111',
|
65
|
+
type: 'isbn'
|
66
|
+
},
|
67
|
+
title: 'The Ordering of Things',
|
68
|
+
notes: 'Not available'
|
69
|
+
}
|
70
|
+
]
|
71
|
+
end
|
72
|
+
|
73
|
+
def party_related_objects
|
74
|
+
{
|
75
|
+
has_association_with: [
|
76
|
+
{
|
77
|
+
key: 'b party',
|
78
|
+
relation: {
|
79
|
+
description: 'Supervisor'
|
80
|
+
}
|
81
|
+
}
|
82
|
+
],
|
83
|
+
is_member_of: [
|
84
|
+
{
|
85
|
+
key: 'some group'
|
86
|
+
}
|
87
|
+
]
|
88
|
+
}
|
89
|
+
end
|
90
|
+
|
91
|
+
def party_locations
|
92
|
+
[
|
93
|
+
{
|
94
|
+
date_from: Time.new(2012, 6, 14).utc,
|
95
|
+
addresses: [
|
96
|
+
{
|
97
|
+
electronic: [
|
98
|
+
{
|
99
|
+
type: 'email',
|
100
|
+
value: 'joe@example.com'
|
101
|
+
},
|
102
|
+
{
|
103
|
+
type: 'uri',
|
104
|
+
value: "http://example.com/people/#{@party_key}",
|
105
|
+
args: [
|
106
|
+
{ value: 'placeholder', required: 'false' }
|
107
|
+
]
|
108
|
+
}
|
109
|
+
],
|
110
|
+
physical: [
|
111
|
+
{
|
112
|
+
type: 'postalAddress',
|
113
|
+
address_parts: [
|
114
|
+
{
|
115
|
+
type: 'country',
|
116
|
+
value: 'Austrlia'
|
117
|
+
},
|
118
|
+
]
|
119
|
+
},
|
120
|
+
{
|
121
|
+
address_parts: [
|
122
|
+
{
|
123
|
+
type: 'telephoneNumber',
|
124
|
+
value: '+61 2 9123 4567'
|
125
|
+
}
|
126
|
+
]
|
127
|
+
}
|
128
|
+
]
|
129
|
+
}
|
130
|
+
]
|
131
|
+
}
|
132
|
+
]
|
133
|
+
end
|
134
|
+
|
135
|
+
def party_coverage
|
136
|
+
[
|
137
|
+
{
|
138
|
+
spatials: [
|
139
|
+
{
|
140
|
+
value: '<gmlPoint gmlid="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"><gmlcoordinates>45.67, 88.56</gmlcoordinates></gmlPoint>',
|
141
|
+
type: 'gml'
|
142
|
+
}
|
143
|
+
],
|
144
|
+
temporals: [
|
145
|
+
{
|
146
|
+
dates: [
|
147
|
+
{
|
148
|
+
value: Time.new(2012, 6, 14).utc,
|
149
|
+
date_format: 'UTC',
|
150
|
+
type: 'dateFrom'
|
151
|
+
},
|
152
|
+
{
|
153
|
+
value: Time.new(2013, 6, 14).utc,
|
154
|
+
date_format: 'UTC',
|
155
|
+
type: 'dateTo'
|
156
|
+
},
|
157
|
+
],
|
158
|
+
text: ['Self destructs in 1 year']
|
159
|
+
}
|
160
|
+
]
|
161
|
+
}
|
162
|
+
]
|
163
|
+
end
|
164
|
+
|
165
|
+
def party_descriptions
|
166
|
+
[
|
167
|
+
{
|
168
|
+
value: 'A researcher',
|
169
|
+
type: 'brief',
|
170
|
+
'xmllang' => nil
|
171
|
+
},
|
172
|
+
{
|
173
|
+
value: 'Not just any researcher',
|
174
|
+
type: 'full'
|
175
|
+
}
|
176
|
+
]
|
177
|
+
end
|
178
|
+
|
179
|
+
def party_existence_dates
|
180
|
+
[
|
181
|
+
{
|
182
|
+
start_date: {
|
183
|
+
value: Time.new(2012, 6, 14).utc,
|
184
|
+
date_format: 'UTC'
|
185
|
+
},
|
186
|
+
end_date: {
|
187
|
+
}
|
188
|
+
}
|
189
|
+
]
|
190
|
+
end
|
191
|
+
|
192
|
+
def party_rights
|
193
|
+
[
|
194
|
+
{
|
195
|
+
rights_statement: {
|
196
|
+
rights_uri: 'http://www.intersect.org.au/policies',
|
197
|
+
value: 'Copyright 2012 Intersect Australia Ltd.'
|
198
|
+
},
|
199
|
+
licence: {
|
200
|
+
value: 'Attribution (CC BY)',
|
201
|
+
rights_uri: 'http://creativecommons.org/licenses/by/3.0',
|
202
|
+
type: ''
|
203
|
+
},
|
204
|
+
access_rights: {
|
205
|
+
value: 'Available to all without restriction'
|
206
|
+
}
|
207
|
+
}
|
208
|
+
]
|
209
|
+
end
|
210
|
+
|
211
|
+
def party_subjects
|
212
|
+
[
|
213
|
+
{
|
214
|
+
value: '123456',
|
215
|
+
type: 'anzsrc-for'
|
216
|
+
}
|
217
|
+
]
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should give a RIF-CS XML Party record for a model" do
|
223
|
+
expected = IO.read(File.join(File.dirname(__FILE__), 'files', 'party.xml'))
|
224
|
+
party = PartyExample.new
|
225
|
+
party.to_rifcs.to_xml.should eq(expected)
|
226
|
+
end
|
227
|
+
|
228
|
+
end
|