active-fedora 3.1.3 → 3.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -75,7 +75,7 @@ As you can see, ActiveFedora.init defaults to using the fedora.yml included in t
75
75
 
76
76
  If you want to use a different yml file, put your info (pointing ActiveFedora to specific Fedora & Solr URLs) into the file and pass its path to ActiveFedora.init:
77
77
 
78
- <pre>ActiveFedora.init("path/to/fedora.yml")</pre>
78
+ <pre>ActiveFedora.init(:fedora_config_path=>"path/to/fedora.yml")</pre>
79
79
 
80
80
  h4. ActiveFedora within Rails
81
81
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active-fedora (3.1.3)
4
+ active-fedora (3.1.4)
5
5
  activeresource (~> 3.0.0)
6
6
  activesupport (~> 3.0.0)
7
7
  equivalent-xml
@@ -13,7 +13,7 @@ PATH
13
13
  om (>= 1.4.3)
14
14
  rdf
15
15
  rdf-rdfxml
16
- rubydora (= 0.2.4)
16
+ rubydora (~> 0.2.6)
17
17
  solr-ruby (>= 0.0.6)
18
18
  solrizer (> 1.0.0)
19
19
  xml-simple (>= 1.0.12)
@@ -42,13 +42,13 @@ GEM
42
42
  nokogiri (>= 1.4.3)
43
43
  facets (2.9.2)
44
44
  fastercsv (1.5.4)
45
- ffi (1.0.10)
45
+ ffi (1.0.11)
46
46
  gyoku (0.4.4)
47
47
  builder (>= 2.1.2)
48
48
  httpi (0.9.5)
49
49
  rack
50
50
  i18n (0.5.0)
51
- jettywrapper (1.0.1)
51
+ jettywrapper (1.1.0)
52
52
  activesupport (>= 3.0.0)
53
53
  childprocess
54
54
  i18n
@@ -87,7 +87,7 @@ GEM
87
87
  ruby-debug-base (~> 0.10.4.0)
88
88
  ruby-debug-base (0.10.4)
89
89
  linecache (>= 0.3)
90
- rubydora (0.2.4)
90
+ rubydora (0.2.6)
91
91
  activemodel
92
92
  activesupport
93
93
  fastercsv
@@ -129,7 +129,7 @@ PLATFORMS
129
129
  DEPENDENCIES
130
130
  RedCloth
131
131
  active-fedora!
132
- jettywrapper (>= 1.0.1)
132
+ jettywrapper (>= 1.1.0)
133
133
  mocha (>= 0.9.8)
134
134
  rake
135
135
  rcov
@@ -1,3 +1,7 @@
1
+ 3.1.4
2
+ Update rubydora to 0.2.6
3
+ Created a consistent implementation of Model.classname_from_uri
4
+
1
5
  3.1.3
2
6
  Set mimeType for all datastreams, default to text/xml
3
7
  Update rubydora to 0.2.4
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
  s.add_dependency("mediashelf-loggable")
28
28
  s.add_dependency("equivalent-xml")
29
29
  s.add_dependency("facets")
30
- s.add_dependency("rubydora", '0.2.4')
30
+ s.add_dependency("rubydora", '~>0.2.6')
31
31
  s.add_dependency("rdf")
32
32
  s.add_dependency("rdf-rdfxml")
33
33
  s.add_development_dependency("yard")
@@ -35,7 +35,7 @@ Gem::Specification.new do |s|
35
35
  s.add_development_dependency("rake")
36
36
  s.add_development_dependency("rcov")
37
37
  s.add_development_dependency("solrizer-fedora", ">=1.1.3") # used by the fixtures rake tasks
38
- s.add_development_dependency("jettywrapper", ">=1.0.1")
38
+ s.add_development_dependency("jettywrapper", ">=1.1.0")
39
39
  s.add_development_dependency("rspec", "<2.0.0")
40
40
  s.add_development_dependency("mocha", ">= 0.9.8")
41
41
  s.add_development_dependency("ruby-debug")
@@ -12,6 +12,7 @@ module ActiveFedora
12
12
  super
13
13
  end
14
14
 
15
+ ### TODO: Shouldn't this be the same as: klass.to_class_uri ? - Justin
15
16
  def self.pid_from_ruby_class(klass,attrs={})
16
17
 
17
18
  unless klass.respond_to? :pid_suffix
@@ -33,7 +34,7 @@ module ActiveFedora
33
34
  end
34
35
 
35
36
  def self.models_asserted_by(obj)
36
- obj.ids_for_outbound(:has_model)
37
+ obj.relationships(:has_model)
37
38
  end
38
39
 
39
40
  def self.known_models_for(obj)
@@ -58,22 +59,11 @@ module ActiveFedora
58
59
  ActiveFedora::Base
59
60
  end
60
61
 
