oa-graph 0.0.2 → 0.0.3

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: d05e95d50b265fbf9d10a4a12c3456ff5ec300e5
4
- data.tar.gz: 9aecffab903d3b419196ef93038d1e6a270887f0
3
+ metadata.gz: c3936395a6626210fe91e9a71feee1c18d771651
4
+ data.tar.gz: 48b82f2b30d2aa1986a024924e5a189d46bfd096
5
5
  SHA512:
6
- metadata.gz: 02ce99c8170c9267b34e309897d3ab24fe0bfc957e257262b692644b220906fc50315db491b563d672c8f92c1b0a0bbda392c84706bf6823ca4b71e3ab7a9594
7
- data.tar.gz: 193919b828241ef41f63f76059b05297bedb4a70eb4face68c08da10b8d44cdcf42aaf15f5d981153c062fcafff88be9e599300977b34cb6e79c7ee1f47e743e
6
+ metadata.gz: 1be7a8c58201d1a98736903981059369a4a9f1c19029533e77fcfe67dbac9c035c7219b82835ff07e01ad83bac340ea28174e8808d60a1a314d6dcec86fa4f67
7
+ data.tar.gz: 6633f12a6587ea7742b54bd358cc41464654c2df01178ce4910c52cefe7643684d1e5e53b3d7ebe5921104ef85d49dc36667288462694d933370636d3e19ff90
data/README.md CHANGED
@@ -1,4 +1,4 @@
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)
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.svg?branch=master)](https://coveralls.io/r/sul-dlss/oa-graph?branch=master) [![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
2
 
3
3
 
4
4
  # OA::Graph
@@ -23,7 +23,9 @@ Or install it yourself as:
23
23
 
24
24
  ## Usage
25
25
 
26
- TODO: Write usage instructions here
26
+ ```ruby
27
+ require 'oa/graph'
28
+ ```
27
29
 
28
30
  ## Contributing
29
31
 
@@ -16,7 +16,7 @@ module OA
16
16
  # Class Methods ----------------------------------------------------------------
17
17
 
18
18
  # given an RDF::Resource (an RDF::Node or RDF::URI), look for all the
19
- # statements with that object as the subject, and recurse through the graph
19
+ # statements with that object as the subject, and recurse through the graph
20
20
  # to find all descendant statements pertaining to the subject
21
21
  # @param subject the RDF object to be used as the subject in the graph
22
22
  # query. Should be an RDF::Node or RDF::URI
@@ -78,30 +78,17 @@ module OA
78
78
  # @return [Array<String>] Array of urls expressing the OA motivated_by
79
79
  # values
80
80
  def motivated_by
81
- motivations = []
82
81
  q = self.class.anno_query.dup
83
82
  q << [:s, RDF::Vocab::OA.motivatedBy, :motivated_by]
84
- solution = @graph.query q
85
- if solution && solution.size > 0
86
- solution.each { |res|
87
- motivations << res.motivated_by.to_s
88
- }
89
- end
90
- # TODO: raise exception if none? (validation)
91
- motivations
83
+ # if the motivation object gives junk with .to_s, then the anno is illegal anyway and we're not responsible
84
+ @graph.query(q).each.collect {|stmt| stmt.motivated_by.to_s}
92
85
  end
93
86
 
94
87
  # @param [RDF::URI] predicate either RDF::Vocab::OA.hasTarget or
95
88
  # RDF::Vocab::OA.hasBody
96
89
  # @return [Array<String>] urls for the predicate, as an Array of Strings
97
90
  def predicate_urls(predicate)
98
- urls = []
99
- predicate_solns = @graph.query [nil, predicate, nil]
100
- predicate_solns.each { |predicate_stmt|
101
- predicate_obj = predicate_stmt.object
102
- urls << predicate_obj.to_str.strip if predicate_obj.is_a?(RDF::URI)
103
- }
104
- urls
91
+ @graph.query([nil, predicate, nil]).each_object.collect {|o| o.to_str.strip if o.is_a?(RDF::URI) }.compact
105
92
  end
106
93
 
107
94
  # For all bodies that are of type ContentAsText, get the characters as a
@@ -109,16 +96,11 @@ module OA
109
96
  # @return [Array<String>] body chars as Strings, in an Array (one element
110
97
  # for each contentAsText body)
111
98
  def body_chars
112
- result = []
113
99
  q = RDF::Query.new
114
100
  q << [nil, RDF::Vocab::OA.hasBody, :body]
115
101
  q << [:body, RDF.type, RDF::Vocab::CNT.ContentAsText]
116
102
  q << [:body, RDF::Vocab::CNT.chars, :body_chars]
117
- solns = @graph.query q
118
- solns.each { |soln|
119
- result << soln.body_chars.value
120
- }
121
- result
103
+ @graph.query(q).each.collect {|stmt| stmt.body_chars.value}
122
104
  end
123
105
 
124
106
  # @return [String] The datetime from the annotatedAt property, or nil
@@ -1,5 +1,5 @@
1
1
  module OA
2
2
  class Graph
3
- VERSION = '0.0.2'
3
+ VERSION = '0.0.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oa-graph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naomi Dushay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-23 00:00:00.000000000 Z
11
+ date: 2015-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: linkeddata
@@ -124,8 +124,7 @@ dependencies:
124
124
  version: '0'
125
125
  description:
126
126
  email:
127
- - ndushay@stanford.edu
128
- - darren.weber@stanford.edu
127
+ - triannon-commits@lists.stanford.edu
129
128
  executables: []
130
129
  extensions: []
131
130
  extra_rdoc_files: []