activefacts 0.7.3 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/LICENSE +19 -0
  2. data/Manifest.txt +24 -2
  3. data/Rakefile +25 -3
  4. data/bin/afgen +1 -1
  5. data/bin/cql +13 -2
  6. data/css/offline.css +3 -0
  7. data/css/orm2.css +24 -0
  8. data/css/print.css +8 -0
  9. data/css/style-print.css +357 -0
  10. data/css/style.css +387 -0
  11. data/download.html +85 -0
  12. data/examples/CQL/Address.cql +3 -3
  13. data/examples/CQL/Blog.cql +13 -14
  14. data/examples/CQL/CompanyDirectorEmployee.cql +4 -4
  15. data/examples/CQL/Death.cql +3 -2
  16. data/examples/CQL/Genealogy.cql +13 -11
  17. data/examples/CQL/Marriage.cql +2 -2
  18. data/examples/CQL/Metamodel.cql +136 -93
  19. data/examples/CQL/MultiInheritance.cql +2 -2
  20. data/examples/CQL/OilSupply.cql +14 -10
  21. data/examples/CQL/Orienteering.cql +22 -19
  22. data/examples/CQL/PersonPlaysGame.cql +3 -2
  23. data/examples/CQL/SchoolActivities.cql +4 -2
  24. data/examples/CQL/SimplestUnary.cql +1 -1
  25. data/examples/CQL/SubtypePI.cql +6 -7
  26. data/examples/CQL/Warehousing.cql +16 -19
  27. data/examples/CQL/unit.cql +584 -0
  28. data/examples/index.html +276 -0
  29. data/examples/intro.html +497 -0
  30. data/examples/local.css +20 -0
  31. data/index.html +96 -0
  32. data/lib/activefacts/api/concept.rb +48 -46
  33. data/lib/activefacts/api/constellation.rb +43 -23
  34. data/lib/activefacts/api/entity.rb +2 -2
  35. data/lib/activefacts/api/instance.rb +6 -2
  36. data/lib/activefacts/api/instance_index.rb +5 -0
  37. data/lib/activefacts/api/value.rb +8 -2
  38. data/lib/activefacts/api/vocabulary.rb +15 -10
  39. data/lib/activefacts/cql/CQLParser.treetop +109 -88
  40. data/lib/activefacts/cql/Concepts.treetop +32 -10
  41. data/lib/activefacts/cql/Context.treetop +34 -0
  42. data/lib/activefacts/cql/Expressions.treetop +9 -9
  43. data/lib/activefacts/cql/FactTypes.treetop +30 -31
  44. data/lib/activefacts/cql/Language/English.treetop +50 -0
  45. data/lib/activefacts/cql/LexicalRules.treetop +2 -1
  46. data/lib/activefacts/cql/Terms.treetop +117 -0
  47. data/lib/activefacts/cql/ValueTypes.treetop +152 -0
  48. data/lib/activefacts/cql/compiler.rb +1718 -0
  49. data/lib/activefacts/cql/parser.rb +124 -57
  50. data/lib/activefacts/generate/absorption.rb +1 -1
  51. data/lib/activefacts/generate/cql.rb +111 -100
  52. data/lib/activefacts/generate/cql/html.rb +5 -5
  53. data/lib/activefacts/generate/oo.rb +3 -3
  54. data/lib/activefacts/generate/ordered.rb +51 -19
  55. data/lib/activefacts/generate/ruby.rb +10 -8
  56. data/lib/activefacts/generate/sql/mysql.rb +14 -10
  57. data/lib/activefacts/generate/sql/server.rb +29 -24
  58. data/lib/activefacts/input/cql.rb +9 -1264
  59. data/lib/activefacts/input/orm.rb +213 -200
  60. data/lib/activefacts/persistence/columns.rb +11 -10
  61. data/lib/activefacts/persistence/index.rb +15 -18
  62. data/lib/activefacts/persistence/reference.rb +17 -17
  63. data/lib/activefacts/persistence/tables.rb +50 -51
  64. data/lib/activefacts/version.rb +1 -1
  65. data/lib/activefacts/vocabulary/extensions.rb +79 -8
  66. data/lib/activefacts/vocabulary/metamodel.rb +183 -114
  67. data/spec/absorption_ruby_spec.rb +99 -0
  68. data/spec/absorption_spec.rb +3 -4
  69. data/spec/api/constellation.rb +1 -1
  70. data/spec/api/entity_type.rb +3 -1
  71. data/spec/api/instance.rb +4 -2
  72. data/spec/api/roles.rb +8 -6
  73. data/spec/api_spec.rb +1 -2
  74. data/spec/cql/context_spec.rb +71 -0
  75. data/spec/cql/samples_spec.rb +154 -0
  76. data/spec/cql/unit_spec.rb +375 -0
  77. data/spec/cql_cql_spec.rb +31 -21
  78. data/spec/cql_mysql_spec.rb +70 -0
  79. data/spec/cql_parse_spec.rb +15 -9
  80. data/spec/cql_ruby_spec.rb +27 -13
  81. data/spec/cql_sql_spec.rb +42 -16
  82. data/spec/cql_symbol_tables_spec.rb +2 -3
  83. data/spec/cqldump_spec.rb +7 -7
  84. data/spec/helpers/file_matcher.rb +39 -0
  85. data/spec/norma_cql_spec.rb +20 -12
  86. data/spec/norma_ruby_spec.rb +6 -3
  87. data/spec/norma_sql_spec.rb +6 -3
  88. data/spec/norma_tables_spec.rb +6 -4
  89. data/spec/spec_helper.rb +27 -8
  90. data/status.html +69 -0
  91. data/why.html +60 -0
  92. metadata +34 -11
  93. data/lib/activefacts/cql/DataTypes.treetop +0 -81
  94. data/spec/cql_unit_spec.rb +0 -330
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2008 Clifford Heath.
2
+
3
+ This software is provided 'as-is', without any express or implied warranty.
4
+ In no event will the authors be held liable for any damages arising from the
5
+ use of this software.
6
+
7
+ Permission is granted to anyone to use this software for any purpose,
8
+ including commercial applications, and to alter it and redistribute it
9
+ freely, subject to the following restrictions:
10
+
11
+ 1. The origin of this software must not be misrepresented; you must not
12
+ claim that you wrote the original software. If you use this software
13
+ in a product, an acknowledgment in the product documentation would be
14
+ appreciated but is not required.
15
+
16
+ 2. Altered source versions must be plainly marked as such, and must not be
17
+ misrepresented as being the original software.
18
+
19
+ 3. This notice may not be removed or altered from any source distribution.
data/Manifest.txt CHANGED
@@ -1,9 +1,16 @@
1
1
  History.txt
