activefacts 0.8.16 → 0.8.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +15 -0
  2. data/Manifest.txt +10 -4
  3. data/bin/afgen +26 -20
  4. data/bin/cql +1 -1
  5. data/css/orm2.css +89 -9
  6. data/examples/CQL/CompanyDirectorEmployee.cql +4 -4
  7. data/examples/CQL/Genealogy.cql +5 -5
  8. data/examples/CQL/Metamodel.cql +121 -91
  9. data/examples/CQL/MonthInSeason.cql +2 -6
  10. data/examples/CQL/SeparateSubtype.cql +11 -9
  11. data/examples/CQL/ServiceDirector.cql +21 -33
  12. data/examples/CQL/Supervision.cql +0 -3
  13. data/examples/CQL/WindowInRoomInBldg.cql +10 -4
  14. data/examples/CQL/unit.cql +1 -1
  15. data/lib/activefacts.rb +1 -0
  16. data/lib/activefacts/cql/CQLParser.treetop +5 -1
  17. data/lib/activefacts/cql/Context.treetop +2 -7
  18. data/lib/activefacts/cql/Expressions.treetop +2 -2
  19. data/lib/activefacts/cql/FactTypes.treetop +37 -31
  20. data/lib/activefacts/cql/Language/English.treetop +21 -4
  21. data/lib/activefacts/cql/LexicalRules.treetop +59 -1
  22. data/lib/activefacts/cql/ObjectTypes.treetop +22 -12
  23. data/lib/activefacts/cql/Terms.treetop +13 -9
  24. data/lib/activefacts/cql/ValueTypes.treetop +30 -11
  25. data/lib/activefacts/cql/compiler.rb +34 -5
  26. data/lib/activefacts/cql/compiler/clause.rb +207 -116
  27. data/lib/activefacts/cql/compiler/constraint.rb +129 -105
  28. data/lib/activefacts/cql/compiler/entity_type.rb +49 -27
  29. data/lib/activefacts/cql/compiler/expression.rb +71 -42
  30. data/lib/activefacts/cql/compiler/fact.rb +70 -64
  31. data/lib/activefacts/cql/compiler/fact_type.rb +108 -57
  32. data/lib/activefacts/cql/compiler/query.rb +178 -0
  33. data/lib/activefacts/cql/compiler/shared.rb +13 -12
  34. data/lib/activefacts/cql/compiler/value_type.rb +10 -4
  35. data/lib/activefacts/cql/nodes.rb +1 -1
  36. data/lib/activefacts/cql/parser.rb +6 -2
  37. data/lib/activefacts/generate/absorption.rb +6 -3
  38. data/lib/activefacts/generate/cql.rb +140 -84
  39. data/lib/activefacts/generate/dm.rb +12 -6
  40. data/lib/activefacts/generate/help.rb +25 -6
  41. data/lib/activefacts/generate/helpers/oo.rb +195 -0
  42. data/lib/activefacts/generate/helpers/ordered.rb +589 -0
  43. data/lib/activefacts/generate/helpers/rails.rb +57 -0
  44. data/lib/activefacts/generate/html/glossary.rb +274 -54
  45. data/lib/activefacts/generate/json.rb +25 -22
  46. data/lib/activefacts/generate/null.rb +1 -0
  47. data/lib/activefacts/generate/rails/models.rb +244 -0
  48. data/lib/activefacts/generate/rails/schema.rb +185 -0
  49. data/lib/activefacts/generate/records.rb +1 -0
  50. data/lib/activefacts/generate/ruby.rb +51 -30
  51. data/lib/activefacts/generate/sql/mysql.rb +5 -3
  52. data/lib/activefacts/generate/sql/server.rb +8 -4
  53. data/lib/activefacts/generate/text.rb +1 -0
  54. data/lib/activefacts/generate/transform/surrogate.rb +209 -0
  55. data/lib/activefacts/generate/version.rb +1 -0
  56. data/lib/activefacts/input/orm.rb +234 -181
  57. data/lib/activefacts/mapping/rails.rb +122 -0
  58. data/lib/activefacts/persistence/columns.rb +34 -18
  59. data/lib/activefacts/persistence/foreignkey.rb +129 -71
  60. data/lib/activefacts/persistence/index.rb +42 -12
  61. data/lib/activefacts/persistence/reference.rb +37 -23
  62. data/lib/activefacts/persistence/tables.rb +53 -19
  63. data/lib/activefacts/registry.rb +11 -0
  64. data/lib/activefacts/support.rb +28 -10
  65. data/lib/activefacts/version.rb +1 -1
  66. data/lib/activefacts/vocabulary/extensions.rb +246 -117
  67. data/lib/activefacts/vocabulary/metamodel.rb +105 -65
  68. data/lib/activefacts/vocabulary/verbaliser.rb +226 -194
  69. data/spec/absorption_spec.rb +1 -0
  70. data/spec/cql/comparison_spec.rb +8 -8
  71. data/spec/cql/contractions_spec.rb +16 -43
  72. data/spec/cql/entity_type_spec.rb +2 -1
  73. data/spec/cql/expressions_spec.rb +2 -2
  74. data/spec/cql/fact_type_matching_spec.rb +4 -1
  75. data/spec/cql/parser/bad_literals_spec.rb +30 -30
  76. data/spec/cql/parser/entity_types_spec.rb +6 -6
  77. data/spec/cql/parser/expressions_spec.rb +25 -19
  78. data/spec/cql/samples_spec.rb +5 -4
  79. data/spec/cql_cql_spec.rb +2 -1
  80. data/spec/cql_dm_spec.rb +4 -0
  81. data/spec/cql_mysql_spec.rb +4 -0
  82. data/spec/cql_parse_spec.rb +2 -0
  83. data/spec/cql_ruby_spec.rb +4 -0
  84. data/spec/cql_sql_spec.rb +4 -0
  85. data/spec/cqldump_spec.rb +7 -4
  86. data/spec/helpers/parse_to_ast_matcher.rb +7 -3
  87. data/spec/helpers/test_parser.rb +2 -0
  88. data/spec/norma_cql_spec.rb +5 -2
  89. data/spec/norma_ruby_spec.rb +4 -1
  90. data/spec/norma_ruby_sql_spec.rb +4 -1
  91. data/spec/norma_sql_spec.rb +4 -1
  92. data/spec/norma_tables_spec.rb +2 -2
  93. data/spec/ruby_api_spec.rb +1 -1
  94. data/spec/spec_helper.rb +2 -0
  95. data/spec/transform_surrogate_spec.rb +59 -0
  96. metadata +70 -60
  97. data/TODO +0 -308
  98. data/lib/activefacts/cql/compiler/join.rb +0 -162
  99. data/lib/activefacts/generate/oo.rb +0 -176
  100. data/lib/activefacts/generate/ordered.rb +0 -602
