dbd_onto 0.0.2 → 0.0.3

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: 35d5a01f7cfad54d12d69aa386c8b6224c350eba
4
- data.tar.gz: 38f1e559e587785ce22a7004b39d409d50323540
3
+ metadata.gz: 739a46718120265eb188bb28df0e65f3086acbf7
4
+ data.tar.gz: 450eee39e90813d0d493de83ebcb471b2839859a
5
5
  SHA512:
6
- metadata.gz: 0f46bec9c0b1ec2f1e1f17984258597dcc310fa9fb671b7c0a7394cdd83e4a6adde8157822b0d0276b5ae47cd0571d1a2d34d13b3dd675e2f86804967803350a
7
- data.tar.gz: b8547fc8357c129249922621c3fe0c210836e5ed5c40671895c5ff15fb36e911f8c0a4293894df3d373dfa96fb0ba31b4a3499f25302e4bac792aa4638f1621b
6
+ metadata.gz: 86d4c7bd75bf84101ea630d6dde7da93d212dcaec68bc33a733c2b7062bf65a83008301cbe982849cac42b448868b8dfb7446c4d8adc59e4ed781d9531636454
7
+ data.tar.gz: 888fc2cd8752a2b6495a41f7168c668442ff8eade3e87c9fa49439003443474bd52b098720914fd845d802bbfc26bc679c733dd78b443906607608bc23381827
data/HISTORY.txt CHANGED
@@ -9,3 +9,8 @@
9
9
 
10
10
  * Update to Dbd 0.0.14 (Provenance => Context)
11
11
  * use dc:creator (instead of dcterms:creator that has a specific range)
12
+
13
+ 0.0.3 (2013-09-03)
14
+ =====
15
+
16
+ * DbdOnto::Meta now has static data (constant id, subject, ...)
data/README.md CHANGED
@@ -28,14 +28,14 @@ The ontology is stored as a [Dbd]::Graph. Displaying it in short format:
28
28
  2.0.0p247 :001 > require 'dbd_onto'
29
29
  => true
30
30
  2.0.0p247 :002 > DbdOnto::Meta.new.each {|f| puts f.short} ; nil
