dbd_onto 0.0.14 → 0.0.15

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: b99c185f81ed86400639cf217c6a6b6fb7a3a7cf
4
- data.tar.gz: 08084f1c85c98cd8cad6a8304c9e53913c3d30f6
3
+ metadata.gz: 93ac0ee5f794eb6e4ee9149fd2a2eaa959da5981
4
+ data.tar.gz: b453f34b146d01ef8a119ec4bfb7a6e3e68e0f21
5
5
  SHA512:
6
- metadata.gz: 01b1332b303ab08583c507809c472af16dcd04c637e9b718538378eaf52d3c6edc696289e3aa5077198dbdf0815c084116bcb25a1ff7376546f8cc8ffd273cff
7
- data.tar.gz: aa2a1d1d78194ecbe995c239ba0da0a0adc8c402e3f79e60b55f04338ad5005890cbfb70c76fb14d894221e50fd1cabc887268db1517fdda52d30203d853f341
6
+ metadata.gz: 3faf6a76c3f351c55c747811e6c453959b0931e70ac62f9d10ed592ee4fe494b92e9a75373a34a8d59a7e4ccf7ff980f51c3f8e1e4cf19cb6e120214f0ed09a4
7
+ data.tar.gz: ec7148d1ac253e12f5c51a114df49c2d79d03bb4d24ee8770eaca6aeb0be53de23b1e0e5b775d62818497c8dca30af7a614e7db6b458bd7c2788ec57601785aa
data/HISTORY.txt CHANGED
@@ -62,3 +62,9 @@
62
62
  ======
63
63
 
64
64
  * 90+ additional schema predicates are added
65
+
66
+ 0.0.15 (2014-04-17)
67
+ ======
68
+
69
+ * Add DbdOnto::Rdf with rdf:type
70
+
data/data/meta.md CHANGED
@@ -1,15 +1,16 @@
1
1
  # Meta ontology
2
2
 
3
- A first meta ontology is constructed with 1 resource as a bootstrap to start defining the rest.
3
+ A first meta ontology is constructed with a few resources as a bootstrap to start defining the rest.
4
4
 
5
- As a bootstrap, this ontology defines itself (the predicate is equal to the object).
6
-
7
- It defines this predicate:
5
+ It defines these predicates:
8
6
 
9
7
  * meta:defines_predicate
10
8
 
9
+ As a bootstrap, this ontology defines itself (the predicate is equal to the object).
10
+
11
+ * meta:predicate_used
12
+
11
13
  This predicate determines if a predicate is used in the UI for new resources (Schema.org
12
14
  has a lot of predicate (600 +) and I prefer not to start using them all at once in a first
13
15
  simplistic implementation).
14
16
 
15
- * meta:predicate_used
data/lib/dbd_onto.rb CHANGED
@@ -4,5 +4,6 @@ require 'dbd_onto/meta_context'
4
4
  require 'dbd_onto/base'
5
5
  require 'dbd_onto/context'
6
6
  require 'dbd_onto/meta'
7
+ require 'dbd_onto/rdf'
7
8
  require 'dbd_onto/schema'
8
9
  require 'dbd_onto/dbd'
@@ -9,6 +9,10 @@ module DbdOnto
9
9
  fixed_context(fixed_schema_context_csv)
10
10
  end
11
11
 
12
+ def rdf_context
13
+ fixed_context(fixed_rdf_context_csv)
14
+ end
15
+
12
16
  private
13
17
 
14
18
  def fixed_context(csv_string)
@@ -38,5 +42,17 @@ EOS
38
42
  "2013-10-14 21:43:42.473845509 UTC","9424e4bc-5922-463b-8fc6-521ca5585c23","","37c0b50f-834e-45f5-a911-e3f2b47fe4b9","dcterms:created","s","2013-10-15 21:56:00 UTC"
39
43
  EOS
40
44
  end
