activefacts 0.8.10 → 0.8.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +3 -2
- data/bin/afgen +25 -23
- data/bin/cql +9 -8
- data/css/orm2.css +23 -3
- data/examples/CQL/CompanyDirectorEmployee.cql +1 -1
- data/examples/CQL/Diplomacy.cql +3 -3
- data/examples/CQL/Insurance.cql +27 -21
- data/examples/CQL/Metamodel.cql +12 -8
- data/examples/CQL/MetamodelNext.cql +172 -149
- data/examples/CQL/ServiceDirector.cql +17 -17
- data/examples/CQL/Supervision.cql +3 -5
- data/examples/CQL/WaiterTips.cql +1 -1
- data/examples/CQL/unit.cql +1 -1
- data/index.html +0 -0
- data/lib/activefacts/cql/FactTypes.treetop +41 -8
- data/lib/activefacts/cql/Language/English.treetop +10 -0
- data/lib/activefacts/cql/ObjectTypes.treetop +3 -1
- data/lib/activefacts/cql/Terms.treetop +34 -53
- data/lib/activefacts/cql/compiler.rb +1 -1
- data/lib/activefacts/cql/compiler/clause.rb +21 -8
- data/lib/activefacts/cql/compiler/constraint.rb +3 -1
- data/lib/activefacts/cql/compiler/entity_type.rb +1 -1
- data/lib/activefacts/cql/compiler/fact_type.rb +9 -3
- data/lib/activefacts/cql/compiler/join.rb +3 -0
- data/lib/activefacts/cql/compiler/value_type.rb +9 -4
- data/lib/activefacts/cql/parser.rb +11 -3
- data/lib/activefacts/generate/oo.rb +3 -3
- data/lib/activefacts/generate/ordered.rb +0 -4
- data/lib/activefacts/input/orm.rb +305 -250
- data/lib/activefacts/persistence/tables.rb +6 -0
- data/lib/activefacts/support.rb +18 -0
- data/lib/activefacts/version.rb +1 -1
- data/lib/activefacts/vocabulary/extensions.rb +59 -20
- data/lib/activefacts/vocabulary/metamodel.rb +23 -13
- data/lib/activefacts/vocabulary/verbaliser.rb +5 -3
- data/spec/absorption_spec.rb +3 -2
- data/spec/cql/comparison_spec.rb +1 -3
- data/spec/cql/context_spec.rb +1 -1
- data/spec/cql/entity_type_spec.rb +2 -2
- data/spec/cql/expressions_spec.rb +2 -4
- data/spec/cql/fact_type_matching_spec.rb +55 -3
- data/spec/cql/parser/fact_types_spec.rb +3 -0
- data/spec/cql/role_matching_spec.rb +8 -7
- data/spec/cql/samples_spec.rb +10 -2
- data/spec/cql_dm_spec.rb +2 -1
- data/spec/helpers/array_matcher.rb +18 -35
- data/spec/helpers/diff_matcher.rb +34 -13
- data/spec/helpers/file_matcher.rb +27 -43
- data/spec/helpers/string_matcher.rb +23 -33
- data/spec/norma_cql_spec.rb +1 -0
- data/spec/norma_tables_spec.rb +1 -2
- metadata +95 -102
| @@ -24,6 +24,9 @@ describe "Fact Types" do | |
| 24 24 | 
             
            #    ],
         | 
| 25 25 | 
             
                [ "A is interesting : b- C has F -g;",
         | 
| 26 26 | 
             
                  ["FactType: [{A} \"is interesting\"] where {b- C} \"has\" {F -g}"]
         | 
| 27 | 
            +
                ],
         | 
| 28 | 
            +
                [ "A has one pre-- bound B;",
         | 
| 29 | 
            +
                  [%q{FactType: [{A} "has" {[1..1] pre-bound- B}]}]
         | 
| 27 30 | 
             
                ]
         | 
| 28 31 | 
             
                # REVISIT: Test all quantifiers
         | 
| 29 32 | 
             
              ]
         | 
| @@ -2,13 +2,14 @@ | |
| 2 2 | 
             
            # ActiveFacts CQL Fact Type matching tests
         | 
| 3 3 | 
             
            # Copyright (c) 2009 Clifford Heath. Read the LICENSE file.
         | 
| 4 4 | 
             
            #
         | 
| 5 | 
            +
            $: << Dir::getwd
         | 
| 5 6 |  | 
| 6 7 | 
             
            require 'rspec/expectations'
         | 
| 7 8 |  | 
| 8 9 | 
             
            require 'activefacts/support'
         | 
| 9 10 | 
             
            require 'activefacts/api/support'
         | 
| 10 11 | 
             
            require 'activefacts/cql/compiler'
         | 
| 11 | 
            -
            require ' | 
| 12 | 
            +
            require File.dirname(__FILE__) + '/../helpers/compile_helpers'
         | 
