dbd 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/Guardfile +0 -1
  3. data/HISTORY.txt +9 -0
  4. data/README.md +47 -39
  5. data/bin/test_1.rb +4 -4
  6. data/bin/test_5.rb +4 -4
  7. data/docs/test.rb +11 -11
  8. data/lib/dbd.rb +2 -2
  9. data/lib/dbd/context.rb +65 -0
  10. data/lib/dbd/context_fact.rb +76 -0
  11. data/lib/dbd/errors.rb +1 -1
  12. data/lib/dbd/fact.rb +37 -37
  13. data/lib/dbd/fact/collection.rb +5 -5
  14. data/lib/dbd/fact/factory.rb +6 -6
  15. data/lib/dbd/graph.rb +2 -2
  16. data/lib/dbd/resource.rb +25 -24
  17. data/lib/dbd/version.rb +1 -1
  18. data/spec/lib/dbd/context/context_spec.rb +74 -0
  19. data/spec/lib/dbd/context_fact/methods_spec.rb +79 -0
  20. data/spec/lib/dbd/context_fact/new_spec.rb +51 -0
  21. data/spec/lib/dbd/context_fact/test_factories_spec.rb +24 -0
  22. data/spec/lib/dbd/errors/errors_spec.rb +30 -0
  23. data/spec/lib/dbd/fact/collection/collection_spec.rb +58 -58
  24. data/spec/lib/dbd/fact/factory/factory_spec.rb +3 -3
  25. data/spec/lib/dbd/fact/methods_spec.rb +12 -12
  26. data/spec/lib/dbd/fact/new_spec.rb +9 -9
  27. data/spec/lib/dbd/fact/subject/test_factories_spec.rb +4 -4
  28. data/spec/lib/dbd/fact/test_factories_spec.rb +18 -18
  29. data/spec/lib/dbd/graph/add_to_graph_spec.rb +22 -22
  30. data/spec/lib/dbd/graph/from_csv_spec.rb +16 -16
  31. data/spec/lib/dbd/graph/test_factories_spec.rb +11 -11
  32. data/spec/lib/dbd/graph/to_csv_spec.rb +18 -18
  33. data/spec/lib/dbd/performance_spec.rb +4 -4
  34. data/spec/lib/dbd/resource/collection_spec.rb +28 -30
  35. data/spec/lib/dbd/resource/new_spec.rb +10 -11
  36. data/spec/lib/dbd/resource/test_factories_spec.rb +8 -7
  37. data/spec/lib/dbd/version/version_spec.rb +9 -0
  38. data/spec/test_factories/context.rb +16 -0
  39. data/spec/test_factories/{provenance_fact.rb → context_fact.rb} +6 -6
  40. data/spec/test_factories/fact.rb +23 -23
  41. data/spec/test_factories/fact/subject.rb +1 -1
  42. data/spec/test_factories/graph.rb +7 -7
  43. data/spec/test_factories/resource.rb +15 -10
  44. metadata +20 -16
  45. data/lib/dbd/provenance_fact.rb +0 -77
  46. data/lib/dbd/provenance_resource.rb +0 -63
  47. data/spec/lib/dbd/provenance_fact/methods_spec.rb +0 -78
  48. data/spec/lib/dbd/provenance_fact/new_spec.rb +0 -51
  49. data/spec/lib/dbd/provenance_fact/test_factories_spec.rb +0 -24
  50. data/spec/lib/dbd/provenance_resource/provenance_resource_spec.rb +0 -75
  51. data/spec/test_factories/provenance_resource.rb +0 -16