61
- # Returns a ruby class corresponding to the given uri if one can be found.
62
- # Returns false if no corresponding class can be found.
63
- def self.uri_to_ruby_class( uri )
64
- classname = uri.split(':')[-1].titlecase.gsub(' ','')
65
-
66
- if class_exists?(classname)
67
- Kernel.const_get(classname)
68
- else
69
- false
70
- end
71
- end
72
62
 
73
63
  # Returns an ActiveFedora Model class corresponding to the given uri if one can be found.
74
64
  # Returns false if no corresponding model can be found.
75
65
  def self.uri_to_model_class( uri )
76
- rc = uri_to_ruby_class(uri)
66
+ rc = Model.from_class_uri(uri)
77
67
  if rc && rc.superclass == ActiveFedora::Base
78
68
  rc
79
69
  else
@@ -81,14 +71,5 @@ module ActiveFedora
81
71
  end
82
72
  end
83
73
 
84
- private
85
-
86
- def self.class_exists?(class_name)
87
- klass = Module.const_get(class_name)
88
- return klass.is_a?(Class)
89
- rescue NameError
90
- return false
91
- end
92
-
93
74
  end
94
75
  end
@@ -14,16 +14,23 @@ module ActiveFedora
14
14
  klass.extend(ClassMethods)
15
15
  end
16
16
 
17
+ # Takes a Fedora URI for a cModel and returns classname, namespace
18
+ def self.classname_from_uri(uri)
19
+ local_path = uri.split('/')[1]
20
+ parts = local_path.split(':')
21
+ return parts[-1].gsub('_','/').classify, parts[0]
22
+ end
23
+
17
24
  # Takes a Fedora URI for a cModel, and returns a
18
25
  # corresponding Model if available
19
26
  # This method should reverse ClassMethods#to_class_uri
20
27
  def self.from_class_uri(uri)
21
- if match_data = /info:fedora\/([a-zA-z0-9\-_]+):(.+)$/.match(uri)
22
- pid_ns = match_data[1]
23
- model_value = match_data[2]
24
- model_value.gsub!('_', '::')
25
- else
26
- raise "model URI incorrectly formatted: #{uri}"
28
+ model_value, pid_ns = classname_from_uri(uri)
29
+ raise "model URI incorrectly formatted: #{uri}" unless model_value
30
+
31
+ unless class_exists?(model_value)
32
+ logger.warn "#{model_value} is not a real class"
33
+ return false
27
34
  end
28
35
  if model_value.include?("::")
29
36
  result = eval(model_value)
@@ -33,7 +40,7 @@ module ActiveFedora
33
40
  unless result.nil?
34
41
  model_ns = (result.respond_to? :pid_namespace) ? result.pid_namespace : DEFAULT_NS
35
42
  if model_ns != pid_ns
36
- logger.warn "Model class namespace (#{model_ns}) and uri namespace (#{pid_ns}) do not match!"
43
+ logger.warn "Model class namespace '#{model_ns}' does not match uri: '#{uri}'"
37
44
  end
38
45
  end
39
46
  result
@@ -80,6 +87,7 @@ module ActiveFedora
80
87
 
81
88
  # Returns a suitable uri object for :has_model
82
89
  # Should reverse Model#from_class_uri
90
+ ### TODO: shouldn't this reverse ContentModel.pid_from_ruby_class
83
91
  def to_class_uri
84
92
  ns = (self.respond_to? :pid_namespace) ? self.pid_namespace : Model::DEFAULT_NS
85
93
  pid = self.name.gsub(/::/,'_')
@@ -274,5 +282,14 @@ module ActiveFedora
274
282
  END
275
283
  end
276
284
 
285
+ private
286
+
287
+ def self.class_exists?(class_name)
288
+ klass = class_name.constantize
289
+ return klass.is_a?(Class)
290
+ rescue NameError
291
+ return false
292
+ end
293
+
277
294
  end
278
295
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "3.1.3"
2
+ VERSION = "3.1.4"
3
3
  end
@@ -73,12 +73,12 @@ describe ActiveFedora::ContentModel do
73
73
  describe "models_asserted_by" do
74
74
  it "should return an array of all of the content models asserted by the given object" do
75
75
  mock_object = mock("ActiveFedora Object")
76
- mock_object.expects(:ids_for_outbound).with(:has_model).returns(["info:fedora/fedora-system:ServiceDefinition-3.0", "info:fedora/afmodel:SampleModel", "info:fedora/afmodel:NonDefinedModel"])
76
+ mock_object.expects(:relationships).with(:has_model).returns(["info:fedora/fedora-system:ServiceDefinition-3.0", "info:fedora/afmodel:SampleModel", "info:fedora/afmodel:NonDefinedModel"])
77
77
  ActiveFedora::ContentModel.models_asserted_by(mock_object).should == ["info:fedora/fedora-system:ServiceDefinition-3.0", "info:fedora/afmodel:SampleModel", "info:fedora/afmodel:NonDefinedModel"]
78
78
  end
79
79
  it "should return an empty array if the object doesn't have a RELS-EXT datastream" do
80
80
  mock_object = mock("ActiveFedora Object")
