activefacts-cql 1.7.1 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf73dfa6319dcc1633fd864489bad8b9a3a206b6
4
- data.tar.gz: 293bef927e2e02a2b136a8c23e5ade074a0efea8
3
+ metadata.gz: f4834d56fd4dadb1f4436611d0d1006b3b9874b6
4
+ data.tar.gz: bc07aa1726255dd1108232f1381e65a56c1dbd02
5
5
  SHA512:
6
- metadata.gz: a0f0136f2c2c8bd84ddc0e00ca76a8f3bb00e10056e4fae8fd576cc105e89de64ee08a37077307ec876ab96bd41076565a032c3f53d88939feb1c5516ac9ab55
7
- data.tar.gz: 8cac3ac7f967093b426cc026e9a09d691fdae0d262d80fbead60f1deda0e8ee944199f61a4b672ac7ecc09db113da2155504383852fed29c6c00f58d75f2700d
6
+ metadata.gz: 6f5a0682fd06cbcfa9cc6630e0e876ba842a795ce56c6c165664f8f4c57819f8353d45f9b9246909293a5612cc34726c7fafcaa176dcac38319f4587e196081f
7
+ data.tar.gz: 88e7e9f70551df5ed95f6b735f69f4a5bcb90a72a0b59052787ed446da102a953498ff2ab6a62455680c22f0e50802503d7f73114bcd5320a9290fd3de10a77b
data/.gitignore CHANGED
@@ -7,5 +7,10 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ lib/activefacts/cql/parser/[A-Z]*.rb
10
11
  *.swp
11
12
  clj
13
+ .DS_Store
14
+ *.rej
15
+ *.orig
16
+ *.diff
data/Gemfile CHANGED
@@ -1,9 +1,9 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in activefacts-cql.gemspec
4
3
  gemspec
5
4
 