| 12 13 |  | 
| 13 14 | 
             
            describe "When comparing roles of a reading with an existing reading" do
         | 
| 14 15 | 
             
              before :each do
         | 
| @@ -48,7 +49,7 @@ describe "When comparing roles of a reading with an existing reading" do | |
| 48 49 | 
             
                  @asts.size.should == 1
         | 
| 49 50 | 
             
                  side_effects = match_readings_to_existing(@asts[0], @simple_ft.all_reading.single)
         | 
| 50 51 | 
             
                  side_effects[0].should_not be_nil
         | 
| 51 | 
            -
                  side_effects.to_s.should == 'side-effects are [{Boy} absorbs 0/0 at 0, {Girl} absorbs 0/0 at 5]'
         | 
| 52 | 
            +
                  side_effects.to_s.should == '[side-effects are [{Boy} absorbs 0/0 at 0, {Girl} absorbs 0/0 at 5]]'
         | 
| 52 53 | 
             
                end
         | 
| 53 54 |  | 
| 54 55 | 
             
                it "should match with explicit leading adjective" do
         | 
| @@ -56,7 +57,7 @@ describe "When comparing roles of a reading with an existing reading" do | |
| 56 57 | 
             
                  @asts.size.should == 1
         | 
| 57 58 | 
             
                  side_effects = match_readings_to_existing(@asts[0], @ugly_ft.all_reading.single)
         | 
| 58 59 | 
             
                  side_effects[0].should_not be_nil
         | 
| 59 | 
            -
                  side_effects.to_s.should == 'side-effects are [{Boy} absorbs 0/0 at 0, {ugly- Girl} absorbs 0/0 at 2]'
         | 
| 60 | 
            +
                  side_effects.to_s.should == '[side-effects are [{Boy} absorbs 0/0 at 0, {ugly- Girl} absorbs 0/0 at 2]]'
         | 
| 60 61 | 
             
                end
         | 
| 61 62 |  | 
| 62 63 | 
             
                it "should match with implicit leading adjective" do
         | 
| @@ -64,7 +65,7 @@ describe "When comparing roles of a reading with an existing reading" do | |
| 64 65 | 
             
                  @asts.size.should == 1
         | 
| 65 66 | 
             
                  side_effects = match_readings_to_existing(@asts[0], @ugly_ft.all_reading.single)
         | 
| 66 67 | 
             
                  side_effects[0].should_not be_nil
         | 
| 67 | 
            -
                  side_effects.to_s.should == 'side-effects are [{Boy} absorbs 0/0 at 0, {Girl} absorbs 1/0 at 3]'
         | 
| 68 | 
            +
                  side_effects.to_s.should == '[side-effects are [{Boy} absorbs 0/0 at 0, {Girl} absorbs 1/0 at 3]]'
         | 
| 68 69 | 
             
                end
         | 
| 69 70 |  | 
| 70 71 | 
             
                it "should match with local leading adjective" do
         | 
| @@ -104,7 +105,7 @@ describe "When comparing roles of a reading with an existing reading" do | |
| 104 105 | 
             
                  side_effects = match_readings_to_existing(@asts[0], @hurts_ft.all_reading.single)
         | 
| 105 106 | 
             
                  pending "Thinks trailing adjectives are always residual"
         | 
| 106 107 | 
             
                  side_effects[0].should_not be_nil
         | 
| 107 | 
            -
                  side_effects.to_s.should == ''
         | 
| 108 | 
            +
                  side_effects[0].to_s.should == ''
         | 
| 108 109 | 
             
                end
         | 
| 109 110 |  | 
| 110 111 | 
             
                it "should match with implicit trailing adjective" do
         | 
| @@ -112,7 +113,7 @@ describe "When comparing roles of a reading with an existing reading" do | |
| 112 113 | 
             
                  @asts.size.should == 1
         | 
| 113 114 | 
             
                  side_effects = match_readings_to_existing(@asts[0], @hurts_ft.all_reading.single)
         | 
| 114 115 | 
             
                  side_effects[0].should_not be_nil
         | 
| 115 | 
            -
                  side_effects.to_s.should == 'side-effects are [{Boy} absorbs 0/1 at 0, {Girl} absorbs 0/0 at 3]'
         | 
| 116 | 
            +
                  side_effects.to_s.should == '[side-effects are [{Boy} absorbs 0/1 at 0, {Girl} absorbs 0/0 at 3]]'
         | 
| 116 117 | 
             
                end
         | 
| 117 118 |  | 
| 118 119 | 
             
                it "should match with local trailing adjective" do
         | 
| @@ -124,7 +125,7 @@ describe "When comparing roles of a reading with an existing reading" do | |
| 124 125 | 
             
                  side_effects = match_readings_to_existing(@asts[0], @simple_ft.all_reading.single)
         | 
| 125 126 | 
             
                  side_effects.size.should == 2
         | 
