dbd 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b783665f6d90bb2b8e08d8f30b16b5ad93839442
4
- data.tar.gz: 74a917c72399200d7a4c1ac257d2a3490cd7c38d
3
+ metadata.gz: a4df1f0e326b407d9c2f0391a7ae7b0980a2deae
4
+ data.tar.gz: a9724f1c990e1fdeaa3c3159ae059b26de4ddc4c
5
5
  SHA512:
6
- metadata.gz: f55e7abd315c57ebd50b4bdba532ef36fdd2b352c29e0d7ae37e1aba68adbff061ca895b491807ec2a8926bf7eb9a6c30761a5ae2270997d66f344c87163ecae
7
- data.tar.gz: 7229d01d566e2455b76e64b6bc07fbb908212bebf95d9f1ca18ebe94da76a802aceab78c53646ada5004c35937d5580c8312862e1d46af464f0a6e2555100c87
6
+ metadata.gz: 391388832659492f0c00259140f97c1626820a0473373d5491ef9fb7e1fca6f1dd0badc3be4fca3bbbb2c567b52bdfa37bfef14bc1efe60f40beaa22813bc0ca
7
+ data.tar.gz: ca0facecd89bca3dfffb24865b8cf14e4676582d8254fed22e26ca268738c61ffc35f4f3fc7b755c8b4e728779e14579a8ae99a91be6f17f306f3c10f2cf490e
data/HISTORY.txt CHANGED
@@ -85,3 +85,9 @@
85
85
  * backslash => '\\\\' (double backslash)
86
86
  => now 1 fact is 1 "line" in the CSV file
87
87
  (allowing file operations that are line oriented)
88
+
89
+ 0.0.14 (9 Aug 2013)
90
+ ======
91
+
92
+ * in to_CSV the time_stamp now comes first (swapped with id)
93
+ * this will allow file level 'sort' on the ISO dates
data/README.md CHANGED
@@ -29,7 +29,7 @@ This is facts based data store, inspired by [RDF] concepts, but adding a log bas
29
29
  provenance is possible per fact (e.g. different properties about the same
30
30
  resource can come from different sources, different visibility etc.)
31
31
  * can keep the original_source reference, creator, date, …
32
- * can have a context that allows filtering data (e.g. private, professional, …)
32
+ * can have a context that allows filtering data (e.g. public, private, professional, …)
33
33
  * separate encryption schemes per context are possible
34
34
  * Context is flexible, since built itself from Facts
35
35
  * Schemaless
@@ -39,7 +39,6 @@ This is facts based data store, inspired by [RDF] concepts, but adding a log bas
39
39
  * the object of each Fact can be another Resource
40
40
  * aimed at exporting to a graph database (e.g. Neo4j) for analysis
41
41
 
42
-
43
42
  ## License
44
43
 
45
44
  Open Source [MIT]
@@ -63,7 +62,7 @@ require 'dbd'
63
62
 
64
63
  context = Dbd::Context.new
65
64
 
66
- context << Dbd::ContextFact.new(predicate: "prov:context_fact", object: "public")
65
+ context << Dbd::ContextFact.new(predicate: "prov:visibility", object: "public")
67
66
  context << Dbd::ContextFact.new(predicate: "prov:source", object: "http://github.com/petervandenabeele/dbd")
68
67
  context << Dbd::ContextFact.new(predicate: "dcterms:creator", object: "@peter_v")
69
68
  context << Dbd::ContextFact.new(predicate: "dcterms:created", object: Time.now.utc)
@@ -84,15 +83,15 @@ puts "facts in short representation:"
84
83
  puts graph.map(&:short)
85
84
 
86
85
  # facts in short representation:
