active-fedora 6.1.1 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +6 -2
- data/History.txt +22 -0
- data/README.textile +3 -2
- data/active-fedora.gemspec +0 -2
- data/gemfiles/gemfile.rails3 +11 -0
- data/gemfiles/gemfile.rails4 +10 -0
- data/lib/active_fedora.rb +26 -0
- data/lib/active_fedora/base.rb +2 -14
- data/lib/active_fedora/delegating.rb +29 -9
- data/lib/active_fedora/file_configurator.rb +5 -4
- data/lib/active_fedora/indexing.rb +1 -0
- data/lib/active_fedora/model.rb +1 -5
- data/lib/active_fedora/rdf_node.rb +49 -12
- data/lib/active_fedora/rdf_node/term_proxy.rb +8 -1
- data/lib/active_fedora/unsaved_digital_object.rb +2 -1
- data/lib/active_fedora/version.rb +1 -1
- data/spec/integration/base_spec.rb +11 -3
- data/spec/integration/complex_rdf_datastream_spec.rb +3 -2
- data/spec/integration/model_spec.rb +1 -1
- data/spec/unit/active_fedora_spec.rb +9 -0
- data/spec/unit/base_delegate_spec.rb +11 -0
- data/spec/unit/base_spec.rb +4 -1
- data/spec/unit/config_spec.rb +2 -2
- data/spec/unit/unsaved_digital_object_spec.rb +5 -0
- metadata +4 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c01087204a8c5f60744938710ac3eb0c461b6e7
|
4
|
+
data.tar.gz: 49f69184528ee7b71ae305da79ea785fa6b682a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b90ee428f9e28fa66d2425dc5a021262a44ee85163a7595c68acb7bac96db4924b409e8b70af51d6a9e6f08efbb74ed4d74349a8af891d4badf910fd986ca41
|
7
|
+
data.tar.gz: 2d0b2da228cb0e2c27a328975ab89e15f0be882a05c18cd2acfd270515b83c6a05dfb50165f8588f15ca56da15080b2c34b061900db88c72da53d2c81f48ac28
|
data/.travis.yml
CHANGED
data/History.txt
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
6.2.0 (2013-06-05)
|
2
|
+
|
3
|
+
Support for rails 4
|
4
|
+
|
5
|
+
Extracted the behavior of resolving a class from a string (ActiveFedora.class_from_string).
|
6
|
+
|
7
|
+
You can now pass parameters to accessor delegates.
|
8
|
+
|
9
|
+
You can set the object state attribute (objState)
|
10
|
+
|
11
|
+
Object state is indexed in solr
|
12
|
+
|
13
|
+
Label is now implemented as a delegate
|
14
|
+
|
15
|
+
Added Base.unique? to test whether a field is specified as being unique or not.
|
16
|
+
|
17
|
+
Removed dependency on builder
|
18
|
+
|
19
|
+
When searching for an rdf term in a complex graph, it should match on predicate and type. Previously
|
20
|
+
it was just matching on type.
|
21
|
+
|
22
|
+
|
1
23
|
6.1.1
|
2
24
|
Rdf nodes should check for an RDF.type when resolving classes
|
3
25
|
Objects loaded via Solr should have datastream properties of same class
|
data/README.textile
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
!https://travis-ci.org/projecthydra/active_fedora.png?branch=master!:https://travis-ci.org/projecthydra/active_fedora
|
2
|
-
|
3
1
|
h2. Description
|
4
2
|
|
3
|
+
!https://travis-ci.org/projecthydra/active_fedora.png?branch=master!:https://travis-ci.org/projecthydra/active_fedora !https://badge.fury.io/rb/active-fedora.png!:http://badge.fury.io/rb/active-fedora !https://gemnasium.com/projecthydra/active_fedora.png!:https://gemnasium.com/projecthydra/active_fedora
|
4
|
+
|
5
|
+
|
5
6
|
RubyFedora and ActiveFedora provide a set of Ruby gems for creating and managing objects in the Fedora Repository Architecture ("http://fedora-commons.org":http://fedora-commons.org). ActiveFedora is loosely based on "ActiveRecord" in Rails. The 3.x series of ActiveFedora depends on Rails 3, specifically activemodel and activesupport.
|
6
7
|
|
7
8
|
h2. Getting Help
|
data/active-fedora.gemspec
CHANGED
@@ -17,9 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.add_dependency('rsolr')
|
18
18
|
s.add_dependency('om', '~> 2.1.0')
|
19
19
|
s.add_dependency('nom-xml', '>=0.5.1')
|
20
|
-
s.add_dependency("activeresource", '>= 3.0.0')
|
21
20
|
s.add_dependency("activesupport", '>= 3.0.0')
|
22
|
-
s.add_dependency("builder", '~> 3.0.0')
|
23
21
|
s.add_dependency("mediashelf-loggable")
|
24
22
|
s.add_dependency("rubydora", '~>1.6')
|
25
23
|
s.add_dependency("rdf")
|
data/lib/active_fedora.rb
CHANGED
@@ -144,6 +144,32 @@ module ActiveFedora #:nodoc:
|
|
144
144
|
def self.version
|
145
145
|
ActiveFedora::VERSION
|
146
146
|
end
|
147
|
+
|
148
|
+
# Convenience method for getting class constant based on a string
|
149
|
+
# @example
|
150
|
+
# ActiveFedora.class_from_string("Om")
|
151
|
+
# => Om
|
152
|
+
# ActiveFedora.class_from_string("ActiveFedora::RdfNode::TermProxy")
|
153
|
+
# => ActiveFedora::RdfNode::TermProxy
|
154
|
+
# @example Search within ActiveFedora::RdfNode for a class called "TermProxy"
|
155
|
+
# ActiveFedora.class_from_string("TermProxy", ActiveFedora::RdfNode)
|
156
|
+
# => ActiveFedora::RdfNode::TermProxy
|
157
|
+
def self.class_from_string(class_name, container_class=nil)
|
158
|
+
if class_name.include?("::")
|
159
|
+
# result = eval(class_name)
|
160
|
+
class_name.split('::').inject(Object) do |mod, class_name|
|
161
|
+
mod.const_get(class_name)
|
162
|
+
end
|
163
|
+
elsif !container_class.nil?
|
164
|
+
begin
|
165
|
+
container_class.const_get(class_name.to_sym)
|
166
|
+
rescue NameError
|
167
|
+
Kernel.const_get(class_name)
|
168
|
+
end
|
169
|
+
else
|
170
|
+
Kernel.const_get(class_name)
|
171
|
+
end
|
172
|
+
end
|
147
173
|
|
148
174
|
end
|
149
175
|
|
data/lib/active_fedora/base.rb
CHANGED
@@ -30,6 +30,8 @@ module ActiveFedora
|
|
30
30
|
self.fedora_connection = {}
|
31
31
|
self.profile_solr_name = ActiveFedora::SolrService.solr_name("object_profile", :displayable)
|
32
32
|
|
33
|
+
delegate :label, :label=, to: :inner_object
|
34
|
+
delegate :state=, :state, to: :inner_object
|
33
35
|
|
34
36
|
def method_missing(name, *args)
|
35
37
|
dsid = corresponding_datastream_name(name)
|
@@ -216,11 +218,6 @@ module ActiveFedora
|
|
216
218
|
"info:fedora/#{pid}"
|
217
219
|
end
|
218
220
|
|
219
|
-
#return the state of the inner object
|
220
|
-
def state
|
221
|
-
@inner_object.state
|
222
|
-
end
|
223
|
-
|
224
221
|
#return the owner id
|
225
222
|
def owner_id
|
226
223
|
@inner_object.ownerId
|
@@ -240,15 +237,6 @@ module ActiveFedora
|
|
240
237
|
@inner_object.new? ? Time.now : @inner_object.profile["objLastModDate"]
|
241
238
|
end
|
242
239
|
|
243
|
-
#return the label of the inner object (unless it's a new object)
|
244
|
-
def label
|
245
|
-
@inner_object.label
|
246
|
-
end
|
247
|
-
|
248
|
-
def label=(new_label)
|
249
|
-
@inner_object.label = new_label
|
250
|
-
end
|
251
|
-
|
252
240
|
def ==(comparison_object)
|
253
241
|
comparison_object.equal?(self) ||
|
254
242
|
(comparison_object.instance_of?(self.class) &&
|
@@ -16,9 +16,14 @@ module ActiveFedora
|
|
16
16
|
array_setter(key, value)
|
17
17
|
end
|
18
18
|
|
19
|
+
|
19
20
|
private
|
20
|
-
def array_reader(field)
|
21
|
-
|
21
|
+
def array_reader(field, *args)
|
22
|
+
if args.present?
|
23
|
+
instance_exec(*args, &self.class.delegates[field][:reader])
|
24
|
+
else
|
25
|
+
instance_exec &self.class.delegates[field][:reader]
|
26
|
+
end
|
22
27
|
end
|
23
28
|
|
24
29
|
def array_setter(field, args)
|
@@ -53,7 +58,8 @@ module ActiveFedora
|
|
53
58
|
# foo = Foo.new
|
54
59
|
# foo.field1 = "My Value"
|
55
60
|
# foo.field1 # => "My Value"
|
56
|
-
# foo.field2 # =>
|
61
|
+
# foo.field2 # => [""]
|
62
|
+
# foo.field3 # => NoMethodError: undefined method `field3' for #<Foo:0x1af30c>
|
57
63
|
|
58
64
|
def delegate(*methods)
|
59
65
|
fields = methods.dup
|
@@ -89,7 +95,8 @@ module ActiveFedora
|
|
89
95
|
# foo = Foo.new
|
90
96
|
# foo.field1 = "My Value"
|
91
97
|
# foo.field1 # => "My Value"
|
92
|
-
# foo.field2 # =>
|
98
|
+
# foo.field2 # => [""]
|
99
|
+
# foo.field3 # => NoMethodError: undefined method `field3' for #<Foo:0x1af30c>
|
93
100
|
|
94
101
|
def delegate_to(datastream,fields,args={})
|
95
102
|
fields.each do |f|
|
@@ -99,22 +106,35 @@ module ActiveFedora
|
|
99
106
|
end
|
100
107
|
end
|
101
108
|
|
109
|
+
# Reveal if the delegated field is unique or not
|
110
|
+
# @params [Symbol] field the field to query
|
111
|
+
# @returns [Boolean]
|
112
|
+
def unique?(field)
|
113
|
+
delegates[field][:unique]
|
114
|
+
end
|
115
|
+
|
102
116
|
private
|
103
117
|
def create_delegate_reader(field, args)
|
104
118
|
self.delegates[field] ||= {}
|
105
|
-
self.delegates[field][:reader] = lambda do
|
119
|
+
self.delegates[field][:reader] = lambda do |*opts|
|
106
120
|
ds = self.send(args[:to])
|
107
121
|
if ds.kind_of?(ActiveFedora::RDFDatastream)
|
108
122
|
ds.send(field)
|
109
123
|
else
|
110
124
|
terminology = args[:at] || [field]
|
111
|
-
|
125
|
+
if terminology.length == 1 && opts.present?
|
126
|
+
ds.send(terminology.first, *opts)
|
127
|
+
else
|
128
|
+
ds.send(:term_values, *terminology)
|
129
|
+
end
|
112
130
|
end
|
113
131
|
end
|
114
132
|
|
115
|
-
|
116
|
-
|
117
|
-
|
133
|
+
self.delegates[field][:unique] = args[:unique]
|
134
|
+
|
135
|
+
define_method field do |*opts|
|
136
|
+
val = array_reader(field, *opts)
|
137
|
+
self.class.unique?(field) ? val.first : val
|
118
138
|
end
|
119
139
|
end
|
120
140
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'erb'
|
2
|
+
require 'psych'
|
2
3
|
|
3
4
|
module ActiveFedora
|
4
5
|
class FileConfigurator
|
@@ -109,7 +110,7 @@ module ActiveFedora
|
|
109
110
|
end
|
110
111
|
|
111
112
|
begin
|
112
|
-
fedora_yml =
|
113
|
+
fedora_yml = Psych.load(config_erb)
|
113
114
|
rescue StandardError => e
|
114
115
|
raise("fedora.yml was found, but could not be parsed.\n")
|
115
116
|
end
|
@@ -132,7 +133,7 @@ module ActiveFedora
|
|
132
133
|
end
|
133
134
|
|
134
135
|
begin
|
135
|
-
solr_yml =
|
136
|
+
solr_yml = Psych.load(config_erb)
|
136
137
|
rescue StandardError => e
|
137
138
|
raise("solr.yml was found, but could not be parsed.\n")
|
138
139
|
end
|
@@ -208,7 +209,7 @@ module ActiveFedora
|
|
208
209
|
|
209
210
|
def predicate_config
|
210
211
|
@predicate_config_path ||= build_predicate_config_path(File.dirname(self.path))
|
211
|
-
|
212
|
+
Psych.load(File.open(@predicate_config_path)) if File.exist?(@predicate_config_path)
|
212
213
|
end
|
213
214
|
|
214
215
|
protected
|
@@ -226,7 +227,7 @@ module ActiveFedora
|
|
226
227
|
end
|
227
228
|
|
228
229
|
def valid_predicate_mapping?(testfile)
|
229
|
-
mapping =
|
230
|
+
mapping = Psych.load(File.open(testfile))
|
230
231
|
return false unless mapping.has_key?(:default_namespace) && mapping[:default_namespace].is_a?(String)
|
231
232
|
return false unless mapping.has_key?(:predicate_mapping) && mapping[:predicate_mapping].is_a?(Hash)
|
232
233
|
true
|
@@ -14,6 +14,7 @@ module ActiveFedora
|
|
14
14
|
m_time = Time.parse(m_time) unless m_time.is_a?(Time)
|
15
15
|
Solrizer.set_field(solr_doc, 'system_create', c_time, :stored_sortable)
|
16
16
|
Solrizer.set_field(solr_doc, 'system_modified', m_time, :stored_sortable)
|
17
|
+
Solrizer.set_field(solr_doc, 'object_state', state, :stored_sortable)
|
17
18
|
Solrizer.set_field(solr_doc, 'active_fedora_model', self.class.inspect, :stored_sortable)
|
18
19
|
solr_doc.merge!(SOLR_DOCUMENT_ID.to_sym => pid)
|
19
20
|
solrize_profile(solr_doc)
|
data/lib/active_fedora/model.rb
CHANGED
@@ -24,11 +24,7 @@ module ActiveFedora
|
|
24
24
|
logger.warn "#{model_value} is not a real class"
|
25
25
|
return false
|
26
26
|
end
|
27
|
-
|
28
|
-
result = eval(model_value)
|
29
|
-
else
|
30
|
-
result = Kernel.const_get(model_value)
|
31
|
-
end
|
27
|
+
result = ActiveFedora.class_from_string(model_value)
|
32
28
|
unless result.nil?
|
33
29
|
model_ns = (result.respond_to? :pid_namespace) ? result.pid_namespace : ContentModel::CMODEL_NAMESPACE
|
34
30
|
if model_ns != pid_ns
|
@@ -25,9 +25,11 @@ module ActiveFedora
|
|
25
25
|
@subject = nil
|
26
26
|
end
|
27
27
|
|
28
|
-
# @param [
|
29
|
-
|
30
|
-
|
28
|
+
# @param [RDF::URI] subject the base node to start the search from
|
29
|
+
# @param [Symbol] term the term to get the values for
|
30
|
+
def get_values(subject, term)
|
31
|
+
options = config_for_term_or_uri(term)
|
32
|
+
predicate = options[:predicate]
|
31
33
|
TermProxy.new(self, subject, predicate, options)
|
32
34
|
end
|
33
35
|
|
@@ -35,7 +37,7 @@ module ActiveFedora
|
|
35
37
|
_, conf = self.class.config_for_predicate(predicate)
|
36
38
|
class_name = conf[:class_name]
|
37
39
|
return nil unless class_name
|
38
|
-
|
40
|
+
ActiveFedora.class_from_string(class_name, self.class)
|
39
41
|
end
|
40
42
|
|
41
43
|
# if there are any existing statements with this predicate, replace them
|
@@ -43,24 +45,23 @@ module ActiveFedora
|
|
43
45
|
# @param [Symbol, RDF::URI] predicate the predicate to insert into the graph
|
44
46
|
# @param [Array,#to_s] values the value/values to insert into the graph
|
45
47
|
def set_value(subject, predicate, values)
|
46
|
-
|
47
48
|
options = config_for_term_or_uri(predicate)
|
48
49
|
predicate = options[:predicate]
|
50
|
+
values = Array(values)
|
51
|
+
|
52
|
+
remove_existing_values(subject, predicate, values)
|
49
53
|
|
50
|
-
|
51
|
-
Array(values).each do |arg|
|
54
|
+
values.each do |arg|
|
52
55
|
if arg.respond_to?(:rdf_subject) # an RdfObject
|
53
56
|
graph.insert([subject, predicate, arg.rdf_subject ])
|
54
57
|
else
|
55
58
|
arg = arg.to_s if arg.kind_of? RDF::Literal
|
56
|
-
|
57
59
|
graph.insert([subject, predicate, arg])
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
61
63
|
TermProxy.new(self, subject, predicate, options)
|
62
64
|
end
|
63
|
-
|
64
65
|
|
65
66
|
def delete_predicate(subject, predicate, values = nil)
|
66
67
|
predicate = find_predicate(predicate) unless predicate.kind_of? RDF::URI
|
@@ -78,7 +79,6 @@ module ActiveFedora
|
|
78
79
|
graph.delete [subject, predicate, v]
|
79
80
|
end
|
80
81
|
end
|
81
|
-
|
82
82
|
end
|
83
83
|
|
84
84
|
# append a value
|
@@ -117,8 +117,8 @@ module ActiveFedora
|
|
117
117
|
def method_missing(name, *args)
|
118
118
|
if (md = /^([^=]+)=$/.match(name.to_s)) && pred = find_predicate(md[1])
|
119
119
|
set_value(rdf_subject, pred, *args)
|
120
|
-
elsif
|
121
|
-
get_values(rdf_subject,
|
120
|
+
elsif find_predicate(name)
|
121
|
+
get_values(rdf_subject, name)
|
122
122
|
else
|
123
123
|
super
|
124
124
|
end
|
@@ -127,6 +127,43 @@ module ActiveFedora
|
|
127
127
|
end
|
128
128
|
|
129
129
|
private
|
130
|
+
|
131
|
+
def remove_existing_values(subject, predicate, values)
|
132
|
+
if values.any? { |x| x.respond_to?(:rdf_subject)}
|
133
|
+
values.each do |arg|
|
134
|
+
if arg.respond_to?(:rdf_subject) # an RdfObject
|
135
|
+
# can't just delete_predicate, have to delete the predicate with the class
|
136
|
+
values_to_delete = find_values_with_class(subject, predicate, arg.class.rdf_type)
|
137
|
+
delete_predicate(subject, predicate, values_to_delete)
|
138
|
+
else
|
139
|
+
delete_predicate(subject, predicate)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
else
|
143
|
+
delete_predicate(subject, predicate)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
|
148
|
+
def find_values_with_class(subject, predicate, rdf_type)
|
149
|
+
matching = []
|
150
|
+
query = RDF::Query.new do
|
151
|
+
pattern [subject, predicate, :value]
|
152
|
+
end
|
153
|
+
query.execute(graph).each do |solution|
|
154
|
+
if rdf_type
|
155
|
+
query2 = RDF::Query.new do
|
156
|
+
pattern [solution.value, RDF.type, rdf_type]
|
157
|
+
end
|
158
|
+
query2.execute(graph).each do |sol2|
|
159
|
+
matching << solution.value
|
160
|
+
end
|
161
|
+
else
|
162
|
+
matching << solution.value
|
163
|
+
end
|
164
|
+
end
|
165
|
+
matching
|
166
|
+
end
|
130
167
|
class Builder
|
131
168
|
def initialize(parent)
|
132
169
|
@parent = parent
|
@@ -46,7 +46,14 @@ module ActiveFedora
|
|
46
46
|
if options[:type] == :date
|
47
47
|
v = Date.parse(v)
|
48
48
|
end
|
49
|
-
|
49
|
+
# If the user provided options[:class_name], we should query to make sure this
|
50
|
+
# potential solution is of the right RDF.type
|
51
|
+
if options[:class_name]
|
52
|
+
klass = class_from_rdf_type(v, predicate)
|
53
|
+
values << v if klass == ActiveFedora.class_from_string(options[:class_name], graph.class)
|
54
|
+
else
|
55
|
+
values << v
|
56
|
+
end
|
50
57
|
end
|
51
58
|
|
52
59
|
if options[:class_name]
|
@@ -2,7 +2,7 @@ module ActiveFedora
|
|
2
2
|
# Helps Rubydora create datastreams of the type defined by the ActiveFedora::Base#datastream_class_for_name
|
3
3
|
class UnsavedDigitalObject
|
4
4
|
include DigitalObject::DatastreamBootstrap
|
5
|
-
attr_accessor :original_class, :ownerId, :datastreams, :label, :namespace
|
5
|
+
attr_accessor :original_class, :ownerId, :state, :datastreams, :label, :namespace
|
6
6
|
|
7
7
|
PLACEHOLDER = '__DO_NOT_USE__'
|
8
8
|
|
@@ -36,6 +36,7 @@ module ActiveFedora
|
|
36
36
|
end
|
37
37
|
obj.ownerId = ownerId if ownerId
|
38
38
|
obj.label = label if label
|
39
|
+
obj.state = state if state
|
39
40
|
obj
|
40
41
|
end
|
41
42
|
|
@@ -25,6 +25,17 @@ describe "A base object with metadata" do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
describe "setting object state" do
|
29
|
+
it "should store it" do
|
30
|
+
obj = MockAFBaseRelationship.create
|
31
|
+
obj.state.should == 'A'
|
32
|
+
obj.state='D'
|
33
|
+
obj.save!
|
34
|
+
obj.reload
|
35
|
+
obj.state.should == 'D'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
28
39
|
describe "that already exists in the repo" do
|
29
40
|
before do
|
30
41
|
@release = MockAFBaseRelationship.create()
|
@@ -245,10 +256,7 @@ describe ActiveFedora::Base do
|
|
245
256
|
@test_object2.save
|
246
257
|
inner_object = @test_object2.inner_object
|
247
258
|
inner_object.pid.should == @test_object2.pid
|
248
|
-
inner_object.should respond_to(:state)
|
249
259
|
inner_object.should respond_to(:lastModifiedDate)
|
250
|
-
inner_object.should respond_to(:ownerId)
|
251
|
-
inner_object.state.should == "A"
|
252
260
|
inner_object.ownerId.should == "fedoraAdmin"
|
253
261
|
end
|
254
262
|
end
|
@@ -183,14 +183,15 @@ END
|
|
183
183
|
series = SpecDatastream::Series.new ds.graph
|
184
184
|
series.title = ["renovating bathrooms"]
|
185
185
|
ds.series = series
|
186
|
-
ds.series.first.type.size.should == 1
|
187
|
-
ds.series.first.type.first.to_s.should == 'http://www.ebu.ch/metadata/ontologies/ebucore#Series'
|
188
186
|
|
189
187
|
program = SpecDatastream::Program.new ds.graph
|
190
188
|
program.title = ["This old House"]
|
191
189
|
ds.program = program
|
190
|
+
|
192
191
|
ds.program.first.type.size.should == 1
|
193
192
|
ds.program.first.type.first.to_s.should == 'http://www.ebu.ch/metadata/ontologies/ebucore#Programme'
|
193
|
+
ds.series.first.type.size.should == 1
|
194
|
+
ds.series.first.type.first.to_s.should == 'http://www.ebu.ch/metadata/ontologies/ebucore#Series'
|
194
195
|
end
|
195
196
|
|
196
197
|
end
|
@@ -52,7 +52,7 @@ describe ActiveFedora::Model do
|
|
52
52
|
subject { ActiveFedora::Base.load_instance_from_solr('hydrangea:fixture_mods_article1') }
|
53
53
|
it { should be_instance_of HydrangeaArticle}
|
54
54
|
end
|
55
|
-
describe "with metadata
|
55
|
+
describe "with metadata datastream spec" do
|
56
56
|
subject { ActiveFedora::Base.load_instance_from_solr('hydrangea:fixture_mods_article1') }
|
57
57
|
it "should create an xml datastream" do
|
58
58
|
subject.datastreams['properties'].should be_kind_of ActiveFedora::SimpleDatastream
|
@@ -102,4 +102,13 @@ describe ActiveFedora do
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|
105
|
+
|
106
|
+
describe "#class_from_string" do
|
107
|
+
it "should return class constants based on strings" do
|
108
|
+
ActiveFedora.class_from_string("Om").should == Om
|
109
|
+
ActiveFedora.class_from_string("ActiveFedora::RdfNode::TermProxy").should == ActiveFedora::RdfNode::TermProxy
|
110
|
+
ActiveFedora.class_from_string("TermProxy", ActiveFedora::RdfNode).should == ActiveFedora::RdfNode::TermProxy
|
111
|
+
|
112
|
+
end
|
113
|
+
end
|
105
114
|
end
|
@@ -62,6 +62,10 @@ describe ActiveFedora::Base do
|
|
62
62
|
@n = BarHistory2.new()
|
63
63
|
end
|
64
64
|
|
65
|
+
it "should reveal the unique properties" do
|
66
|
+
BarHistory2.unique?(:fubar).should be_true
|
67
|
+
BarHistory2.unique?(:cow).should be_false
|
68
|
+
end
|
65
69
|
|
66
70
|
it "should save a delegated property uniquely" do
|
67
71
|
@n.fubar="Quack"
|
@@ -71,6 +75,13 @@ describe ActiveFedora::Base do
|
|
71
75
|
@n.donkey.should == "Bray"
|
72
76
|
@n.xmlish.term_values(:donkey).first.should == 'Bray'
|
73
77
|
end
|
78
|
+
|
79
|
+
it "should allow passing parameters to the delegate accessor" do
|
80
|
+
@n.cow=["one", "two"]
|
81
|
+
@n.cow(1).should == ['two']
|
82
|
+
end
|
83
|
+
|
84
|
+
|
74
85
|
it "should return an array if not marked as unique" do
|
75
86
|
### Metadata datastream does not appear to support multiple value setting
|
76
87
|
@n.cow=["one", "two"]
|
data/spec/unit/base_spec.rb
CHANGED
@@ -7,6 +7,7 @@ describe ActiveFedora::Base do
|
|
7
7
|
ActiveFedora::Base.descendants.should include(HydrangeaArticle, SpecialThing)
|
8
8
|
end
|
9
9
|
end
|
10
|
+
|
10
11
|
describe "sharding" do
|
11
12
|
it "should have a shard_index" do
|
12
13
|
ActiveFedora::Base.shard_index(@this_pid).should == 0
|
@@ -406,12 +407,14 @@ describe ActiveFedora::Base do
|
|
406
407
|
@test_object.should respond_to(:to_solr)
|
407
408
|
end
|
408
409
|
|
409
|
-
it "should add pid, system_create_date and
|
410
|
+
it "should add pid, system_create_date, system_modified_date and object_state from object attributes" do
|
410
411
|
@test_object.should_receive(:create_date).and_return("2012-03-04T03:12:02Z")
|
411
412
|
@test_object.should_receive(:modified_date).and_return("2012-03-07T03:12:02Z")
|
413
|
+
@test_object.state = "D"
|
412
414
|
solr_doc = @test_object.to_solr
|
413
415
|
solr_doc[ActiveFedora::SolrService.solr_name("system_create", :stored_sortable, type: :date)].should eql("2012-03-04T03:12:02Z")
|
414
416
|
solr_doc[ActiveFedora::SolrService.solr_name("system_modified", :stored_sortable, type: :date)].should eql("2012-03-07T03:12:02Z")
|
417
|
+
solr_doc[ActiveFedora::SolrService.solr_name("object_state", :stored_sortable)].should eql("D")
|
415
418
|
solr_doc[:id].should eql("#{@test_object.pid}")
|
416
419
|
end
|
417
420
|
|
data/spec/unit/config_spec.rb
CHANGED
@@ -2,13 +2,13 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveFedora::Config do
|
4
4
|
describe "with a single fedora instance" do
|
5
|
-
conf =
|
5
|
+
conf = Psych.load(File.read('spec/fixtures/rails_root/config/fedora.yml'))['test']
|
6
6
|
subject { ActiveFedora::Config.new(conf) }
|
7
7
|
its(:credentials) { should == {:url => 'http://testhost.com:8983/fedora', :user=> 'fedoraAdmin', :password=> 'fedoraAdmin'}}
|
8
8
|
it { should_not be_sharded }
|
9
9
|
end
|
10
10
|
describe "with several fedora shards" do
|
11
|
-
conf =
|
11
|
+
conf = Psych.load(File.read('spec/fixtures/sharded_fedora.yml'))['test']
|
12
12
|
subject { ActiveFedora::Config.new(conf) }
|
13
13
|
its(:credentials) { should == [{:url => 'http://127.0.0.1:8983/fedora1', :user=> 'fedoraAdmin', :password=> 'fedoraAdmin'},
|
14
14
|
{:url => 'http://127.0.0.1:8983/fedora2', :user=> 'fedoraAdmin', :password=> 'fedoraAdmin'},
|
@@ -11,6 +11,11 @@ describe ActiveFedora::UnsavedDigitalObject do
|
|
11
11
|
@obj.ownerId.should == 'fooo'
|
12
12
|
end
|
13
13
|
|
14
|
+
it "should have state" do
|
15
|
+
@obj.ownerId = 'D'
|
16
|
+
@obj.ownerId.should == 'D'
|
17
|
+
end
|
18
|
+
|
14
19
|
it "should have a default pid" do
|
15
20
|
@obj.pid.should == "__DO_NOT_USE__"
|
16
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Zumwalt
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-05
|
13
|
+
date: 2013-06-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsolr
|
@@ -54,20 +54,6 @@ dependencies:
|
|
54
54
|
- - '>='
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: 0.5.1
|
57
|
-
- !ruby/object:Gem::Dependency
|
58
|
-
name: activeresource
|
59
|
-
requirement: !ruby/object:Gem::Requirement
|
60
|
-
requirements:
|
61
|
-
- - '>='
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: 3.0.0
|
64
|
-
type: :runtime
|
65
|
-
prerelease: false
|
66
|
-
version_requirements: !ruby/object:Gem::Requirement
|
67
|
-
requirements:
|
68
|
-
- - '>='
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: 3.0.0
|
71
57
|
- !ruby/object:Gem::Dependency
|
72
58
|
name: activesupport
|
73
59
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,20 +68,6 @@ dependencies:
|
|
82
68
|
- - '>='
|
83
69
|
- !ruby/object:Gem::Version
|
84
70
|
version: 3.0.0
|
85
|
-
- !ruby/object:Gem::Dependency
|
86
|
-
name: builder
|
87
|
-
requirement: !ruby/object:Gem::Requirement
|
88
|
-
requirements:
|
89
|
-
- - ~>
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
version: 3.0.0
|
92
|
-
type: :runtime
|
93
|
-
prerelease: false
|
94
|
-
version_requirements: !ruby/object:Gem::Requirement
|
95
|
-
requirements:
|
96
|
-
- - ~>
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
version: 3.0.0
|
99
71
|
- !ruby/object:Gem::Dependency
|
100
72
|
name: mediashelf-loggable
|
101
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -320,6 +292,8 @@ files:
|
|
320
292
|
- config/solr.yml
|
321
293
|
- config/solr_mappings_af_0.1.yml
|
322
294
|
- config/solr_mappings_bl_2.4.yml
|
295
|
+
- gemfiles/gemfile.rails3
|
296
|
+
- gemfiles/gemfile.rails4
|
323
297
|
- lib/active-fedora.rb
|
324
298
|
- lib/active_fedora.rb
|
325
299
|
- lib/active_fedora/associations.rb
|