| 126 127 | 
             
                  side_effects[0].should_not be_nil
         | 
| 127 | 
            -
                  side_effects.to_s.should == 'side-effects are [{Boy} absorbs 0/0 at 0, {Girl -troublemaker} absorbs 0/0 at 5 with residual adjectives] with residual adjectives'
         | 
| 128 | 
            +
                  side_effects.to_s.should == '[side-effects are [{Boy} absorbs 0/0 at 0, {Girl -troublemaker} absorbs 0/0 at 5 with residual adjectives] with residual adjectives, nil]'
         | 
| 128 129 | 
             
                end
         | 
| 129 130 |  | 
| 130 131 | 
             
                it "should match with explicit and local trailing adjective" do
         | 
    
        data/spec/cql/samples_spec.rb
    CHANGED
    
    | @@ -103,6 +103,14 @@ describe "Sample data" do | |
| 103 103 | 
             
                ],
         | 
| 104 104 | 
             
              ]
         | 
| 105 105 |  | 
| 106 | 
            +
              def render_value v
         | 
| 107 | 
            +
                if v.to_s !~ /[^-+0-9.]/ and (n = eval(v.to_s) rescue nil)
         | 
| 108 | 
            +
                  n
         | 
| 109 | 
            +
                else
         | 
| 110 | 
            +
                  "'"+v.to_s.gsub(/'/,'\\\'')+"'"
         | 
| 111 | 
            +
                end
         | 
| 112 | 
            +
              end
         | 
| 113 | 
            +
             | 
| 106 114 | 
             
              # REVISIT: This code does a better job than verbalise. Consider incorporating it?
         | 
| 107 115 | 
             
              def instance_name(i)
         | 
| 108 116 | 
             
                if i.is_a?(ActiveFacts::Metamodel::Fact)
         | 
| @@ -112,14 +120,14 @@ describe "Sample data" do | |
| 112 120 | 
             
                  role_values_in_reading_order = fact.all_role_value.sort_by{|rv| reading_roles.index(rv.role) }
         | 
| 113 121 | 
             
                  instance_verbalisations = role_values_in_reading_order.map do |rv|
         | 
| 114 122 | 
             
                    next nil unless v = rv.instance.value
         | 
| 115 | 
            -
                    v | 
| 123 | 
            +
                    render_value(v)
         | 
| 116 124 | 
             
                  end
         | 
| 117 125 | 
             
                  return reading.expand([], false, instance_verbalisations)
         | 
| 118 126 | 
             
                  # REVISIT: Include the instance_names of all role players
         | 
| 119 127 | 
             
                end
         | 
| 120 128 |  | 
| 121 129 | 
             
                if i.object_type.is_a?(ActiveFacts::Metamodel::ValueType)
         | 
| 122 | 
            -
                  return "#{i.object_type.name} #{i.value}"
         | 
| 130 | 
            +
                  return "#{i.object_type.name} #{render_value(i.value)}"
         | 
| 123 131 | 
             
                end
         | 
| 124 132 |  | 
| 125 133 | 
             
                if i.object_type.fact_type      # An instance of an objectified fact type
         | 
    
        data/spec/cql_dm_spec.rb
    CHANGED
    
    | @@ -38,8 +38,9 @@ describe "CQL Loader with DataMapper output" do | |
| 38 38 | 
             
              mapping_failures = {  # These models can't be mapped to DM
         | 
| 39 39 | 
             
                'OrienteeringER' => 'Invalid CQL results in unmappable model',
         | 
| 40 40 | 
             
                'Insurance' => 'Cannot handle models that contain classes like Vehicle Incident with external supertypes (Incident)',
         | 
| 41 | 
            -
                'MetamodelNext' => 'Cannot handle models that contain classes like Constraint with external supertypes (ObjectType)',
         | 
| 42 41 | 
             
                'MultiInheritance' => 'Cannot handle models that contain classes like Australian Employee with external supertypes (Australian)',
         | 
| 42 | 
            +
                'Metamodel' => 'cannot be used as a property name since it collides with an existing method',
         | 
| 43 | 
            +
                'MetamodelNext' => 'Cannot map classes like Constraint with roles inherited from external supertypes (Concept)',
         | 
| 43 44 | 
             
                'SeparateSubtype' => 'Cannot handle models that contain classes like Vehicle Incident with external supertypes (Incident)',
         | 
| 44 45 | 
             
                'ServiceDirector' => 'Cannot handle models that contain classes like Client with external supertypes (Company)',
         | 
| 45 46 | 
             
              }
         | 
| @@ -1,40 +1,23 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
               | 
| 3 | 
            -
                 | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
                      match_for_should do |actual|
         | 
| 7 | 
            -
                        perform_match(actual, _expected[0])
         | 
| 8 | 
            -
                        @extra + @missing != []
         | 
