triannon 0.5.1 → 0.5.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38673b232f1a66c6710ed058242fcd79fb49ec92
4
- data.tar.gz: eedb16b6f71893c5a8559d3f45628790392eaf61
3
+ metadata.gz: ba1a1f91829594f2fbeb8e4bd61922cc8c97bd25
4
+ data.tar.gz: a9adfc5f66aa751fd7772b3e94e2eeb7bcc448ad
5
5
  SHA512:
6
- metadata.gz: d4791ad9be0bb23424dfdfe2de1e63249a527d30aa8c908f5b2718a4c166c0d9f8a013271f7a349ba0d6d1c250675782bacd27975dfd14d9d57b15ce0919e342
7
- data.tar.gz: dc163e2632dfb58b34f4bd07517e04701fc05ce8a54f8c047b3829289f575b00c3de726d993d6e734decc0c997ed55cb0990f7c696b9a5e642d83f2b520c853e
6
+ metadata.gz: 86d1fa8358fad5e023fd4996830b9c08fe249a86c3df56a8cd81f8957acd69dfdf2f7082f60cece97dc0677abc6f9a3c25326dc7ac233d46405b86ba517d39ec
7
+ data.tar.gz: 66ec8e8824ce0c734d6e025625f8ed86c0749848bd00f895c5a7c0a44d631320ac2267c9319e1b8b7be6700c8811bd265b8e6a17ac3dd47d0f75af010cfcd74b
@@ -54,37 +54,40 @@ module Triannon
54
54
  # @return [Hash] a hash to be written to Solr, populated appropriately
55
55
  def solr_hash
56
56
  doc_hash = {}
57
- # chars in Solr/Lucene query syntax are a big pain in Solr id fields, so we only use
58
- # the uuid portion of the Triannon anno id, not the full url
59
- solr_id = id_as_url.sub(Triannon.config[:triannon_base_url], "")
60
- doc_hash[:id] = solr_id.sub(/^\//, "") # remove first char slash if it is there
57
+ triannon_id = id_as_url
58
+ if triannon_id
59
+ # chars in Solr/Lucene query syntax are a big pain in Solr id fields, so we only use
60
+ # the uuid portion of the Triannon anno id, not the full url
61
+ solr_id = triannon_id.sub(Triannon.config[:triannon_base_url], "")
62
+ doc_hash[:id] = solr_id.sub(/^\//, "") # remove first char slash if it is there
61
63
 
62
- # use short strings for motivation field
63
- doc_hash[:motivation] = motivated_by.map { |m| m.sub(RDF::OpenAnnotation.to_s, "") }
64
+ # use short strings for motivation field
65
+ doc_hash[:motivation] = motivated_by.map { |m| m.sub(RDF::OpenAnnotation.to_s, "") }
64
66
 
65
- # date field format: 1995-12-31T23:59:59Z; or w fractional seconds: 1995-12-31T23:59:59.999Z
66
- if annotated_at
67
- begin
68
- dt = Time.parse(annotated_at)
69
- doc_hash[:annotated_at] = dt.iso8601 if dt
70
- rescue ArgumentError
71
- # ignore invalid datestamps
67
+ # date field format: 1995-12-31T23:59:59Z; or w fractional seconds: 1995-12-31T23:59:59.999Z
68
+ if annotated_at
69
+ begin
70
+ dt = Time.parse(annotated_at)
71
+ doc_hash[:annotated_at] = dt.iso8601 if dt
72
+ rescue ArgumentError
73
+ # ignore invalid datestamps
74
+ end
72
75
  end
73
- end
74
- # doc_hash[:annotated_by_stem] # not yet implemented
76
+ #doc_hash[:annotated_by_stem] # not yet implemented
75
77
 
76
- doc_hash[:target_url] = predicate_urls RDF::OpenAnnotation.hasTarget
77
- # TODO: recognize more target types
78
- doc_hash[:target_type] = ['external_URI'] if doc_hash[:target_url].size > 0
78
+ doc_hash[:target_url] = predicate_urls RDF::OpenAnnotation.hasTarget
79
+ # TODO: recognize more target types
80
+ doc_hash[:target_type] = ['external_URI'] if doc_hash[:target_url].size > 0
79
81
 
80
- doc_hash[:body_url] = predicate_urls RDF::OpenAnnotation.hasBody
81
- doc_hash[:body_type] = []
82
- doc_hash[:body_type] << 'external_URI' if doc_hash[:body_url].size > 0
83
- doc_hash[:body_chars_exact] = body_chars.map {|bc| bc.strip}
84
- doc_hash[:body_type] << 'content_as_text' if doc_hash[:body_chars_exact].size > 0
85
- doc_hash[:body_type] << 'no_body' if doc_hash[:body_type].size == 0
82
+ doc_hash[:body_url] = predicate_urls RDF::OpenAnnotation.hasBody
83
+ doc_hash[:body_type] = []
84
+ doc_hash[:body_type] << 'external_URI' if doc_hash[:body_url].size > 0
85
+ doc_hash[:body_chars_exact] = body_chars.map {|bc| bc.strip}
86
+ doc_hash[:body_type] << 'content_as_text' if doc_hash[:body_chars_exact].size > 0
87
+ doc_hash[:body_type] << 'no_body' if doc_hash[:body_type].size == 0
86
88
 
87
- doc_hash[:anno_jsonld] = jsonld_oa
89
+ doc_hash[:anno_jsonld] = jsonld_oa
90
+ end
88
91
  doc_hash
89
92
  end
90
93
 
@@ -1,3 +1,3 @@
1
1
  module Triannon
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: triannon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-02-04 00:00:00.000000000 Z
13
+ date: 2015-02-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails