rubydora 1.8.1 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +573 -0
- data/.travis.yml +6 -6
- data/Gemfile +2 -3
- data/README.md +86 -0
- data/Rakefile +22 -25
- data/VERSION +1 -1
- data/lib/rubydora.rb +3 -6
- data/lib/rubydora/array_with_callback.rb +4 -4
- data/lib/rubydora/audit_trail.rb +7 -7
- data/lib/rubydora/callbacks.rb +9 -9
- data/lib/rubydora/datastream.rb +43 -39
- data/lib/rubydora/digital_object.rb +31 -33
- data/lib/rubydora/fc3_service.rb +10 -14
- data/lib/rubydora/fedora_url_helpers.rb +21 -22
- data/lib/rubydora/models_mixin.rb +4 -4
- data/lib/rubydora/profile_parser.rb +8 -8
- data/lib/rubydora/relationships_mixin.rb +15 -16
- data/lib/rubydora/repository.rb +11 -11
- data/lib/rubydora/resource_index.rb +10 -14
- data/lib/rubydora/rest_api_client.rb +52 -53
- data/lib/rubydora/transactions.rb +42 -51
- data/rubydora.gemspec +25 -25
- data/spec/audit_trail_spec.rb +1 -1
- data/spec/lib/datastream_spec.rb +34 -32
- data/spec/lib/digital_object_spec.rb +13 -10
- data/spec/lib/integration_test_spec.rb +116 -119
- data/spec/lib/profile_parser_spec.rb +1 -1
- data/spec/lib/repository_spec.rb +5 -5
- data/spec/lib/rest_api_client_spec.rb +60 -66
- data/spec/lib/transactions_spec.rb +4 -6
- data/spec/spec_helper.rb +2 -9
- metadata +30 -31
- data/.gitmodules +0 -0
- data/README.rdoc +0 -79
- data/gemfiles/gemfile.rails3 +0 -11
- data/gemfiles/gemfile.rails4 +0 -10
@@ -2,10 +2,10 @@ module Rubydora
|
|
2
2
|
|
3
3
|
# This class represents a Fedora object and provides
|
4
4
|
# helpers for managing attributes, datastreams, and
|
5
|
-
# relationships.
|
5
|
+
# relationships.
|
6
6
|
#
|
7
|
-
# Using the extension framework, implementors may
|
8
|
-
# provide additional functionality to this base
|
7
|
+
# Using the extension framework, implementors may
|
8
|
+
# provide additional functionality to this base
|
9
9
|
# implementation.
|
10
10
|
class DigitalObject
|
11
11
|
extend ActiveModel::Callbacks
|
@@ -18,14 +18,14 @@ module Rubydora
|
|
18
18
|
extend Deprecation
|
19
19
|
|
20
20
|
attr_reader :pid
|
21
|
-
|
21
|
+
|
22
22
|
# mapping object parameters to profile elements
|
23
23
|
OBJ_ATTRIBUTES = {:state => :objState, :ownerId => :objOwnerId, :label => :objLabel, :logMessage => nil, :lastModifiedDate => :objLastModDate, :createdDate => :objCreateDate }
|
24
24
|
|
25
25
|
OBJ_DEFAULT_ATTRIBUTES = { }
|
26
26
|
|
27
27
|
define_attribute_methods OBJ_ATTRIBUTES.keys
|
28
|
-
|
28
|
+
|
29
29
|
OBJ_ATTRIBUTES.each do |attribute, profile_name|
|
30
30
|
class_eval <<-RUBY
|
31
31
|
def #{attribute.to_s}
|
@@ -39,7 +39,7 @@ module Rubydora
|
|
39
39
|
RUBY
|
40
40
|
end
|
41
41
|
|
42
|
-
def state=
|
42
|
+
def state=(val)
|
43
43
|
raise ArgumentError, "Allowed values for state are 'I', 'A' and 'D'. You provided '#{val}'" unless ['I', 'A', 'D'].include?(val)
|
44
44
|
state_will_change! unless val == state
|
45
45
|
@state = val
|
@@ -49,8 +49,8 @@ module Rubydora
|
|
49
49
|
#
|
50
50
|
# @param [String] pid
|
51
51
|
# @param [Rubydora::Repository] context
|
52
|
-
# @raise [RecordNotFound] if the record is not found in Fedora
|
53
|
-
def self.find
|
52
|
+
# @raise [RecordNotFound] if the record is not found in Fedora
|
53
|
+
def self.find(pid, repository = nil, options = {})
|
54
54
|
obj = self.new pid, repository, options
|
55
55
|
if obj.new?
|
56
56
|
raise Rubydora::RecordNotFound, "DigitalObject.find called for an object that doesn't exist"
|
@@ -63,7 +63,7 @@ module Rubydora
|
|
63
63
|
# @param [String] pid
|
64
64
|
# @param [Rubydora::Repository] repository context
|
65
65
|
# @param [Hash] options default attribute values (used esp. for creating new datastreams
|
66
|
-
def self.find_or_initialize
|
66
|
+
def self.find_or_initialize(*args)
|
67
67
|
self.new *args
|
68
68
|
end
|
69
69
|
|
@@ -71,7 +71,7 @@ module Rubydora
|
|
71
71
|
# @param [String] pid
|
72
72
|
# @param [Hash] options
|
73
73
|
# @param [Rubydora::Repository] context
|
74
|
-
def self.create
|
74
|
+
def self.create(pid, options = {}, repository = nil)
|
75
75
|
repository ||= Rubydora.repository
|
76
76
|
assigned_pid = repository.ingest(options.merge(:pid => pid))
|
77
77
|
|
@@ -83,11 +83,11 @@ module Rubydora
|
|
83
83
|
# may not already exist in the data store.
|
84
84
|
#
|
85
85
|
# Provides `after_initialize` callback for extensions
|
86
|
-
#
|
86
|
+
#
|
87
87
|
# @param [String] pid
|
88
88
|
# @param [Rubydora::Repository] repository context
|
89
89
|
# @param [Hash] options default attribute values (used esp. for creating new datastreams
|
90
|
-
def initialize
|
90
|
+
def initialize(pid, repository = nil, options = {})
|
91
91
|
run_callbacks :initialize do
|
92
92
|
self.pid = pid
|
93
93
|
@repository = repository
|
@@ -103,7 +103,6 @@ module Rubydora
|
|
103
103
|
@audit_trail ||= repository.audit_trail(self.pid)
|
104
104
|
end
|
105
105
|
|
106
|
-
|
107
106
|
##
|
108
107
|
# Return a full uri pid (for use in relations, etc
|
109
108
|
def uri
|
@@ -119,15 +118,15 @@ module Rubydora
|
|
119
118
|
end
|
120
119
|
alias :new? :new_record?
|
121
120
|
|
122
|
-
def asOfDateTime
|
123
|
-
if asOfDateTime
|
121
|
+
def asOfDateTime(asOfDateTime = nil)
|
122
|
+
if asOfDateTime.nil?
|
124
123
|
return @asOfDateTime
|
125
124
|
end
|
126
125
|
|
127
|
-
|
126
|
+
self.class.new(pid, @repository, @options.merge(:asOfDateTime => asOfDateTime))
|
128
127
|
end
|
129
128
|
|
130
|
-
def asOfDateTime=
|
129
|
+
def asOfDateTime=(val)
|
131
130
|
@asOfDateTime = val
|
132
131
|
end
|
133
132
|
|
@@ -142,16 +141,15 @@ module Rubydora
|
|
142
141
|
|
143
142
|
def versions
|
144
143
|
repository.versions_for_object(pid).map do |changeDate|
|
145
|
-
self.class.new pid, repository, :asOfDateTime => changeDate
|
144
|
+
self.class.new pid, repository, :asOfDateTime => changeDate
|
146
145
|
end
|
147
146
|
end
|
148
147
|
|
149
|
-
|
150
148
|
# List of datastreams
|
151
|
-
# @return [Array<Rubydora::Datastream>]
|
149
|
+
# @return [Array<Rubydora::Datastream>]
|
152
150
|
def datastreams
|
153
151
|
@datastreams ||= begin
|
154
|
-
h = Hash.new { |h,k| h[k] = datastream_object_for(k) }
|
152
|
+
h = Hash.new { |h,k| h[k] = datastream_object_for(k) }
|
155
153
|
|
156
154
|
begin
|
157
155
|
options = { :pid => pid, :profiles => 'true' }
|
@@ -160,8 +158,8 @@ module Rubydora
|
|
160
158
|
# pre-3.6, the profiles parm will be ignored
|
161
159
|
datastreams_xml.gsub! '<objectDatastreams', '<objectDatastreams xmlns="http://www.fedora.info/definitions/1/0/access/"' unless datastreams_xml =~ /xmlns=/
|
162
160
|
doc = Nokogiri::XML(datastreams_xml)
|
163
|
-
doc.xpath('//access:datastream', {'access' => "http://www.fedora.info/definitions/1/0/access/"}).each do |ds|
|
164
|
-
h[ds['dsid']] = datastream_object_for ds['dsid']
|
161
|
+
doc.xpath('//access:datastream', {'access' => "http://www.fedora.info/definitions/1/0/access/"}).each do |ds|
|
162
|
+
h[ds['dsid']] = datastream_object_for ds['dsid']
|
165
163
|
end
|
166
164
|
# post-3.6, full ds profiles will be returned
|
167
165
|
doc.xpath('//access:datastreamProfile', {'access' => "http://www.fedora.info/definitions/1/0/access/"}).each do |ds|
|
@@ -176,18 +174,18 @@ module Rubydora
|
|
176
174
|
end
|
177
175
|
alias_method :datastream, :datastreams
|
178
176
|
|
179
|
-
# provide an hash-like way to access datastreams
|
180
|
-
def fetch
|
177
|
+
# provide an hash-like way to access datastreams
|
178
|
+
def fetch(dsid)
|
181
179
|
datastreams[dsid]
|
182
180
|
end
|
183
181
|
alias_method :[], :fetch
|
184
182
|
|
185
|
-
# persist the object to Fedora, either as a new object
|
183
|
+
# persist the object to Fedora, either as a new object
|
186
184
|
# by modifing the existing object
|
187
185
|
#
|
188
|
-
# also will save all `:changed?` datastreams that already exist
|
186
|
+
# also will save all `:changed?` datastreams that already exist
|
189
187
|
# new datastreams must be directly saved
|
190
|
-
#
|
188
|
+
#
|
191
189
|
# @return [Rubydora::DigitalObject] a new copy of this object
|
192
190
|
def save
|
193
191
|
check_if_read_only
|
@@ -196,7 +194,7 @@ module Rubydora
|
|
196
194
|
if self.new?
|
197
195
|
self.pid = repository.ingest to_api_params.merge(:pid => pid)
|
198
196
|
@profile = nil #will cause a reload with updated data
|
199
|
-
else
|
197
|
+
else
|
200
198
|
p = to_api_params
|
201
199
|
unless p.empty?
|
202
200
|
mod_time = repository.modify_object p.merge(:pid => pid)
|
@@ -237,11 +235,11 @@ module Rubydora
|
|
237
235
|
# set the pid of the object
|
238
236
|
# @param [String] pid
|
239
237
|
# @return [String] the base pid
|
240
|
-
def pid=
|
238
|
+
def pid=(pid=nil)
|
241
239
|
@pid = pid.gsub('info:fedora/', '') if pid
|
242
240
|
end
|
243
241
|
|
244
|
-
# datastream parameters
|
242
|
+
# datastream parameters
|
245
243
|
# @return [Hash]
|
246
244
|
def to_api_params
|
247
245
|
h = default_api_params
|
@@ -261,7 +259,7 @@ module Rubydora
|
|
261
259
|
# instantiate a datastream object for a dsid
|
262
260
|
# @param [String] dsid
|
263
261
|
# @return [Datastream]
|
264
|
-
def datastream_object_for
|
262
|
+
def datastream_object_for(dsid, options = {})
|
265
263
|
options[:asOfDateTime] ||= asOfDateTime if asOfDateTime
|
266
264
|
Datastream.new self, dsid, options
|
267
265
|
end
|
@@ -271,7 +269,7 @@ module Rubydora
|
|
271
269
|
end
|
272
270
|
|
273
271
|
private
|
274
|
-
def attribute_will_change!
|
272
|
+
def attribute_will_change!(*args)
|
275
273
|
check_if_read_only
|
276
274
|
super
|
277
275
|
end
|
data/lib/rubydora/fc3_service.rb
CHANGED
@@ -23,28 +23,24 @@ module Rubydora
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
26
|
# repository profile (from API-A-LITE data)
|
28
27
|
# @return [Hash]
|
29
28
|
def repository_profile
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
h[key] = value.first
|
36
|
-
end
|
37
|
-
|
38
|
-
h
|
39
|
-
rescue
|
40
|
-
nil
|
29
|
+
profile_xml = self.describe.strip
|
30
|
+
h = ProfileParser.parse_repository_profile(profile_xml)
|
31
|
+
h.select { |key, value| value.length == 1 }.each do |key, value|
|
32
|
+
next if key == 'objModels'
|
33
|
+
h[key] = value.first
|
41
34
|
end
|
35
|
+
h
|
36
|
+
rescue
|
37
|
+
nil
|
42
38
|
end
|
43
39
|
|
44
40
|
def object_profile(pid, asOfDateTime = nil)
|
45
41
|
options = {pid: pid}
|
46
42
|
options[:asOfDateTime] = asOfDateTime if asOfDateTime
|
47
|
-
begin
|
43
|
+
begin
|
48
44
|
xml = object(options)
|
49
45
|
ProfileParser.parse_object_profile(xml)
|
50
46
|
rescue RestClient::ResourceNotFound
|
@@ -54,7 +50,7 @@ module Rubydora
|
|
54
50
|
|
55
51
|
def datastream_profile(pid, dsid, validateChecksum, asOfDateTime = nil)
|
56
52
|
xml = begin
|
57
|
-
options = {
|
53
|
+
options = {pid: pid, dsid: dsid}
|
58
54
|
options[:validateChecksum] = validateChecksum if validateChecksum
|
59
55
|
options[:asOfDateTime] = asOfDateTime if asOfDateTime
|
60
56
|
options[:validateChecksum] = true if config[:validateChecksum]
|
@@ -2,17 +2,17 @@ module Rubydora
|
|
2
2
|
module FedoraUrlHelpers
|
3
3
|
# Fedora API documentation available at {https://wiki.duraspace.org/display/FCR30/REST+API}
|
4
4
|
API_DOCUMENTATION = 'https://wiki.duraspace.org/display/FCR30/REST+API'
|
5
|
-
|
6
|
-
# Generate a REST API compatible URI
|
5
|
+
|
6
|
+
# Generate a REST API compatible URI
|
7
7
|
# @param [String] base base URI
|
8
8
|
# @param [Hash] options to convert to URL parameters
|
9
9
|
# @return [String] URI
|
10
|
-
def url_for
|
10
|
+
def url_for(base, options = nil)
|
11
11
|
return base unless options.is_a? Hash
|
12
|
-
"#{base}" + (("?#{options.map { |key, value| "#{CGI::escape(key.to_s)}=#{CGI::escape(value.to_s)}"}.join("&") }" if options
|
12
|
+
"#{base}" + (("?#{options.map { |key, value| "#{CGI::escape(key.to_s)}=#{CGI::escape(value.to_s)}"}.join("&") }" if options && !options.empty?) || '')
|
13
13
|
end
|
14
14
|
|
15
|
-
def describe_repository_url
|
15
|
+
def describe_repository_url(options = nil)
|
16
16
|
url_for("describe", options)
|
17
17
|
end
|
18
18
|
|
@@ -20,23 +20,23 @@ module Rubydora
|
|
20
20
|
# @param [String] pid
|
21
21
|
# @param [Hash] options to convert to URL parameters
|
22
22
|
# @return [String] URI
|
23
|
-
def object_url
|
23
|
+
def object_url(pid, options = nil)
|
24
24
|
url_for("objects" + (("/#{CGI::escape(pid.to_s.gsub('info:fedora/', ''))}" if pid) || ''), options)
|
25
25
|
end
|
26
26
|
|
27
|
-
def new_object_url
|
27
|
+
def new_object_url(options = nil)
|
28
28
|
object_url "new", options
|
29
29
|
end
|
30
30
|
|
31
31
|
# @param [Hash] options to convert to URL parameters
|
32
32
|
# @return [String] URI
|
33
|
-
def next_pid_url
|
33
|
+
def next_pid_url(options = nil)
|
34
34
|
url_for("objects/nextPID", options)
|
35
35
|
end
|
36
36
|
|
37
37
|
# @param [Hash] options to convert to URL parameters
|
38
38
|
# @return [String] URI
|
39
|
-
def find_objects_url
|
39
|
+
def find_objects_url(options = nil)
|
40
40
|
url_for("objects", options)
|
41
41
|
end
|
42
42
|
|
@@ -46,7 +46,7 @@ module Rubydora
|
|
46
46
|
# @param [String] method
|
47
47
|
# @param [Hash] options to convert to URL parameters
|
48
48
|
# @return [String] URI
|
49
|
-
def dissemination_url
|
49
|
+
def dissemination_url(pid, sdef = nil, method = nil, options = nil)
|
50
50
|
raise ArgumentError, "You must provide a pid" unless pid
|
51
51
|
url_for(object_url(pid) + "/methods" + (("/#{CGI::escape(sdef)}" if sdef) || '') + (("/#{CGI::escape(method)}" if method) || ''), options)
|
52
52
|
end
|
@@ -56,18 +56,17 @@ module Rubydora
|
|
56
56
|
# @param [String] dsid
|
57
57
|
# @param [Hash] options to convert to URL parameters
|
58
58
|
# @return [String] URI
|
59
|
-
def datastream_url
|
60
|
-
raise ArgumentError, "You must provide a pid and a dsid" unless pid
|
59
|
+
def datastream_url(pid, dsid, options = nil)
|
60
|
+
raise ArgumentError, "You must provide a pid and a dsid" unless pid && dsid
|
61
61
|
url_for(object_url(pid) + "/datastreams/#{CGI::escape(dsid)}", options)
|
62
62
|
end
|
63
63
|
|
64
|
-
|
65
64
|
# Generate a base datastream REST API endpoint URI
|
66
65
|
# @param [String] pid
|
67
66
|
# @param [String] dsid
|
68
67
|
# @param [Hash] options to convert to URL parameters
|
69
68
|
# @return [String] URI
|
70
|
-
def datastreams_url
|
69
|
+
def datastreams_url(pid, options = nil)
|
71
70
|
raise ArgumentError, "You must provide a pid" unless pid
|
72
71
|
url_for(object_url(pid) + "/datastreams", options)
|
73
72
|
end
|
@@ -76,7 +75,7 @@ module Rubydora
|
|
76
75
|
# @param [String] dsid
|
77
76
|
# @param [Hash] options to convert to URL parameters
|
78
77
|
# @return [String] URI
|
79
|
-
def datastream_content_url
|
78
|
+
def datastream_content_url(pid, dsid = nil, options = nil)
|
80
79
|
url_for(datastream_url(pid, dsid) + "/content", options)
|
81
80
|
end
|
82
81
|
|
@@ -84,49 +83,49 @@ module Rubydora
|
|
84
83
|
# @param [String] dsid
|
85
84
|
# @param [Hash] options to convert to URL parameters
|
86
85
|
# @return [String] URI
|
87
|
-
def datastream_history_url
|
86
|
+
def datastream_history_url(pid, dsid = nil, options = nil)
|
88
87
|
url_for(datastream_url(pid, dsid) + "/history", options)
|
89
88
|
end
|
90
89
|
|
91
90
|
# @param [String] pid
|
92
91
|
# @param [Hash] options to convert to URL parameters
|
93
92
|
# @return [String] URI
|
94
|
-
def validate_object_url
|
93
|
+
def validate_object_url(pid, options = nil)
|
95
94
|
url_for(object_url(pid) + "/validate", options)
|
96
95
|
end
|
97
96
|
|
98
97
|
# @param [String] pid
|
99
98
|
# @param [Hash] options to convert to URL parameters
|
100
99
|
# @return [String] URI
|
101
|
-
def export_object_url
|
100
|
+
def export_object_url(pid, options = nil)
|
102
101
|
url_for(object_url(pid) + "/export", options)
|
103
102
|
end
|
104
103
|
|
105
104
|
# @param [String] pid
|
106
105
|
# @param [Hash] options to convert to URL parameters
|
107
106
|
# @return [String] URI
|
108
|
-
def object_versions_url
|
107
|
+
def object_versions_url(pid, options = nil)
|
109
108
|
url_for(object_url(pid) + "/versions", options)
|
110
109
|
end
|
111
110
|
|
112
111
|
# @param [String] pid
|
113
112
|
# @param [Hash] options to convert to URL parameters
|
114
113
|
# @return [String] URI
|
115
|
-
def object_xml_url
|
114
|
+
def object_xml_url(pid, options = nil)
|
116
115
|
url_for(object_url(pid) + "/objectXML", options)
|
117
116
|
end
|
118
117
|
|
119
118
|
# @param [String] pid
|
120
119
|
# @param [Hash] options to convert to URL parameters
|
121
120
|
# @return [String] URI
|
122
|
-
def object_relationship_url
|
121
|
+
def object_relationship_url(pid, options = nil)
|
123
122
|
url_for(object_url(pid) + "/relationships", options)
|
124
123
|
end
|
125
124
|
|
126
125
|
# @param [String] pid
|
127
126
|
# @param [Hash] options to convert to URL parameters
|
128
127
|
# @return [String] URI
|
129
|
-
def new_object_relationship_url
|
128
|
+
def new_object_relationship_url(pid, options = nil)
|
130
129
|
url_for(object_relationship_url(pid) + "/new", options)
|
131
130
|
end
|
132
131
|
end
|
@@ -4,18 +4,18 @@ module Rubydora
|
|
4
4
|
# FIXME: Ruby 1.9 provides instance_exec, which should make it
|
5
5
|
# possible to subsume this into Rubydora::RelationshipsMixin
|
6
6
|
module ModelsMixin
|
7
|
-
|
7
|
+
|
8
8
|
# Provides an accessor to the object content models
|
9
9
|
# @param [Hash] args
|
10
10
|
# @option args [Array] :values if nil, will query the resource index for related objects
|
11
|
-
# @return [ArrayWithCallback<Rubydora::DigitalObject>] an array that will call the #relationship_changed callback when values are modified
|
12
|
-
def models
|
11
|
+
# @return [ArrayWithCallback<Rubydora::DigitalObject>] an array that will call the #relationship_changed callback when values are modified
|
12
|
+
def models(args = {})
|
13
13
|
@models = nil if args.delete(:refetch)
|
14
14
|
@models ||= relationship('info:fedora/fedora-system:def/model#hasModel', :values => args[:values] || profile['objModels'] || [])
|
15
15
|
end
|
16
16
|
|
17
17
|
# provides a setter that behaves as does #models
|
18
|
-
def models=
|
18
|
+
def models=(arr)
|
19
19
|
arr &&= [arr] unless arr.is_a? Array
|
20
20
|
old = models.dup || []
|
21
21
|
arr = @models = relationship('info:fedora/fedora-system:def/model#hasModel', :values => arr.flatten)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Rubydora
|
2
2
|
module ProfileParser
|
3
|
-
def self.parse_datastream_profile
|
3
|
+
def self.parse_datastream_profile(profile_xml)
|
4
4
|
# since the profile may be in the management or the access namespace, use the CSS selector
|
5
5
|
ndoc = Nokogiri::XML(profile_xml)
|
6
6
|
doc = (ndoc.name == 'datastreamProfile') ? ndoc : ndoc.css('datastreamProfile').first
|
@@ -12,24 +12,24 @@ module Rubydora
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.hash_datastream_profile_node
|
15
|
+
def self.hash_datastream_profile_node(doc)
|
16
16
|
h = doc.xpath('./*').inject({}) do |sum, node|
|
17
17
|
sum[node.name] ||= []
|
18
18
|
sum[node.name] << node.text
|
19
19
|
sum
|
20
|
-
end.reject { |key, values| values.nil?
|
20
|
+
end.reject { |key, values| values.nil? || values.empty? }
|
21
21
|
h.select { |key, values| values.length == 1 }.each do |key, values|
|
22
|
-
h[key] = values.reject { |x| x.empty? }.first
|
22
|
+
h[key] = values.reject { |x| x.empty? }.first
|
23
23
|
end
|
24
24
|
|
25
25
|
h['dsSize'] &&= h['dsSize'].to_i rescue h['dsSize']
|
26
26
|
h['dsCreateDate'] &&= Time.parse(h['dsCreateDate']) rescue h['dsCreateDate']
|
27
|
-
h['dsChecksumValid'] &&= h['dsChecksumValid'] == 'true'
|
28
|
-
h['dsVersionable'] &&= h['dsVersionable'] == 'true'
|
27
|
+
h['dsChecksumValid'] &&= h['dsChecksumValid'] == 'true'
|
28
|
+
h['dsVersionable'] &&= h['dsVersionable'] == 'true'
|
29
29
|
h.with_indifferent_access
|
30
30
|
end
|
31
31
|
|
32
|
-
def self.parse_object_profile
|
32
|
+
def self.parse_object_profile(profile_xml)
|
33
33
|
profile_xml.gsub! '<objectProfile', '<objectProfile xmlns="http://www.fedora.info/definitions/1/0/access/"' unless profile_xml =~ /xmlns=/
|
34
34
|
doc = Nokogiri::XML(profile_xml)
|
35
35
|
h = doc.xpath('/access:objectProfile/*', {'access' => "http://www.fedora.info/definitions/1/0/access/"} ).inject({}) do |sum, node|
|
@@ -50,7 +50,7 @@ module Rubydora
|
|
50
50
|
h.with_indifferent_access
|
51
51
|
end
|
52
52
|
|
53
|
-
def self.parse_repository_profile
|
53
|
+
def self.parse_repository_profile(profile_xml)
|
54
54
|
profile_xml.gsub! '<fedoraRepository', '<fedoraRepository xmlns="http://www.fedora.info/definitions/1/0/access/"' unless profile_xml =~ /xmlns=/
|
55
55
|
doc = Nokogiri::XML(profile_xml)
|
56
56
|
xmlns = { 'access' => "http://www.fedora.info/definitions/1/0/access/" }
|