active-fedora 9.0.0.beta5 → 9.0.0.beta6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/active-fedora.gemspec +1 -1
- data/lib/active_fedora.rb +1 -0
- data/lib/active_fedora/attributes.rb +3 -3
- data/lib/active_fedora/attributes/node_config.rb +13 -0
- data/lib/active_fedora/attributes/property_builder.rb +21 -2
- data/lib/active_fedora/fedora_attributes.rb +1 -2
- data/lib/active_fedora/loadable_from_json.rb +1 -1
- data/lib/active_fedora/rdf/rdf_datastream.rb +1 -2
- data/lib/active_fedora/version.rb +1 -1
- data/spec/unit/rdf_datastream_spec.rb +1 -8
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8fb1d0fea1b50349e3da9a6cb685e3865fcb716
|
4
|
+
data.tar.gz: 518c8edc13fd3a87ef09c7022eee3d6a29c2ddb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c0bce8730af54df688fc1a3c0d5f41bc7df148070b21bfbeb81246c7766f650d73abf12b70deb3cefc415e40d416fb31c7856808705be923886334ced6200de
|
7
|
+
data.tar.gz: f6467c70c153178f4c190a42d084727093b57387fe571d8a33722ca3bfea90b5ef4d2f9dd043ccac253e6ec8cef808889c255f31a6fe6bc37af0e1f732f40201
|
data/active-fedora.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.add_dependency 'om', '~> 3.1'
|
19
19
|
s.add_dependency 'nom-xml', '>= 0.5.1'
|
20
20
|
s.add_dependency "activesupport", '>= 4.1.0'
|
21
|
-
s.add_dependency "active-triples", '~> 0.
|
21
|
+
s.add_dependency "active-triples", '~> 0.5.0'
|
22
22
|
s.add_dependency "rdf-rdfxml", '~> 1.1.0'
|
23
23
|
s.add_dependency "linkeddata"
|
24
24
|
s.add_dependency "deprecation"
|
data/lib/active_fedora.rb
CHANGED
@@ -169,10 +169,10 @@ module ActiveFedora
|
|
169
169
|
end
|
170
170
|
|
171
171
|
def property name, properties={}, &block
|
172
|
-
|
172
|
+
properties = { multiple: true }.merge(properties)
|
173
|
+
find_or_create_defined_attribute(name, nil, properties)
|
173
174
|
raise ArgumentError, "#{name} is a keyword and not an acceptable property name." if protected_property_name? name
|
174
|
-
|
175
|
-
reflection = ActiveFedora::Attributes::PropertyBuilder.build(self, name, properties.except(:multiple), &block)
|
175
|
+
reflection = ActiveFedora::Attributes::PropertyBuilder.build(self, name, properties, &block)
|
176
176
|
# reflection = ActiveTriple::PropertyBuilder.build(self, name, properties, &block)
|
177
177
|
ActiveTriples::Reflection.add_reflection self, name, reflection
|
178
178
|
end
|
@@ -4,8 +4,13 @@ module ActiveFedora::Attributes
|
|
4
4
|
def self.define_accessors(model, reflection)
|
5
5
|
mixin = model.generated_property_methods
|
6
6
|
name = reflection.term
|
7
|
-
|
8
|
-
|
7
|
+
if reflection.multiple?
|
8
|
+
define_readers(mixin, name)
|
9
|
+
define_writers(mixin, name)
|
10
|
+
else
|
11
|
+
define_singular_readers(mixin, name)
|
12
|
+
define_singular_writers(mixin, name)
|
13
|
+
end
|
9
14
|
end
|
10
15
|
|
11
16
|
def self.define_writers(mixin, name)
|
@@ -19,6 +24,14 @@ module ActiveFedora::Attributes
|
|
19
24
|
CODE
|
20
25
|
end
|
21
26
|
|
27
|
+
def self.define_singular_readers(mixin, name)
|
28
|
+
mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
|
29
|
+
def #{name}(*args)
|
30
|
+
get_values(:#{name}).first
|
31
|
+
end
|
32
|
+
CODE
|
33
|
+
end
|
34
|
+
|
22
35
|
def self.define_singular_writers(mixin, name)
|
23
36
|
mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
|
24
37
|
def #{name}=(value)
|
@@ -29,5 +42,11 @@ module ActiveFedora::Attributes
|
|
29
42
|
end
|
30
43
|
CODE
|
31
44
|
end
|
45
|
+
|
46
|
+
def build(&block)
|
47
|
+
NodeConfig.new(name, options[:predicate], options.except(:predicate)) do |config|
|
48
|
+
config.with_index(&block) if block_given?
|
49
|
+
end
|
50
|
+
end
|
32
51
|
end
|
33
52
|
end
|
@@ -66,8 +66,7 @@ module ActiveFedora
|
|
66
66
|
klass.properties.merge(self.properties).each do |property, config|
|
67
67
|
klass.property(config.term,
|
68
68
|
predicate: config.predicate,
|
69
|
-
class_name: config.class_name
|
70
|
-
multivalue: config.multivalue)
|
69
|
+
class_name: config.class_name)
|
71
70
|
end
|
72
71
|
klass
|
73
72
|
end
|
@@ -102,8 +102,7 @@ module ActiveFedora
|
|
102
102
|
klass.properties.merge(self.class.properties).each do |prop, config|
|
103
103
|
klass.property(config.term,
|
104
104
|
predicate: config.predicate,
|
105
|
-
class_name: config.class_name
|
106
|
-
multivalue: config.multivalue)
|
105
|
+
class_name: config.class_name)
|
107
106
|
end
|
108
107
|
klass.accepts_nested_attributes_for(*nested_attributes_options.keys) unless nested_attributes_options.blank?
|
109
108
|
uri_stub = self.class.rdf_subject.call(self)
|
@@ -12,7 +12,7 @@ describe ActiveFedora::RDFDatastream do
|
|
12
12
|
before do
|
13
13
|
class MyDatastream < ActiveFedora::NtriplesRDFDatastream
|
14
14
|
property :title, predicate: ::RDF::DC.title
|
15
|
-
property :description, predicate: ::RDF::DC.description
|
15
|
+
property :description, predicate: ::RDF::DC.description
|
16
16
|
end
|
17
17
|
class MyObj < ActiveFedora::Base
|
18
18
|
has_metadata 'descMetadata', type: MyDatastream
|
@@ -39,13 +39,6 @@ describe ActiveFedora::RDFDatastream do
|
|
39
39
|
expect(subject.title).to eq ['']
|
40
40
|
end
|
41
41
|
|
42
|
-
describe "when multivalue: false" do
|
43
|
-
it "should return single values" do
|
44
|
-
subject.description = 'my description'
|
45
|
-
expect(subject.description).to eq 'my description'
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
42
|
it "should clear stuff" do
|
50
43
|
subject.title = ['one', 'two', 'three']
|
51
44
|
subject.title.clear
|
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: 9.0.0.
|
4
|
+
version: 9.0.0.beta6
|
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: 2014-12-
|
13
|
+
date: 2014-12-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsolr
|
@@ -74,14 +74,14 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - "~>"
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: 0.
|
77
|
+
version: 0.5.0
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
82
|
- - "~>"
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version: 0.
|
84
|
+
version: 0.5.0
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: rdf-rdfxml
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
@@ -312,6 +312,7 @@ files:
|
|
312
312
|
- lib/active_fedora/attribute_methods/read.rb
|
313
313
|
- lib/active_fedora/attribute_methods/write.rb
|
314
314
|
- lib/active_fedora/attributes.rb
|
315
|
+
- lib/active_fedora/attributes/node_config.rb
|
315
316
|
- lib/active_fedora/attributes/primary_key.rb
|
316
317
|
- lib/active_fedora/attributes/property_builder.rb
|
317
318
|
- lib/active_fedora/attributes/serializers.rb
|