@@ -20,7 +20,7 @@ describe "CQL Loader" do
20
20
  "units" => "Unit verbalisation into CQL is not implemented"
21
21
  }
22
22
  cql_cql_failures = {
23
- # "Insurance" => "Misses a join in a subset constraint",
23
+ # "Insurance" => "Misses a query in a subset constraint",
24
24
  # "OddIdentifier" => "Doesn't support identification of object fact types using mixed external/internal roles",
25
25
  }
26
26
  # Generate and return the CQL for the given vocabulary
@@ -52,6 +52,7 @@ describe "CQL Loader" do
52
52
  raise
53
53
  end
54
54
  end
55
+ vocabulary.finalise
55
56
 
56
57
  # Build and save the actual file:
57
58
  cql_text = cql(vocabulary)
@@ -64,6 +64,8 @@ describe "CQL Loader with DataMapper output" do
64
64
  actual_file = cql_file.sub(%r{examples/CQL/(.*).cql\Z}, 'spec/actual/\1.dm.rb')
65
65
  base = File.basename(cql_file, ".cql")
66
66
 
67
+ next unless ENV["AFTESTS"] || File.exists?(expected_file)
68
+
67
69
  it "should load #{cql_file} and dump DataMapper models matching #{expected_file}" do
68
70
  vocabulary = nil
69
71
  broken = cql_failures[base]
@@ -74,12 +76,14 @@ describe "CQL Loader with DataMapper output" do
74
76
  else
75
77
  vocabulary = ActiveFacts::Input::CQL.readfile(cql_file)
76
78
  end
79
+ vocabulary.finalise
77
80
 
78
81
  # Build and save the actual file:
79
82
  dm_text = ''
80
83
  lambda do
81
84
  begin
82
85
  dm_text = dm(vocabulary)
86
+ Dir.mkdir "spec/actual" rescue nil
83
87
  File.open(actual_file, "w") { |f| f.write dm_text }
84
88
  rescue
85
89
  raise unless mapping_failures[base]
@@ -33,6 +33,8 @@ describe "CQL Loader with SQL output" do
33
33
  actual_file = cql_file.sub(%r{examples/CQL/(.*).cql}, 'spec/actual/\1.my.sql')
34
34
  expected_file = cql_file.sub(%r{examples/CQL/(.*).cql\Z}, 'examples/MySQL/\1.sql')
35
35
 
36
+ next unless ENV["AFTESTS"] || File.exists?(expected_file)
37
+
36
38
  it "should load #{cql_file} and dump MySQL matching #{expected_file}" do
37
39
  broken = cql_failures[File.basename(cql_file, ".cql")]
38
40
  vocabulary = nil
@@ -43,9 +45,11 @@ describe "CQL Loader with SQL output" do
43
45
  else
44
46
  lambda { vocabulary = ActiveFacts::Input::CQL.readfile(cql_file) }.should_not raise_error
45
47
  end
48
+ vocabulary.finalise
46
49
 
47
50
  # Build and save the actual file:
48
51
  sql_text = sql(vocabulary)
52
+ Dir.mkdir "spec/actual" rescue nil
49
53
  File.open(actual_file, "w") { |f| f.write sql_text }