| 9 | 
            -
                      end
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                      match_for_should_not do |actual|
         | 
| 12 | 
            -
                        perform_match(actual, _expected[0])
         | 
| 13 | 
            -
                        @extra + @missing == []
         | 
| 14 | 
            -
                      end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                      def perform_match(actual, expected)
         | 
| 17 | 
            -
                        @extra = actual - expected
         | 
| 18 | 
            -
                        @missing = expected - actual
         | 
| 19 | 
            -
                      end
         | 
| 1 | 
            +
            RSpec::Matchers.define :be_different_array_from do |x|
         | 
| 2 | 
            +
              match do |actual|
         | 
| 3 | 
            +
                perform_match(actual, expected)
         | 
| 4 | 
            +
                @extra + @missing != []
         | 
| 5 | 
            +
              end
         | 
| 20 6 |  | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 7 | 
            +
              def perform_match(actual, expected)
         | 
| 8 | 
            +
                @extra = actual - expected
         | 
| 9 | 
            +
                @missing = expected - actual
         | 
| 10 | 
            +
              end
         | 
| 24 11 |  | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
                            (@extra.empty? ? nil : 'has extra '+@extra.sort.inspect)
         | 
| 29 | 
            -
                          ].compact * ' and '
         | 
| 30 | 
            -
                        }"
         | 
| 31 | 
            -
                      end
         | 
| 32 | 
            -
                    end
         | 
| 33 | 
            -
                  end
         | 
| 34 | 
            -
                end
         | 
| 12 | 
            +
              failure_message_for_should do |actual|
         | 
| 13 | 
            +
                "expected a difference in the two lists, but got none"
         | 
| 14 | 
            +
              end
         | 
| 35 15 |  | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 16 | 
            +
              failure_message_for_should_not do |actual|
         | 
| 17 | 
            +
                "expected no difference, but result #{
         | 
| 18 | 
            +
                  [ (@missing.empty? ? nil : 'lacks '+@missing.sort.inspect),
         | 
| 19 | 
            +
                    (@extra.empty? ? nil : 'has extra '+@extra.sort.inspect)
         | 
| 20 | 
            +
                  ].compact * ' and '
         | 
| 21 | 
            +
                }"
         | 
| 39 22 | 
             
              end
         | 
| 40 23 | 
             
            end
         | 
| @@ -1,18 +1,39 @@ | |
| 1 1 | 
             
            require 'pathname'
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
                   | 
| 14 | 
            -
             | 
| 15 | 
            -
                   | 
| 3 | 
            +
            require 'rspec/matchers'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            class RSpec::Matchers::DSL::Matcher
         | 
| 6 | 
            +
              attr_writer :expected
         | 
| 7 | 
            +
            end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            RSpec::Matchers.define :differ_from do |expected|
         | 
| 10 | 
            +
              match do |actual|
         | 
| 11 | 
            +
                case expected
         | 
| 12 | 
            +
                when Pathname
         | 
| 13 | 
            +
                  @m = have_different_contents
         | 
| 14 | 
            +
                  @m.expected = expected
         | 
| 15 | 
            +
                  @m.matches?(actual)
         | 
| 16 | 
            +
                when Array
         | 
| 17 | 
            +
                  # If we pass "expected" here, it expects an array.
         | 
| 18 | 
            +
                  # Works here, but not for Pathname or String
         | 
| 19 | 
            +
                  # Hence the need for the attr_writer hack above.
         | 
| 20 | 
            +
                  @m = be_different_array_from
         | 
| 21 | 
            +
                  @m.expected = expected
         | 
| 22 | 
            +
                  @m.matches?(actual)
         | 
| 23 | 
            +
                when String
         | 
| 24 | 
            +
                  @m = have_different_contents
         | 
| 25 | 
            +
                  @m.expected = expected
         | 
| 26 | 
            +
                  @m.matches?(actual)
         | 
| 27 | 
            +
                else
         | 
| 28 | 
            +
                  raise "DiffMatcher doesn't know how to match a #{expected.class}"
         | 
| 16 29 | 
             
                end
         | 
| 17 30 | 
             
              end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              failure_message_for_should do |actual|
         | 
| 33 | 
            +
                @m.failure_message_for_should
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
              failure_message_for_should_not do |actual|
         | 
| 37 | 
            +
                @m.failure_message_for_should_not
         | 
| 38 | 
            +
              end
         | 
| 18 39 | 
             
            end
         | 
| @@ -1,50 +1,34 @@ | |
| 1 1 | 
             
            require 'diff/lcs'
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
               | 
| 5 | 
            -
                 | 
| 6 | 
            -
             | 
| 7 | 
            -
                    super(:have_different_contents, expected) do |*_expected|
         | 
| 8 | 
            -
                      match_for_should do |actual|
         | 
| 9 | 
            -
                        perform_match(actual, _expected[0])
         | 
