tripod 0.9.10 → 0.9.11
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/lib/tripod/attributes.rb +13 -16
- data/lib/tripod/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: df9c2c92e357b7825de2a0e0553a165f642e3f1a
|
|
4
|
+
data.tar.gz: 488f952481dd46680238d0d332217091e1763d85
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1c6e1c3dbdd4522b1e2a8d812478de1681761f712ce6c4272d2688faa63fe3a2d8c725e77ef0c58bf51abb9c66ae55339bb75b0d3ccb2b5f1129ab26d465e333
|
|
7
|
+
data.tar.gz: 3addfc697fcc94c825453570e008e91f8729d61ce2dc0488f1a03220934a92f64ccfcebb232052179e778ec06d6556b2de0723bf343ab4de106264683b01f798
|
data/lib/tripod/attributes.rb
CHANGED
|
@@ -24,15 +24,20 @@ module Tripod::Attributes
|
|
|
24
24
|
raise Tripod::Errors::FieldNotPresent.new unless field
|
|
25
25
|
|
|
26
26
|
attr_values = read_predicate(field.predicate)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
# If the field is multivalued, return an array of the results
|
|
30
|
-
# If it's not multivalued, return the first (should be only) result.
|
|
31
|
-
|
|
27
|
+
|
|
32
28
|
if field.multivalued
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
attr_values.
|
|
29
|
+
# If the field is multivalued, return an array of the results
|
|
30
|
+
# just return the uri or the value of the literal.
|
|
31
|
+
attr_values.map { |v| field.is_uri? ? v : v.object }
|
|
32
|
+
else
|
|
33
|
+
# If it's not multivalued, return the first (should be only) result.
|
|
34
|
+
if field.is_uri?
|
|
35
|
+
attr_values.first
|
|
36
|
+
else
|
|
37
|
+
# try to get it in english if it's there. (TODO: make it configurable what the default is)
|
|
38
|
+
val = attr_values.select{ |v| v.language == :en }.first || attr_values.first
|
|
39
|
+
val.object if val
|
|
40
|
+
end
|
|
36
41
|
end
|
|
37
42
|
end
|
|
38
43
|
alias :[] :read_attribute
|
|
@@ -72,14 +77,6 @@ module Tripod::Attributes
|
|
|
72
77
|
|
|
73
78
|
private
|
|
74
79
|
|
|
75
|
-
def read_value_for_field(value, field)
|
|
76
|
-
if field.is_uri?
|
|
77
|
-
value
|
|
78
|
-
else
|
|
79
|
-
value.object
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
|
|
83
80
|
def write_value_for_field(value, field)
|
|
84
81
|
return if value.blank?
|
|
85
82
|
|
data/lib/tripod/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tripod
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ric Roberts
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2014-08-
|
|
13
|
+
date: 2014-08-27 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: rest-client
|