tripod 0.9.10 → 0.9.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3f4b77f60b44c3d2471ca37daa9608abcd25502b
4
- data.tar.gz: a76daf16003cd434e172c924db465845dd9b5009
3
+ metadata.gz: df9c2c92e357b7825de2a0e0553a165f642e3f1a
4
+ data.tar.gz: 488f952481dd46680238d0d332217091e1763d85
5
5
  SHA512:
6
- metadata.gz: bd2701dbd4e32689e700a80876a51fb0f93ff907bc73ebe7bcc663b068746b3255422a5fdde3aee845a845fac5e8c7360fe5b207b4f948bda2406d2e7307e850
7
- data.tar.gz: 778f6876ea0cb79dcdab35d71c93c715786a4b9f95013678a2a5890aae32ca7c060798ec67a849423db30036a5230e074fe6cef8c0eec08cd82adc4701e3a810
6
+ metadata.gz: 1c6e1c3dbdd4522b1e2a8d812478de1681761f712ce6c4272d2688faa63fe3a2d8c725e77ef0c58bf51abb9c66ae55339bb75b0d3ccb2b5f1129ab26d465e333
7
+ data.tar.gz: 3addfc697fcc94c825453570e008e91f8729d61ce2dc0488f1a03220934a92f64ccfcebb232052179e778ec06d6556b2de0723bf343ab4de106264683b01f798
@@ -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
- attr_values.map! { |v| read_value_for_field(v, field) }
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
- attr_values
34
- else
35
- attr_values.first
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
 
@@ -1,3 +1,3 @@
1
1
  module Tripod
2
- VERSION = "0.9.10"
2
+ VERSION = "0.9.11"
3
3
  end
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.10
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-21 00:00:00.000000000 Z
13
+ date: 2014-08-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client