| 10 | 
            -
                      end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                      match_for_should_not do |actual|
         | 
| 13 | 
            -
                        !perform_match(actual, _expected[0])
         | 
| 14 | 
            -
                      end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                      def perform_match(actual, expected)
         | 
| 17 | 
            -
                        expected = File.open(expected).read if expected.is_a?(Pathname)
         | 
| 18 | 
            -
                        expected = expected.scan(/[^\n]+/) unless expected.is_a?(Array)
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                        actual = File.open(actual).read if actual.is_a?(Pathname)
         | 
| 21 | 
            -
                        actual = actual.scan(/[^\n]+/) unless actual.is_a?(Array)
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                        differences = Diff::LCS::diff(expected, actual)
         | 
| 24 | 
            -
                        @diff = differences.map do |chunk|
         | 
| 25 | 
            -
                            added_at = (add = chunk.detect{|d| d.action == '+'}) && add.position+1
         | 
| 26 | 
            -
                            removed_at = (remove = chunk.detect{|d| d.action == '-'}) && remove.position+1
         | 
| 27 | 
            -
                            "Line #{added_at}/#{removed_at}:\n"+
         | 
| 28 | 
            -
                            chunk.map do |change|
         | 
| 29 | 
            -
                              "#{change.action} #{change.element}"
         | 
| 30 | 
            -
                            end*"\n"
         | 
| 31 | 
            -
                          end*"\n"
         | 
| 32 | 
            -
                        @diff != ''
         | 
| 33 | 
            -
                      end
         | 
| 3 | 
            +
            RSpec::Matchers.define :have_different_contents do |x|
         | 
| 4 | 
            +
              match do |actual|
         | 
| 5 | 
            +
                perform_match(actual, expected)
         | 
| 6 | 
            +
              end
         | 
| 34 7 |  | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 8 | 
            +
              def perform_match(actual, expected)
         | 
| 9 | 
            +
                expected = File.open(expected).read if expected.is_a?(Pathname)
         | 
| 10 | 
            +
                expected = expected.scan(/[^\n]+/) unless expected.is_a?(Array)
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                actual = File.open(actual).read if actual.is_a?(Pathname)
         | 
| 13 | 
            +
                actual = actual.scan(/[^\n]+/) unless actual.is_a?(Array)
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                differences = Diff::LCS::diff(expected, actual)
         | 
| 16 | 
            +
                @diff = differences.map do |chunk|
         | 
| 17 | 
            +
                    added_at = (add = chunk.detect{|d| d.action == '+'}) && add.position+1
         | 
| 18 | 
            +
                    removed_at = (remove = chunk.detect{|d| d.action == '-'}) && remove.position+1
         | 
| 19 | 
            +
                    "Line #{added_at}/#{removed_at}:\n"+
         | 
| 20 | 
            +
                    chunk.map do |change|
         | 
| 21 | 
            +
                      "#{change.action} #{change.element}"
         | 
| 22 | 
            +
                    end*"\n"
         | 
| 23 | 
            +
                  end*"\n"
         | 
| 24 | 
            +
                @diff != ''
         | 
| 25 | 
            +
              end
         | 
| 38 26 |  | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
                    end
         | 
| 43 | 
            -
                  end
         | 
| 44 | 
            -
                end
         | 
| 27 | 
            +
              failure_message_for_should do |actual|
         | 
| 28 | 
            +
                "expected a difference, but got none"
         | 
| 29 | 
            +
              end
         | 
| 45 30 |  | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
                end
         | 
| 31 | 
            +
              failure_message_for_should_not do |actual|
         | 
| 32 | 
            +
                "expected no difference, but got:\n#{@diff}"
         | 
| 49 33 | 
             
              end
         | 
| 50 34 | 
             
            end
         | 
| @@ -1,40 +1,30 @@ | |
| 1 1 | 
             
            require 'diff/lcs'
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
               | 
| 5 | 
            -
                 | 
| 6 | 
            -
             | 
| 7 | 
            -
                    match_for_should do |actual|
         | 
| 8 | 
            -
                      perform_match(actual, _expected)
         | 
| 9 | 
            -
                    end
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                    match_for_should_not do |actual|
         | 
| 12 | 
            -
                      !perform_match(actual, _expected)
         | 
| 13 | 
            -
                    end
         | 
| 3 | 
            +
            RSpec::Matchers.define :have_different_contents do |x|
         | 
| 4 | 
            +
              match do |actual|
         | 
| 5 | 
            +
                perform_match(actual, expected)
         | 
| 6 | 
            +
              end
         | 
| 14 7 |  | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 8 | 
            +
              def perform_match(actual, expected)
         | 
| 9 | 
            +
                expected_lines = expected.scan(/[^\n]+/)
         | 
| 10 | 
            +
                actual_lines = actual.scan(/[^\n]+/)
         | 
