oa-graph 0.0.1 → 0.0.2

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: 1ee82d3a04f3b61c10ce562151dcdb0e72c90547
4
- data.tar.gz: 70110ef9417988e88c8f3c301731767e218e4ced
3
+ metadata.gz: d05e95d50b265fbf9d10a4a12c3456ff5ec300e5
4
+ data.tar.gz: 9aecffab903d3b419196ef93038d1e6a270887f0
5
5
  SHA512:
6
- metadata.gz: 7fb5b5f0cdab266514db38680df4016a46dcf9a35338f69a1db00a541ac2c43ad44106c33a6bd698076c68fc5e9baf5548170ea2ffe49b313e4ce2323db73965
7
- data.tar.gz: 31470a60d945d2e04501d40b78c10163d6b0f615b0b70c8b202f72a7f25da533b57e1655c57bfbb32dcbac12114c9a2f7d5311b0ddc78a8c71f61f61c6a755d5
6
+ metadata.gz: 02ce99c8170c9267b34e309897d3ab24fe0bfc957e257262b692644b220906fc50315db491b563d672c8f92c1b0a0bbda392c84706bf6823ca4b71e3ab7a9594
7
+ data.tar.gz: 193919b828241ef41f63f76059b05297bedb4a70eb4face68c08da10b8d44cdcf42aaf15f5d981153c062fcafff88be9e599300977b34cb6e79c7ee1f47e743e
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
- # Oa::Graph
1
+ [![Build Status](https://travis-ci.org/sul-dlss/oa-graph.svg?branch=master)](https://travis-ci.org/sul-dlss/oa-graph) [![Coverage Status](https://coveralls.io/repos/sul-dlss/oa-graph/badge.png)](https://coveralls.io/r/sul-dlss/oa-graph) [![Dependency Status](https://gemnasium.com/sul-dlss/oa-graph.svg)](https://gemnasium.com/sul-dlss/oa-graph) [![Gem Version](https://badge.fury.io/rb/oa-graph.svg)](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
 
@@ -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
- return if solution && solution.size == 1
70
-
71
- rdf_resource = solution.first.s
72
- rdf_resource.to_s if rdf_resource.is_a?(RDF::URI)
73
- # TODO: raise exception if not a URI?
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 RDF::Vocab::OA.hasBody
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
- return if solution && solution.size == 1
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 associated
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
- } unless !OA::Graph.subject_statements(pred_obj, @graph)
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
@@ -1,5 +1,5 @@
1
1
  module OA
2
2
  class Graph
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  end
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.1
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