45
+
46
+ def fixed_rdf_context_csv
47
+ <<EOS
48
+ "2014-04-17 19:23:43.473735776 UTC","b71d95c4-a9a1-4ef2-a257-1cc5a3949c30","","38c0b50f-834e-45f5-a911-e3f2b47fe4b9","context:visibility","s","public"
49
+ "2014-04-17 19:23:43.473775562 UTC","b71d95c4-a9a1-4ef2-a257-1cc5a3949c31","","38c0b50f-834e-45f5-a911-e3f2b47fe4b9","context:encryption","s","clear"
50
+ "2014-04-17 19:23:43.473796239 UTC","b71d95c4-a9a1-4ef2-a257-1cc5a3949c32","","38c0b50f-834e-45f5-a911-e3f2b47fe4b9","context:license","s","Copyright 2014 Peter Vandenabeele"
51
+ "2014-04-17 19:23:43.473812175 UTC","b71d95c4-a9a1-4ef2-a257-1cc5a3949c33","","38c0b50f-834e-45f5-a911-e3f2b47fe4b9","dc:source","s","http://www.w3.org/TR/rdf-schema/"
52
+ "2014-04-17 19:23:43.473828787 UTC","b71d95c4-a9a1-4ef2-a257-1cc5a3949c34","","38c0b50f-834e-45f5-a911-e3f2b47fe4b9","dc:creator","s","Peter Vandenabeele (@peter_v)"
53
+ "2014-04-17 19:23:43.473845509 UTC","b71d95c4-a9a1-4ef2-a257-1cc5a3949c35","","38c0b50f-834e-45f5-a911-e3f2b47fe4b9","dcterms:created","s","2014-04-17 19:43:00 UTC"
54
+ EOS
55
+ end
56
+
41
57
  end
42
58
  end
@@ -0,0 +1,27 @@
1
+ module DbdOnto
2
+ class Rdf < Base
3
+
4
+ def initialize
5
+ super
6
+ self << rdf_context
7
+ self << rdf_resource
8
+ end
9
+
10
+ private
11
+
12
+ def rdf_resource
13
+ ::Dbd::Graph.new.from_CSV(rdf_resource_csv)
14
+ end
15
+
16
+ def rdf_resource_csv
17
+ <<EOS
18
+ "2014-04-17 19:30:36.627034414 UTC","74eae2a4-06c6-41c1-94b9-298905dcbd00","38c0b50f-834e-45f5-a911-e3f2b47fe4b9","619e69d4-6dad-4b14-bfce-8fd67d8e126c","meta:defines_predicate","s","rdf:type"
19
+ "2014-04-17 19:30:36.627066056 UTC","74eae2a4-06c6-41c1-94b9-298905dcbd01","38c0b50f-834e-45f5-a911-e3f2b47fe4b9","619e69d4-6dad-4b14-bfce-8fd67d8e126c","rdfs:label","s","RDF type"
20
+ "2014-04-17 19:30:36.627067056 UTC","74eae2a4-06c6-41c1-94b9-298905dcbd02","38c0b50f-834e-45f5-a911-e3f2b47fe4b9","619e69d4-6dad-4b14-bfce-8fd67d8e126c","dbd:rdf_uri","s","http://www.w3.org/TR/rdf-schema/#ch_type"
21
+ "2014-04-17 19:30:36.627068056 UTC","74eae2a4-06c6-41c1-94b9-298905dcbd03","38c0b50f-834e-45f5-a911-e3f2b47fe4b9","619e69d4-6dad-4b14-bfce-8fd67d8e126c","rdfs:comment","s","Is used to state that a resource is an instance of a class."
22
+ "2014-04-17 19:30:36.627069056 UTC","74eae2a4-06c6-41c1-94b9-298905dcbd04","38c0b50f-834e-45f5-a911-e3f2b47fe4b9","619e69d4-6dad-4b14-bfce-8fd67d8e126c","meta:predicate_used","s","true"
23
+ EOS
24
+ end
25
+
26
+ end
27
+ end
@@ -1,12 +1,10 @@
1
- require 'dbd'
2
-
3
1
  module DbdOnto
4
2
  class Schema < Base
5
3
 
6
4
  def initialize
7
5
  super
8
6
  self << schema_context
9
- self << self.class.schema_resource
7
+ self << self.class.schema
10
8
  self << self.class.used_predicates
11
9
  self.freeze
12
10
  end
@@ -18,21 +16,21 @@ module DbdOnto
18
16
  end
19
17
 
20
18
  def self.used_predicates_filename
21
- File.expand_path('../../../data/used_predicates_data.csv', __FILE__)
19
+ File.expand_path('../../../data/used_schema_predicates_data.csv', __FILE__)
22
20
  end
23
21
 
24
22
  # performance optimization (a bit ugly, but it works ...)
25
- # use a class instance variable to cache the schema_resource
23
+ # use a class instance variable to cache the schema
26
24
  # at _load_ time! Also tried "memoization" increases reported