2
+ LICENSE
2
3
  Manifest.txt
3
4
  README.rdoc
4
5
  Rakefile
5
6
  bin/afgen
6
7
  bin/cql
8
+ css/offline.css
9
+ css/orm2.css
10
+ css/print.css
11
+ css/style-print.css
12
+ css/style.css
13
+ download.html
7
14
  examples/CQL/Address.cql
8
15
  examples/CQL/Blog.cql
9
16
  examples/CQL/CompanyDirectorEmployee.cql
@@ -20,6 +27,11 @@ examples/CQL/SimplestUnary.cql
20
27
  examples/CQL/SubtypePI.cql
21
28
  examples/CQL/Warehousing.cql
22
29
  examples/CQL/WindowInRoomInBldg.cql
30
+ examples/CQL/unit.cql
31
+ examples/index.html
32
+ examples/intro.html
33
+ examples/local.css
34
+ index.html
23
35
  lib/activefacts.rb
24
36
  lib/activefacts/api.rb
25
37
  lib/activefacts/api/concept.rb
@@ -38,12 +50,15 @@ lib/activefacts/api/vocabulary.rb
38
50
  lib/activefacts/cql.rb
39
51
  lib/activefacts/cql/CQLParser.treetop
40
52
  lib/activefacts/cql/Concepts.treetop
41
- lib/activefacts/cql/DataTypes.treetop
53
+ lib/activefacts/cql/Context.treetop
42
54
  lib/activefacts/cql/Expressions.treetop