50
54
 
51
55
  pending("expected output file #{expected_file} not found") unless File.exists? expected_file
@@ -20,6 +20,7 @@ describe "CQL Parser" do
20
20
  it "should load CQL #{cql_file} without parse errors" do
21
21
  broken = cql_failures[File.basename(cql_file, ".cql")]
22
22
 
23
+ vocabulary = nil
23
24
  if broken
24
25
  pending(broken) {
25
26
  lambda { vocabulary = ActiveFacts::Input::CQL.readfile(cql_file) }.should_not raise_error
@@ -27,6 +28,7 @@ describe "CQL Parser" do
27
28
  else
28
29
  lambda { vocabulary = ActiveFacts::Input::CQL.readfile(cql_file) }.should_not raise_error
29
30
  end
31
+ vocabulary.finalise
30
32
  end
31
33
  end
32
34
  end
@@ -38,6 +38,8 @@ describe "CQL Loader with Ruby output" do
38
38
  expected_file = cql_file.sub(%r{/CQL/(.*).cql\Z}, '/ruby/\1.rb')
39
39
  actual_file = cql_file.sub(%r{examples/CQL/(.*).cql\Z}, 'spec/actual/\1.rb')
40
40
 
41
+ next unless ENV["AFTESTS"] || File.exists?(expected_file)
42
+
41
43
  it "should load #{cql_file} and dump Ruby matching #{expected_file}" do
42
44
  vocabulary = nil
43
45
  broken = cql_failures[File.basename(cql_file, ".cql")]
@@ -48,9 +50,11 @@ describe "CQL Loader with Ruby output" do
48
50
  else
49
51
  vocabulary = ActiveFacts::Input::CQL.readfile(cql_file)
50
52
  end
53
+ vocabulary.finalise
51
54
 
52
55
  # Build and save the actual file:
53
56
  ruby_text = ruby(vocabulary)
57
+ Dir.mkdir "spec/actual" rescue nil
54
58
  File.open(actual_file, "w") { |f| f.write ruby_text }
55
59
 
56
60
  pending("expected output file #{expected_file} not found") unless File.exists? expected_file
@@ -33,6 +33,8 @@ describe "CQL Loader with SQL output" do
33
33
  actual_file = cql_file.sub(%r{examples/CQL/(.*).cql}, 'spec/actual/\1.sql')
34
34
  expected_file = cql_file.sub(%r{examples/CQL/(.*).cql\Z}, 'examples/SQL/\1.sql')
35
35
 
36
+ next unless ENV["AFTESTS"] || File.exists?(expected_file)
37
+
36
38
  it "should load #{cql_file} and dump SQL matching #{expected_file}" do
37
39
  vocabulary = nil
38
40
  broken = cql_failures[File.basename(cql_file, ".cql")]
@@ -43,9 +45,11 @@ describe "CQL Loader with SQL output" do
43
45
  else
44
46
  vocabulary = ActiveFacts::Input::CQL.readfile(cql_file)
45
47
  end
48
+ vocabulary.finalise
46
49
 
47
50
  # Build and save the actual file:
48
51
  sql_text = sql(vocabulary)
52
+ Dir.mkdir "spec/actual" rescue nil
49
53
  File.open(actual_file, "w") { |f| f.write sql_text }
50
54
 
51
55
  pending("expected output file #{expected_file} not found") unless File.exists? expected_file
@@ -4,6 +4,7 @@
4
4
  #
5
5
 
6
6
  require 'stringio'
7
+ require 'activefacts'
7
8
  require 'activefacts/support'
8
9
  require 'activefacts/vocabulary'
9
10
  require 'activefacts/generate/cql'
@@ -58,15 +59,17 @@ END
58
59
  end
59
60
 
60
61
  def value_type(name, datatype = "String", length = 0, scale = 0)
61
- dt = @constellation.ValueType(@vocabulary, datatype, :guid => :new)
62
- vt = @constellation.ValueType(@vocabulary, name, :supertype => dt, :guid => :new)
62
+ dt = @constellation.ValueType[[@vocabulary.identifying_role_values, datatype]] ||
63
+ @constellation.ValueType(@vocabulary, datatype, :guid => :new)
64
+ vt = @constellation.ValueType[[@vocabulary.identifying_role_values, name]] ||
65
+ @constellation.ValueType(@vocabulary, name, :supertype => dt, :guid => :new)
63
66
  vt.length = length if length != 0
64
67
  vt.scale = scale if scale != 0
65
68
  vt
66
69
  end
67
70
 
68
71
  def one_to_many(one, many, reading)
69
- # Join them with a fact type:
72
+ # Combine them with a fact type:
70
73
  ft = @constellation.FactType(:new)
71
74
  role0 = @constellation.Role(ft, 0, :object_type => one, :guid => :new)
72
75
  role1 = @constellation.Role(ft, 1, :object_type => many, :guid => :new)
@@ -88,7 +91,7 @@ END
88
91
  end
89
92
 
90
93
  def one_to_one(first, second, reading)
91
- # Join them with a fact type:
94
+ # Combine them with a fact type:
92
95
  ft = @constellation.FactType(:new)
93
96
  role0 = @constellation.Role(ft, 0, :object_type => first, :guid => :new)
94
97
  role1 = @constellation.Role(ft, 1, :object_type => second, :guid => :new)
@@ -52,9 +52,13 @@ end
52
52
 
53
53
  RSpec::Matchers.define :fail_to_parse do |*error_regexp|
54
54
  match do |actual|
55
- @parser = TestParser.new
56
- @actual = actual
57
- @result = @parser.parse_all(actual, :definition)
55
+ begin
56
+ @parser = TestParser.new
57
+ @actual = actual
58
+ @result = @parser.parse_all(actual, :definition)
59
+ rescue => e
60
+ @exception = e.message
61
+ end
58
62
  @result.should be_nil
59
63
  if @re = error_regexp[0]
60
64
  @parser.failure_reason.should =~ @re
@@ -1,5 +1,7 @@
1
1
  # The test parser regards any word starting with an upper-case letter as a pre-existing term
2
+ require 'activefacts/cql/Language/English'
2
3
  class TestParser < ActiveFacts::CQL::Parser
4
+ include ActiveFacts::CQL::English
3
5
  def context
4
6
  @context ||= Context.new(self)
5
7
  end
@@ -12,12 +12,12 @@ require 'activefacts/generate/cql'
12
12
 
13
13
  describe "Norma Loader" do
14
14
  orm_failures = {
15
- "SubtypePI" => "Has an illegal uniqueness join constraint",
15
+ "SubtypePI" => "Has an illegal uniqueness constraint",
16
16
  }
17
17
  orm_cql_failures = {
18
18
  # "OddIdentifier" => "Strange identification pattern is incorrectly verbalised to CQL", # Fixed
19
19
  "UnaryIdentification" => "No PI for VisitStatus",
20
- "Supervision" => "Join constraints not imported from NORMA",
20
+ "Supervision" => "Derivations are not imported from NORMA",
21
21
  }
22
22
  # Generate and return the CQL for the given vocabulary
23
23
  def cql(vocabulary)
@@ -34,6 +34,8 @@ describe "Norma Loader" do
34
34
  actual_file = orm_file.sub(%r{examples/norma/(.*).orm\Z}, 'spec/actual/\1.cql')
35
35
  base = File.basename(orm_file, ".orm")
36
36
 
37
+ next unless ENV["AFTESTS"] || File.exists?(expected_file)
38
+
37
39
  it "should load #{orm_file} and dump CQL matching #{expected_file}" do
38
40
  begin
39
41
  vocabulary = ActiveFacts::Input::ORM.readfile(orm_file)
@@ -44,6 +46,7 @@ describe "Norma Loader" do
44
46
 
45
47
  cql_text = cql(vocabulary)
46
48
  # Save the actual file:
49
+ Dir.mkdir "spec/actual" rescue nil
47
50
  File.open(actual_file, "w") { |f| f.write cql_text }
48
51
 
49
52
  pending("expected output file #{expected_file} not found") unless File.exists? expected_file
@@ -19,7 +19,7 @@ end
19
19
 
20
20
  describe "NORMA Loader with Ruby output" do
21
21
  orm_failures = {
22
- "SubtypePI" => "Has an illegal uniqueness join constraint",
22
+ "SubtypePI" => "Has an illegal uniqueness constraint",
23
23
  }
24
24
 
25
25
  # Generate and return the Ruby for the given vocabulary
@@ -37,6 +37,8 @@ describe "NORMA Loader with Ruby output" do
37
37
  actual_file = orm_file.sub(%r{examples/norma/(.*).orm\Z}, 'spec/actual/\1.rb')
38
38
  base = File.basename(orm_file, ".orm")
39
39
 
40
+ next unless ENV["AFTESTS"] || File.exists?(expected_file)
41
+
40
42
  it "should load #{orm_file} and dump Ruby matching #{expected_file}" do
41
43
  begin
42
44
  vocabulary = ActiveFacts::Input::ORM.readfile(orm_file)
@@ -47,6 +49,7 @@ describe "NORMA Loader with Ruby output" do
47
49
 
48
50
  # Build and save the actual file:
49
51
  ruby_text = ruby(vocabulary)
52
+ Dir.mkdir "spec/actual" rescue nil
50
53
  File.open(actual_file, "w") { |f| f.write ruby_text }
51
54
 
52
55
  pending("expected output file #{expected_file} not found") unless File.exists? expected_file
@@ -13,7 +13,7 @@ require 'activefacts/generate/ruby'
13
13
 
14
14
  describe "Column lists from absorption compared with Ruby's" do
15
15
  orm_failures = {
16
- "SubtypePI" => "Has an illegal uniqueness join constraint",
16
+ "SubtypePI" => "Has an illegal uniqueness constraint",
17
17
  }
18
18
  norma_ruby_failures = {
19
19
  "UnaryIdentification" => "No PI for VisitStatus",
@@ -35,6 +35,8 @@ describe "Column lists from absorption compared with Ruby's" do
35
35
  actual_file = orm_file.sub(%r{examples/norma/(.*).orm\Z}, 'spec/actual/\1.rb')
36
36
  base = File.basename(orm_file, ".orm")
37
37
 
38
+ next unless ENV["AFTESTS"] || File.exists?(expected_file)
39
+
38
40
  it "should load #{orm_file} and generate relational composition and Ruby with matching column names" do
39
41
  begin
40
42
  vocabulary = ActiveFacts::Input::ORM.readfile(orm_file)
@@ -49,6 +51,7 @@ describe "Column lists from absorption compared with Ruby's" do
49
51
 
50
52
  # Build the Ruby and eval it:
51
53
  ruby_text = ruby(vocabulary)
54
+ Dir.mkdir "spec/actual" rescue nil
52
55
  File.open(actual_file, "w") { |f| f.write ruby_text }
53
56
 
54
57
  broken = norma_ruby_failures[base]
@@ -13,7 +13,7 @@ require 'activefacts/generate/sql/server'
13
13
 
14
14
  describe "NORMA Loader with SQL output" do
15
15
  orm_failures = {
16
- "SubtypePI" => "Has an illegal uniqueness join constraint",
16
+ "SubtypePI" => "Has an illegal uniqueness constraint",
17
17
  }
18
18
  # Generate and return the SQL for the given vocabulary
19
19
  def sql(vocabulary)
@@ -30,6 +30,8 @@ describe "NORMA Loader with SQL output" do
30
30
  actual_file = orm_file.sub(%r{examples/norma/(.*).orm\Z}, 'spec/actual/\1.sql')
31
31
  base = File.basename(orm_file, ".orm")
32
32
 
33
+ next unless ENV["AFTESTS"] || File.exists?(expected_file)
34
+
33
35
  it "should load #{orm_file} and dump SQL matching #{expected_file}" do
34
36
  begin
35
37
  vocabulary = ActiveFacts::Input::ORM.readfile(orm_file)
@@ -40,6 +42,7 @@ describe "NORMA Loader with SQL output" do
40
42
 
41
43
  # Build and save the actual file:
42
44
  sql_text = sql(vocabulary)
45
+ Dir.mkdir "spec/actual" rescue nil
43
46
  File.open(actual_file, "w") { |f| f.write sql_text }
44
47
 
45
48
  pending("expected output file #{expected_file} not found") unless File.exists? expected_file
@@ -18,14 +18,14 @@ require 'activefacts/input/orm'
18
18
  orm_failures = {
19
19
  }
20
20
  norma_table_exceptions = {
21
- "Metamodel" => [[], %w{Agreement Enforcement}], # ActiveFacts absorbs Agreement into ContextNote, Enforcement into Constraint
21
+ "Metamodel" => [%w{Concept}, %w{Agreement Enforcement}], # ActiveFacts absorbs Agreement into ContextNote, Enforcement into Constraint
22
22
  "MetamodelNext" => [[], %w{Agreement Enforcement TypeInheritance}],
23
23
  "Orienteering" => [%w{Punch}, []], # NORMA doesn't make a table for the IDENTITY field
24
24
  "OrienteeringER" => [%w{SeriesEvent}, []], # NORMA doesn't make a table for the IDENTITY field
25
25
  "RedundantDependency" => [%w{Politician StateOrProvince}, %w{LegislativeDistrict}], # NORMA doesn't make a table for the 3 IDENTITY fields
26
26
  "Warehousing" => [%w{Product Warehouse}, []], # NORMA doesn't make a table for the IDENTITY field
27
27
  "ServiceDirector" => [%w{DataStoreService MonitorNotificationUser}, %w{DataStoreFileHostSystem }],
28
-
28
+ "SeparateSubtype" => [%w{Claim}, %w{Incident}],
29
29
  }
30
30
 
31
31
  def extract_created_tables_from_sql sql_file
@@ -17,7 +17,7 @@ describe "Requiring vocabularies in Ruby" do
17
17
  base = File.basename(ruby_file, ".rb")
18
18
  next if ruby_failures.include?(base)
19
19
  it "#{ruby_file} should load cleanly" do
20
- require ruby_file
20
+ require "./"+ruby_file
21
21
  end
22
22
  end
23
23
  end
@@ -11,6 +11,8 @@ require 'helpers/file_matcher'
11
11
  require 'helpers/string_matcher'
12
12
  require 'helpers/parse_to_ast_matcher'
13
13
 
14
+ Dir[File.dirname(__FILE__)+"/helpers/**rb"].each do |helper| require helper; end
15
+
14
16
  class String
15
17
  def strip_comments()
16
18
  c_comment = %r{/\*((?!\*/).)*\*/}m
@@ -0,0 +1,59 @@
1
+ #
2
+ # ActiveFacts tests: Parse all CQL files and check the surrogate key transformation
3
+ # Copyright (c) 2012 Clifford Heath. Read the LICENSE file.
4
+ #
5
+
6
+ require 'spec_helper'
7
+ require 'stringio'
8
+ require 'activefacts/vocabulary'
9
+ require 'activefacts/support'
10
+ require 'activefacts/input/cql'
11
+ require 'activefacts/generate/absorption'
12
+ require 'activefacts/generate/transform/surrogate'
13
+
14
+ describe "CQL Loader with Surrogate transformation" do
15
+ cql_failures = {
16
+ }
17
+
18
+ pattern = ENV["AFTESTS"] || "*"
19
+ Dir["examples/CQL/#{pattern}.cql"].each do |cql_file|
20
+ expected_file = cql_file.sub(%r{/CQL/(.*).cql\Z}, '/transform-surrogate/\1.transform-surrogate')
21
+ actual_file = cql_file.sub(%r{examples/CQL/(.*).cql\Z}, 'spec/actual/\1.transform-surrogate')
22
+
23
+ next unless ENV["AFTESTS"] || File.exists?(expected_file)
24
+
25
+ it "should load #{cql_file} and make transformations like #{expected_file}" do
26
+ vocabulary = nil
27
+ broken = cql_failures[File.basename(cql_file, ".cql")]
28
+ if broken
29
+ pending(broken) {
30
+ vocabulary = ActiveFacts::Input::CQL.readfile(cql_file)
31
+ }
32
+ else
33
+ vocabulary = ActiveFacts::Input::CQL.readfile(cql_file)
34
+ end
35
+ vocabulary.finalise
36
+
37
+ # Build and save the actual file:
38
+ output = StringIO.new
39
+
40
+ transformer = ActiveFacts::Generate::Transform::Surrogate.new(vocabulary)
41
+ transformer.generate(output)
42
+
43
+ absorption = ActiveFacts::Generate::Absorption.new(vocabulary)
44
+ absorption.generate(output)
45
+
46
+ # Save the output from the StringIO:
47
+ output.rewind
48
+ transformed_text = output.read
49
+ Dir.mkdir "spec/actual" rescue nil
50
+ File.open(actual_file, "w") { |f| f.write transformed_text }
51
+
52
+ pending("expected output file #{expected_file} not found") unless File.exists? expected_file
53
+
54
+ expected_text = File.open(expected_file) {|f| f.read }
55
+ transformed_text.should_not differ_from(expected_text)
56
+ File.delete(actual_file) # It succeeded, we don't need the file.
57
+ end
58
+ end
59
+ end
metadata CHANGED
@@ -1,36 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activefacts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.16
5
- prerelease:
4
+ version: 0.8.18
6
5
  platform: ruby
7
6
  authors:
8
7
  - Clifford Heath
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-01 00:00:00.000000000 Z
11
+ date: 2013-11-15 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activefacts-api
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: 0.9.3
19
+ version: 0.9.8
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: 0.9.3
26
+ version: 0.9.8
30
27
  - !ruby/object:Gem::Dependency
31
- name: treetop
28
+ name: rbtree-pure
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,15 +34,27 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: treetop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 1.4.14
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.4.14
46
55
  - !ruby/object:Gem::Dependency
47
56
  name: nokogiri
48
57
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
58
  requirements:
51
59
  - - ! '>='
52
60
  - !ruby/object:Gem::Version
@@ -54,15 +62,27 @@ dependencies:
54
62
  type: :runtime
55
63
  prerelease: false
56
64
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
65
  requirements:
59
66
  - - ! '>='
60
67
  - !ruby/object:Gem::Version
61
68
  version: '0'
62
69
  - !ruby/object:Gem::Dependency
63
- name: dm-core
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: debugger
64
85
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
86
  requirements:
67
87
  - - ! '>='
68
88
  - !ruby/object:Gem::Version
@@ -70,15 +90,13 @@ dependencies:
70
90
  type: :development
71
91
  prerelease: false
72
92
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
93
  requirements:
75
94
  - - ! '>='
76
95
  - !ruby/object:Gem::Version
77
96
  version: '0'
78
97
  - !ruby/object:Gem::Dependency
79
- name: dm-constraints
98
+ name: activesupport
80
99
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
100
  requirements:
83
101
  - - ! '>='
84
102
  - !ruby/object:Gem::Version
@@ -86,15 +104,13 @@ dependencies:
86
104
  type: :development
87
105
  prerelease: false
88
106
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
107
  requirements:
91
108
  - - ! '>='
92
109
  - !ruby/object:Gem::Version
93
110
  version: '0'
94
111
  - !ruby/object:Gem::Dependency
95
- name: dm-migrations
112
+ name: dm-core
96
113
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
114
  requirements:
99
115
  - - ! '>='
100
116
  - !ruby/object:Gem::Version
@@ -102,15 +118,13 @@ dependencies:
102
118
  type: :development
103
119
  prerelease: false
104
120
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
121
  requirements:
107
122
  - - ! '>='
108
123
  - !ruby/object:Gem::Version
109
124
  version: '0'
110
125
  - !ruby/object:Gem::Dependency
111
- name: jeweler
126
+ name: dm-constraints
112
127
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
128
  requirements:
115
129
  - - ! '>='
116
130
  - !ruby/object:Gem::Version
@@ -118,31 +132,27 @@ dependencies:
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
135
  requirements:
123
136
  - - ! '>='
124
137
  - !ruby/object:Gem::Version
125
138
  version: '0'
126
139
  - !ruby/object:Gem::Dependency
127
- name: rspec
140
+ name: dm-migrations
128
141
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
142
  requirements:
131
- - - ~>
143
+ - - ! '>='
132
144
  - !ruby/object:Gem::Version
133
- version: 2.11.0
145
+ version: '0'
134
146
  type: :development
135
147
  prerelease: false
136
148
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
149
  requirements:
139
- - - ~>
150
+ - - ! '>='
140
151
  - !ruby/object:Gem::Version
141
- version: 2.11.0
152
+ version: '0'
142
153
  - !ruby/object:Gem::Dependency
143
- name: rake
154
+ name: jeweler
144
155
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
156
  requirements:
147
157
  - - ! '>='
148
158
  - !ruby/object:Gem::Version
@@ -150,15 +160,27 @@ dependencies:
150
160
  type: :development
151
161
  prerelease: false
152
162
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
163
  requirements:
155
164
  - - ! '>='
156
165
  - !ruby/object:Gem::Version
157
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rspec
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: 2.11.0
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ~>
179
+ - !ruby/object:Gem::Version
180
+ version: 2.11.0
158
181
  - !ruby/object:Gem::Dependency
159
182
  name: activefacts-api
160
183
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
184
  requirements:
163
185
  - - ~>
164
186
  - !ruby/object:Gem::Version
@@ -166,7 +188,6 @@ dependencies:
166
188
  type: :runtime
167
189
  prerelease: false
168
190
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
191
  requirements:
171
192
  - - ~>
172
193
  - !ruby/object:Gem::Version
@@ -174,7 +195,6 @@ dependencies:
174
195
  - !ruby/object:Gem::Dependency
175
196
  name: treetop
176
197
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
198
  requirements:
179
199
  - - ! '>='
180
200
  - !ruby/object:Gem::Version
@@ -182,7 +202,6 @@ dependencies:
182
202
  type: :runtime
183
203
  prerelease: false
184
204
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
205
  requirements:
187
206
  - - ! '>='
188
207
  - !ruby/object:Gem::Version
@@ -190,7 +209,6 @@ dependencies:
190
209
  - !ruby/object:Gem::Dependency
191
210
  name: nokogiri
192
211
  requirement: !ruby/object:Gem::Requirement
193
- none: false
194
212
  requirements:
195
213
  - - ! '>='
196
214
  - !ruby/object:Gem::Version
@@ -198,7 +216,6 @@ dependencies:
198
216
  type: :runtime
199
217
  prerelease: false
200
218
  version_requirements: !ruby/object:Gem::Requirement
201
- none: false
202
219
  requirements:
203
220
  - - ! '>='
204
221
  - !ruby/object:Gem::Version
@@ -206,7 +223,6 @@ dependencies:
206
223
  - !ruby/object:Gem::Dependency
207
224
  name: rspec
208
225
  requirement: !ruby/object:Gem::Requirement
209
- none: false
210
226
  requirements:
211
227
  - - ~>
212
228
  - !ruby/object:Gem::Version
@@ -214,7 +230,6 @@ dependencies:
214
230
  type: :development
215
231
  prerelease: false
216
232
  version_requirements: !ruby/object:Gem::Requirement
217
- none: false
218
233
  requirements:
219
234
  - - ~>
220
235
  - !ruby/object:Gem::Version
@@ -222,7 +237,6 @@ dependencies:
222
237
  - !ruby/object:Gem::Dependency
223
238
  name: bundler
224
239
  requirement: !ruby/object:Gem::Requirement
225
- none: false
226
240
  requirements:
227
241
  - - ~>
228
242
  - !ruby/object:Gem::Version
@@ -230,7 +244,6 @@ dependencies:
230
244
  type: :development
231
245
  prerelease: false
232
246
  version_requirements: !ruby/object:Gem::Requirement
233
- none: false
234
247
  requirements:
235
248
  - - ~>
236
249
  - !ruby/object:Gem::Version
@@ -238,7 +251,6 @@ dependencies:
238
251
  - !ruby/object:Gem::Dependency
239
252
  name: jeweler
240
253
  requirement: !ruby/object:Gem::Requirement
241
- none: false
242
254
  requirements:
243
255
  - - ~>
244
256
  - !ruby/object:Gem::Version
@@ -246,7 +258,6 @@ dependencies:
246
258
  type: :development
247
259
  prerelease: false
248
260
  version_requirements: !ruby/object:Gem::Requirement
249
- none: false
250
261
  requirements:
251
262
  - - ~>
252
263
  - !ruby/object:Gem::Version
@@ -254,7 +265,6 @@ dependencies:
254
265
  - !ruby/object:Gem::Dependency
255
266
  name: rdoc
256
267
  requirement: !ruby/object:Gem::Requirement
257
- none: false
258
268
  requirements:
259
269
  - - ! '>='
260
270
  - !ruby/object:Gem::Version
@@ -262,7 +272,6 @@ dependencies:
262
272
  type: :development
263
273
  prerelease: false
264
274
  version_requirements: !ruby/object:Gem::Requirement
265
- none: false
266
275
  requirements:
267
276
  - - ! '>='
268
277
  - !ruby/object:Gem::Version
@@ -289,7 +298,6 @@ extensions:
289
298
  extra_rdoc_files:
290
299
  - LICENSE
291
300
  - README.rdoc
292
- - TODO
293
301
  files:
294
302
  - History.txt
295
303
  - LICENSE
@@ -359,7 +367,7 @@ files:
359
367
  - lib/activefacts/cql/compiler/expression.rb
360
368
  - lib/activefacts/cql/compiler/fact.rb
361
369
  - lib/activefacts/cql/compiler/fact_type.rb
362
- - lib/activefacts/cql/compiler/join.rb
370
+ - lib/activefacts/cql/compiler/query.rb
363
371
  - lib/activefacts/cql/compiler/shared.rb
364
372
  - lib/activefacts/cql/compiler/value_type.rb
365
373
  - lib/activefacts/cql/nodes.rb
@@ -368,19 +376,24 @@ files:
368
376
  - lib/activefacts/generate/cql.rb
369
377
  - lib/activefacts/generate/dm.rb
370
378
  - lib/activefacts/generate/help.rb
379
+ - lib/activefacts/generate/helpers/oo.rb
380
+ - lib/activefacts/generate/helpers/ordered.rb
381
+ - lib/activefacts/generate/helpers/rails.rb
371
382
  - lib/activefacts/generate/html/glossary.rb
372
383
  - lib/activefacts/generate/json.rb
373
384
  - lib/activefacts/generate/null.rb
374
- - lib/activefacts/generate/oo.rb
375
- - lib/activefacts/generate/ordered.rb
385
+ - lib/activefacts/generate/rails/models.rb
386
+ - lib/activefacts/generate/rails/schema.rb
376
387
  - lib/activefacts/generate/records.rb
377
388
  - lib/activefacts/generate/ruby.rb
378
389
  - lib/activefacts/generate/sql/mysql.rb
379
390
  - lib/activefacts/generate/sql/server.rb
380
391
  - lib/activefacts/generate/text.rb
392
+ - lib/activefacts/generate/transform/surrogate.rb
381
393
  - lib/activefacts/generate/version.rb
382
394
  - lib/activefacts/input/cql.rb
383
395
  - lib/activefacts/input/orm.rb
396
+ - lib/activefacts/mapping/rails.rb
384
397
  - lib/activefacts/persistence.rb
385
398
  - lib/activefacts/persistence/columns.rb
386
399
  - lib/activefacts/persistence/foreignkey.rb
@@ -388,6 +401,7 @@ files:
388
401
  - lib/activefacts/persistence/object_type.rb
389
402
  - lib/activefacts/persistence/reference.rb
390
403
  - lib/activefacts/persistence/tables.rb
404
+ - lib/activefacts/registry.rb
391
405
  - lib/activefacts/support.rb
392
406
  - lib/activefacts/version.rb
393
407
  - lib/activefacts/vocabulary.rb
@@ -436,12 +450,13 @@ files:
436
450
  - spec/norma_tables_spec.rb
437
451
  - spec/ruby_api_spec.rb
438
452
  - spec/spec_helper.rb
453
+ - spec/transform_surrogate_spec.rb
439
454
  - status.html
440
455
  - why.html
441
- - TODO
442
456
  homepage: http://github.com/cjheath/activefacts
443
457
  licenses:
444
458
  - MIT
459
+ metadata: {}
445
460
  post_install_message: For more information on ActiveFacts, see http://dataconstellation.com/ActiveFacts
446
461
  rdoc_options:
447
462
  - -S
@@ -452,25 +467,20 @@ rdoc_options:
452
467
  require_paths:
453
468
  - lib
454
469
  required_ruby_version: !ruby/object:Gem::Requirement
455
- none: false
456
470
  requirements:
457
471
  - - ! '>='
458
472
  - !ruby/object:Gem::Version
459
473
  version: '0'
460
- segments:
461
- - 0
462
- hash: 3445837228112835093
463
474
  required_rubygems_version: !ruby/object:Gem::Requirement
464
- none: false
465
475
  requirements:
466
476
  - - ! '>='
467
477
  - !ruby/object:Gem::Version
468
478
  version: '0'
469
479
  requirements: []
470
480
  rubyforge_project:
471
- rubygems_version: 1.8.24
481
+ rubygems_version: 2.1.10
472
482
  signing_key:
473
- specification_version: 3
483
+ specification_version: 4
474
484
  summary: A semantic modeling and query language (CQL) and application runtime (the
475
485
  Constellation API)
476
486
  test_files: []