activefacts-generators 1.8.1 → 1.8.2

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: 1b8cf08b3a5a39113eb4e04697ee25b4f4abdb4f
4
- data.tar.gz: aeed8fc142836d0d79321eff69c97b38d016dc45
3
+ metadata.gz: fae26b2c7cc83608173f074aaed203e14715b5a5
4
+ data.tar.gz: c4d0e31dc92866f042a82baebe67c0369414cb2d
5
5
  SHA512:
6
- metadata.gz: 13ce57f363db35fce13e217a916d17661fcfcd6349c0345d1873d0832a45fff625a5f656eb36cd8e758fb53d93df025234feade6defd6839ce50a9d2c9069f4f
7
- data.tar.gz: b3a5c20cb3b066cb77774d88e1b55d3c95053672c079decf4f7f00b79a05e5da89a0c62d46a25a0b6f2ed13c58fe2a9aa1cabcfa0c178702f220db89a59f1e15
6
+ metadata.gz: d2f8719f99dcb8f5b4425d46e558e9862ba0a0dc51c16ab58a67c78ba4faa0add7fc2ced31fc5a58188bc568a7b76fdfecb23892fda04261591a8c8806bc68f4
7
+ data.tar.gz: 930d7bc060c4d53c4913dec4510b4609dd1177cc13a005e1e13993527ee083a79e32e3f600b60b25c8381c17df72f3d016d713aacc732b40a57163151d9cd406
data/Gemfile CHANGED
@@ -2,9 +2,10 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- if ENV['PWD'] =~ %r{\A#{ENV['HOME']}/work}
6
- $stderr.puts "Using work area gems for #{File.basename(File.dirname(__FILE__))} from activefacts-generators"
7
- gem 'activefacts-api', path: '/Users/cjh/work/activefacts/api'
8
- gem 'activefacts-metamodel', path: '/Users/cjh/work/activefacts/metamodel'
9
- # gem 'activefacts-metamodel', git: 'git://github.com/cjheath/activefacts-metamodel.git'
5
+ this_file = File.absolute_path(__FILE__)
6
+ if this_file =~ %r{\A#{ENV['HOME']}}i
7
+ dir = File.dirname(File.dirname(this_file))
8
+ $stderr.puts "Using work area gems in #{dir} from activefacts-generators"
9
+ gem 'activefacts-api', path: dir+'/api'
10
+ gem 'activefacts-metamodel', path: dir+'/metamodel'
10
11
  end
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "activefacts-generators"
7
- spec.version = "1.8.1"
7
+ spec.version = "1.8.2"
8
8
  spec.authors = ["Clifford Heath"]
9
9
  spec.email = ["clifford.heath@gmail.com"]
10
10
 
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.add_development_dependency "rake", "~> 10.0"
21
21
  spec.add_development_dependency "rspec", "~> 3.3"
22
22
 
23
- spec.add_runtime_dependency "activefacts-metamodel", ">= 1.8", "~> 1"
24
- spec.add_runtime_dependency "activefacts-rmap", ">= 1.8", "~> 1"
25
- spec.add_runtime_dependency "activesupport", ">= 4.2", "~> 4.2.4"
23
+ spec.add_runtime_dependency "activefacts-metamodel", "~> 1", ">= 1.8"
24
+ spec.add_runtime_dependency "activefacts-rmap", "~> 1", ">= 1.8"
25
+ spec.add_runtime_dependency "activesupport", "~> 4.2", "~> 4.2.4"
26
26
  end
@@ -0,0 +1,124 @@
1
+ a:link, a:visited {
2
+ color: #8A0092; text-decoration: underline;
3
+ }
4
+
5
+ ul {
6
+ margin: 0px 0px 0px 2em;
7
+ -webkit-margin-before: 0px;
8
+ -webkit-margin-after: 0px;
9
+ -webkit-padding-start: 0px;
10
+ padding: 0px;
11
+ }
12
+
13
+ pre.slide {
14
+ background-color: #000;
15
+ padding: 5px;
16
+ display: table-cell;
17
+ border-style: dashed;
18
+ border-width: 2px;
19
+ border-color: #BBB;
20
+ }
21
+
22
+ span {
23
+ font-family: "Frutiger", sans-serif;
24
+ }
25
+
26
+ .keyword {
27
+ color: #0000CC;
28
+ }
29
+ .term, .concept {
30
+ /* Xcolor: #6A0072; The color used by NORMA */
31
+ color: #8A0092;
32
+ }
33
+ .vocabulary, .object_type {
34
+ /* Xcolor: #6A0072; The color used by NORMA */
35
+ color: #8A0092;
36
+ }
37
+ .linking, .copula {
38
+ color: #0E5400;
39
+ }
40
+ .literal, .value {
41
+ color: #FF990E;
42
+ }
43
+
44
+ dd {
45
+ margin-bottom: 0.5em;
46
+ margin-left: 60px;
47
+ text-indent: -20px;
48
+ }
49
+
50
+ dd ul {
51
+ margin-left: -80px;
52
+ text-indent: 80px;
53
+ }
54
+
55
+
56
+ .glossary-sidebar {
57
+ position: absolute;
58
+ top: 0px;
59
+ bottom: 0px;
60
+ right: 0px;
61
+ width: 240px;
62
+ display: block;
63
+ margin: 0;
64
+ padding: 0 16px;
65
+ border-right: solid #DDD 3px;
66
+ background: #EEE;
67
+ }
68
+
69
+ .glossary-toc {
70
+ position: absolute;
71
+ top: 0px;
72
+ bottom: 24px;
73
+ overflow: auto;
74
+ margin: 0;
75
+ padding: 0 0;
76
+ list-style: none;
77
+ font-family: Menlo, Consolas, Monaco, "Lucida Console", monospace;
78
+ }
79
+
80
+ .glossary-controls {
81
+ position: absolute; bottom: 0px;
82
+ }
83
+
84
+ .glossary-doc {
85
+ position: absolute;
86
+ display: block;
87
+ background: #FFF;
88
+ border-right: solid #EEE 3px;
89
+ font: 300 16px/1.4 "Myriad Pro", "Helvetica Neue", Helvetica, "Arial Unicode MS", Arial, sans-serif;
90
+ overflow: auto;
91
+ padding: 0 0 0 30px;
92
+ top: 0px;
93
+ bottom: 0px;
94
+ left: 0px;
95
+ right: 270px;
96
+ }
97
+
98
+ .glossary-toc li {
99
+ margin-left: 20px;
100
+ text-indent: -20px;
101
+ }
102
+
103
+ .glossary-doc dl {
104
+ margin-bottom: 1600px;
105
+ }
106
+
107
+ .glossary-doc dd {
108
+ margin-bottom: 30px;
109
+ }
110
+
111
+ .glossary-constraint {
112
+ background: #EDC;
113
+ }
114
+
115
+ .value {
116
+ display: inline;
117
+ }
118
+
119
+ .keyword,
120
+ .glossary-facttype,
121
+ .glossary-reading {
122
+ display: inline;
123
+ XXbackground: #E8E8E8;
124
+ }
@@ -293,8 +293,9 @@ module ActiveFacts
293
293
 
294
294
  # Alternate identification of objectified fact type?
295
295
  primary_supertype = supertypes[0]
296
- pi = fact_type.entity_type.preferred_identifier
297
- if pi && primary_supertype && primary_supertype.preferred_identifier != pi
296
+ if fact_type.all_role.size > 1 and
297
+ pi = fact_type.entity_type.preferred_identifier and
298
+ primary_supertype && primary_supertype.preferred_identifier != pi
298
299
  puts identified_by(o, pi) + ';'
299
300
  return
300
301
  end
@@ -46,6 +46,7 @@ module ActiveFacts
46
46
  if o.is_a?(ActiveFacts::Metamodel::EntityType) and
47
47
  p = o.preferred_identifier and
48
48
  (rrs = p.role_sequence.all_role_ref).size == 1 and
49
+ !(o.fact_type && o.fact_type.all_role.size == 1) and
49
50
  (r = rrs.single.role).fact_type != o.fact_type and
50
51
  r.object_type.is_a?(ActiveFacts::Metamodel::ValueType) and
51
52
  !r.fact_type.is_a?(ActiveFacts::Metamodel::TypeInheritance)
@@ -210,7 +210,9 @@ module ActiveFacts
210
210
  # Here, we must find the role_ref containing the adjectives that we need for each identifier,
211
211
  # which will be attached to the uniqueness constraint on this object in the binary FT that
212
212
  # attaches that identifying role.
213
- identifying_role_refs = pi.role_sequence.all_role_ref.sort_by{|role_ref| role_ref.ordinal}
213
+ identifying_role_refs =
214
+ (o.fact_type && o.fact_type.all_role.size == 1 ? o.fact_type.preferred_reading : pi).
215
+ role_sequence.all_role_ref_in_order
214
216
 
215
217
  # We need to get the adjectives for the roles from the identifying fact's preferred readings:
216
218
  identifying_facts = ([o.fact_type]+identifying_role_refs.map{|rr| rr.role.fact_type }).compact.uniq
@@ -336,6 +338,7 @@ module ActiveFacts
336
338
  return if skip_fact_type(fact_type)
337
339
 
338
340
  if (et = fact_type.entity_type) &&
341
+ fact_type.all_role.size > 1 &&
339
342
  (pi = et.preferred_identifier) &&
340
343
  pi.role_sequence.all_role_ref.detect{|rr| rr.role.fact_type != fact_type }
341
344
  # trace "Dumping objectified FT #{et.name} as an entity, non-fact PI"
@@ -0,0 +1,132 @@
1
+ require 'activefacts/metamodel'
2
+ require 'activefacts/rmap'
3
+ require 'active_support'
4
+ require 'digest/sha1'
5
+
6
+ module ActiveFacts
7
+ module RMap
8
+ def self.rails_name_trunc name
9
+ if name.length > 63
10
+ hash = Digest::SHA1.hexdigest name
11
+ name = name[0, 53] + '__' + hash[0, 8]
12
+ end
13
+ name
14
+ end
15
+
16
+ def self.rails_plural_name name
17
+ # Crunch spaces and pluralise the first part, all in snake_case
18
+ name.pop if name.is_a?(Array) and name.last == []
19
+ name = name[0]*'_' if name.is_a?(Array) and name.size == 1
20
+ if name.is_a?(Array)
21
+ name = ActiveSupport::Inflector.tableize((name[0]*'_').gsub(/\s+/, '_')) +
22
+ '_' +
23
+ ActiveSupport::Inflector.underscore((name[1..-1].flatten*'_').gsub(/\s+/, '_'))
24
+ else
25
+ ActiveSupport::Inflector.tableize(name.gsub(/\s+/, '_'))
26
+ end
27
+ end
28
+
29
+ def self.rails_singular_name name
30
+ # Crunch spaces and convert to snake_case
31
+ name = name.flatten*'_' if name.is_a?(Array)
32
+ ActiveSupport::Inflector.underscore(name.gsub(/\s+/, '_'))
33
+ end
34
+
35
+ class Column
36
+ def rails_name
37
+ RMap::rails_singular_name(name('_'))
38
+ end
39
+
40
+ def rails_type
41
+ type_name, params, constraints = *type()
42
+ rails_type = case type_name
43
+ when /^Auto ?Counter$/i
44
+ 'serial' # REVISIT: Need to detect surrogate ID fields and handle them correctly
45
+
46
+ when /^[Ug]uid$/i
47
+ 'uuid'
48
+
49
+ when /^Unsigned ?Integer$/i,
50
+ /^Integer$/i,
51
+ /^Signed ?Integer$/i,
52
+ /^Unsigned ?Small ?Integer$/i,
53
+ /^Signed ?Small ?Integer$/i,
54
+ /^Unsigned ?Tiny ?Integer$/i
55
+ length = nil
56
+ 'integer'
57
+
58
+ when /^Decimal$/i
59
+ 'decimal'
60
+
61
+ when /^Float$/i, /^Double$/i, /^Real$/i
62
+ 'float'
63
+
64
+ when /^Fixed ?Length ?Text$/i, /^Char$/i
65
+ 'string'
66
+ when /^Variable ?Length ?Text$/i, /^String$/i
67
+ 'string'
68
+ when /^Large ?Length ?Text$/i, /^Text$/i
69
+ 'text'
70
+
71
+ when /^Date ?And ?Time$/i, /^Date ?Time$/i
72
+ 'datetime'
73
+ when /^Date$/i
74
+ 'datetime'
75
+ when /^Time$/i
76
+ 'time'
77
+ when /^Auto ?Time ?Stamp$/i
78
+ 'timestamp'
79
+
80
+ when /^Money$/i
81
+ 'decimal'
82
+ when /^Picture ?Raw ?Data$/i, /^Image$/i, /^Variable ?Length ?Raw ?Data$/i, /^Blob$/i
83
+ 'binary'
84
+ when /^BIT$/i, /^Boolean$/i
85
+ 'boolean'
86
+ else
87
+ type_name # raise "ActiveRecord type unknown for standard type #{type}"
88
+ end
89
+ [rails_type, params[:length]]
90
+ end
91
+ end
92
+
93
+ class Index
94
+ def rails_name
95
+ column_names = columns.map{|c| c.rails_name }
96
+ index_name = "index_#{on.rails_name+'_on_'+column_names*'_'}"
97
+ RMap.rails_name_trunc index_name
98
+ end
99
+ end
100
+
101
+ class ForeignKey
102
+ def rails_from_association_name
103
+ RMap::rails_singular_name(to_name.join('_'))
104
+ end
105
+
106
+ def rails_to_association
107
+ jump = jump_reference
108
+ if jump.is_one_to_one
109
+ [ "has_one", RMap::rails_singular_name(from_name)]
110
+ else
111
+ [ "has_many", RMap::rails_plural_name(from_name)]
112
+ end
113
+ end
114
+ end
115
+ end
116
+
117
+ module Metamodel
118
+ class ObjectType
119
+ def rails_name
120
+ RMap::rails_plural_name(name)
121
+ end
122
+
123
+ def rails_singular_name
124
+ RMap::rails_singular_name(name)
125
+ end
126
+
127
+ def rails_class_name
128
+ ActiveSupport::Inflector.camelize(name.gsub(/\s+/, '_'))
129
+ end
130
+ end
131
+ end
132
+ end
@@ -222,7 +222,7 @@ module ActiveFacts
222
222
  table_role = ref.fact_type.all_role.detect{|r| r.object_type == table}
223
223
  if table_role
224
224
  remote_table = ref.to
225
- while remote_table.absorbed_via
225
+ while remote_table && remote_table.absorbed_via
226
226
  absorbed_into = remote_table.absorbed_via.from
227
227
  remote_table = absorbed_into
228
228
  end
@@ -15,7 +15,7 @@ module ActiveFacts
15
15
  def add_surrogate type_name = 'Auto Counter', suffix = 'ID'
16
16
  # Find or assert the surrogate value type
17
17
  auto_counter = vocabulary.valid_value_type_name(type_name) ||
18
- constellation.ValueType(:vocabulary => vocabulary, :name => type_name, :concept => :new)
18
+ constellation.ValueType(:vocabulary => vocabulary, :name => type_name, :concept => [:new, :implication_rule => 'Surrogate key transform'])
19
19
 
20
20
  # Create a subtype to identify this entity type:
21
21
  vt_name = self.name + ' '+suffix
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activefacts-generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clifford Heath
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-04 00:00:00.000000000 Z
11
+ date: 2016-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -62,47 +62,47 @@ dependencies:
62
62
  name: activefacts-metamodel
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: '1.8'
68
65
  - - "~>"
69
66
  - !ruby/object:Gem::Version
70
67
  version: '1'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '1.8'
71
71
  type: :runtime
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: '1.8'
78
75
  - - "~>"
79
76
  - !ruby/object:Gem::Version
80
77
  version: '1'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '1.8'
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: activefacts-rmap
83
83
  requirement: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- version: '1.8'
88
85
  - - "~>"
89
86
  - !ruby/object:Gem::Version
90
87
  version: '1'
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '1.8'
91
91
  type: :runtime
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- version: '1.8'
98
95
  - - "~>"
99
96
  - !ruby/object:Gem::Version
100
97
  version: '1'
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '1.8'
101
101
  - !ruby/object:Gem::Dependency
102
102
  name: activesupport
103
103
  requirement: !ruby/object:Gem::Requirement
104
104
  requirements:
105
- - - ">="
105
+ - - "~>"
106
106
  - !ruby/object:Gem::Version
107
107
  version: '4.2'
108
108
  - - "~>"
@@ -112,7 +112,7 @@ dependencies:
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '4.2'
118
118
  - - "~>"
@@ -134,6 +134,7 @@ files:
134
134
  - README.md
135
135
  - Rakefile
136
136
  - activefacts-generators.gemspec
137
+ - css/orm2.css
137
138
  - lib/activefacts/dependency_analyser.rb
138
139
  - lib/activefacts/generators/absorption.rb
139
140
  - lib/activefacts/generators/composition.rb
@@ -158,6 +159,7 @@ files:
158
159
  - lib/activefacts/generators/traits/datavault.rb
159
160
  - lib/activefacts/generators/traits/oo.rb
160
161
  - lib/activefacts/generators/traits/ordered.rb
162
+ - lib/activefacts/generators/traits/rails.rb
161
163
  - lib/activefacts/generators/traits/ruby.rb
162
164
  - lib/activefacts/generators/traits/scala.rb
163
165
  - lib/activefacts/generators/transform/datavault.rb
@@ -183,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
185
  version: '0'
184
186
  requirements: []
185
187
  rubyforge_project:
186
- rubygems_version: 2.2.2
188
+ rubygems_version: 2.4.5
187
189
  signing_key:
188
190
  specification_version: 4
189
191
  summary: Code Generators for the ActiveFacts suite