dbd 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.txt +5 -0
- data/README.md +28 -16
- data/docs/stories/012_provenance_fact_properties_from_provenance_ontology.txt +1 -1
- data/docs/test.rb +25 -24
- data/lib/dbd/graph.rb +17 -3
- data/lib/dbd/version.rb +1 -1
- data/spec/lib/dbd/graph_spec.rb +27 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52008013920900a7e6910513c2dd0cde838b386b
|
4
|
+
data.tar.gz: 0eae581b08f64c6dc3a7f459d6c39d58dff670c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c61721ceb5d4161f317d8e2fa1f2a15cfef35ffac18d0a9c5e536a2929bdb1e744be061619f599bb26045067ccb2bd93bd1e1d0023f394005e628b6261497d71
|
7
|
+
data.tar.gz: 16ce5f0c1be7867338e9c0e37a808d260ed9beef25a7d299f6ea575bcf542fb87b79352987e9c90166102167cd1fce353c9ac8057f6f82b5637613697a288a04
|
data/HISTORY.txt
CHANGED
data/README.md
CHANGED
@@ -46,30 +46,30 @@ Open Source [MIT]
|
|
46
46
|
|
47
47
|
## Examples
|
48
48
|
|
49
|
+
Also see the file `docs/test.rb`.
|
50
|
+
|
49
51
|
```
|
50
52
|
require 'dbd'
|
51
53
|
|
52
54
|
provenance = Dbd::ProvenanceResource.new
|
53
55
|
|
54
|
-
# PREFIX prov: <https://data.vandenabeele.com/ontologies/provenance#>
|
55
|
-
# PREFIX dcterms: <http://purl.org/dc/terms/>
|
56
56
|
fact_context_public = Dbd::ProvenanceFact.new(predicate: "prov:context", object: "public")
|
57
57
|
fact_source_dbd = Dbd::ProvenanceFact.new(predicate: "prov:source", object: "http://github.com/petervandenabeele/dbd")
|
58
58
|
fact_creator_peter_v = Dbd::ProvenanceFact.new(predicate: "dcterms:creator", object: "@peter_v")
|
59
59
|
fact_created_now = Dbd::ProvenanceFact.new(predicate: "dcterms:created", object: Time.now.utc)
|
60
|
+
fact_license_MIT = Dbd::ProvenanceFact.new(predicate: "prov:license", object: "MIT")
|
60
61
|
provenance << fact_context_public
|
61
62
|
provenance << fact_source_dbd
|
62
63
|
provenance << fact_creator_peter_v
|
63
64
|
provenance << fact_created_now
|
65
|
+
provenance << fact_license_MIT
|
64
66
|
|
65
67
|
nobel_peace_2012 = Dbd::Resource.new(provenance_subject: provenance.subject)
|
66
68
|
|
67
|
-
|
68
|
-
# PREFIX base: <https://data.vandenabeele.com/ontologies/base#>
|
69
|
-
fact_nobel_peace_2012 = Dbd::Fact.new(predicate: "base:nobelPeacePriceWinner", object: "2012")
|
69
|
+
fact_nobel_peace_2012 = Dbd::Fact.new(predicate: "todo:nobelPeacePriceWinner", object: "2012")
|
70
70
|
fact_EU_label = Dbd::Fact.new(predicate: "rdfs:label", object: "EU") # this will use some RDF predicates in future
|
71
71
|
fact_EU_comment = Dbd::Fact.new(predicate: "rdfs:comment", object: "European Union")
|
72
|
-
fact_EU_story = Dbd::Fact.new(predicate: "
|
72
|
+
fact_EU_story = Dbd::Fact.new(predicate: "todo:story", object: "A long period of peace,\n that is a \"bliss\".")
|
73
73
|
nobel_peace_2012 << fact_nobel_peace_2012
|
74
74
|
nobel_peace_2012 << fact_EU_label
|
75
75
|
nobel_peace_2012 << fact_EU_comment
|
@@ -77,22 +77,34 @@ nobel_peace_2012 << fact_EU_story
|
|
77
77
|
|
78
78
|
graph = Dbd::Graph.new
|
79
79
|
|
80
|
-
graph << provenance
|
81
|
-
graph << nobel_peace_2012
|
80
|
+
graph << [provenance, nobel_peace_2012]
|
82
81
|
|
83
82
|
puts "facts in short representation:"
|
84
83
|
puts graph.map(&:short)
|
85
|
-
#
|
86
|
-
# [ prov ] :
|
87
|
-
# [ prov ] :
|
88
|
-
# [ prov ] :
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
#
|
84
|
+
# facts in short representation:
|
85
|
+
# [ prov ] : 78b0d99b : prov:context : public
|
86
|
+
# [ prov ] : 78b0d99b : prov:source : http://github.com/petervandenabeele/dbd
|
87
|
+
# [ prov ] : 78b0d99b : dcterms:creator : @peter_v
|
88
|
+
# [ prov ] : 78b0d99b : dcterms:created : 2013-05-29 22:10:14 UTC
|
89
|
+
# [ prov ] : 78b0d99b : prov:license : MIT
|
90
|
+
# 78b0d99b : 0db0caee : todo:nobelPeacePriceWinn : 2012
|
91
|
+
# 78b0d99b : 0db0caee : rdfs:label : EU
|
92
|
+
# 78b0d99b : 0db0caee : rdfs:comment : European Union
|
93
|
+
# 78b0d99b : 0db0caee : todo:story : A long period of peace,_ that is a "bliss".
|
93
94
|
|
94
95
|
puts "facts in full detail in CSV:"
|
95
96
|
puts graph.to_CSV
|
97
|
+
# facts in full detail in CSV:
|
98
|
+
# "58c33e41-87c7-4403-b058-60e4ebf063ed","2013-05-29 22:10:14.811038737 UTC","","78b0d99b-aaf9-4b67-9b84-43c3b7d44729","prov:context","public"
|
99
|
+
# "44f72707-f0af-4e1e-8674-8009aedda826","2013-05-29 22:10:14.811075014 UTC","","78b0d99b-aaf9-4b67-9b84-43c3b7d44729","prov:source","http://github.com/petervandenabeele/dbd"
|
100
|
+
# "dd409d99-cdb5-4a99-a3c1-cfb64b1eaa62","2013-05-29 22:10:14.811092335 UTC","","78b0d99b-aaf9-4b67-9b84-43c3b7d44729","dcterms:creator","@peter_v"
|
101
|
+
# "a135916e-b055-4da5-805f-6adba927c935","2013-05-29 22:10:14.811105102 UTC","","78b0d99b-aaf9-4b67-9b84-43c3b7d44729","dcterms:created","2013-05-29 22:10:14 UTC"
|
102
|
+
# "345d455d-3f2d-4b9e-9084-d866c767feba","2013-05-29 22:10:14.811116493 UTC","","78b0d99b-aaf9-4b67-9b84-43c3b7d44729","prov:license","MIT"
|
103
|
+
# "1d49db69-9b7a-49b7-be87-7ca7e88a20f6","2013-05-29 22:10:14.811135641 UTC","78b0d99b-aaf9-4b67-9b84-43c3b7d44729","0db0caee-cc05-4f02-b90e-1ad4e72050a5","todo:nobelPeacePriceWinner","2012"
|
104
|
+
# "ce620335-a661-4a72-a932-1fe904f3db8a","2013-05-29 22:10:14.811151313 UTC","78b0d99b-aaf9-4b67-9b84-43c3b7d44729","0db0caee-cc05-4f02-b90e-1ad4e72050a5","rdfs:label","EU"
|
105
|
+
# "a694f74b-219d-4e23-936a-5f10b77fe321","2013-05-29 22:10:14.811164540 UTC","78b0d99b-aaf9-4b67-9b84-43c3b7d44729","0db0caee-cc05-4f02-b90e-1ad4e72050a5","rdfs:comment","European Union"
|
106
|
+
# "85732e38-79d9-48d0-8611-0bed25883bd3","2013-05-29 22:10:14.811176113 UTC","78b0d99b-aaf9-4b67-9b84-43c3b7d44729","0db0caee-cc05-4f02-b90e-1ad4e72050a5","todo:story","A long period of peace,
|
107
|
+
# that is a ""bliss""."
|
96
108
|
```
|
97
109
|
|
98
110
|
[RDF]: http://www.w3.org/RDF/
|
data/docs/test.rb
CHANGED
@@ -2,25 +2,23 @@ require 'dbd'
|
|
2
2
|
|
3
3
|
provenance = Dbd::ProvenanceResource.new
|
4
4
|
|
5
|
-
# PREFIX prov: <https://data.vandenabeele.com/ontologies/provenance#>
|
6
|
-
# PREFIX dcterms: <http://purl.org/dc/terms/>
|
7
5
|
fact_context_public = Dbd::ProvenanceFact.new(predicate: "prov:context", object: "public")
|
8
6
|
fact_source_dbd = Dbd::ProvenanceFact.new(predicate: "prov:source", object: "http://github.com/petervandenabeele/dbd")
|
9
7
|
fact_creator_peter_v = Dbd::ProvenanceFact.new(predicate: "dcterms:creator", object: "@peter_v")
|
10
8
|
fact_created_now = Dbd::ProvenanceFact.new(predicate: "dcterms:created", object: Time.now.utc)
|
9
|
+
fact_license_MIT = Dbd::ProvenanceFact.new(predicate: "prov:license", object: "MIT")
|
11
10
|
provenance << fact_context_public
|
12
11
|
provenance << fact_source_dbd
|
13
12
|
provenance << fact_creator_peter_v
|
14
13
|
provenance << fact_created_now
|
14
|
+
provenance << fact_license_MIT
|
15
15
|
|
16
16
|
nobel_peace_2012 = Dbd::Resource.new(provenance_subject: provenance.subject)
|
17
17
|
|
18
|
-
|
19
|
-
# PREFIX base: <https://data.vandenabeele.com/ontologies/base#>
|
20
|
-
fact_nobel_peace_2012 = Dbd::Fact.new(predicate: "base:nobelPeacePriceWinner", object: "2012")
|
18
|
+
fact_nobel_peace_2012 = Dbd::Fact.new(predicate: "todo:nobelPeacePriceWinner", object: "2012")
|
21
19
|
fact_EU_label = Dbd::Fact.new(predicate: "rdfs:label", object: "EU") # this will use some RDF predicates in future
|
22
20
|
fact_EU_comment = Dbd::Fact.new(predicate: "rdfs:comment", object: "European Union")
|
23
|
-
fact_EU_story = Dbd::Fact.new(predicate: "
|
21
|
+
fact_EU_story = Dbd::Fact.new(predicate: "todo:story", object: "A long period of peace,\n that is a \"bliss\".")
|
24
22
|
nobel_peace_2012 << fact_nobel_peace_2012
|
25
23
|
nobel_peace_2012 << fact_EU_label
|
26
24
|
nobel_peace_2012 << fact_EU_comment
|
@@ -28,28 +26,31 @@ nobel_peace_2012 << fact_EU_story
|
|
28
26
|
|
29
27
|
graph = Dbd::Graph.new
|
30
28
|
|
31
|
-
graph << provenance
|
32
|
-
graph << nobel_peace_2012
|
29
|
+
graph << [provenance, nobel_peace_2012]
|
33
30
|
|
34
31
|
puts "facts in short representation:"
|
35
32
|
puts graph.map(&:short)
|
36
|
-
#
|
37
|
-
# [ prov ] :
|
38
|
-
# [ prov ] :
|
39
|
-
# [ prov ] :
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
33
|
+
# facts in short representation:
|
34
|
+
# [ prov ] : 78b0d99b : prov:context : public
|
35
|
+
# [ prov ] : 78b0d99b : prov:source : http://github.com/petervandenabeele/dbd
|
36
|
+
# [ prov ] : 78b0d99b : dcterms:creator : @peter_v
|
37
|
+
# [ prov ] : 78b0d99b : dcterms:created : 2013-05-29 22:10:14 UTC
|
38
|
+
# [ prov ] : 78b0d99b : prov:license : MIT
|
39
|
+
# 78b0d99b : 0db0caee : todo:nobelPeacePriceWinn : 2012
|
40
|
+
# 78b0d99b : 0db0caee : rdfs:label : EU
|
41
|
+
# 78b0d99b : 0db0caee : rdfs:comment : European Union
|
42
|
+
# 78b0d99b : 0db0caee : todo:story : A long period of peace,_ that is a "bliss".
|
44
43
|
|
45
44
|
puts "facts in full detail in CSV:"
|
46
45
|
puts graph.to_CSV
|
47
|
-
#
|
48
|
-
# "
|
49
|
-
# "
|
50
|
-
# "
|
51
|
-
# "
|
52
|
-
# "
|
53
|
-
# "
|
54
|
-
# "
|
46
|
+
# facts in full detail in CSV:
|
47
|
+
# "58c33e41-87c7-4403-b058-60e4ebf063ed","2013-05-29 22:10:14.811038737 UTC","","78b0d99b-aaf9-4b67-9b84-43c3b7d44729","prov:context","public"
|
48
|
+
# "44f72707-f0af-4e1e-8674-8009aedda826","2013-05-29 22:10:14.811075014 UTC","","78b0d99b-aaf9-4b67-9b84-43c3b7d44729","prov:source","http://github.com/petervandenabeele/dbd"
|
49
|
+
# "dd409d99-cdb5-4a99-a3c1-cfb64b1eaa62","2013-05-29 22:10:14.811092335 UTC","","78b0d99b-aaf9-4b67-9b84-43c3b7d44729","dcterms:creator","@peter_v"
|
50
|
+
# "a135916e-b055-4da5-805f-6adba927c935","2013-05-29 22:10:14.811105102 UTC","","78b0d99b-aaf9-4b67-9b84-43c3b7d44729","dcterms:created","2013-05-29 22:10:14 UTC"
|
51
|
+
# "345d455d-3f2d-4b9e-9084-d866c767feba","2013-05-29 22:10:14.811116493 UTC","","78b0d99b-aaf9-4b67-9b84-43c3b7d44729","prov:license","MIT"
|
52
|
+
# "1d49db69-9b7a-49b7-be87-7ca7e88a20f6","2013-05-29 22:10:14.811135641 UTC","78b0d99b-aaf9-4b67-9b84-43c3b7d44729","0db0caee-cc05-4f02-b90e-1ad4e72050a5","todo:nobelPeacePriceWinner","2012"
|
53
|
+
# "ce620335-a661-4a72-a932-1fe904f3db8a","2013-05-29 22:10:14.811151313 UTC","78b0d99b-aaf9-4b67-9b84-43c3b7d44729","0db0caee-cc05-4f02-b90e-1ad4e72050a5","rdfs:label","EU"
|
54
|
+
# "a694f74b-219d-4e23-936a-5f10b77fe321","2013-05-29 22:10:14.811164540 UTC","78b0d99b-aaf9-4b67-9b84-43c3b7d44729","0db0caee-cc05-4f02-b90e-1ad4e72050a5","rdfs:comment","European Union"
|
55
|
+
# "85732e38-79d9-48d0-8611-0bed25883bd3","2013-05-29 22:10:14.811176113 UTC","78b0d99b-aaf9-4b67-9b84-43c3b7d44729","0db0caee-cc05-4f02-b90e-1ad4e72050a5","todo:story","A long period of peace,
|
55
56
|
# that is a ""bliss""."
|
data/lib/dbd/graph.rb
CHANGED
@@ -10,11 +10,11 @@ module Dbd
|
|
10
10
|
include Fact::Collection
|
11
11
|
|
12
12
|
##
|
13
|
-
# Add a Fact or Resource
|
13
|
+
# Add a Fact or Resource or any set recursively.
|
14
14
|
#
|
15
15
|
# This will add a time_stamp to the Facts.
|
16
|
-
def <<(
|
17
|
-
|
16
|
+
def <<(recursive_fact_collection)
|
17
|
+
loop_recursively(recursive_fact_collection) do |fact|
|
18
18
|
enforce_strictly_monotonic_time(fact)
|
19
19
|
super(fact)
|
20
20
|
end
|
@@ -42,5 +42,19 @@ module Dbd
|
|
42
42
|
fact.time_stamp = TimeStamp.new(larger_than: newest_time_stamp) unless fact.time_stamp
|
43
43
|
end
|
44
44
|
|
45
|
+
def loop_recursively(recursive_collection, &block)
|
46
|
+
Array(recursive_collection).each do |fact_or_collection|
|
47
|
+
further_recursion_or_stop(fact_or_collection, &block)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def further_recursion_or_stop(fact_or_collection, &block)
|
52
|
+
if fact_or_collection.respond_to?(:each)
|
53
|
+
loop_recursively(fact_or_collection, &block)
|
54
|
+
else
|
55
|
+
yield(fact_or_collection)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
45
59
|
end
|
46
60
|
end
|
data/lib/dbd/version.rb
CHANGED
data/spec/lib/dbd/graph_spec.rb
CHANGED
@@ -18,6 +18,10 @@ module Dbd
|
|
18
18
|
let(:subject_regexp) { Fact::Subject.regexp }
|
19
19
|
let(:id_regexp) { Fact::ID.regexp }
|
20
20
|
|
21
|
+
let(:provenance_resource) { Factories::ProvenanceResource.provenance_resource }
|
22
|
+
let(:resource) { Factories::Resource.facts_resource(provenance_resource.subject) }
|
23
|
+
let(:resource_array) { [provenance_resource, resource]}
|
24
|
+
|
21
25
|
describe "create a graph" do
|
22
26
|
it "does not fail" do
|
23
27
|
described_class.new # should_not raise_error
|
@@ -88,9 +92,6 @@ module Dbd
|
|
88
92
|
|
89
93
|
describe "a ProvenanceResource and a Resource" do
|
90
94
|
|
91
|
-
let(:provenance_resource) { Factories::ProvenanceResource.provenance_resource }
|
92
|
-
let(:resource) { Factories::Resource.facts_resource(provenance_resource.subject) }
|
93
|
-
|
94
95
|
it "does not fail" do
|
95
96
|
subject << provenance_resource
|
96
97
|
end
|
@@ -108,6 +109,29 @@ module Dbd
|
|
108
109
|
subject.last.class.should == Fact
|
109
110
|
end
|
110
111
|
end
|
112
|
+
|
113
|
+
describe "an array of Resources" do
|
114
|
+
it "does not fail" do
|
115
|
+
subject << resource_array
|
116
|
+
end
|
117
|
+
|
118
|
+
it "Adds the facts from the provenance_resource and the resource to the graph" do
|
119
|
+
subject << resource_array
|
120
|
+
subject.first.class.should == ProvenanceFact
|
121
|
+
subject.last.class.should == Fact
|
122
|
+
subject.size.should == 4
|
123
|
+
end
|
124
|
+
|
125
|
+
it "goes 3 levels over collection deep" do
|
126
|
+
subject << [resource_array]
|
127
|
+
subject.size.should == 4
|
128
|
+
end
|
129
|
+
|
130
|
+
it "works with different levels deep in 1 collection" do
|
131
|
+
subject << [provenance_resource, [[resource]]]
|
132
|
+
subject.size.should == 4
|
133
|
+
end
|
134
|
+
end
|
111
135
|
end
|
112
136
|
|
113
137
|
describe "#to_CSV with only provenance_facts" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Vandenabeele
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|