rubydora 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rubydora/digital_object.rb +15 -10
- data/lib/rubydora/resource_index.rb +8 -1
- data/lib/rubydora/rest_api_client.rb +1 -1
- data/spec/digital_object_spec.rb +8 -0
- metadata +28 -28
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
@@ -41,7 +41,7 @@ module Rubydora
|
|
41
41
|
# @param [String] pid
|
42
42
|
# @param [Rubydora::Repository] context
|
43
43
|
def self.find pid, repository = nil
|
44
|
-
|
44
|
+
self.new pid, repository
|
45
45
|
end
|
46
46
|
|
47
47
|
# create a new fedora object (see also DigitalObject#save)
|
@@ -51,7 +51,7 @@ module Rubydora
|
|
51
51
|
def self.create pid, options = {}, repository = nil
|
52
52
|
repository ||= Rubydora.repository
|
53
53
|
assigned_pid = repository.ingest(options.merge(:pid => pid))
|
54
|
-
|
54
|
+
self.new assigned_pid, repository
|
55
55
|
end
|
56
56
|
|
57
57
|
##
|
@@ -121,13 +121,18 @@ module Rubydora
|
|
121
121
|
def datastreams
|
122
122
|
@datastreams ||= begin
|
123
123
|
h = Hash.new { |h,k| h[k] = Datastream.new self, k }
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
124
|
+
|
125
|
+
begin
|
126
|
+
datastreams_xml = repository.datastreams(:pid => pid)
|
127
|
+
datastreams_xml.gsub! '<objectDatastreams', '<objectDatastreams xmlns="http://www.fedora.info/definitions/1/0/access/"' unless datastreams_xml =~ /xmlns=/
|
128
|
+
doc = Nokogiri::XML(datastreams_xml)
|
129
|
+
doc.xpath('//access:datastream', {'access' => "http://www.fedora.info/definitions/1/0/access/"}).each do |ds|
|
130
|
+
h[ds['dsid']] = Datastream.new self, ds['dsid']
|
131
|
+
end
|
132
|
+
rescue RestClient::ResourceNotFound
|
133
|
+
end
|
134
|
+
|
128
135
|
h
|
129
|
-
rescue RestClient::ResourceNotFound
|
130
|
-
h = Hash.new { |h,k| h[k] = Datastream.new self, k }
|
131
136
|
end
|
132
137
|
end
|
133
138
|
alias_method :datastream, :datastreams
|
@@ -176,8 +181,8 @@ module Rubydora
|
|
176
181
|
# set the pid of the object
|
177
182
|
# @param [String] pid
|
178
183
|
# @return [String] the base pid
|
179
|
-
def pid= pid
|
180
|
-
@pid = pid.gsub('info:fedora/', '')
|
184
|
+
def pid= pid=nil
|
185
|
+
@pid = pid.gsub('info:fedora/', '') if pid
|
181
186
|
end
|
182
187
|
|
183
188
|
# datastream parameters
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'enumerator'
|
2
|
+
|
1
3
|
module Rubydora
|
2
4
|
# Fedora resource index helpers
|
3
5
|
module ResourceIndex
|
@@ -7,7 +9,12 @@ module Rubydora
|
|
7
9
|
# @option options [String] :binding the SPARQL binding name to create new objects from
|
8
10
|
# @return [Array<Rubydora::DigitalObject>]
|
9
11
|
def find_by_sparql query, options = { :binding => 'pid' }
|
10
|
-
|
12
|
+
return to_enum(:find_by_sparql, query, options).to_a unless block_given?
|
13
|
+
|
14
|
+
self.sparql(query).each do |x|
|
15
|
+
obj = self.find(x[options[:binding]]) rescue nil
|
16
|
+
yield obj if obj
|
17
|
+
end
|
11
18
|
end
|
12
19
|
|
13
20
|
# Find new objects by their relationship to a subject
|
@@ -12,7 +12,7 @@ module Rubydora
|
|
12
12
|
# @return [RestClient::Resource]
|
13
13
|
def client config = {}
|
14
14
|
config = self.config.merge(config)
|
15
|
-
@client ||= RestClient::Resource.new
|
15
|
+
@client ||= RestClient::Resource.new(config[:url], :user => config[:user], :password => config[:password], :timeout => config[:timeout], :open_timeout => config[:timeout])
|
16
16
|
end
|
17
17
|
|
18
18
|
# {include:RestApiClient::API_DOCUMENTATION}
|
data/spec/digital_object_spec.rb
CHANGED
@@ -43,6 +43,14 @@ describe Rubydora::DigitalObject do
|
|
43
43
|
@mock_repository.should_receive(:ingest).with(hash_including(:pid => 'pid')).and_return('pid')
|
44
44
|
@object.save
|
45
45
|
end
|
46
|
+
|
47
|
+
it "should create a new Fedora object with a generated PID if no PID is provided" do
|
48
|
+
object = Rubydora::DigitalObject.new nil, @mock_repository
|
49
|
+
@mock_repository.should_receive(:ingest).with(hash_including(:pid => nil)).and_return('pid')
|
50
|
+
@mock_repository.should_receive(:datastreams).with(hash_including(:pid => 'pid')).and_raise(RestClient::ResourceNotFound)
|
51
|
+
object.save
|
52
|
+
object.pid.should == 'pid'
|
53
|
+
end
|
46
54
|
end
|
47
55
|
|
48
56
|
describe "create" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubydora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
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-08-30 00:00:00.000000000 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: fastercsv
|
17
|
-
requirement: &
|
17
|
+
requirement: &2160489700 !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: *2160489700
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rest-client
|
28
|
-
requirement: &
|
28
|
+
requirement: &2160489140 !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: *2160489140
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: nokogiri
|
39
|
-
requirement: &
|
39
|
+
requirement: &2160488580 !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: *2160488580
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: mime-types
|
50
|
-
requirement: &
|
50
|
+
requirement: &2160488140 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2160488140
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: activesupport
|
61
|
-
requirement: &
|
61
|
+
requirement: &2160487500 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :runtime
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *2160487500
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: activemodel
|
72
|
-
requirement: &
|
72
|
+
requirement: &2160482940 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: '0'
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *2160482940
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: savon
|
83
|
-
requirement: &
|
83
|
+
requirement: &2160482400 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ! '>='
|
@@ -88,10 +88,10 @@ dependencies:
|
|
88
88
|
version: '0'
|
89
89
|
type: :runtime
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *2160482400
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: rake
|
94
|
-
requirement: &
|
94
|
+
requirement: &2160481860 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
97
97
|
- - ! '>='
|
@@ -99,10 +99,10 @@ dependencies:
|
|
99
99
|
version: '0'
|
100
100
|
type: :development
|
101
101
|
prerelease: false
|
102
|
-
version_requirements: *
|
102
|
+
version_requirements: *2160481860
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: shoulda
|
105
|
-
requirement: &
|
105
|
+
requirement: &2160481260 !ruby/object:Gem::Requirement
|
106
106
|
none: false
|
107
107
|
requirements:
|
108
108
|
- - ! '>='
|
@@ -110,10 +110,10 @@ dependencies:
|
|
110
110
|
version: '0'
|
111
111
|
type: :development
|
112
112
|
prerelease: false
|
113
|
-
version_requirements: *
|
113
|
+
version_requirements: *2160481260
|
114
114
|
- !ruby/object:Gem::Dependency
|
115
115
|
name: bundler
|
116
|
-
requirement: &
|
116
|
+
requirement: &2160480780 !ruby/object:Gem::Requirement
|
117
117
|
none: false
|
118
118
|
requirements:
|
119
119
|
- - ! '>='
|
@@ -121,10 +121,10 @@ dependencies:
|
|
121
121
|
version: '0'
|
122
122
|
type: :development
|
123
123
|
prerelease: false
|
124
|
-
version_requirements: *
|
124
|
+
version_requirements: *2160480780
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rspec
|
127
|
-
requirement: &
|
127
|
+
requirement: &2160480220 !ruby/object:Gem::Requirement
|
128
128
|
none: false
|
129
129
|
requirements:
|
130
130
|
- - ! '>='
|
@@ -132,10 +132,10 @@ dependencies:
|
|
132
132
|
version: '0'
|
133
133
|
type: :development
|
134
134
|
prerelease: false
|
135
|
-
version_requirements: *
|
135
|
+
version_requirements: *2160480220
|
136
136
|
- !ruby/object:Gem::Dependency
|
137
137
|
name: yard
|
138
|
-
requirement: &
|
138
|
+
requirement: &2160479760 !ruby/object:Gem::Requirement
|
139
139
|
none: false
|
140
140
|
requirements:
|
141
141
|
- - ! '>='
|
@@ -143,7 +143,7 @@ dependencies:
|
|
143
143
|
version: '0'
|
144
144
|
type: :development
|
145
145
|
prerelease: false
|
146
|
-
version_requirements: *
|
146
|
+
version_requirements: *2160479760
|
147
147
|
description: ! 'Fedora Commons REST API ruby library : REQUIRES FCREPO 3.4+'
|
148
148
|
email:
|
149
149
|
- chris@cbeer.info
|
@@ -201,7 +201,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
201
201
|
version: '0'
|
202
202
|
segments:
|
203
203
|
- 0
|
204
|
-
hash: -
|
204
|
+
hash: -4272510233954143371
|
205
205
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
206
|
none: false
|
207
207
|
requirements:
|
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
210
|
version: '0'
|
211
211
|
segments:
|
212
212
|
- 0
|
213
|
-
hash: -
|
213
|
+
hash: -4272510233954143371
|
214
214
|
requirements: []
|
215
215
|
rubyforge_project:
|
216
216
|
rubygems_version: 1.6.2
|