activefacts-compositions 1.9.4 → 1.9.5

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: bad26d18580fa095acc7cbb4a2722694f0020c30
4
- data.tar.gz: 45c9fc0cf6516095c7794bd7fb291ce33c80b074
3
+ metadata.gz: 61900437c96a5fa32c68fdcc195c8a681ace3cd9
4
+ data.tar.gz: 9f4917265c5b36482552e74c554197e2fa390874
5
5
  SHA512:
6
- metadata.gz: 76fafc569a0516de38ddb19e604c243ec7b87318823fffac3bd3b8b84ec491e131d4429dae139944322a2882574e2c6d9693fad176fa9962dcf2f5495851f13b
7
- data.tar.gz: ca70f4978bffffea9737812c3199503a81242809f0f0a27674be0c769b96d82aef6937a7cbd0213ac50ac971684ee2ec476e9c6c517729de1d92a109b45bd782
6
+ metadata.gz: c052e52630a0a814533cab84d1880bf9518968be13dde299d167514496c411acc4a5708c4c9bd35f0f670c0e15f28a5973ee0fc8b8868921f6df4b146bf5b8e4
7
+ data.tar.gz: 7f475031a473c7f0ee566d33baaf49c9785cca3e4c2b142e16e0e176993ee387d64bf03e893debb3ee575e4f72afbd6aa652e059bdaec8fc644dea524cad71fe
@@ -23,9 +23,9 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
  spec.add_development_dependency "rspec", "~> 3.3"
25
25
 
26
- spec.add_runtime_dependency("activefacts-api", "~> 1", ">= 1.9.2")
27
- spec.add_runtime_dependency("activefacts-metamodel", "~> 1", ">= 1.9.1")
28
- spec.add_runtime_dependency "tracing", "~> 2", ">= 2.0.5"
26
+ spec.add_runtime_dependency("activefacts-api", "~> 1", ">= 1.9.4")
27
+ spec.add_runtime_dependency("activefacts-metamodel", "~> 1", ">= 1.9.5")
28
+ spec.add_runtime_dependency "tracing", "~> 2", ">= 2.0.6"
29
29
 
30
30
  spec.add_development_dependency "activefacts", "~> 1", ">= 1.8"
31
31
  spec.add_development_dependency "activefacts-cql", "~> 1", ">= 1.8"
@@ -20,6 +20,7 @@ while arg = ARGV.shift and arg =~ /^-/
20
20
  end
21
21
 
22
22
  validate = options.delete('validate')
23
+ show = options.delete('show')
23
24
 
24
25
  # Load the file type input method
25
26
  if arg
@@ -47,10 +48,46 @@ begin
47
48
 
48
49
  compositor = ActiveFacts::Compositions::Relational.new(vocabulary.constellation, "test", options)
49
50
  compositor.generate
50
- trace.enable 'composition_validator'
51
- compositor.validate do |component, problem|
52
- trace :composition_validator, "!!PROBLEM!! #{component.inspect}: #{problem}"
53
- end if validate
51
+
52
+ if validate
53
+ trace.enable 'composition_validator'
54
+ compositor.validate do |component, problem|
55
+ trace :composition_validator, "!!PROBLEM!! #{component.inspect}: #{problem}"
56
+ end
57
+ end
58
+
59
+ if show
60
+ compositor.
61
+ composition.
62
+ all_composite.
63
+ sort_by{|composite| composite.mapping.name}.
64
+ each do |composite|
65
+ puts composite.mapping.name
66
+ indices = composite.all_indices_by_rank
67
+
68
+ composite.mapping.leaves.each do |leaf|
69
+ # Build a symbolic representation of the index participation of this leaf
70
+ pos = 0
71
+ indexing = indices.inject([]) do |a, index|
72
+ pos += 1
73
+ if part = index.position_in_index(leaf)
74
+ a << "#{pos}.#{part}"
75
+ end
76
+ a
77
+ end
78
+
79
+ puts "\t#{leaf.path.map{|component|
80
+ if component.is_a?(ActiveFacts::Metamodel::Absorption) && component.foreign_key
81
+ "[#{component.name}]"
82
+ else
83
+ component.name
84
+ end +
85
+ (component.is_a?(ActiveFacts::Metamodel::Absorption) && !component.parent_role.is_mandatory ? '?' : '')
86
+ }*'->'}" +
87
+ (indexing.empty? ? '' : "[#{indexing*','}]") # Show the indexing
88
+ end
89
+ end
90
+ end
54
91
 