31
- [ cont ] : bd5ae676 : context:visibility : public
32
- [ cont ] : bd5ae676 : context:encryption : clear
33
- [ cont ] : bd5ae676 : context:license : Copyright 2013 Peter Vandenabeele (http://vandenabeele.com), licensed under MIT
34
- [ cont ] : bd5ae676 : dc:source : https://github.com/petervandenabeele/dbd/blob/d37360070e7f8e61a19c2bca210c881a15
35
- [ cont ] : bd5ae676 : dc:creator : Peter Vandenabeele (@peter_v)
36
- [ cont ] : bd5ae676 : dcterms:created : 2013-08-09 21:45:00 UTC
37
- bd5ae676 : 8c20a99a : meta:defines_predicate : meta:defines_predicate
38
- bd5ae676 : 8c20a99a : rdfs:label : Defines predicate
31
+ [ cont ] : 36c0b50f : context:visibility : public
32
+ [ cont ] : 36c0b50f : context:encryption : clear
33
+ [ cont ] : 36c0b50f : context:license : Copyright 2013 Peter Vandenabeele (http://vandenabeele.com), licensed under MIT
34
+ [ cont ] : 36c0b50f : dc:source : https://github.com/petervandenabeele/dbd/blob/d37360070e7f8e61a19c2bca210c881a15
35
+ [ cont ] : 36c0b50f : dc:creator : Peter Vandenabeele (@peter_v)
36
+ [ cont ] : 36c0b50f : dcterms:created : 2013-08-09 21:45:00 UTC
37
+ 36c0b50f : 619e69d4 : meta:defines_predicate : meta:defines_predicate
38
+ 36c0b50f : 619e69d4 : rdfs:label : Defines predicate
39
39
  => nil
40
40
  2.0.0p247 :003 > DbdOnto::Context.new.each {|f| puts f.short} ; nil
41
41
  [ cont ] : 6aac5473 : context:visibility : public
data/dbd_onto.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency 'guard-rspec'
24
24
  spec.add_development_dependency 'terminal-notifier-guard'
25
25
  spec.add_development_dependency 'yard'
26
- spec.add_runtime_dependency 'rdf', '~> 1.0.6'
26
+ spec.add_runtime_dependency 'rdf'
27
27
  spec.add_runtime_dependency 'ruby_peter_v', '>= 0.0.11'
28
- spec.add_runtime_dependency 'dbd', '>= 0.0.14'
28
+ spec.add_runtime_dependency 'dbd', '>= 0.0.18'
29
29
  end
data/lib/dbd_onto/meta.rb CHANGED
@@ -6,21 +6,32 @@ module DbdOnto
6
6
  def initialize
7
7
  super
8
8
  self << meta_context
9
- self << meta_resources
9
+ self << meta_resource
10
10
  end
11
11
 
12
12
  private
13
13
 
14
- def meta_resources
15
- META_ATTRIBUTES.map do |attribute|
16
- resource = resource_with_meta_context
17
- resource << fact_defines_predicate_meta(attribute)
18
- resource << fact_label(attribute)
14
+ def meta_resource
15
+ graph = Dbd::Graph.new.from_CSV(meta_facts_csv)
16
+ subject = graph.subjects.single
17
+ meta_facts = graph.by_subject(subject)
18
+ resource = resource_with_meta_context(subject: subject)
19
+ add_meta_facts(resource, meta_facts)
20
+ resource
21
+ end
22
+
23
+ def add_meta_facts(resource, meta_facts)
24
+ # NOTE this can be cleaned-up when Dbd is Context << [] is fixed
25
+ meta_facts.each do |meta_fact|
26
+ resource << meta_fact
19
27
  end
20
28
  end
21
29
 
22
- def fact_defines_predicate_meta(attribute)
23
- Dbd::Fact.new(predicate: 'meta:defines_predicate', object: "meta:#{attribute}")
30
+ def meta_facts_csv
31
+ <<EOS
32
+ "2013-09-03 21:41:36.627034414 UTC","1e84b23b-edf0-49f5-8ad3-76182dcfa124","36c0b50f-834e-45f5-a911-e3f2b47fe4b9","619e69d4-6dad-4b14-bfce-8fd67d8e126c","meta:defines_predicate","meta:defines_predicate"
33
+ "2013-09-03 21:41:36.627066056 UTC","96d595be-205d-4c3a-8724-35b46457f9ed","36c0b50f-834e-45f5-a911-e3f2b47fe4b9","619e69d4-6dad-4b14-bfce-8fd67d8e126c","rdfs:label","Defines predicate"
34
+ EOS
24
35
  end
25
36
 
26
37
  end
@@ -1,42 +1,41 @@
1
1
  module DbdOnto
2
2
  module MetaContext
3
3
 
4
- def resource_with_meta_context
5
- Dbd::Resource.new(context_subject: meta_context.subject)
4
+ def resource_with_meta_context(options = {})
5
+ Dbd::Resource.new(context_subject: meta_context.subject, subject: options[:subject])
6
6
  end
7
7
 
8
8
  def meta_context
9
- # memoize to avoid making new_context on each call
10
- @context_resource ||= new_context_resource
9
+ fixed_meta_context
11
10
  end
12
11
 
13
12
  private
14
13
 
15
- def new_context_resource
16
- Dbd::Context.new.tap do |_context|
17
- context_attributes.each do |context_fact_data|
18
- _context << context_fact(context_fact_data)
19
- end
14
+ def fixed_meta_context
15
+ graph = Dbd::Graph.new.from_CSV(fixed_meta_context_csv)
16
+ subject = graph.subjects.single
17
+ context_facts = graph.by_subject(subject)
18
+ Dbd::Context.new(subject: subject).tap do |context|
19
+ add_context_facts(context, context_facts)
20
20
  end
21
21
  end
22
22
 
23
- def context_fact(context_fact_data)
24
- Dbd::ContextFact.new(
25
- predicate: context_fact_data.first,
26
- object: context_fact_data.last)
23
+ def add_context_facts(context, context_facts)
24
+ # NOTE this can be cleaned-up when Dbd is Context << [] is fixed
25
+ context_facts.each do |context_fact|
26
+ context << context_fact
27
+ end
27
28
  end
28
29
 
29
- def context_attributes
30
- [
31
- #[predicate, object]
32
- ['context:visibility', 'public'],
33
- ['context:encryption', 'clear'],
34
- ['context:license', 'Copyright 2013 Peter Vandenabeele (http://vandenabeele.com), licensed under MIT license.'],
35
- ['dc:source' , 'https://github.com/petervandenabeele/dbd/blob/d37360070e7f8e61a19c2bca210c881a151ded75/docs/rationale.md'],
36
- ['dc:creator' , 'Peter Vandenabeele (@peter_v)'],
37
- ['dcterms:created', Time.new(2013,8,9,23,45,0,'+02:00').utc]
38
- ]
30
+ def fixed_meta_context_csv
31
+ <<EOS
32
+ "2013-09-03 20:54:42.473735776 UTC","d680b54c-5aad-44a7-9e9e-c8d7a7084275","","36c0b50f-834e-45f5-a911-e3f2b47fe4b9","context:visibility","public"
33
+ "2013-09-03 20:54:42.473775562 UTC","be5b97ec-d026-4a73-b8fb-a13995966ec0","","36c0b50f-834e-45f5-a911-e3f2b47fe4b9","context:encryption","clear"
34
+ "2013-09-03 20:54:42.473796239 UTC","1251e568-f7e6-44bf-b5b0-54c15cefe5d9","","36c0b50f-834e-45f5-a911-e3f2b47fe4b9","context:license","Copyright 2013 Peter Vandenabeele (http://vandenabeele.com), licensed under MIT license."
35
+ "2013-09-03 20:54:42.473812175 UTC","c73715de-4cb3-4022-93c6-fb9ec95851be","","36c0b50f-834e-45f5-a911-e3f2b47fe4b9","dc:source","https://github.com/petervandenabeele/dbd/blob/d37360070e7f8e61a19c2bca210c881a151ded75/docs/rationale.md"
36
+ "2013-09-03 20:54:42.473828787 UTC","3aaa9125-6278-4a70-9a40-7f2baf32ad99","","36c0b50f-834e-45f5-a911-e3f2b47fe4b9","dc:creator","Peter Vandenabeele (@peter_v)"
37
+ "2013-09-03 20:54:42.473845509 UTC","9324e4bc-5922-463b-8fc6-521ca5585c22","","36c0b50f-834e-45f5-a911-e3f2b47fe4b9","dcterms:created","2013-08-09 21:45:00 UTC"
38
+ EOS
39
39
  end
40
-
41
40
  end
42
41
  end
@@ -1,3 +1,3 @@
1
1
  module DbdOnto
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -4,18 +4,18 @@ describe DbdOnto::Context do
4
4
 
5
5
  include Spec::Context
6
6
 
7
- it "is a Dbd::Graph" do
7
+ it 'is a Dbd::Graph' do
8
8
  subject.should be_a(Dbd::Graph)
9
9
  end
10
10
 
11
- it "all facts in the context ontology have the meta context as context" do
11
+ it 'all facts in the context ontology have the meta context as context' do
12
12
  subject.all? do |fact|
13
13
  fact.is_a?(Dbd::ContextFact) ||
14
14
  check_context?(subject.by_subject(fact.context_subject))
15
15
  end.should be_true
16
16
  end
17
17
 
18
- describe "properties include" do
18
+ describe 'properties include' do
19
19
 
20
20
  let(:visibility_subject) do
21
21
  subject.detect do |fact|
@@ -38,21 +38,21 @@ describe DbdOnto::Context do
38
38
  end.subject
39
39
  end
40
40
 
41
- describe "prov:subject and prov:source" do
42
- it "are different subjects" do
41
+ describe 'context:visibility and dc:source' do
42
+ it 'are different subjects' do
43
43
  visibility_subject.should_not == source_subject
44
44
  end
45
45
  end
46
46
 
47
- describe "context:visibility" do
47
+ describe 'context:visibility' do
48
48
 
49
49
  let(:visibility_facts) { subject.by_subject(visibility_subject) }
50
50
 
51
- it "defines the predicate context:visibility" do
51
+ it 'defines the predicate context:visibility' do
52
52
  visibility_subject.should_not be_nil
53
53
  end
54
54
 
55
- it "has label Context" do
55
+ it 'has label Context' do
56
56
  visibility_facts.detect do |fact|
57
57
  fact.predicate == 'rdfs:label' &&
58
58
  fact.object == 'Visibility'
@@ -60,15 +60,15 @@ describe DbdOnto::Context do
60
60
  end
61
61
  end
62
62
 
63
- describe "prov:encryption" do
63
+ describe 'context:encryption' do
64
64
 
65
65
  let(:encryption_facts) { subject.by_subject(encryption_subject) }
66
66
 
67
- it "defines the predicate prov:encryption" do
67
+ it 'defines the predicate context:encryption' do
68
68
  encryption_subject.should_not be_nil
69
69
  end
70
70
 
71
- it "has label Encryption" do
71
+ it 'has label Encryption' do
72
72
  encryption_facts.detect do |fact|
73
73
  fact.predicate == 'rdfs:label' &&
74
74
  fact.object == 'Encryption'
@@ -76,15 +76,15 @@ describe DbdOnto::Context do
76
76
  end
77
77
  end
78
78
 
79
- describe "prov:source" do
79
+ describe 'dc:source' do
80
80
 
81
81
  let(:source_facts) { subject.by_subject(source_subject) }
82
82
 
83
- it "defines the predicate prov:source" do
83
+ it 'defines the predicate dc:source' do
84
84
  source_subject.should_not be_nil
85
85
  end
86
86
 
87
- it "has label Source" do
87
+ it 'has label Source' do
88
88
  source_facts.detect do |fact|
89
89
  fact.predicate == 'rdfs:label' &&
90
90
  fact.object == 'Source'
@@ -92,8 +92,8 @@ describe DbdOnto::Context do
92
92
  end
93
93
  end
94
94
 
95
- describe "dc:creator" do
96
- it "defines the predicate" do
95
+ describe 'dc:creator' do
96
+ it 'defines the predicate' do
97
97
  subject.detect do |fact|
98
98
  fact.predicate == 'meta:defines_predicate' &&
99
99
  fact.object == 'dc:creator'
@@ -101,8 +101,8 @@ describe DbdOnto::Context do
101
101
  end
102
102
  end
103
103
 
104
- describe "dcterms:created" do
105
- it "defines the predicate" do
104
+ describe 'dcterms:created' do
105
+ it 'defines the predicate' do
106
106
  subject.detect do |fact|
107
107
  fact.predicate == 'meta:defines_predicate' &&
108
108
  fact.object == 'dcterms:created'
@@ -110,8 +110,8 @@ describe DbdOnto::Context do
110
110
  end
111
111
  end
112
112
 
113
- describe "context:license" do
114
- it "defines the predicate" do
113
+ describe 'context:license' do
114
+ it 'defines the predicate' do
115
115
  subject.detect do |fact|
116
116
  fact.predicate == 'meta:defines_predicate' &&
117
117
  fact.object == 'context:license'
@@ -1,28 +1,26 @@
1
1
  require 'spec_helper'
2
2
 
3
- module DbdOnto
4
- describe MetaContext do
3
+ describe DbdOnto::MetaContext do
5
4
 
6
- include Spec::Context
5
+ include Spec::Context
7
6
 
8
- let(:meta_context) do
9
- Object.new.tap do |_meta_context|
10
- _meta_context.extend(described_class)
11
- end.meta_context
12
- end
7
+ let(:meta_context) do
8
+ Object.new.tap do |_meta_context|
9
+ _meta_context.extend(described_class)
10
+ end.meta_context
11
+ end
13
12
 
14
- it "is a Dbd::Context" do
15
- meta_context.should be_a(Dbd::Context)
16
- end
13
+ it 'is a Dbd::Context' do
14
+ meta_context.should be_a(Dbd::Context)
15
+ end
17
16
 
18
- it "all facts in the meta_context are context facts" do
19
- meta_context.all? do |context_fact|
20
- context_fact.should be_a(Dbd::ContextFact)
21
- end
17
+ it 'all facts in the meta_context are context facts' do
18
+ meta_context.all? do |context_fact|
19
+ context_fact.should be_a(Dbd::ContextFact)
22
20
  end
21
+ end
23
22
 
24
- it "the meta_context has all the needed entries" do
25
- check_context?(meta_context).should be_true
26
- end
23
+ it 'the meta_context has all the needed entries' do
24
+ check_context?(meta_context).should be_true
27
25
  end
28
26
  end
@@ -4,18 +4,18 @@ describe DbdOnto::Meta do
4
4
 
5
5
  include Spec::Context
6
6
 
7
- it "is a Dbd::Graph" do
7
+ it 'is a Dbd::Graph' do
8
8
  subject.should be_a(Dbd::Graph)
9
9
  end
10
10
 
11
- it "all facts in the meta ontology have the meta context" do
11
+ it 'all facts in the meta ontology have the meta_context' do
12
12
  subject.all? do |fact|
13
13
  fact.is_a?(Dbd::ContextFact) ||
14
14
  check_context?(subject.by_subject(fact.context_subject))
15
15
  end.should be_true
16
16
  end
17
17
 
18
- describe "properties include" do
18
+ describe 'properties include' do
19
19
 
20
20
  let(:meta_defines_predicate_subject) do
21
21
  subject.detect do |fact|
@@ -24,15 +24,15 @@ describe DbdOnto::Meta do
24
24
  end.subject
25
25
  end
26
26
 
27
- describe "meta:defines_predicate" do
27
+ describe 'meta:defines_predicate' do
28
28
 
29
29
  let(:defines_predicate_facts) { subject.by_subject(meta_defines_predicate_subject) }
30
30
 
31
- it "defines the predicate meta:defines_predicate" do
31
+ it 'defines the predicate meta:defines_predicate' do
32
32
  meta_defines_predicate_subject.should_not be_nil
33
33
  end
34
34
 
35
- it "has label 'Defines predicate'" do
35
+ it 'has label "Defines predicate"' do
36
36
  defines_predicate_facts.detect do |fact|
37
37
  fact.predicate == 'rdfs:label' &&
38
38
  fact.object == 'Defines predicate'
@@ -1,13 +1,13 @@
1
1
  module Spec
2
2
  module Context
3
3
 
4
- def check_context?(context_resource)
5
- context_resource.detect {|p| p.predicate == 'context:visibility' && p.object == 'public'} &&
6
- context_resource.detect {|p| p.predicate == 'context:encryption' && p.object == 'clear'} &&
7
- context_resource.detect {|p| p.predicate == 'context:license'} &&
8
- context_resource.detect {|p| p.predicate == 'dc:source'} &&
9
- context_resource.detect {|p| p.predicate == 'dc:creator'} &&
10
- context_resource.detect {|p| p.predicate == 'dcterms:created'}
4
+ def check_context?(meta_context)
5
+ meta_context.detect {|p| p.predicate == 'context:visibility' && p.object == 'public'} &&
6
+ meta_context.detect {|p| p.predicate == 'context:encryption' && p.object == 'clear'} &&
7
+ meta_context.detect {|p| p.predicate == 'context:license'} &&
8
+ meta_context.detect {|p| p.predicate == 'dc:source'} &&
9
+ meta_context.detect {|p| p.predicate == 'dc:creator'} &&
10
+ meta_context.detect {|p| p.predicate == 'dcterms:created'}
11
11
  end
12
12
 
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbd_onto
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
  - Peter Vandenabeele
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-09 00:00:00.000000000 Z
11
+ date: 2013-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: rdf
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
- version: 1.0.6
89
+ version: '0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
- version: 1.0.6
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: ruby_peter_v
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - '>='
116
116
  - !ruby/object:Gem::Version
117
- version: 0.0.14
117
+ version: 0.0.18
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - '>='
123
123
  - !ruby/object:Gem::Version
124
- version: 0.0.14
124
+ version: 0.0.18
125
125
  description: Ontologies for Dbd
126
126
  email:
127
127
  - peter@vandenabeele.com