27
25
  # RSpec test time from 0.20 to 0.67 seconds (which could be
28
26
  # relevant, since we really want to minimize the _run-time_
29
27
  # cost after loading the Ruby/Rails app (e.g. in Passenger))
30
28
 
31
- @schema_resource = Dbd::Graph.new.from_CSV(File.open(schema_filename))
29
+ @schema = Dbd::Graph.new.from_CSV(File.open(schema_filename))
32
30
  @used_predicates = Dbd::Graph.new.from_CSV(File.open(used_predicates_filename))
33
31
 
34
- def self.schema_resource
35
- @schema_resource
32
+ def self.schema
33
+ @schema
36
34
  end
37
35
 
38
36
  def self.used_predicates
@@ -42,13 +40,14 @@ module DbdOnto
42
40
  # This code is reused on 2013-10-15 with permission from the ruby-rdf/rdf project
43
41
  # from the file https://github.com/ruby-rdf/rdf/blob/master/lib/rdf/vocab/schema.rb
44
42
  # It was licensed as "public domain" (https://github.com/ruby-rdf/rdf/blob/master/UNLICENSE)
45
- def self.generate_schema_data
43
+ def self.generate_schema
46
44
  require 'addressable/uri'
47
45
  require 'rdf/rdfa'
48
46
  v = RDF::Graph.load("http://schema.org/docs/schema_org_rdfa.html", format: :rdfa)
49
47
 
50
48
  schema_hash = {}
51
49
 
50
+ # NOTE: it is unclear if this now generates rdf:uri or dbd:rdf_uri as predicates
52
51
  # build the list of schema:predicates
53
52
  v.query(property: RDF.type, object: RDF.Property) do |c|
54
53
  uri = c.subject.to_s
@@ -72,8 +71,8 @@ module DbdOnto
72
71
 
73
72
  # create a graoh with 1 resource per schema:<predicate>
74
73
  # we now save the schema:<predicate>, rdf:uri, rdfs:label and rdfs:comment
75
- schema_resource = Base.new
76
- schema_context = schema_resource.schema_context
74
+ schema = Base.new
75
+ schema_context = schema.schema_context
77
76
 
78
77
  schema_hash.each do |schema_predicate, properties_hash|
79
78
  resource = Dbd::Resource.new(context_subject: schema_context.subject)
@@ -83,14 +82,14 @@ module DbdOnto
83
82
  object_type: 's', # should 'u' for the uri
84
83
  object: object)
85
84
  end
86
- schema_resource << resource
85
+ schema << resource
87
86
  end
88
87
 
89
- schema_resource.to_CSV
88
+ schema.to_CSV
90
89
  end
91
90
 
92
91
  def self.used_predicates_list_filename
93
- File.expand_path('../../../data/used_predicates_list.csv', __FILE__)
92
+ File.expand_path('../../../data/used_schema_predicates_list.csv', __FILE__)
94
93
  end
95
94
 
96
95
  def self.generate_used_predicates_data
@@ -121,7 +120,7 @@ module DbdOnto
121
120
  end
122
121
 
123
122
  csv_data = used_predicates_graph.to_CSV
124
- filename = '/Users/peter_v/Documents/data/github/petervandenabeele/dbd_onto/data/used_predicates_data.csv'
123
+ filename = '/Users/peter_v/Documents/data/github/petervandenabeele/dbd_onto/data/used_schema_predicates_data.csv'
125
124
  File.open(filename, 'w') do |file|
126
125
  file << csv_data
127
126
  end
@@ -1,3 +1,3 @@
1
1
  module DbdOnto
2
- VERSION = "0.0.14"
2
+ VERSION = "0.0.15"
3
3
  end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe DbdOnto::Rdf do