43
55
  lib/activefacts/cql/FactTypes.treetop
44
56
  lib/activefacts/cql/Language/English.treetop
45
57
  lib/activefacts/cql/LexicalRules.treetop
46
58
  lib/activefacts/cql/Rakefile
59
+ lib/activefacts/cql/Terms.treetop
60
+ lib/activefacts/cql/ValueTypes.treetop
61
+ lib/activefacts/cql/compiler.rb
47
62
  lib/activefacts/cql/parser.rb
48
63
  lib/activefacts/generate/absorption.rb
49
64
  lib/activefacts/generate/cql.rb
@@ -70,6 +85,7 @@ lib/activefacts/vocabulary.rb
70
85
  lib/activefacts/vocabulary/extensions.rb
71
86
  lib/activefacts/vocabulary/metamodel.rb
72
87
  script/txt2html
88
+ spec/absorption_ruby_spec.rb
73
89
  spec/absorption_spec.rb
74
90
  spec/api/autocounter.rb
75
91
  spec/api/constellation.rb
@@ -78,16 +94,22 @@ spec/api/instance.rb
78
94
  spec/api/roles.rb
79
95
  spec/api/value_type.rb
80
96
  spec/api_spec.rb
97
+ spec/cql/context_spec.rb
98
+ spec/cql/samples_spec.rb
99
+ spec/cql/unit_spec.rb
81
100
  spec/cql_cql_spec.rb
101
+ spec/cql_mysql_spec.rb
82
102
  spec/cql_parse_spec.rb
83
103
  spec/cql_ruby_spec.rb
84
104
  spec/cql_sql_spec.rb
85
105
  spec/cql_symbol_tables_spec.rb
86
- spec/cql_unit_spec.rb
87
106
  spec/cqldump_spec.rb
107
+ spec/helpers/file_matcher.rb
88
108
  spec/norma_cql_spec.rb
89
109
  spec/norma_ruby_spec.rb
90
110
  spec/norma_sql_spec.rb
91
111
  spec/norma_tables_spec.rb
92
112
  spec/spec.opts
93
113
  spec/spec_helper.rb
114
+ status.html
115
+ why.html
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- %w[rubygems rake rake/clean fileutils newgem rubigen spec spec/rake/spectask].each { |f| require f }
1
+ %w[rubygems hoe rake rake/clean fileutils newgem rubigen spec spec/rake/spectask].each { |f| require f }
2
2
 
3
3
  require 'hanna/rdoctask'
4
4
 
@@ -6,13 +6,35 @@ require File.dirname(__FILE__) + '/lib/activefacts'
6
6
 
7
7
  # Generate all the Rake tasks
8
8
  # Run 'rake -T' to see list of generated tasks (from gem root directory)
9
- $hoe = Hoe.new('activefacts', ActiveFacts::VERSION) do |p|
9
+ $hoe = Hoe.spec('activefacts') do |p|
10
+ p.version = ActiveFacts::VERSION
11
+ p.summary = "A semantic modeling and query language (CQL) and application runtime (the Constellation API)"
12
+ p.description = %q{
13
+ ActiveFacts is a semantic modeling toolkit, comprising an implementation
14
+ of the Constellation Query Language, the Constellation API, and code
15
+ generators that receive CQL or ORM (Object Role Modeling files, from
16
+ NORMA) to emit CQL, Ruby and SQL.
17
+
18
+ Semantic modeling is a refinement of fact-based modeling techniques
19
+ that draw on natural language verbalisation and formal logic. Fact
20
+ based modeling is essentially the same as relational modeling in the
21
+ sixth normal form. The tools provided here automatically condense
22
+ that to third normal form for efficient storage. They also generate
23
+ object models as a Ruby module which has an effective mapping to
24
+ both the original semantic model and to the generated SQL.
25
+
26
+ The result is a formal language that reads like plain English, and
27
+ allows creation of relational and object models that are guaranteed
28
+ equivalent, and much more stable in the face of schema evolution than
29
+ SQL is.
30
+ }
31
+ p.url = "http://dataconstellation.com/ActiveFacts/"
10
32
  p.developer('Clifford Heath', 'cjh@dataconstellation.org')
11
33
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
12
34
  p.post_install_message = 'For more information on ActiveFacts, see http://dataconstellation.com/ActiveFacts'
13
35
  p.rubyforge_name = "cjheath@rubyforge.org"
14
36
  p.extra_deps = [
15
- ['treetop','>= 1.2.4'],
37
+ ['treetop','>= 1.4.1'],
16
38
  ]
17
39
  p.extra_dev_deps = [
18
40
  ['newgem', ">= #{::Newgem::VERSION}"]
data/bin/afgen CHANGED
@@ -13,7 +13,7 @@ require 'activefacts/vocabulary'
13
13
  if ENV['DEBUG']
14
14
  begin
15
15
  require 'ruby-debug'
16
- debugger if debug :exception
16
+ Debugger.start(:post_mortem => true) # Stop when an exception is thrown, but before it's rescued
17
17
  rescue LoadError
18
18
  # Ok, no debugger, tough luck.
19
19
  end
data/bin/cql CHANGED
@@ -1,4 +1,4 @@
1
- #! env ruby
1
+ #! /usr/bin/env ruby
2
2
  #
3
3
  # ActiveFacts: Interactive CQL command-line. Incomplete; only parses CQL and shows the parse trees
4
4
  #
@@ -9,9 +9,19 @@ require 'activefacts'
9
9
  require 'activefacts/cql/parser'
10
10
  require 'readline'
11
11
 
12
+ if ENV['DEBUG']
13
+ begin
14
+ require 'ruby-debug'
15
+ debugger if debug :exception
16
+ rescue LoadError
17
+ # Ok, no debugger, tough luck.
18
+ end
19
+ end
20
+ true # Ok, got the stack set up, continue to the fault
21
+
12
22
  puts "This is a stub for the CQL interactive commandline. At the moment it only parses CQL and shows the parse trees."
13
23
 
14
- parser = ActiveFacts::CQLParser.new
24
+ parser = ActiveFacts::CQL::Parser.new
15
25
  parser.root = :definition
16
26
  statement = nil
17
27
  while line = Readline::readline(statement ? "CQL+ " : "CQL? ", [])
@@ -36,6 +46,7 @@ while line = Readline::readline(statement ? "CQL+ " : "CQL? ", [])
36
46
  p result.value
37
47
  rescue => e
38
48
  puts e.to_s+":"
49
+ puts e.backtrace*"\n\t" if ENV["DEBUG"] =~ /exception/
39
50
  p result # In case the root is changed and there's no value()
40
51
  end
41
52
  #p parser.definition(result)
data/css/offline.css ADDED
@@ -0,0 +1,3 @@
1
+ .online {
2
+ display: none;
3
+ }
data/css/orm2.css ADDED
@@ -0,0 +1,24 @@
1
+ pre {
2
+ background-color: #000;
3
+ padding: 5px;
4
+ display: table-cell;
5
+ border-style: dashed;
6
+ border-width: 2px;
7
+ border-color: #BBB;
8
+ }
9
+
10
+ .keyword {
11
+ Xcolor: #00F;
12
+ color: #66F;
13
+ }
14
+ .concept {
15
+ Xcolor: #808;
16
+ color: #E0E;
17
+ }
18
+ .copula {
19
+ Xcolor: #060;
20
+ color: #0C0;
21
+ }
22
+ .value {
23
+ color: #FF990E;
24
+ }
data/css/print.css ADDED
@@ -0,0 +1,8 @@
1
+ #navcontainer, .localnav, .noprint {
2
+ display: none;
3
+ }
4
+
5
+ img {
6
+ max-width: 100%;
7
+ height: auto;
8
+ }
@@ -0,0 +1,357 @@
1
+ body
2
+ {
3
+ color : #000000;
4
+ background-color : #FFFFFF;
5
+ line-height : 1.5em;
6
+ font-family : Calibri, Verdana, sans-serif;
7
+ }
8
+
9
+ /* emphasis */
10
+
11
+ em,
12
+ blockquote
13
+ {
14
+ font-family : Cambria, Georgia, serif;
15
+ }
16
+
17
+ /* headings */
18
+
19
+ h1,
20
+ h2,
21
+ h3,
22
+ h4,
23
+ h5,
24
+ h6,
25
+ .title
26
+ {
27
+ font-weight : lighter;
28
+ font-family : Constantia, "Book Antiqua", "URW Bookman L", serif;
29
+ }
30
+
31
+ #lof h1,
32
+ #lof h2,
33
+ #lof h3,
34
+ #lof h4,
35
+ #lof h5,
36
+ #lof h6
37
+ {
38
+ margin-top : 1.25em;
39
+ }
40
+
41
+ #content h1,
42
+ #content h2,
43
+ #content h3,
44
+ #content h4,
45
+ #content h5,
46
+ #content h6
47
+ {
48
+ margin-top : 2.5em;
49
+ line-height : 1.25em;
50
+ }
51
+
52
+ #content h1
53
+ {
54
+ font-size : 2.0em;
55
+ }
56
+
57
+ #content h2
58
+ {
59
+ font-size : 1.8em;
60
+ }
61
+
62
+ #content h3
63
+ {
64
+ font-size : 1.6em;
65
+ }
66
+
67
+ #content h4
68
+ {
69
+ font-size : 1.4em;
70
+ }
71
+
72
+ #content h5
73
+ {
74
+ font-size : 1.2em;
75
+ }
76
+
77
+ #content h6
78
+ {
79
+ font-size : 1.0em;
80
+ }
81
+
82
+ /* tables */
83
+
84
+ table
85
+ {
86
+ border : none;
87
+ }
88
+
89
+ th,
90
+ td
91
+ {
92
+ padding : 1em;
93
+ border : 1px solid #C0C0C0;
94
+ vertical-align : top;
95
+ background-color : #FFFFFF;
96
+ }
97
+
98
+ th
99
+ {
100
+ background-color : #F5F5F5;
101
+ }
102
+
103
+ table
104
+ {
105
+ margin : auto;
106
+ }
107
+
108
+ /* document structure */
109
+
110
+ #header
111
+ {
112
+ margin-bottom : 5em;
113
+ text-align : center;
114
+ }
115
+
116
+ #abstract
117
+ {
118
+ margin-bottom : 5em;
119
+ }
120
+
121
+ #toc li
122
+ {
123
+ list-style-type : none;
124
+ }
125
+
126
+ #toc li ul
127
+ {
128
+ padding-bottom : 1em;
129
+ border-left : thick solid #F5F5F5;
130
+ _border-left : none; /* for IE6 */
131
+ }
132
+
133
+ #toc li ul:hover
134
+ {
135
+ border-color : #DCDCDC;
136
+ }
137
+
138
+ #toc > ul
139
+ {
140
+ padding-left : 1em;
141
+ }
142
+
143
+ #references
144
+ {
145
+ margin-top : 5em;
146
+ }
147
+
148
+ #footer
149
+ {
150
+ border-top : thick dotted #DCDCDC;
151
+ padding-top : 1em;
152
+ margin-top : 5em;
153
+ text-align : center;
154
+ }
155
+
156
+ /* document nodes */
157
+
158
+ .part > .title,
159
+ .chapter > .title
160
+ {
161
+ padding-bottom : 0.5em;
162
+ }
163
+
164
+ .part > .title > big,
165
+ .chapter > .title > big
166
+ {
167
+ display : block;
168
+ margin-top : 0.25em;
169
+ }
170
+
171
+ .part .title big,
172
+ .chapter .title big
173
+ {
174
+ _display : block; /* for IE6 */
175
+ _margin-top : 0.25em; /* for IE6 */
176
+ _margin-bottom : 0.75em; /* for IE6 */
177
+ }
178
+
179
+ .paragraph > .title,
180
+ .tip > .title,
181
+ .note > .title,
182
+ .caution > .title,
183
+ .warning > .title,
184
+ .important > .title,
185
+ .figure > .title,
186
+ .table > .title,
187
+ .example > .title,
188
+ .equation > .title,
189
+ .procedure > .title
190
+ {
191
+ font-size : large;
192
+ margin-top : 2em;
193
+ }
194
+
195
+ .paragraph .title,
196
+ .tip .title,
197
+ .note .title,
198
+ .caution .title,
199
+ .warning .title,
200
+ .important .title,
201
+ .figure .title,
202
+ .table .title,
203
+ .example .title,
204
+ .equation .title,
205
+ .procedure .title
206
+ {
207
+ _font-size : large; /* for IE6 */
208
+ _font-weight : bold; /* large is not bold in IE6 */
209
+ _margin-top : 2em; /* for IE6 */
210
+ }
211
+
212
+ .tip ,
213
+ .note ,
214
+ .caution ,
215
+ .warning ,
216
+ .important,
217
+ .figure ,
218
+ .table ,
219
+ .example ,
220
+ .equation ,
221
+ .procedure
222
+ {
223
+ margin : 3em;
224
+ }
225
+
226
+ .tip > .icon,
227
+ .note > .icon,
228
+ .caution > .icon,
229
+ .warning > .icon,
230
+ .important > .icon
231
+ {
232
+ float : left;
233
+ margin : 0 1em 1em 0; /* top right bottom left */
234
+ }
235
+
236
+ .tip .icon,
237
+ .note .icon,
238
+ .caution .icon,
239
+ .warning .icon,
240
+ .important .icon
241
+ {
242
+ _display : none; /* IE6 cannot display embedded images */
243
+ }
244
+
245
+ .figure > .title
246
+ {
247
+ text-align : center;
248
+ }
249
+
250
+ .figure .title
251
+ {
252
+ _text-align : center; /* for IE6 */
253
+ }
254
+
255
+ .figure > .content > img
256
+ {
257
+ display : block;
258
+ margin : auto;
259
+ }
260
+
261
+ .figure .content img
262
+ {
263
+ _display : block; /* for IE6 */
264
+ _margin : auto; /* for IE6 */
265
+ }
266
+
267
+ /* headings */
268
+
269
+ h1,
270
+ h2,
271
+ h3,
272
+ h4,
273
+ h5,
274
+ h6
275
+ {
276
+ font-weight : normal;
277
+ }
278
+
279
+ /* hyperlinks */
280
+
281
+ a:link,
282
+ a:visited,
283
+ a:active
284
+ {
285
+ color : #0000FF;
286
+ font-weight : bold;
287
+ text-decoration : underline;
288
+ }
289
+
290
+ a:after
291
+ {
292
+ content : " (" attr(href) ")";
293
+ font-family : sans-serif;
294
+ font-weight : normal;
295
+ font-size : 90%;
296
+ }
297
+
298
+ a[href^="#"]:after
299
+ {
300
+ content : "";
301
+ }
302
+
303
+ a[href^="#"]
304
+ {
305
+ color : #A52A2A;
306
+ font-weight : lighter;
307
+ text-decoration : none;
308
+ font-style : italic;
309
+ }
310
+
311
+ a.toc:link,
312
+ a.toc:visited
313
+ {
314
+ color : inherit;
315
+ .color : #000000; /* for IE6 and IE7 */
316
+ font-weight : inherit;
317
+ text-decoration : none;
318
+ font-style : normal;
319
+ }
320
+
321
+ /* source code */
322
+
323
+ tt
324
+ {
325
+ color : inherit;
326
+ background-color : inherit;
327
+ font-weight : normal;
328
+ }
329
+
330
+ pre,
331
+ .code
332
+ {
333
+ border : none;
334
+ overflow : visible;
335
+ background-color : inherit;
336
+ }
337
+
338
+ /* document structure */
339
+
340
+ #lof
341
+ {
342
+ display : none;
343
+ }
344
+
345
+ /* document nodes */
346
+
347
+ .part > .title > big,
348
+ .chapter > .title > big
349
+ {
350
+ padding-bottom : 0.5em;
351
+ }
352
+
353
+ .part .title big,
354
+ .chapter .title big
355
+ {
356
+ _padding-bottom : 0.5em; /* for IE6 */
357
+ }