oa-graph 0.0.1 → 0.0.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 +4 -4
- data/README.md +4 -1
- data/lib/oa/graph.rb +15 -12
- data/lib/oa/graph/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d05e95d50b265fbf9d10a4a12c3456ff5ec300e5
|
4
|
+
data.tar.gz: 9aecffab903d3b419196ef93038d1e6a270887f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02ce99c8170c9267b34e309897d3ab24fe0bfc957e257262b692644b220906fc50315db491b563d672c8f92c1b0a0bbda392c84706bf6823ca4b71e3ab7a9594
|
7
|
+
data.tar.gz: 193919b828241ef41f63f76059b05297bedb4a70eb4face68c08da10b8d44cdcf42aaf15f5d981153c062fcafff88be9e599300977b34cb6e79c7ee1f47e743e
|
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
[](https://travis-ci.org/sul-dlss/oa-graph) [](https://coveralls.io/r/sul-dlss/oa-graph) [](https://gemnasium.com/sul-dlss/oa-graph) [](http://badge.fury.io/rb/oa-graph)
|
2
|
+
|
3
|
+
|
4
|
+
# OA::Graph
|
2
5
|
|
3
6
|
A wrapper class for RDF::Graph that adds methods specific to OpenAnnotation graphs (See http://www.openannotation.org/spec/core/). Intended to be used for a single instance of an OpenAnnotation; adds methods specific to OpenAnnotation RDF::Graph objects.
|
4
7
|
|
data/lib/oa/graph.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'oa/graph/version'
|
2
2
|
require 'linkeddata'
|
3
3
|
|
4
|
+
# OA is for OpenAnnotation
|
4
5
|
module OA
|
6
|
+
|
5
7
|
# a wrapper class for RDF::Graph that adds methods specific to OpenAnnotation
|
6
8
|
# (http://www.openannotation.org/spec/core/) Annotation objects. This is
|
7
9
|
# intended to be used for an RDF::Graph of a single annotation
|
@@ -66,11 +68,11 @@ module OA
|
|
66
68
|
# is a Node
|
67
69
|
def id_as_url
|
68
70
|
solution = @graph.query self.class.anno_query
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
71
|
+
if solution && solution.size == 1
|
72
|
+
rdf_resource = solution.first.s
|
73
|
+
rdf_resource.to_s if rdf_resource.is_a?(RDF::URI)
|
74
|
+
# TODO: raise exception if not a URI?
|
75
|
+
end
|
74
76
|
end
|
75
77
|
|
76
78
|
# @return [Array<String>] Array of urls expressing the OA motivated_by
|
@@ -89,7 +91,8 @@ module OA
|
|
89
91
|
motivations
|
90
92
|
end
|
91
93
|
|
92
|
-
# @param [RDF::URI] predicate either RDF::Vocab::OA.hasTarget or
|
94
|
+
# @param [RDF::URI] predicate either RDF::Vocab::OA.hasTarget or
|
95
|
+
# RDF::Vocab::OA.hasBody
|
93
96
|
# @return [Array<String>] urls for the predicate, as an Array of Strings
|
94
97
|
def predicate_urls(predicate)
|
95
98
|
urls = []
|
@@ -121,9 +124,7 @@ module OA
|
|
121
124
|
# @return [String] The datetime from the annotatedAt property, or nil
|
122
125
|
def annotated_at
|
123
126
|
solution = @graph.query [nil, RDF::Vocab::OA.annotatedAt, nil]
|
124
|
-
|
125
|
-
|
126
|
-
solution.first.object.to_s
|
127
|
+
solution.first.object.to_s if solution && solution.size == 1
|
127
128
|
end
|
128
129
|
|
129
130
|
|
@@ -137,8 +138,8 @@ module OA
|
|
137
138
|
remove_has_body_statements
|
138
139
|
end
|
139
140
|
|
140
|
-
# remove all RDF::Vocab::OA.hasBody statements and any other statements
|
141
|
-
# with body objects
|
141
|
+
# remove all RDF::Vocab::OA.hasBody statements and any other statements
|
142
|
+
# associated with body objects
|
142
143
|
def remove_has_body_statements
|
143
144
|
remove_predicate_and_its_object_statements RDF::Vocab::OA.hasBody
|
144
145
|
end
|
@@ -157,7 +158,7 @@ module OA
|
|
157
158
|
pred_obj = pstmt.object
|
158
159
|
OA::Graph.subject_statements(pred_obj, @graph).each { |s|
|
159
160
|
@graph.delete s
|
160
|
-
}
|
161
|
+
} if OA::Graph.subject_statements(pred_obj, @graph)
|
161
162
|
@graph.delete pstmt
|
162
163
|
}
|
163
164
|
end
|
@@ -178,6 +179,8 @@ module OA
|
|
178
179
|
predicate: s.predicate,
|
179
180
|
object: s.object)
|
180
181
|
@graph.delete s
|
182
|
+
else
|
183
|
+
next
|
181
184
|
end
|
182
185
|
}
|
183
186
|
end
|
data/lib/oa/graph/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oa-graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naomi Dushay
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry-byebug
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description:
|
112
126
|
email:
|
113
127
|
- ndushay@stanford.edu
|