81
- mock_object.expects(:ids_for_outbound).with(:has_model).returns([])
81
+ mock_object.expects(:relationships).with(:has_model).returns([])
82
82
  ActiveFedora::ContentModel.models_asserted_by(mock_object).should == []
83
83
  end
84
84
  end
@@ -86,36 +86,27 @@ describe ActiveFedora::ContentModel do
86
86
  describe "known_models_asserted_by" do
87
87
  it "should figure out the applicable models to load" do
88
88
  mock_object = mock("ActiveFedora Object")
89
- mock_object.expects(:ids_for_outbound).with(:has_model).returns(["info:fedora/fedora-system:ServiceDefinition-3.0", "info:fedora/afmodel:SampleModel", "info:fedora/afmodel:NonDefinedModel"])
89
+ mock_object.expects(:relationships).with(:has_model).returns(["info:fedora/fedora-system:ServiceDefinition-3.0", "info:fedora/afmodel:SampleModel", "info:fedora/afmodel:NonDefinedModel"])
90
90
  ActiveFedora::ContentModel.known_models_for(mock_object).should == [SampleModel]
91
91
  end
92
92
  it "should support namespaced models" do
93
93
  pending "This is harder than it looks."
94
94
  mock_object = mock("ActiveFedora Object")
95
- mock_object.expects(:ids_for_outbound).with(:has_model).returns(["info:fedora/afmodel:Sample_NamespacedModel"])
95
+ mock_object.expects(:relationships).with(:has_model).returns(["info:fedora/afmodel:Sample_NamespacedModel"])
96
96
  ActiveFedora::ContentModel.known_models_for(mock_object).should == [Sample::NamespacedModel]
97
97
  end
98
98
  it "should default to using ActiveFedora::Base as the model" do
99
99
  mock_object = mock("ActiveFedora Object")
100
- mock_object.expects(:ids_for_outbound).with(:has_model).returns(["info:fedora/afmodel:NonDefinedModel"])
100
+ mock_object.expects(:relationships).with(:has_model).returns(["info:fedora/afmodel:NonDefinedModel"])
101
101
  ActiveFedora::ContentModel.known_models_for(mock_object).should == [ActiveFedora::Base]
102
102
  end
103
103
  it "should still work even if the object doesn't have a RELS-EXT datastream" do
104
104
  mock_object = mock("ActiveFedora Object")
105
- mock_object.expects(:ids_for_outbound).with(:has_model).returns([])
105
+ mock_object.expects(:relationships).with(:has_model).returns([])
106
106
  ActiveFedora::ContentModel.known_models_for(mock_object).should == [ActiveFedora::Base]
107
107
  end
108
108
  end
109
109
 
110
- describe "uri_to_ruby_class" do
111
- it "should return ruby class corresponding to the given uri if a valid class can be found" do
112
- ActiveFedora::ContentModel.uri_to_ruby_class("info:fedora/afmodel:SampleModel").should == SampleModel
113
- ActiveFedora::ContentModel.uri_to_ruby_class("info:fedora/afmodel:NonDefinedModel").should == false
114
- ActiveFedora::ContentModel.uri_to_ruby_class("info:fedora/afmodel:String").should == String
115
- ActiveFedora::ContentModel.uri_to_ruby_class("info:fedora/hydra-cModel:genericContent").should == GenericContent
116
- end
117
- end
118
-
119
110
  describe "uri_to_model_class" do
120
111
  it "should return an ActiveFedora Model class corresponding to the given uri if a valid model can be found" do
121
112
  ActiveFedora::ContentModel.uri_to_model_class("info:fedora/afmodel:SampleModel").should == SampleModel
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-fedora
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
- - 3
10
- version: 3.1.3
9
+ - 4
10
+ version: 3.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Zumwalt
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-11-18 00:00:00 -06:00
19
+ date: 2011-11-28 00:00:00 -06:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -209,14 +209,14 @@ dependencies:
209
209
  version_requirements: &id013 !ruby/object:Gem::Requirement
210
210
  none: false
211
211
  requirements:
212
- - - "="
212
+ - - ~>
213
213
  - !ruby/object:Gem::Version
214
- hash: 31
214
+ hash: 27
215
215
  segments:
216
216
  - 0
217
217
  - 2
218
- - 4
219
- version: 0.2.4
218
+ - 6
219
+ version: 0.2.6
220
220
  requirement: *id013
221
221
  - !ruby/object:Gem::Dependency
222
222
  name: rdf
@@ -327,12 +327,12 @@ dependencies:
327
327
  requirements:
328
328
  - - ">="
329
329
  - !ruby/object:Gem::Version
330
- hash: 21
330
+ hash: 19
331
331
  segments:
332
332
  - 1
333
- - 0
334
333
  - 1
335
- version: 1.0.1
334
+ - 0
335
+ version: 1.1.0
336
336
  requirement: *id021
337
337
  - !ruby/object:Gem::Dependency
338
338
  name: rspec