| 11 | 
            +
                differences = Diff::LCS::diff(expected_lines, actual_lines)
         | 
| 12 | 
            +
                @diff = differences.map do |chunk|
         | 
| 13 | 
            +
                    added_at = (add = chunk.detect{|d| d.action == '+'}) && add.position+1
         | 
| 14 | 
            +
                    removed_at = (remove = chunk.detect{|d| d.action == '-'}) && remove.position+1
         | 
| 15 | 
            +
                    "Line #{added_at}/#{removed_at}:\n"+
         | 
| 16 | 
            +
                    chunk.map do |change|
         | 
| 17 | 
            +
                      "#{change.action} #{change.element}"
         | 
| 18 | 
            +
                    end*"\n"
         | 
| 19 | 
            +
                  end*"\n"
         | 
| 20 | 
            +
                @diff != ''
         | 
| 21 | 
            +
              end
         | 
| 29 22 |  | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 23 | 
            +
              failure_message_for_should do |actual|
         | 
| 24 | 
            +
                "expected a difference, but got none"
         | 
| 25 | 
            +
              end
         | 
| 33 26 |  | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
                    end
         | 
| 37 | 
            -
                  end
         | 
| 38 | 
            -
                end
         | 
| 27 | 
            +
              failure_message_for_should_not do |actual|
         | 
| 28 | 
            +
                "expected no difference, but got:\n#{@diff}"
         | 
| 39 29 | 
             
              end
         | 
| 40 30 | 
             
            end
         | 
    
        data/spec/norma_cql_spec.rb
    CHANGED
    
    | @@ -17,6 +17,7 @@ describe "Norma Loader" do | |
| 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 21 | 
             
              }
         | 
| 21 22 | 
             
              # Generate and return the CQL for the given vocabulary
         | 
| 22 23 | 
             
              def cql(vocabulary)
         | 
    
        data/spec/norma_tables_spec.rb
    CHANGED
    
    | @@ -19,11 +19,10 @@ orm_failures = { | |
| 19 19 | 
             
            }
         | 