87
- # [ cont ] : 7d0ccaa8 : prov:context_fact : public
88
- # [ cont ] : 7d0ccaa8 : prov:source : http://github.com/petervandenabeele/dbd
89
- # [ cont ] : 7d0ccaa8 : dcterms:creator : @peter_v
90
- # [ cont ] : 7d0ccaa8 : dcterms:created : 2013-07-10 21:34:32 UTC
91
- # [ cont ] : 7d0ccaa8 : prov:license : MIT
92
- # 7d0ccaa8 : 47acd35d : todo:nobelPeacePriceWinn : 2012
93
- # 7d0ccaa8 : 47acd35d : rdfs:label : EU
94
- # 7d0ccaa8 : 47acd35d : rdfs:comment : European Union
95
- # 7d0ccaa8 : 47acd35d : todo:story : A long period of peace,_ that is a "bliss".
86
+ # [ cont ] : d5ad0ca1 : prov:visibility : public
87
+ # [ cont ] : d5ad0ca1 : prov:source : http://github.com/petervandenabeele/dbd
88
+ # [ cont ] : d5ad0ca1 : dcterms:creator : @peter_v
89
+ # [ cont ] : d5ad0ca1 : dcterms:created : 2013-08-09 20:15:24 UTC
90
+ # [ cont ] : d5ad0ca1 : prov:license : MIT
91
+ # d5ad0ca1 : dede3cf8 : todo:nobelPeacePriceWinn : 2012
92
+ # d5ad0ca1 : dede3cf8 : rdfs:label : EU
93
+ # d5ad0ca1 : dede3cf8 : rdfs:comment : European Union
94
+ # d5ad0ca1 : dede3cf8 : todo:story : A long period of peace,_ that is a "bliss".
96
95
 
97
96
  csv = graph.to_CSV
98
97
 
@@ -100,30 +99,29 @@ puts "facts in full detail in CSV:"
100
99
  puts csv
101
100
 
102
101
  # facts in full detail in CSV:
103
- # "be44bc07-0c0e-450b-8bbc-4cc1f472be33","2013-07-10 21:34:32.759424573 UTC","","7d0ccaa8-b641-4f1b-82ad-f36ba3757aa0","prov:context_fact","public"
104
- # "dae577a3-f210-4aab-9079-d87a4a362bd5","2013-07-10 21:34:32.759475097 UTC","","7d0ccaa8-b641-4f1b-82ad-f36ba3757aa0","prov:source","http://github.com/petervandenabeele/dbd"
105
- # "750904f8-c052-46af-8b0a-266a701a6e06","2013-07-10 21:34:32.759497534 UTC","","7d0ccaa8-b641-4f1b-82ad-f36ba3757aa0","dcterms:creator","@peter_v"
106
- # "a62ff09f-76a5-42ab-be9a-fc66c727ba41","2013-07-10 21:34:32.759513249 UTC","","7d0ccaa8-b641-4f1b-82ad-f36ba3757aa0","dcterms:created","2013-07-10 21:34:32 UTC"
107
- # "427f9dc3-0544-4f33-9b30-ffa32930f5a8","2013-07-10 21:34:32.759528346 UTC","","7d0ccaa8-b641-4f1b-82ad-f36ba3757aa0","prov:license","MIT"
108
- # "a8dbdfe6-6ead-4a35-bb6e-ec3f233aed5b","2013-07-10 21:34:32.759546366 UTC","7d0ccaa8-b641-4f1b-82ad-f36ba3757aa0","47acd35d-f2b1-4b36-8a37-90b0f08217d5","todo:nobelPeacePriceWinner","2012"
109
- # "186571ac-1eca-4621-8b7e-9f263550e27b","2013-07-10 21:34:32.759564395 UTC","7d0ccaa8-b641-4f1b-82ad-f36ba3757aa0","47acd35d-f2b1-4b36-8a37-90b0f08217d5","rdfs:label","EU"
110
- # "5a58d782-59bc-4ac0-b410-7ac637572f74","2013-07-10 21:34:32.759579688 UTC","7d0ccaa8-b641-4f1b-82ad-f36ba3757aa0","47acd35d-f2b1-4b36-8a37-90b0f08217d5","rdfs:comment","European Union"
111
- # "2c3e9e63-fd94-4c0f-ac39-7a85b4dbb20d","2013-07-10 21:34:32.759594496 UTC","7d0ccaa8-b641-4f1b-82ad-f36ba3757aa0","47acd35d-f2b1-4b36-8a37-90b0f08217d5","todo:story","A long period of peace,
112
- # that is a ""bliss""."
102
+ # "2013-08-09 20:15:24.022368550 UTC","9cc48236-cb12-40e8-8641-08407b9a03fb","","d5ad0ca1-645f-41a8-8384-7f411a1f94e2","prov:visibility","public"
103
+ # "2013-08-09 20:15:24.022416066 UTC","86afeade-0802-4fe7-b0d7-9a09d5441dbf","","d5ad0ca1-645f-41a8-8384-7f411a1f94e2","prov:source","http://github.com/petervandenabeele/dbd"
104
+ # "2013-08-09 20:15:24.022435168 UTC","97d7fd9f-77e1-45e9-bdaa-9a283345c8ec","","d5ad0ca1-645f-41a8-8384-7f411a1f94e2","dcterms:creator","@peter_v"
105
+ # "2013-08-09 20:15:24.022449630 UTC","aa0897ce-d5ea-497a-8c4b-3a9339f6cc52","","d5ad0ca1-645f-41a8-8384-7f411a1f94e2","dcterms:created","2013-08-09 20:15:24 UTC"
106
+ # "2013-08-09 20:15:24.022463761 UTC","154d2b46-99df-4eaf-8a75-9e3b7d5df2a7","","d5ad0ca1-645f-41a8-8384-7f411a1f94e2","prov:license","MIT"
107
+ # "2013-08-09 20:15:24.022480963 UTC","0590f53a-346a-4ece-b510-fc1179e76e05","d5ad0ca1-645f-41a8-8384-7f411a1f94e2","dede3cf8-2d3f-4170-8ce5-3fe7c0db5529","todo:nobelPeacePriceWinner","2012"
108
+ # "2013-08-09 20:15:24.022497483 UTC","b28dc6fb-1779-47d3-9109-882075b28d08","d5ad0ca1-645f-41a8-8384-7f411a1f94e2","dede3cf8-2d3f-4170-8ce5-3fe7c0db5529","rdfs:label","EU"
109
+ # "2013-08-09 20:15:24.022512505 UTC","5474dbc0-ee47-4e7a-aa0a-cd60f8467d84","d5ad0ca1-645f-41a8-8384-7f411a1f94e2","dede3cf8-2d3f-4170-8ce5-3fe7c0db5529","rdfs:comment","European Union"
110
+ # "2013-08-09 20:15:24.022526505 UTC","a8c0a137-8c45-49bf-9a87-5915a24725b9","d5ad0ca1-645f-41a8-8384-7f411a1f94e2","dede3cf8-2d3f-4170-8ce5-3fe7c0db5529","todo:story","A long period of peace,\n that is a ""bliss""."
113
111
 