55
92
  rescue => e
56
93
  $stderr.puts "#{e.message}"
@@ -16,12 +16,13 @@ require "activefacts/metamodel"
16
16
  module ActiveFacts
17
17
  module Compositions
18
18
  class Compositor
19
- attr_reader :options, :name
19
+ attr_reader :options, :name, :composition
20
20
 
21
21
  def initialize constellation, name, options = {}
22
22
  @constellation = constellation
23
23
  @name = name
24
24
  @options = options
25
+ $stderr.puts "Unknown options: #{options.inspect}" unless options.empty?
25
26
  end
26
27
 
27
28
  # Generate all Mappings into @binary_mappings for a binary composition of all ObjectTypes in this constellation
@@ -16,6 +16,12 @@ module ActiveFacts
16
16
  private
17
17
  MM = ActiveFacts::Metamodel
18
18
  public
19
+ def initialize constellation, name, options = {}
20
+ # Extract recognised options so our superclass doesn't complain:
21
+ @option_surrogates = options.delete('surrogates')
22
+ super constellation, name, options
23
+ end
24
+
19
25
  def generate
20
26
  super
21
27
 
@@ -36,7 +42,7 @@ module ActiveFacts
36
42
  inject_value_fields
37
43
 
38
44
  # Inject surrogate keys if the options ask for that
39
- inject_surrogates if @options['surrogates']
45
+ inject_surrogates if @option_surrogates
40
46
 
41
47
  # Remove the un-used absorption paths
42
48
  delete_reverse_absorptions
@@ -264,7 +270,7 @@ module ActiveFacts
264
270
  end
265
271
 
266
272
  def inject_surrogates
267
- surrogate_type_name = [true, '', 'true', 'yes'].include?(t = @options['surrogates']) ? 'Auto Counter' : t
273
+ surrogate_type_name = [true, '', 'true', 'yes'].include?(t = @option_surrogates) ? 'Auto Counter' : t
268
274
  composites = @composition.all_composite.to_a
269
275
  return if composites.empty?
270
276
  vocabulary = composites[0].mapping.object_type.vocabulary # REVISIT: Crappy: choose the first (currently always single)
@@ -1,5 +1,5 @@
1
1
  module ActiveFacts
2
2
  module Compositions
3
- VERSION = "1.9.4"
3
+ VERSION = "1.9.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activefacts-compositions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.4
4
+ version: 1.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clifford Heath
@@ -67,7 +67,7 @@ dependencies:
67
67
  version: '1'
68
68
  - - ">="
69
69
  - !ruby/object:Gem::Version
70
- version: 1.9.2
70
+ version: 1.9.4
71
71
  type: :runtime
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
@@ -77,7 +77,7 @@ dependencies:
77
77
  version: '1'
78
78
  - - ">="
79
79
  - !ruby/object:Gem::Version
80
- version: 1.9.2
80
+ version: 1.9.4
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: activefacts-metamodel
83
83
  requirement: !ruby/object:Gem::Requirement
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '1'
88
88
  - - ">="
89
89
  - !ruby/object:Gem::Version
90
- version: 1.9.1
90
+ version: 1.9.5
91
91
  type: :runtime
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
@@ -97,7 +97,7 @@ dependencies:
97
97
  version: '1'
98
98
  - - ">="
99
99
  - !ruby/object:Gem::Version
100
- version: 1.9.1
100
+ version: 1.9.5
101
101
  - !ruby/object:Gem::Dependency
102
102
  name: tracing
103
103
  requirement: !ruby/object:Gem::Requirement
@@ -107,7 +107,7 @@ dependencies:
107
107
  version: '2'
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: 2.0.5
110
+ version: 2.0.6
111
111
  type: :runtime
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
@@ -117,7 +117,7 @@ dependencies:
117
117
  version: '2'
118
118
  - - ">="
119
119
  - !ruby/object:Gem::Version
120
- version: 2.0.5
120
+ version: 2.0.6
121
121
  - !ruby/object:Gem::Dependency
122
122
  name: activefacts
123
123
  requirement: !ruby/object:Gem::Requirement