6
- if ENV['PWD'] =~ %r{\A/Users/cjh/work/activefacts}
5
+ if ENV['PWD'] =~ %r{\A#{ENV['HOME']}/work}
6
+ $stderr.puts "Using work area gems for #{File.basename(File.dirname(__FILE__))} from activefacts-cql"
7
7
  gem 'activefacts-api', path: '/Users/cjh/work/activefacts/api'
8
8
  gem 'activefacts-metamodel', path: '/Users/cjh/work/activefacts/metamodel'
9
9
  # gem 'activefacts-metamodel', git: 'git://github.com/cjheath/activefacts-metamodel.git'
@@ -19,11 +19,11 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_development_dependency "bundler", "~> 1.10.a"
22
+ spec.add_development_dependency "bundler", ">= 1.10", "~> 1.10.6"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "rspec", "~> 3.3"
25
25
 
26
- spec.add_runtime_dependency(%q<activefacts-metamodel>, [">= 1.7.0", "~> 1.7"])
26
+ spec.add_runtime_dependency("activefacts-metamodel", ">= 1.8", "~> 1.8.0")
27
27
  spec.add_runtime_dependency(%q<treetop>, [">= 1.4.14", "~> 1.4"])
28
28
  end
29
29
 
@@ -223,7 +223,7 @@ module ActiveFacts
223
223
  end
224
224
 
225
225
  @fact_type = @entity_type.fact_type = fact_type
226
- @entity_type.create_implicit_fact_types # REVISIT: Could there be readings for the implicit fact types here?
226
+ @entity_type.create_link_fact_types # REVISIT: Could there be readings for the implicit fact types here?
227
227
  @fact_type
228
228
  end
229
229
 
@@ -238,58 +238,12 @@ module ActiveFacts
238
238
  # By default, the first supertype identifies this entity type
239
239
  is_identifying_supertype = !not_identifying && @entity_type.all_type_inheritance_as_subtype.size == 0
240
240
 
241
- inheritance_fact = @constellation.TypeInheritance(@entity_type, supertype, :concept => :new)
242
-
243
241
  assimilation_pragmas = ['absorbed', 'separate', 'partitioned']
244
242
  assimilations = @pragmas.select { |p| assimilation_pragmas.include? p}
245
243
  @pragmas -= assimilation_pragmas
246
244
  raise "Conflicting assimilation pragmas #{assimilations*', '}" if assimilations.size > 1
247
- inheritance_fact.assimilation = assimilations[0]
248
-
249
- # Create a reading:
250
- sub_role = @constellation.Role(inheritance_fact, 0, :object_type => @entity_type, :concept => :new)
251
- super_role = @constellation.Role(inheritance_fact, 1, :object_type => supertype, :concept => :new)
252
-
253
- rs = @constellation.RoleSequence(:new)
254
- @constellation.RoleRef(rs, 0, :role => sub_role)
255
- @constellation.RoleRef(rs, 1, :role => super_role)
256
- @constellation.Reading(inheritance_fact, 0, :role_sequence => rs, :text => "{0} is a kind of {1}", :is_negative => false)
257
-
258
- rs2 = @constellation.RoleSequence(:new)
259
- @constellation.RoleRef(rs2, 0, :role => super_role)
260
- @constellation.RoleRef(rs2, 1, :role => sub_role)
261
- # Decide in which order to include is a/is an. Provide both, but in order.
262
- n = 'aeioh'.include?(sub_role.object_type.name.downcase[0]) ? 'n' : ''
263
- @constellation.Reading(inheritance_fact, 2, :role_sequence => rs2, :text => "{0} is a#{n} {1}", :is_negative => false)
264
-
265
- if is_identifying_supertype
266
- inheritance_fact.provides_identification = true
267
- end
268
245
 
269
- # Create uniqueness constraints over the subtyping fact type.
270
- p1rs = @constellation.RoleSequence(:new)
271
- @constellation.RoleRef(p1rs, 0).role = sub_role
272
- pc1 = @constellation.PresenceConstraint(:new, :vocabulary => @vocabulary)
273
- pc1.name = "#{@entity_type.name}MustHaveSupertype#{supertype.name}"
274
- pc1.role_sequence = p1rs
275
- pc1.is_mandatory = true # A subtype instance must have a supertype instance
276
- pc1.min_frequency = 1
277
- pc1.max_frequency = 1
278
- pc1.is_preferred_identifier = false
279
- trace :constraint, "Made new subtype PC GUID=#{pc1.concept.guid} min=1 max=1 over #{p1rs.describe}"
280
-
281
- p2rs = @constellation.RoleSequence(:new)
282
- constellation.RoleRef(p2rs, 0).role = super_role
283
- pc2 = constellation.PresenceConstraint(:new, :vocabulary => @vocabulary)
284
- pc2.name = "#{supertype.name}MayBeA#{@entity_type.name}"
285
- pc2.role_sequence = p2rs
286
- pc2.is_mandatory = false
287
- pc2.min_frequency = 0
288
- pc2.max_frequency = 1
289
- # The supertype role often identifies the subtype:
290
- pc2.is_preferred_identifier = inheritance_fact.provides_identification
291
- trace :supertype, "identification of #{@entity_type.name} via supertype #{supertype.name} was #{inheritance_fact.provides_identification ? '' : 'not '}added"
292
- trace :constraint, "Made new supertype PC GUID=#{pc2.concept.guid} min=1 max=1 over #{p2rs.describe}"
246
+ @entity_type.add_supertype(supertype, is_identifying_supertype, assimilations[0])
293
247
  end
294
248
  end
295
249
 
@@ -105,7 +105,7 @@ module ActiveFacts
105
105
  # * Objectify the fact type if @name
106
106
  #
107
107
 
108
- # Prepare to objectify the fact type (so readings for implicit fact types can be created)
108
+ # Prepare to objectify the fact type (so readings for link fact types can be created)
109
109
  if @name
110
110
  entity_type = @vocabulary.valid_entity_type_name(@name)
111
111
  raise "You can't objectify #{@name}, it already exists" if entity_type
@@ -120,8 +120,8 @@ module ActiveFacts
120
120
  return true unless @clauses.size > 0 # Nothing interesting was said.
121
121
 
122
122
  if @entity_type
123
- # Extract readings for implicit fact types
124
- @implicit_readings, @clauses =
123
+ # Extract readings for link fact types
124
+ @link_fact_type_clauses, @clauses =
125
125
  @clauses.partition do |clause|
126
126
  clause.refs.size == 2 and clause.refs.detect{|ref| ref.player == @entity_type}
127
127
  end
@@ -137,7 +137,6 @@ module ActiveFacts
137
137
  @fact_type = first_clause.make_fact_type(@vocabulary)
138
138
  first_clause.make_reading(@vocabulary, @fact_type)
139
139
  first_clause.make_embedded_constraints vocabulary
140
- @fact_type.create_implicit_fact_type_for_unary if @fact_type.all_role.size == 1 && !@name
141
140
  @existing_clauses = [first_clause]
142
141
  elsif (n = @clauses.size - @existing_clauses.size) > 0
143
142
  raise "Cannot extend a negated fact type" if @existing_clauses.detect {|clause| clause.certainty == false }
@@ -164,8 +163,8 @@ module ActiveFacts
164
163
  if @fact_type.entity_type and @name != @fact_type.entity_type.name
165
164
  raise "Cannot objectify fact type as #{@name} and as #{@fact_type.entity_type.name}"
166
165
  end
167
- ifts = @entity_type.create_implicit_fact_types
168
- create_implicit_readings(ifts)
166
+ ifts = @entity_type.create_link_fact_types
167
+ create_link_fact_type_readings(ifts)
169
168
  if @pragmas
170
169
  @entity_type.is_independent = true if @pragmas.delete('independent')
171
170
  end
@@ -193,25 +192,24 @@ module ActiveFacts
193
192
  @fact_type
194
193
  end
195
194
 
196
- def create_implicit_readings(ifts)
197
- @implicit_readings.each do |clause|
195
+ def create_link_fact_type_readings(ifts)
196
+ @link_fact_type_clauses.each do |clause|
198
197
  #next false unless clause.refs.size == 2 and clause.refs.detect{|r| r.role.object_type == @entity_type }
199
198
  other_ref = clause.refs.detect{|ref| ref.player != @entity_type}
200
199
  ift = ifts.detect do |ift|
201
200
  other_ref.binding.refs.map{|r| r.role}.include?(ift.implying_role)
202
201
  end
203
- next unless ift
204
- # This clause is a reading for the implicit LinkFactType ift
202
+ unless ift
203
+ raise "Clause #{clause} in unmatched in definition of objectified fact type #{@name}"
204
+ next
205
+ end
206
+ # This clause is a reading for the LinkFactType ift
205
207
  i = 0
206
208
  reading_text = clause.phrases.map do |phrase|
207
209
  next phrase if String === phrase
208
210
  "{#{(i += 1)-1}}"
209
211
  end*' '
210
- ir = ActiveFacts::Metamodel::LinkFactType::ImplicitReading
211
- irrs = ir::ImplicitReadingRoleSequence
212
- irrf = irrs::ImplicitReadingRoleRef
213
- reading = ir.new(ift, reading_text)
214
- ift.add_reading reading
212
+ clause.make_reading(@vocabulary, ift)
215
213
  end
216
214
  end
217
215
 
@@ -720,7 +720,7 @@ module ActiveFacts
720
720
  if next_step.is_unary_step
721
721
  # Objectified unaries get emitted as unaries, not as objectifications:
722
722
  role = next_step.input_play.role
723
- role = role.fact_type.implying_role if role.fact_type.is_a?(LinkFactType)
723
+ role = role.fact_type.implying_role if role.fact_type.is_a?(ActiveFacts::Metamodel::LinkFactType)
724
724
  next_reading = role.fact_type.preferred_reading(next_step.is_disallowed) || role.fact_type.preferred_reading
725
725
  readings += " and " unless readings.empty?
726
726
  readings += "it is not the case that " if !next_step.is_disallowed != !next_reading.is_negative
@@ -1,5 +1,5 @@
1
1
  module ActiveFacts
2
2
  module CQL
3
- VERSION = "1.7.1"
3
+ VERSION = "1.8.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activefacts-cql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clifford Heath
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-08 00:00:00.000000000 Z
11
+ date: 2015-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
17
20
  - - "~>"
18
21
  - !ruby/object:Gem::Version
19
- version: 1.10.a
22
+ version: 1.10.6
20
23
  type: :development
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '1.10'
24
30
  - - "~>"
25
31
  - !ruby/object:Gem::Version
26
- version: 1.10.a
32
+ version: 1.10.6
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rake
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -42,36 +48,36 @@ dependencies:
42
48
  name: rspec
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - ">="
51
+ - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '0'
53
+ version: '3.3'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - ">="
58
+ - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: '0'
60
+ version: '3.3'
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: activefacts-metamodel
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - ">="
60
66
  - !ruby/object:Gem::Version
61
- version: 1.7.0
67
+ version: '1.8'
62
68
  - - "~>"
63
69
  - !ruby/object:Gem::Version
64
- version: '1.7'
70
+ version: 1.8.0
65
71
  type: :runtime
66
72
  prerelease: false
67
73
  version_requirements: !ruby/object:Gem::Requirement
68
74
  requirements:
69
75
  - - ">="
70
76
  - !ruby/object:Gem::Version
71
- version: 1.7.0
77
+ version: '1.8'
72
78
  - - "~>"
73
79
  - !ruby/object:Gem::Version
74
- version: '1.7'
80
+ version: 1.8.0
75
81
  - !ruby/object:Gem::Dependency
76
82
  name: treetop
77
83
  requirement: !ruby/object:Gem::Requirement