rdf-tabular 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rdf/tabular/metadata.rb +611 -659
- data/lib/rdf/tabular/reader.rb +59 -54
- data/spec/metadata_spec.rb +191 -376
- data/spec/suite_helper.rb +5 -0
- data/spec/suite_spec.rb +53 -39
- metadata +2 -2
data/spec/suite_helper.rb
CHANGED
@@ -93,6 +93,7 @@ module Fixtures
|
|
93
93
|
|
94
94
|
class Entry < JSON::LD::Resource
|
95
95
|
attr_accessor :debug
|
96
|
+
attr_accessor :warnings
|
96
97
|
attr_accessor :metadata
|
97
98
|
|
98
99
|
def id
|
@@ -140,6 +141,10 @@ module Fixtures
|
|
140
141
|
type.include?("Validation")
|
141
142
|
end
|
142
143
|
|
144
|
+
def warning?
|
145
|
+
type.include?("Warning")
|
146
|
+
end
|
147
|
+
|
143
148
|
def positive_test?
|
144
149
|
!negative_test?
|
145
150
|
end
|
data/spec/suite_spec.rb
CHANGED
@@ -18,53 +18,67 @@ describe RDF::Tabular::Reader do
|
|
18
18
|
m.entries.each do |t|
|
19
19
|
specify "#{t.id.split("/").last}: #{t.name} - #{t.comment}" do
|
20
20
|
t.debug = []
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
t.warnings = []
|
22
|
+
begin
|
23
|
+
RDF::Tabular::Reader.open(t.action,
|
24
|
+
t.reader_options.merge(
|
25
|
+
base_uri: t.base,
|
26
|
+
validate: t.validation?,
|
27
|
+
debug: t.debug,
|
28
|
+
warnings: t.warnings
|
29
|
+
)
|
30
|
+
) do |reader|
|
31
|
+
expect(reader).to be_a RDF::Reader
|
29
32
|
|
30
|
-
|
31
|
-
|
33
|
+
t.metadata = reader.metadata # for debug output
|
34
|
+
t.metadata = t.metadata.parent if t.metadata && t.metadata.parent
|
32
35
|
|
33
|
-
|
36
|
+
graph = RDF::Repository.new
|
34
37
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
if t.positive_test?
|
39
|
+
if t.json?
|
40
|
+
result = reader.to_json
|
41
|
+
if t.evaluate?
|
42
|
+
RDF::Util::File.open_file(t.result) do |res|
|
43
|
+
expect(::JSON.parse(result)).to produce(::JSON.parse(res.read), t)
|
44
|
+
end
|
45
|
+
else
|
46
|
+
expect(::JSON.parse(result)).to be_a(Hash)
|
47
|
+
end
|
48
|
+
else # RDF or Validation
|
49
|
+
begin
|
50
|
+
graph << reader
|
51
|
+
rescue Exception => e
|
52
|
+
expect(e.message).to produce("Not exception #{e.inspect}\n#{e.backtrace.join("\n")}", t.debug)
|
41
53
|
end
|
42
|
-
else
|
43
|
-
expect(::JSON.parse(result)).to be_a(Hash)
|
44
|
-
end
|
45
|
-
else # RDF or Validation
|
46
|
-
begin
|
47
|
-
graph << reader
|
48
|
-
rescue Exception => e
|
49
|
-
expect(e.message).to produce("Not exception #{e.inspect}\n#{e.backtrace.join("\n")}", t.debug)
|
50
|
-
end
|
51
54
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
+
if t.sparql?
|
56
|
+
RDF::Util::File.open_file(t.result) do |query|
|
57
|
+
expect(graph).to pass_query(query, t)
|
58
|
+
end
|
59
|
+
elsif t.evaluate?
|
60
|
+
output_graph = RDF::Repository.load(t.result, format: :ttl, base_uri: t.base)
|
61
|
+
expect(graph).to be_equivalent_graph(output_graph, t)
|
62
|
+
elsif t.validation?
|
63
|
+
expect(graph).to be_a(RDF::Enumerable)
|
64
|
+
|
65
|
+
if t.warning?
|
66
|
+
expect(t.warnings.length).to produce 1, t
|
67
|
+
else
|
68
|
+
expect(t.warnings).to produce [], t
|
69
|
+
end
|
55
70
|
end
|
56
|
-
elsif t.evaluate?
|
57
|
-
output_graph = RDF::Repository.load(t.result, format: :ttl, base_uri: t.base)
|
58
|
-
expect(graph).to be_equivalent_graph(output_graph, t)
|
59
|
-
else
|
60
|
-
expect(graph).to be_a(RDF::Enumerable)
|
61
71
|
end
|
72
|
+
else
|
73
|
+
expect {
|
74
|
+
graph << reader
|
75
|
+
expect(graph.dump(:ntriples)).to produce("not this", t.debug)
|
76
|
+
}.to raise_error(RDF::Tabular::Error)
|
62
77
|
end
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
}.to raise_error(RDF::Tabular::Error)
|
78
|
+
end
|
79
|
+
rescue Exception => e
|
80
|
+
unless t.negative_test? && t.validation?
|
81
|
+
raise
|
68
82
|
end
|
69
83
|
end
|
70
84
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf-tabular
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregg Kellogg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bcp47
|