4
+
5
+ include Spec::Context
6
+
7
+ it 'is a Dbd::Graph' do
8
+ subject.should be_a(Dbd::Graph)
9
+ end
10
+
11
+ it 'all facts in the rdf ontology have the rdf_context' do
12
+ subject.all? do |fact|
13
+ fact.is_a?(Dbd::ContextFact) ||
14
+ check_rdf_context?(subject.by_subject(fact.context_subject))
15
+ end.should be_true
16
+ end
17
+
18
+ describe 'properties include' do
19
+
20
+ let(:rdf_type_subject) do
21
+ subject.detect do |fact|
22
+ fact.predicate == 'meta:defines_predicate' &&
23
+ fact.object == 'rdf:type'
24
+ end.subject
25
+ end
26
+
27
+ describe 'rdf_type' do
28
+
29
+ let(:rdf_type_facts) { subject.by_subject(rdf_type_subject) }
30
+
31
+ it 'defines the predicate rdf_type' do
32
+ rdf_type_subject.should_not be_nil
33
+ end
34
+
35
+ it 'has label "RDF type"' do
36
+ rdf_type_facts.detect do |fact|
37
+ begin
38
+ fact.predicate == 'rdfs:label' &&
39
+ fact.object == 'RDF type'
40
+ end
41
+ end.should_not be_nil
42
+ end
43
+
44
+ it 'has a URI' do
45
+ rdf_type_facts.detect do |fact|
46
+ fact.predicate == 'dbd:rdf_uri'
47
+ end.should_not be_nil
48
+ end
49
+
50
+ it 'has a comment' do
51
+ rdf_type_facts.detect do |fact|
52
+ fact.predicate == 'rdfs:comment'
53
+ end.should_not be_nil
54
+ end
55
+
56
+ it 'is used' do
57
+ rdf_type_facts.detect do |fact|
58
+ fact.predicate == 'meta:predicate_used'
59
+ end.should_not be_nil
60
+ end
61
+ end
62
+ end
63
+ end
@@ -19,5 +19,14 @@ module Spec
19
19
  meta_context.detect {|p| p.predicate == 'dcterms:created'}
20
20
  end
21
21
 
22
+ def check_rdf_context?(meta_context)
23
+ meta_context.detect {|p| p.predicate == 'context:visibility' && p.object == 'public'} &&
24
+ meta_context.detect {|p| p.predicate == 'context:encryption' && p.object == 'clear'} &&
25
+ meta_context.detect {|p| p.predicate == 'context:license'} &&
26
+ meta_context.detect {|p| p.predicate == 'dc:source' && p.object == 'http://www.w3.org/TR/rdf-schema/'} &&
27
+ meta_context.detect {|p| p.predicate == 'dc:creator' && p.object == 'Peter Vandenabeele (@peter_v)'} &&
28
+ meta_context.detect {|p| p.predicate == 'dcterms:created'}
29
+ end
30
+
22
31
  end
23
32
  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.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Vandenabeele
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-17 00:00:00.000000000 Z
11
+ date: 2014-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -172,8 +172,8 @@ files:
172
172
  - data/meta.md
173
173
  - data/schema_data.csv
174
174
  - data/schema_predicates_list.csv
175
- - data/used_predicates_data.csv
176
- - data/used_predicates_list.csv
175
+ - data/used_schema_predicates_data.csv
176
+ - data/used_schema_predicates_list.csv
177
177
  - dbd_onto.gemspec
178
178
  - lib/dbd_onto.rb
179
179
  - lib/dbd_onto/base.rb
@@ -181,6 +181,7 @@ files:
181
181
  - lib/dbd_onto/dbd.rb
182
182
  - lib/dbd_onto/meta.rb
183
183
  - lib/dbd_onto/meta_context.rb
184
+ - lib/dbd_onto/rdf.rb
184
185
  - lib/dbd_onto/schema.rb
185
186
  - lib/dbd_onto/version.rb
186
187
  - spec/lib/dbd_onto/base_spec.rb
@@ -188,6 +189,7 @@ files:
188
189
  - spec/lib/dbd_onto/dbd_spec.rb
189
190
  - spec/lib/dbd_onto/meta_context_spec.rb
190
191
  - spec/lib/dbd_onto/meta_spec.rb
192
+ - spec/lib/dbd_onto/rdf_spec.rb
191
193
  - spec/lib/dbd_onto/schema_spec.rb
192
194
  - spec/spec_helper.rb
193
195
  - spec/support/meta_context.rb
@@ -221,6 +223,7 @@ test_files:
221
223
  - spec/lib/dbd_onto/dbd_spec.rb
222
224
  - spec/lib/dbd_onto/meta_context_spec.rb
223
225
  - spec/lib/dbd_onto/meta_spec.rb
226
+ - spec/lib/dbd_onto/rdf_spec.rb
224
227
  - spec/lib/dbd_onto/schema_spec.rb
225
228
  - spec/spec_helper.rb
226
229
  - spec/support/meta_context.rb