| 20 20 | 
             
            norma_table_exceptions = {
         | 
| 21 21 | 
             
              "Metamodel" => [[], %w{Agreement Enforcement}],                   # ActiveFacts absorbs Agreement into ContextNote, Enforcement into Constraint
         | 
| 22 | 
            -
              "MetamodelNext" => [[], %w{Agreement Enforcement}],
         | 
| 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 | 
            -
              "SeparateSubtype" => [%w{Claim}, %w{Incident}],                   # NORMA doesn't make a table for the IDENTITY field. Even when Claim is independent, it still doesn't absorb Incident either and I don't know why, must ask Matt.
         | 
| 27 26 | 
             
              "Warehousing" => [%w{Product Warehouse}, []],                     # NORMA doesn't make a table for the IDENTITY field
         | 
| 28 27 | 
             
              "ServiceDirector" => [%w{DataStoreService MonitorNotificationUser}, %w{DataStoreFileHostSystem }],
         | 
| 29 28 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,120 +1,121 @@ | |
| 1 | 
            -
            --- !ruby/object:Gem::Specification | 
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: activefacts
         | 
| 3 | 
            -
            version: !ruby/object:Gem::Version | 
| 4 | 
            -
               | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.8.12
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 | 
            -
              segments: 
         | 
| 7 | 
            -
              - 0
         | 
| 8 | 
            -
              - 8
         | 
| 9 | 
            -
              - 10
         | 
| 10 | 
            -
              version: 0.8.10
         | 
| 11 6 | 
             
            platform: ruby
         | 
| 12 | 
            -
            authors: | 
| 7 | 
            +
            authors:
         | 
| 13 8 | 
             
            - Clifford Heath
         | 
| 14 9 | 
             
            autorequire: 
         | 
| 15 10 | 
             
            bindir: bin
         | 
| 16 11 | 
             
            cert_chain: []
         | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 12 | 
            +
            date: 2012-10-15 00:00:00.000000000 Z
         | 
| 13 | 
            +
            dependencies:
         | 
| 14 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 21 15 | 
             
              name: activefacts-api
         | 
| 22 | 
            -
               | 
| 23 | 
            -
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 16 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 24 17 | 
             
                none: false
         | 
| 25 | 
            -
                requirements: | 
| 26 | 
            -
                - -  | 
| 27 | 
            -
                  - !ruby/object:Gem::Version | 
| 28 | 
            -
                     | 
| 29 | 
            -
                    segments: 
         | 
| 30 | 
            -
                    - 0
         | 
| 31 | 
            -
                    - 8
         | 
| 32 | 
            -
                    - 10
         | 
| 33 | 
            -
                    version: 0.8.10
         | 
| 18 | 
            +
                requirements:
         | 
| 19 | 
            +
                - - ! '>='
         | 
| 20 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            +
                    version: 0.8.12
         | 
| 34 22 | 
             
              type: :runtime
         | 
| 35 | 
            -
              version_requirements: *id001
         | 
| 36 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 37 | 
            -
              name: treetop
         | 
| 38 23 | 
             
              prerelease: false
         | 
| 39 | 
            -
               | 
| 24 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            +
                none: false
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - ! '>='
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: 0.8.12
         | 
| 30 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 31 | 
            +
              name: treetop
         | 
| 32 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 40 33 | 
             
                none: false
         | 
| 41 | 
            -
                requirements: | 
| 42 | 
            -
                - -  | 
| 43 | 
            -
                  - !ruby/object:Gem::Version | 
| 44 | 
            -
                    hash: 5
         | 
| 45 | 
            -
                    segments: 
         | 
| 46 | 
            -
                    - 1
         | 
| 47 | 
            -
                    - 4
         | 
| 48 | 
            -
                    - 1
         | 
| 34 | 
            +
                requirements:
         | 
| 35 | 
            +
                - - ! '>='
         | 
| 36 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 49 37 | 
             
                    version: 1.4.1
         | 
| 50 38 | 
             
              type: :runtime
         | 
| 51 | 
            -
              version_requirements: *id002
         | 
| 52 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 53 | 
            -
              name: rake
         | 
| 54 39 | 
             
              prerelease: false
         | 
| 55 | 
            -
               | 
| 40 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 56 41 | 
             
                none: false
         | 
| 57 | 
            -
                requirements: | 
| 58 | 
            -
                - -  | 
| 59 | 
            -
                  - !ruby/object:Gem::Version | 
| 60 | 
            -
                     | 
| 61 | 
            -
             | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 42 | 
            +
                requirements:
         | 
| 43 | 
            +
                - - ! '>='
         | 
| 44 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            +
                    version: 1.4.1
         | 
| 46 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 47 | 
            +
              name: rake
         | 
| 48 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 49 | 
            +
                none: false
         | 
| 50 | 
            +
                requirements:
         | 
| 51 | 
            +
                - - ! '>='
         | 
| 52 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 65 53 | 
             
                    version: 0.8.7
         | 
| 66 54 | 
             
              type: :runtime
         | 
| 67 | 
            -
              version_requirements: *id003
         | 
| 68 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 69 | 
            -
              name: newgem
         | 
| 70 55 | 
             
              prerelease: false
         | 
| 71 | 
            -
               | 
| 56 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 72 57 | 
             
                none: false
         | 
| 73 | 
            -
                requirements: | 
| 74 | 
            -
                - -  | 
| 75 | 
            -
                  - !ruby/object:Gem::Version | 
| 76 | 
            -
                     | 
| 77 | 
            -
             | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ! '>='
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: 0.8.7
         | 
| 62 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 63 | 
            +
              name: newgem
         | 
| 64 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                none: false
         | 
| 66 | 
            +
                requirements:
         | 
| 67 | 
            +
                - - ! '>='
         | 
| 68 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 81 69 | 
             
                    version: 1.5.3
         | 
| 82 70 | 
             
              type: :development
         | 
| 83 | 
            -
              version_requirements: *id004
         | 
| 84 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 85 | 
            -
              name: hoe
         | 
| 86 71 | 
             
              prerelease: false
         | 
| 87 | 
            -
               | 
| 72 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 88 73 | 
             
                none: false
         | 
| 89 | 
            -
                requirements: | 
| 74 | 
            +
                requirements:
         | 
| 75 | 
            +
                - - ! '>='
         | 
| 76 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 77 | 
            +
                    version: 1.5.3
         | 
| 78 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 79 | 
            +
              name: hoe
         | 
| 80 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 81 | 
            +
                none: false
         | 
| 82 | 
            +
                requirements:
         | 
| 90 83 | 
             
                - - ~>
         | 
| 91 | 
            -
                  - !ruby/object:Gem::Version | 
| 92 | 
            -
                     | 
| 93 | 
            -
                    segments: 
         | 
| 94 | 
            -
                    - 2
         | 
| 95 | 
            -
                    - 9
         | 
| 96 | 
            -
                    version: "2.9"
         | 
| 84 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 85 | 
            +
                    version: '3.1'
         | 
| 97 86 | 
             
              type: :development
         | 
| 98 | 
            -
               | 
| 99 | 
            -
             | 
| 100 | 
            -
             | 
| 87 | 
            +
              prerelease: false
         | 
| 88 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 89 | 
            +
                none: false
         | 
| 90 | 
            +
                requirements:
         | 
| 91 | 
            +
                - - ~>
         | 
| 92 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 93 | 
            +
                    version: '3.1'
         | 
| 94 | 
            +
            description: ! '
         | 
| 95 | 
            +
             | 
| 101 96 | 
             
              ActiveFacts provides a semantic modeling language, the Constellation
         | 
| 97 | 
            +
             | 
| 102 98 | 
             
              Query Language (CQL).  CQL combines natural language verbalisation and
         | 
| 99 | 
            +
             | 
| 103 100 | 
             
              formal logic, producing a formal language that reads like plain
         | 
| 101 | 
            +
             | 
| 104 102 | 
             
              English. ActiveFacts converts semantic models from CQL to relational
         | 
| 103 | 
            +
             | 
| 105 104 | 
             
              and object models in SQL, Ruby and other languages.
         | 
| 106 105 |  | 
| 107 | 
            -
             | 
| 106 | 
            +
            '
         | 
| 107 | 
            +
            email:
         | 
| 108 108 | 
             
            - cjh@dataconstellation.org
         | 
| 109 | 
            -
            executables: | 
| 109 | 
            +
            executables:
         | 
| 110 110 | 
             
            - afgen
         | 
| 111 111 | 
             
            - cql
         | 
| 112 | 
            -
            extensions: | 
| 112 | 
            +
            extensions:
         | 
| 113 113 | 
             
            - lib/activefacts/cql/Rakefile
         | 
| 114 | 
            -
            extra_rdoc_files: | 
| 114 | 
            +
            extra_rdoc_files:
         | 
| 115 115 | 
             
            - History.txt
         | 
| 116 116 | 
             
            - Manifest.txt
         | 
| 117 | 
            -
             | 
| 117 | 
            +
            - README.rdoc
         | 
| 118 | 
            +
            files:
         | 
| 118 119 | 
             
            - History.txt
         | 
| 119 120 | 
             
            - LICENSE
         | 
| 120 121 | 
             
            - Manifest.txt
         | 
| @@ -259,40 +260,32 @@ files: | |
| 259 260 | 
             
            - .gemtest
         | 
| 260 261 | 
             
            homepage: http://dataconstellation.com/ActiveFacts/
         | 
| 261 262 | 
             
            licenses: []
         | 
| 262 | 
            -
             | 
| 263 263 | 
             
            post_install_message: For more information on ActiveFacts, see http://dataconstellation.com/ActiveFacts
         | 
| 264 | 
            -
            rdoc_options: | 
| 264 | 
            +
            rdoc_options:
         | 
| 265 265 | 
             
            - -S
         | 
| 266 266 | 
             
            - -x
         | 
| 267 267 | 
             
            - lib/activefacts/cql/.*.rb
         | 
| 268 268 | 
             
            - -x
         | 
| 269 269 | 
             
            - lib/activefacts/vocabulary/.*.rb
         | 
| 270 | 
            -
            require_paths: | 
| 270 | 
            +
            require_paths:
         | 
| 271 271 | 
             
            - lib
         | 
| 272 | 
            -
            required_ruby_version: !ruby/object:Gem::Requirement | 
| 272 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 273 273 | 
             
              none: false
         | 
| 274 | 
            -
              requirements: | 
| 275 | 
            -
              - -  | 
| 276 | 
            -
                - !ruby/object:Gem::Version | 
| 277 | 
            -
                   | 
| 278 | 
            -
             | 
| 279 | 
            -
                  - 0
         | 
| 280 | 
            -
                  version: "0"
         | 
| 281 | 
            -
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 274 | 
            +
              requirements:
         | 
| 275 | 
            +
              - - ! '>='
         | 
| 276 | 
            +
                - !ruby/object:Gem::Version
         | 
| 277 | 
            +
                  version: '0'
         | 
| 278 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 282 279 | 
             
              none: false
         | 
| 283 | 
            -
              requirements: | 
| 284 | 
            -
              - -  | 
| 285 | 
            -
                - !ruby/object:Gem::Version | 
| 286 | 
            -
                   | 
| 287 | 
            -
                  segments: 
         | 
| 288 | 
            -
                  - 0
         | 
| 289 | 
            -
                  version: "0"
         | 
| 280 | 
            +
              requirements:
         | 
| 281 | 
            +
              - - ! '>='
         | 
| 282 | 
            +
                - !ruby/object:Gem::Version
         | 
| 283 | 
            +
                  version: '0'
         | 
| 290 284 | 
             
            requirements: []
         | 
| 291 | 
            -
             | 
| 292 285 | 
             
            rubyforge_project: cjheath@rubyforge.org
         | 
| 293 | 
            -
            rubygems_version: 1.8. | 
| 286 | 
            +
            rubygems_version: 1.8.24
         | 
| 294 287 | 
             
            signing_key: 
         | 
| 295 288 | 
             
            specification_version: 3
         | 
| 296 | 
            -
            summary: A semantic modeling and query language (CQL) and application runtime (the | 
| 289 | 
            +
            summary: A semantic modeling and query language (CQL) and application runtime (the
         | 
| 290 | 
            +
              Constellation API)
         | 
| 297 291 | 
             
            test_files: []
         | 
| 298 | 
            -
             |