@@ -1,78 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Dbd
4
- describe ProvenanceFact do
5
-
6
- let(:subject) { described_class.factory.new_subject }
7
-
8
- let(:provenance_fact_1) do
9
- TestFactories::ProvenanceFact.context(subject)
10
- end
11
-
12
- let(:provenance_fact_created) do
13
- TestFactories::ProvenanceFact.created(subject)
14
- end
15
-
16
- describe 'short' do
17
- it 'for a provenance fact shows [ prov ], subj, predicate, object' do
18
- provenance_fact_1.short.should match(/^\[ prov \] : [0-9a-f]{8} : https:\/\/data\.vandenabeel : public$/)
19
- end
20
-
21
- it 'for a provenance fact with non string object also works' do
22
- provenance_fact_created.short.should match(/^\[ prov \] : [0-9a-f]{8} : dcterms:created : \d{4}/)
23
- end
24
- end
25
-
26
- describe 'errors' do
27
- it 'the factory has no errors' do
28
- provenance_fact_1.errors.should be_empty
29
- end
30
-
31
- describe 'with a provenance_subject' do
32
-
33
- before(:each) do
34
- provenance_fact_1.stub(:provenance_subject).and_return(subject)
35
- end
36
-
37
- it 'errors returns an array with 1 error message' do
38
- provenance_fact_1.errors.single.should match(/Provenance subject should not be present in Provenance Fact/)
39
- end
40
- end
41
-
42
- describe 'without subject' do
43
-
44
- before(:each) do
45
- provenance_fact_1.stub(:subject).and_return(nil)
46
- end
47
-
48
- it 'errors returns an array with an error message' do
49
- provenance_fact_1.errors.single.should match(/Subject is missing/)
50
- end
51
- end
52
- end
53
-
54
- describe 'update_used_provenance_subjects' do
55
- it 'does nothing for a provenance_fact' do
56
- h = {}
57
- provenance_fact_1.update_used_provenance_subjects(h)
58
- h.should be_empty
59
- end
60
- end
61
-
62
- describe 'attributes and values' do
63
- it 'there are 6 attributes' do
64
- described_class.attributes.size.should == 6
65
- end
66
-
67
- it 'there are 6 values' do
68
- provenance_fact_1.values.size.should == 6
69
- end
70
- end
71
-
72
- describe 'provenance_fact?' do
73
- it 'is true for ProvenanceFact or derived from it' do
74
- provenance_fact_1.provenance_fact?.should be_true
75
- end
76
- end
77
- end
78
- end
@@ -1,51 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Dbd
4
- describe ProvenanceFact do
5
-
6
- let(:subject) { described_class.factory.new_subject }
7
- let(:id_class) { described_class.factory.new_id.class }
8
-
9
- let(:provenance_fact_1) do
10
- TestFactories::ProvenanceFact.context(subject)
11
- end
12
-
13
- let(:provenance_fact_2) do
14
- TestFactories::ProvenanceFact.created_by(subject)
15
- end
16
-
17
- describe '#new' do
18
- it 'has a unique id (new_id.class)' do
19
- provenance_fact_1.id.should be_a(id_class)
20
- end
21
-
22
- it 'two provenance_facts have different id' do
23
- provenance_fact_1.id.should_not == provenance_fact_2.id
24
- end
25
-
26
- it 'has nil provenance_subject' do
27
- provenance_fact_1.provenance_subject.should be_nil
28
- end
29
-
30
- it 'has correct subject' do
31
- provenance_fact_1.subject.should == subject
32
- end
33
-
34
- it 'has correct predicate' do
35
- provenance_fact_1.predicate.should == 'https://data.vandenabeele.com/ontologies/provenance#context'
36
- end
37
-
38
- it 'has correct object' do
39
- provenance_fact_1.object.should == 'public'
40
- end
41
-
42
- it 'raises an ProvenanceError when provenance_subject is present in options hash' do
43
- lambda { described_class.new(
44
- provenance_subject: subject,
45
- predicate: 'test',
46
- object: 'test') } .
47
- should raise_error ProvenanceError
48
- end
49
- end
50
- end
51
- end
@@ -1,24 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module TestFactories
4
- describe ProvenanceFact do
5
-
6
- describe 'TestFactories do not fail' do
7
- it 'TestFactories::ProvenanceFact.context is OK' do
8
- described_class.context.should_not be_nil
9
- end
10
-
11
- it 'TestFactories::ProvenanceFact.created_by is OK' do
12
- described_class.created_by.should_not be_nil
13
- end
14
-
15
- it 'TestFactories::ProvenanceFact.original_source is OK' do
16
- described_class.original_source.should_not be_nil
17
- end
18
-
19
- it 'TestFactories::ProvenanceFact.new_subject is OK' do
20
- described_class.new_subject.should be_a(ProvenanceFact.new_subject.class)
21
- end
22
- end
23
- end
24
- end
@@ -1,75 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Dbd
4
- describe ProvenanceResource do
5
-
6
- let(:provenance_resource) { described_class.new }
7
- let(:provenance_resource_subject) { provenance_resource.subject }
8
-
9
- describe '.new' do
10
- describe 'without a subject argument' do
11
- it 'has created a new subject' do
12
- provenance_resource.subject.should be_a(described_class.new_subject.class)
13
- end
14
- end
15
-
16
- describe 'with a subject argument' do
17
- it 'has stored the resource_subject' do
18
- described_class.new(subject: provenance_resource_subject).subject.
19
- should == provenance_resource_subject
20
- end
21
- end
22
-
23
- describe 'with a provenance_subject argument' do
24
- it 'raises an ProvenanceError' do
25
- lambda{ described_class.new(provenance_subject: provenance_resource_subject) }.
26
- should raise_error(ArgumentError)
27
- end
28
- end
29
- end
30
-
31
- describe 'provenance_subject' do
32
- it 'raises NoMethodError when called' do
33
- lambda{ provenance_resource.provenance_subject }.should raise_error(NoMethodError)
34
- end
35
- end
36
-
37
- describe 'TestFactories::Resource' do
38
- it '.provenance_resource works' do
39
- TestFactories::ProvenanceResource.provenance_resource
40
- end
41
- end
42
-
43
- describe 'the collection' do
44
-
45
- let(:provenance_fact_context) { TestFactories::ProvenanceFact.context }
46
- let(:provenance_fact_context_with_incorrect_subject) { TestFactories::ProvenanceFact.context(TestFactories::ProvenanceFact.new_subject) }
47
- let(:provenance_fact_context_with_correct_subject) { TestFactories::ProvenanceFact.context(provenance_resource_subject) }
48
- let(:fact_1) { TestFactories::Fact.fact_1(provenance_resource_subject) }
49
-
50
- describe 'adding provenance facts with << ' do
51
- it 'with correct subject it works' do
52
- provenance_resource << provenance_fact_context_with_correct_subject
53
- provenance_resource.first.subject.should == provenance_resource_subject
54
- end
55
-
56
- it 'with incorrect subject it raises SetOnceError' do
57
- lambda{ provenance_resource << provenance_fact_context_with_incorrect_subject }.
58
- should raise_error(RubyPeterV::SetOnceError),
59
- 'Value of subject was #{provenance_fact_context_with_incorrect_subject.subject}, ' \
60
- 'trying to set it to #{provenance_resource.subject}'
61
- end
62
-
63
- it 'with nil subject it sets the subject' do
64
- provenance_resource << provenance_fact_context
65
- provenance_resource.first.subject.should == provenance_resource_subject
66
- end
67
-
68
- it 'with nil (=correct) provenance_subject it is a noop' do
69
- provenance_resource << provenance_fact_context
70
- provenance_resource.first.provenance_subject.should be_nil
71
- end
72
- end
73
- end
74
- end
75
- end
@@ -1,16 +0,0 @@
1
- module TestFactories
2
- module ProvenanceResource
3
-
4
- def self.factory_for
5
- ::Dbd::ProvenanceResource
6
- end
7
-
8
- def self.provenance_resource
9
- factory_for.new.tap do |provenance_resource|
10
- provenance_resource << TestFactories::ProvenanceFact.context
11
- provenance_resource << TestFactories::ProvenanceFact.created_by
12
- end
13
- end
14
-
15
- end
16
- end