114
112
  imported_graph = Dbd::Graph.new.from_CSV(csv)
115
113
 
116
114
  puts imported_graph.map(&:short)
117
115
 
118
- # [ cont ] : 7d0ccaa8 : prov:context_fact : public
119
- # [ cont ] : 7d0ccaa8 : prov:source : http://github.com/petervandenabeele/dbd
120
- # [ cont ] : 7d0ccaa8 : dcterms:creator : @peter_v
121
- # [ cont ] : 7d0ccaa8 : dcterms:created : 2013-07-10 21:34:32 UTC
122
- # [ cont ] : 7d0ccaa8 : prov:license : MIT
123
- # 7d0ccaa8 : 47acd35d : todo:nobelPeacePriceWinn : 2012
124
- # 7d0ccaa8 : 47acd35d : rdfs:label : EU
125
- # 7d0ccaa8 : 47acd35d : rdfs:comment : European Union
126
- # 7d0ccaa8 : 47acd35d : todo:story : A long period of peace,_ that is a "bliss".
116
+ # [ cont ] : d5ad0ca1 : prov:visibility : public
117
+ # [ cont ] : d5ad0ca1 : prov:source : http://github.com/petervandenabeele/dbd
118
+ # [ cont ] : d5ad0ca1 : dcterms:creator : @peter_v
119
+ # [ cont ] : d5ad0ca1 : dcterms:created : 2013-08-09 20:15:24 UTC
120
+ # [ cont ] : d5ad0ca1 : prov:license : MIT
121
+ # d5ad0ca1 : dede3cf8 : todo:nobelPeacePriceWinn : 2012
122
+ # d5ad0ca1 : dede3cf8 : rdfs:label : EU
123
+ # d5ad0ca1 : dede3cf8 : rdfs:comment : European Union
124
+ # d5ad0ca1 : dede3cf8 : todo:story : A long period of peace,_ that is a "bliss".
127
125
  ```
128
126
 
129
127
  ## Performance tests on 10 M facts
@@ -164,6 +162,10 @@ The significantly larger times to read from_CSV versus writing to_CSV are _not_
164
162
  significantly caused by input validation (a test in JRuby without validation on
165
163
  reading 1M facts was only 6% faster with the input validation turned off).
166
164
 
165
+ Version 0.0.13 introduced newline escaping for to_CSV and from_CSV and this
166
+ has added a performance penalty of approx. 30% (all strings are sent through
167
+ gsub with a regexp).
168
+
167
169
  [RDF]: http://www.w3.org/RDF/
168
170
  [Rationale]: http://github.com/petervandenabeele/dbd/blob/master/docs/rationale.md
169
171
  [MIT]: https://github.com/petervandenabeele/dbd/blob/master/LICENSE.txt
@@ -10,10 +10,16 @@ So, the newlines in the String object need to be escaped
10
10
  * escape on writing, suggest:
11
11
  * "\n" => "\\n" (a back slash and a letter n)
12
12
  "C:\nuby" => "C:\\nuby"
13
- * do we need to escape a "real" slash (or slash + n) now ??
13
+ * do we need to escape a "real" backslash ??
14
+ => yes, escape single backslash to double backslash
14
15
 
15
- * escape on reading, suggest:
16
- * "\\n" => "\n" (a newline)
17
- * what with a slash + n ?
16
+ * unescape on reading, suggest:
17
+ * "\\n" (backslash n) => "\n" (a newline)
18
+ * "\\\\" (double backslash) => "\\" (single backslash)
19
+
20
+ * the magic upon unescaping is that a uneven amount of backslashes,
21
+ followed by a 'n' can only be an escaped newline. A real
22
+ "backslash n" will always trigger an even amount of backslashes
23
+ in the escaped version.
18
24
 
19
25
  * validate that write + read performance is not degraded too much
data/docs/test.rb CHANGED
@@ -2,7 +2,7 @@ require 'dbd'
2
2
 
3
3
  context = Dbd::Context.new
4
4
 
5
- context << Dbd::ContextFact.new(predicate: "prov:context_fact", object: "public")
5
+ context << Dbd::ContextFact.new(predicate: "prov:visibility", object: "public")
6
6
  context << Dbd::ContextFact.new(predicate: "prov:source", object: "http://github.com/petervandenabeele/dbd")
7
7
  context << Dbd::ContextFact.new(predicate: "dcterms:creator", object: "@peter_v")
8
8
  context << Dbd::ContextFact.new(predicate: "dcterms:created", object: Time.now.utc)
@@ -23,15 +23,15 @@ puts "facts in short representation:"
23
23
  puts graph.map(&:short)
24
24
 
25
25
  # facts in short representation:
26
- # [ prov ] : 5eb1ea27 : prov:context_fact : public
27
- # [ prov ] : 5eb1ea27 : prov:source : http://github.com/petervandenabeele/dbd
28
- # [ prov ] : 5eb1ea27 : dcterms:creator : @peter_v
29
- # [ prov ] : 5eb1ea27 : dcterms:created : 2013-06-19 22:02:20 UTC
30
- # [ prov ] : 5eb1ea27 : prov:license : MIT
31
- # 5eb1ea27 : 3767c493 : todo:nobelPeacePriceWinn : 2012
32
- # 5eb1ea27 : 3767c493 : rdfs:label : EU
33
- # 5eb1ea27 : 3767c493 : rdfs:comment : European Union
34
- # 5eb1ea27 : 3767c493 : todo:story : A long period of peace,_ that is a "bliss".
26
+ # [ cont ] : d5ad0ca1 : prov:visibility : public
27
+ # [ cont ] : d5ad0ca1 : prov:source : http://github.com/petervandenabeele/dbd
28
+ # [ cont ] : d5ad0ca1 : dcterms:creator : @peter_v
29
+ # [ cont ] : d5ad0ca1 : dcterms:created : 2013-08-09 20:15:24 UTC
30
+ # [ cont ] : d5ad0ca1 : prov:license : MIT
31
+ # d5ad0ca1 : dede3cf8 : todo:nobelPeacePriceWinn : 2012
32
+ # d5ad0ca1 : dede3cf8 : rdfs:label : EU
33
+ # d5ad0ca1 : dede3cf8 : rdfs:comment : European Union
34
+ # d5ad0ca1 : dede3cf8 : todo:story : A long period of peace,_ that is a "bliss".
35
35
 
36
36
  csv = graph.to_CSV
37
37
 
@@ -39,27 +39,26 @@ puts "facts in full detail in CSV:"
39
39
  puts csv
40
40
 
41
41
  # facts in full detail in CSV:
42
- # "4720034a-01ea-4b6b-b9aa-45cb8c7c5e64","2013-06-19 22:02:20.489834224 UTC","","5eb1ea27-6691-4a57-ab13-8a59021968e1","prov:context_fact","public"
43
- # "d05a0a6c-a003-4320-b52b-a6e49e854437","2013-06-19 22:02:20.489889896 UTC","","5eb1ea27-6691-4a57-ab13-8a59021968e1","prov:source","http://github.com/petervandenabeele/dbd"
44
- # "fc47abbd-da2d-4562-bb6b-ed8b84005734","2013-06-19 22:02:20.489913758 UTC","","5eb1ea27-6691-4a57-ab13-8a59021968e1","dcterms:creator","@peter_v"
45
- # "f240e975-5d39-41eb-bb5a-cc59ede4c1a6","2013-06-19 22:02:20.489932320 UTC","","5eb1ea27-6691-4a57-ab13-8a59021968e1","dcterms:created","2013-06-19 22:02:20 UTC"
46
- # "d592b1e8-2910-4329-b502-7d960cebb399","2013-06-19 22:02:20.489950713 UTC","","5eb1ea27-6691-4a57-ab13-8a59021968e1","prov:license","MIT"
47
- # "a2d55e46-03f2-470e-8347-c36b31e7facc","2013-06-19 22:02:20.489973271 UTC","5eb1ea27-6691-4a57-ab13-8a59021968e1","3767c493-79d3-4a97-a832-79e6361ddc4c","todo:nobelPeacePriceWinner","2012"
48
- # "0766dd24-70e5-487d-a018-d58da75dcdad","2013-06-19 22:02:20.489996422 UTC","5eb1ea27-6691-4a57-ab13-8a59021968e1","3767c493-79d3-4a97-a832-79e6361ddc4c","rdfs:label","EU"
49
- # "eda61baa-b331-462e-b7b5-5d6eb2e9a053","2013-06-19 22:02:20.490014676 UTC","5eb1ea27-6691-4a57-ab13-8a59021968e1","3767c493-79d3-4a97-a832-79e6361ddc4c","rdfs:comment","European Union"
50
- # "a3da9295-b43a-4c3a-8e8c-97c3f04c1fa3","2013-06-19 22:02:20.490036790 UTC","5eb1ea27-6691-4a57-ab13-8a59021968e1","3767c493-79d3-4a97-a832-79e6361ddc4c","todo:story","A long period of peace,
51
- # that is a ""bliss""."
42
+ # "2013-08-09 20:15:24.022368550 UTC","9cc48236-cb12-40e8-8641-08407b9a03fb","","d5ad0ca1-645f-41a8-8384-7f411a1f94e2","prov:visibility","public"
43
+ # "2013-08-09 20:15:24.022416066 UTC","86afeade-0802-4fe7-b0d7-9a09d5441dbf","","d5ad0ca1-645f-41a8-8384-7f411a1f94e2","prov:source","http://github.com/petervandenabeele/dbd"
44
+ # "2013-08-09 20:15:24.022435168 UTC","97d7fd9f-77e1-45e9-bdaa-9a283345c8ec","","d5ad0ca1-645f-41a8-8384-7f411a1f94e2","dcterms:creator","@peter_v"
45
+ # "2013-08-09 20:15:24.022449630 UTC","aa0897ce-d5ea-497a-8c4b-3a9339f6cc52","","d5ad0ca1-645f-41a8-8384-7f411a1f94e2","dcterms:created","2013-08-09 20:15:24 UTC"
46
+ # "2013-08-09 20:15:24.022463761 UTC","154d2b46-99df-4eaf-8a75-9e3b7d5df2a7","","d5ad0ca1-645f-41a8-8384-7f411a1f94e2","prov:license","MIT"
47
+ # "2013-08-09 20:15:24.022480963 UTC","0590f53a-346a-4ece-b510-fc1179e76e05","d5ad0ca1-645f-41a8-8384-7f411a1f94e2","dede3cf8-2d3f-4170-8ce5-3fe7c0db5529","todo:nobelPeacePriceWinner","2012"
48
+ # "2013-08-09 20:15:24.022497483 UTC","b28dc6fb-1779-47d3-9109-882075b28d08","d5ad0ca1-645f-41a8-8384-7f411a1f94e2","dede3cf8-2d3f-4170-8ce5-3fe7c0db5529","rdfs:label","EU"
49
+ # "2013-08-09 20:15:24.022512505 UTC","5474dbc0-ee47-4e7a-aa0a-cd60f8467d84","d5ad0ca1-645f-41a8-8384-7f411a1f94e2","dede3cf8-2d3f-4170-8ce5-3fe7c0db5529","rdfs:comment","European Union"
50
+ # "2013-08-09 20:15:24.022526505 UTC","a8c0a137-8c45-49bf-9a87-5915a24725b9","d5ad0ca1-645f-41a8-8384-7f411a1f94e2","dede3cf8-2d3f-4170-8ce5-3fe7c0db5529","todo:story","A long period of peace,\n that is a ""bliss""."
52
51
 
53
52
  imported_graph = Dbd::Graph.new.from_CSV(csv)
54
53
 
55
54
  puts imported_graph.map(&:short)
56
55
 
57
- # [ prov ] : 5eb1ea27 : prov:context_fact : public
58
- # [ prov ] : 5eb1ea27 : prov:source : http://github.com/petervandenabeele/dbd
59
- # [ prov ] : 5eb1ea27 : dcterms:creator : @peter_v
60
- # [ prov ] : 5eb1ea27 : dcterms:created : 2013-06-19 22:02:20 UTC
61
- # [ prov ] : 5eb1ea27 : prov:license : MIT
62
- # 5eb1ea27 : 3767c493 : todo:nobelPeacePriceWinn : 2012
63
- # 5eb1ea27 : 3767c493 : rdfs:label : EU
64
- # 5eb1ea27 : 3767c493 : rdfs:comment : European Union
65
- # 5eb1ea27 : 3767c493 : todo:story : A long period of peace,_ that is a "bliss".
56
+ # [ cont ] : d5ad0ca1 : prov:visibility : public
57
+ # [ cont ] : d5ad0ca1 : prov:source : http://github.com/petervandenabeele/dbd
58
+ # [ cont ] : d5ad0ca1 : dcterms:creator : @peter_v
59
+ # [ cont ] : d5ad0ca1 : dcterms:created : 2013-08-09 20:15:24 UTC
60
+ # [ cont ] : d5ad0ca1 : prov:license : MIT
61
+ # d5ad0ca1 : dede3cf8 : todo:nobelPeacePriceWinn : 2012
62
+ # d5ad0ca1 : dede3cf8 : rdfs:label : EU
63
+ # d5ad0ca1 : dede3cf8 : rdfs:comment : European Union
64
+ # d5ad0ca1 : dede3cf8 : todo:story : A long period of peace,_ that is a "bliss".
data/lib/dbd/fact.rb CHANGED
@@ -14,10 +14,6 @@ module Dbd
14
14
  # Framework) concept, but with different and extended functionality.
15
15
  #
16
16
  # Each basic fact has:
17
- # * a unique and invariant *id* (a uuid)
18
- #
19
- # To allow referencing back to it (e.g. to invalidate it later in a fact stream).
20
- #
21
17
  # * a *time_stamp* (time with nanosecond granularity)
22
18
  #
23
19
  # To allow verifying that the order in a fact stream is correct.
@@ -26,6 +22,10 @@ module Dbd
26
22
  # creation of the fact, but it has to increase in strictly monotic
27
23
  # order in a fact stream.
28
24
  #
25
+ # * a unique and invariant *id* (a uuid)
26
+ #
27
+ # To allow referencing back to it (e.g. to invalidate it later in a fact stream).
28
+ #
29
29
  # * a *context_subject* (a uuid)
30
30
  #
31
31
  # The subject of the Context (a set of Contexts with
@@ -67,8 +67,8 @@ module Dbd
67
67
  ##
68
68
  # @return [Array] The 6 attributes of a Fact.
69
69
  def self.attributes
70
- [:id,
71
- :time_stamp,
70
+ [:time_stamp,
71
+ :id,
72
72
  :context_subject,
73
73
  :subject,
74
74
  :predicate,
@@ -114,15 +114,15 @@ module Dbd
114
114
  # Builds a new Fact.
115
115
  #
116
116
  # @param [Hash{Symbol => Object}] options
117
- # @option options [#to_s] :predicate Required : the predicate for this Fact
118
117
  # @option options [#to_s] :object Required : the object for this Fact (required)
119
- # @option options [String (uuid)] :context_subject (nil) Optional: the subject of the Context
120
- # @option options [String (uuid)] :subject (nil) Optional: the subject for this Fact
121
- # @option options [TimeStamp] :time_stamp (nil) Optional: the time_stamp for this Fact
118
+ # @option options [#to_s] :predicate Required : the predicate for this Fact
119
+ # @option options [String (uuid)] :subject Optional : the subject for this Fact
120
+ # @option options [String (uuid)] :context_subject Optional : the subject of the Context
122
121
  # @option options [String (uuid)] :id Optional : set the id
122
+ # @option options [TimeStamp] :time_stamp Optional : the time_stamp for this Fact
123
123
  def initialize(options)
124
- @id = options[:id] || self.class.factory.new_id
125
124
  @time_stamp = options[:time_stamp]
125
+ @id = options[:id] || self.class.factory.new_id
126
126
  @context_subject = options[:context_subject]
127
127
  @subject = options[:subject]
128
128
  @predicate = options[:predicate]
data/lib/dbd/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dbd
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
@@ -8,7 +8,7 @@ module Dbd
8
8
  let(:subject) { factory.new_subject }
9
9
  let(:fact_1) { TestFactories::Fact.fact_1(context_subject) }
10
10
  let(:fact_2_with_subject) { TestFactories::Fact.fact_2_with_subject(context_subject) }
11
- let(:fact_with_newline) { TestFactories::Fact.fact_with_newline(context_subject) }
11
+ let(:fact_with_newline) { TestFactories::Fact.data_fact_EU(context_subject) }
12
12
  let(:fact_with_special_chars) { TestFactories::Fact.fact_with_special_chars(context_subject) }
13
13
  let(:full_fact) { TestFactories::Fact.full_fact }
14
14
 
@@ -77,7 +77,7 @@ module Dbd
77
77
 
78
78
  it 'for a fact with a newline replaces it with a underscore' do
79
79
  fact_with_newline.subject = subject
80
- fact_with_newline.short.should match(/^[0-9a-f]{8} : [0-9a-f]{8} : http:\/\/example\.org\/test\/ : A long story_really.$/)
80
+ fact_with_newline.short.should match(/^[0-9a-f]{8} : [0-9a-f]{8} : http:\/\/example\.org\/test\/ : \\n_\\n_\\_\\\\_\\\\\\_European_Union\\n$/)
81
81
  end
82
82
  end
83
83
 
@@ -114,8 +114,12 @@ module Dbd
114
114
  described_class.attributes.size.should == 6
115
115
  end
116
116
 
117
- it 'first attribute is :id' do
118
- described_class.attributes.first.should == :id
117
+ it 'first attribute is :time_stamp' do
118
+ described_class.attributes.first.should == :time_stamp
119
+ end
120
+
121
+ it 'second attribute is :id' do
122
+ described_class.attributes[1].should == :id
119
123
  end
120
124
  end
121
125
 
@@ -124,8 +128,8 @@ module Dbd
124
128
  full_fact.values.size.should == 6
125
129
  end
126
130
 
127
- it 'the second element (time_stamp) is a TimeStamp' do
128
- full_fact.values[1].should be_a(TimeStamp)
131
+ it 'the first element (time_stamp) is a TimeStamp' do
132
+ full_fact.values.first.should be_a(TimeStamp)
129
133
  end
130
134
  end
131
135
 
@@ -134,12 +138,12 @@ module Dbd
134
138
  full_fact.string_values.size.should == 6
135
139
  end
136
140
 
137
- it 'the second element (time_stamp) is a String' do
138
- full_fact.string_values[1].should be_a(String)
141
+ it 'the first element (time_stamp) is a String' do
142
+ full_fact.string_values.first.should be_a(String)
139
143
  end
140
144
 
141
145
  it 'escapes a newline into \n and \n into \\\\n (two backslashes and a n)' do
142
- full_fact.string_values[5].should == "Gandhi\\nKing\\\\n" # backslash newline
146
+ full_fact.string_values.last.should == "Gandhi\\nKing\\\\n" # backslash newline
143
147
  end
144
148
  end
145
149
 
@@ -175,7 +179,7 @@ module Dbd
175
179
 
176
180
  it 'is true when the time_stamp is 500 ns larger' do
177
181
  string_values_time_modified = string_values.dup.tap { |_string_values|
178
- _string_values[1] = '2013-06-17 21:55:09.967653513 UTC'
182
+ _string_values[0] = '2013-06-17 21:55:09.967653513 UTC'
179
183
  }
180
184
  other = factory.from_string_values(string_values_time_modified)
181
185
  other.should be_equivalent(ref)
@@ -52,12 +52,12 @@ module Dbd
52
52
  subject.to_CSV.lines.to_a.first.chomp
53
53
  end
54
54
 
55
- it 'has id (a Fact::ID) as first value' do
56
- first_line.split(',')[0].gsub(/"/, '').should match(id_valid_regexp)
55
+ it 'has time_stamp as first value' do
56
+ first_line.split(',')[0][1..-2].should match(time_stamp_valid_regexp)
57
57
  end
58
58
 
59
- it 'has time_stamp as second value' do
60
- first_line.split(',')[1][1..-2].should match(time_stamp_valid_regexp)
59
+ it 'has id (a Fact::ID) as second value' do
60
+ first_line.split(',')[1].gsub(/"/, '').should match(id_valid_regexp)
61
61
  end
62
62
 
63
63
  it 'has an empty third value (signature of a context_fact)' do
@@ -119,12 +119,12 @@ module Dbd
119
119
  subject.to_CSV.lines.to_a.first.chomp
120
120
  end
121
121
 
122
- it 'has id (a Fact::ID) as first value' do
123
- first_line.split(',')[0].gsub(/"/, '').should match(id_valid_regexp)
122
+ it 'has time_stamp as first value' do
123
+ first_line.split(',')[0][1..-2].should match(time_stamp_valid_regexp)
124
124
  end
125
125
 
126
- it 'has time_stamp as second value' do
127
- first_line.split(',')[1][1..-2].should match(time_stamp_valid_regexp)
126
+ it 'has id (a Fact::ID) as second value' do
127
+ first_line.split(',')[1].gsub(/"/, '').should match(id_valid_regexp)
128
128
  end
129
129
 
130
130
  it 'has context_fact_1.subject as third value' do
@@ -10,8 +10,8 @@ module TestFactories
10
10
  end
11
11
 
12
12
  def self.string_values
13
- ['825e44d5-af33-4858-8047-549bd813daa8',
14
- '2013-06-17 21:55:09.967653013 UTC',
13
+ ['2013-06-17 21:55:09.967653013 UTC',
14
+ '825e44d5-af33-4858-8047-549bd813daa8',
15
15
  '40fab407-9b04-4a51-9a52-d978abfcbb1f',
16
16
  '2e9fbc87-2e94-47e9-a8fd-121cc4bc3e8f',
17
17
  'http://example.org/test/name',
@@ -79,14 +79,6 @@ module TestFactories
79
79
  object: "\\n\n\\n\n\\\n\\\\\n\\\\\\\nEuropean\nUnion\\n")
80
80
  end
81
81
 
82
- def self.fact_with_newline(context_subject = nil, subject = nil)
83
- factory_for.new(
84
- context_subject: context_subject,
85
- subject: subject,
86
- predicate: 'http://example.org/test/comment',
87
- object: "A long story\nreally.")
88
- end
89
-
90
82
  def self.full_fact
91
83
  fixed_id = TestFactories::Fact::ID.fixed_id
92
84
  fact_with_forced_id(fixed_id).tap do |fact|
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.13
4
+ version: 0.0.14
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-07 00:00:00.000000000 Z
11
+ date: 2013-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler