rubydora 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -59,7 +59,7 @@ module Rubydora
59
59
  # @param [Rubydora::Repository] repository context
60
60
  # @param [Hash] options default attribute values (used esp. for creating new datastreams
61
61
  def initialize pid, repository = nil, options = {}
62
- @pid = pid
62
+ @pid = pid.gsub('info:fedora/', '')
63
63
  @repository = repository
64
64
 
65
65
  options.each do |key, value|
@@ -82,7 +82,7 @@ module Rubydora::Ext
82
82
  def datastreams_to_solr doc
83
83
  datastreams.each do |dsid, ds|
84
84
  doc['disseminates_s'] ||= []
85
- doc['disseminates_s'] << [dsid]
85
+ doc['disseminates_s'] << dsid
86
86
  ds.to_solr(doc)
87
87
  end
88
88
  end
@@ -1,18 +1,9 @@
1
1
  module Rubydora::RestApiClient
2
2
  # Fall-back implementations for fcrepo < 3.4
3
3
  module V33
4
- # SOAP API endpoint
5
- # @return [SOAP::WSDLDriverFactory]
6
- def soap
7
- return @soap if @soap
8
- gem "soap4r"
9
- require 'soap/wsdlDriver'
10
-
11
- @soap = SOAP::WSDLDriverFactory.new("#{ config[:url] }/wsdl?api=API-M").create_rpc_driver
12
- @soap.options['protocol.http.basic_auth'] << [config[:url], config[:user], config[:password]]
13
-
14
- @soap
15
-
4
+ # @param [Rubydora::Repository] repository
5
+ def self.extended repository
6
+ repository.send(:extend, Rubydora::Soap)
16
7
  end
17
8
 
18
9
  # {include:RestApiClient#relationships}
@@ -0,0 +1,21 @@
1
+ module Rubydora
2
+ # Fedora SOAP API extension
3
+ module Soap
4
+ # @param [Rubydora::Repository] repository
5
+ def self.extended repository
6
+ gem "soap4r"
7
+ require 'soap/wsdlDriver'
8
+ end
9
+
10
+ # SOAP API endpoint
11
+ # @return [SOAP::RPC::Driver]
12
+ def soap
13
+ return @soap if @soap
14
+
15
+ @soap = SOAP::WSDLDriverFactory.new("#{ config[:url] }/wsdl?api=API-M").create_rpc_driver
16
+ @soap.options['protocol.http.basic_auth'] << [config[:url], config[:user], config[:password]]
17
+
18
+ @soap
19
+ end
20
+ end
21
+ end
data/lib/rubydora.rb CHANGED
@@ -4,6 +4,7 @@ module Rubydora
4
4
  autoload :Repository, "rubydora/repository"
5
5
  autoload :ResourceIndex, "rubydora/resource_index"
6
6
  autoload :RestApiClient, "rubydora/rest_api_client"
7
+ autoload :Soap, "rubydora/soap"
7
8
  autoload :ModelsMixin, "rubydora/models_mixin"
8
9
  autoload :Ext, "rubydora/ext"
9
10
  autoload :RelationshipsMixin, "rubydora/relationships_mixin"
data/rubydora.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rubydora}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Chris Beer"]
12
- s.date = %q{2011-04-19}
12
+ s.date = %q{2011-04-21}
13
13
  s.description = %q{Fedora Commons REST API ruby library : REQUIRES FCREPO 3.4+}
14
14
  s.email = %q{chris@cbeer.info}
15
15
  s.extra_rdoc_files = [
@@ -37,6 +37,7 @@ Gem::Specification.new do |s|
37
37
  "lib/rubydora/resource_index.rb",
38
38
  "lib/rubydora/rest_api_client.rb",
39
39
  "lib/rubydora/rest_api_client/v33.rb",
40
+ "lib/rubydora/soap.rb",
40
41
  "rubydora.gemspec",
41
42
  "spec/datastream_spec.rb",
42
43
  "spec/digital_object_spec.rb",
@@ -47,6 +48,7 @@ Gem::Specification.new do |s|
47
48
  "spec/repository_spec.rb",
48
49
  "spec/resource_index_spec.rb",
49
50
  "spec/rest_api_client_spec.rb",
51
+ "spec/soap_spec.rb",
50
52
  "spec/spec_helper.rb"
51
53
  ]
52
54
  s.homepage = %q{http://github.com/cbeer/rubydora}
@@ -64,6 +66,7 @@ Gem::Specification.new do |s|
64
66
  "spec/repository_spec.rb",
65
67
  "spec/resource_index_spec.rb",
66
68
  "spec/rest_api_client_spec.rb",
69
+ "spec/soap_spec.rb",
67
70
  "spec/spec_helper.rb"
68
71
  ]
69
72
 
@@ -2,9 +2,11 @@ require 'spec_helper'
2
2
  require 'rubydora/ext/solr'
3
3
 
4
4
  describe Rubydora::Ext::Solr do
5
+ before(:all) do
6
+ Rubydora::Ext::Solr.load
7
+ end
5
8
  describe "load" do
6
9
  it "should load mixins" do
7
- Rubydora::Ext::Solr.load
8
10
  @mock_repository = mock(Rubydora::Repository)
9
11
  obj = Rubydora::DigitalObject.new('pid', @mock_repository)
10
12
  obj.should be_a_kind_of(Rubydora::Ext::Solr::DigitalObjectMixin)
@@ -45,7 +47,6 @@ describe Rubydora::Ext::Solr do
45
47
  @object = Rubydora::DigitalObject.new('pid', @mock_repository)
46
48
  end
47
49
  it "should call the members of solr_mapping_logic" do
48
-
49
50
  @object.should_receive(:solr_mapping_logic).and_return([:mock_solr_step, :another_mock_solr_step])
50
51
  @object.should_receive(:mock_solr_step)
51
52
  @object.should_receive(:another_mock_solr_step)
@@ -66,5 +67,78 @@ describe Rubydora::Ext::Solr do
66
67
  @object.to_solr.should == { :a => 'a', :b => 'b'}
67
68
  end
68
69
  end
70
+
71
+ describe "object_profile_to_solr" do
72
+ before(:each) do
73
+ @mock_repository = mock(Rubydora::Repository)
74
+ @object = Rubydora::DigitalObject.new('pid', @mock_repository)
75
+ end
76
+
77
+ it "should map the pid and id" do
78
+ @object.should_receive(:profile).and_return({})
79
+ doc = {}
80
+ @object.object_profile_to_solr(doc)
81
+
82
+ doc['id'].should == 'pid'
83
+ doc['pid_s'].should == 'pid'
84
+ end
85
+
86
+ it "should map the profile hash to generic document fields" do
87
+ @object.should_receive(:profile).and_return({'a' => 1, 'b' => 2})
88
+ doc = {}
89
+ @object.object_profile_to_solr(doc)
90
+ doc['a_s'].should == 1
91
+ doc['b_s'].should == 2
92
+ end
93
+ end
94
+
95
+ describe "datastreams_to_solr" do
96
+ before(:each) do
97
+ @mock_repository = mock(Rubydora::Repository)
98
+ @object = Rubydora::DigitalObject.new('pid', @mock_repository)
99
+ end
100
+
101
+ it "should map the list of datastreams" do
102
+ @mock_ds = mock(Rubydora::Datastream)
103
+ @mock_ds2 = mock(Rubydora::Datastream)
104
+
105
+ @mock_ds.should_receive(:to_solr).with(instance_of(Hash))
106
+ @mock_ds2.should_receive(:to_solr).with(instance_of(Hash))
107
+ @object.should_receive(:datastreams).and_return(:a => @mock_ds, :b => @mock_ds2)
108
+ doc = {}
109
+ @object.datastreams_to_solr(doc)
110
+
111
+ doc['disseminates_s'].should == [:a, :b]
112
+ end
113
+
114
+ it "should let the datastreams inject any document attributes" do
115
+ @mock_ds = mock(Rubydora::Datastream)
116
+
117
+ @mock_ds.should_receive(:to_solr) do |doc|
118
+ doc['a'] = 1
119
+ end
120
+ @object.should_receive(:datastreams).and_return(:a => @mock_ds)
121
+ doc = {}
122
+ @object.datastreams_to_solr(doc)
123
+
124
+ doc['a'].should == 1
125
+ end
126
+ end
127
+
128
+ describe "relations_to_solr" do
129
+ before(:each) do
130
+ @mock_repository = mock(Rubydora::Repository)
131
+ @object = Rubydora::DigitalObject.new('pid', @mock_repository)
132
+ end
133
+
134
+ it "should lazily map relationships from SPARQL" do
135
+ @object.repository.should_receive(:sparql).and_return([{'relation' => '...#isPartOf', 'object' => 'info:fedora/test:pid'}])
136
+ doc = {}
137
+ @object.relations_to_solr(doc)
138
+ doc['ri_isPartOf_s'].should == ['info:fedora/test:pid']
139
+ end
140
+ end
141
+
142
+
69
143
  end
70
144
 
@@ -69,6 +69,11 @@ end
69
69
  @mock_repository = ApiAbstractionTestClass.new
70
70
  @mock_repository.should be_a_kind_of(Rubydora::RestApiClient::V33)
71
71
  end
72
+
73
+ it "should automatically load the SOAP endpoint when needed" do
74
+ @mock_repository = ApiAbstractionTestClass.new
75
+ @mock_repository.should be_a_kind_of(Rubydora::Soap)
76
+ end
72
77
  end
73
78
 
74
79
  describe "find_by_sparql" do
data/spec/soap_spec.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rubydora::Soap do
4
+ before(:all) do
5
+ @repository = Rubydora.connect({ :url => 'http://localhost:8080/fedora', :user => 'fedoraAdmin', :password => 'fedoraAdmin' })
6
+ @repository.send(:extend, Rubydora::Soap)
7
+ end
8
+
9
+ it "should provide a SOAP endpoint accessor" do
10
+ @repository.soap.should be_a_kind_of(SOAP::RPC::Driver)
11
+ end
12
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubydora
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Chris Beer
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-19 00:00:00 -04:00
18
+ date: 2011-04-21 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -192,6 +192,7 @@ files:
192
192
  - lib/rubydora/resource_index.rb
193
193
  - lib/rubydora/rest_api_client.rb
194
194
  - lib/rubydora/rest_api_client/v33.rb
195
+ - lib/rubydora/soap.rb
195
196
  - rubydora.gemspec
196
197
  - spec/datastream_spec.rb
197
198
  - spec/digital_object_spec.rb
@@ -202,6 +203,7 @@ files:
202
203
  - spec/repository_spec.rb
203
204
  - spec/resource_index_spec.rb
204
205
  - spec/rest_api_client_spec.rb
206
+ - spec/soap_spec.rb
205
207
  - spec/spec_helper.rb
206
208
  has_rdoc: true
207
209
  homepage: http://github.com/cbeer/rubydora
@@ -247,4 +249,5 @@ test_files:
247
249
  - spec/repository_spec.rb
248
250
  - spec/resource_index_spec.rb
249
251
  - spec/rest_api_client_spec.rb
252
+ - spec/soap_spec.rb
250
253
  - spec/spec_helper.rb