k_domain 0.0.5 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +11 -1
- data/Gemfile +10 -0
- data/Rakefile +3 -1
- data/STORIES.md +15 -0
- data/k_domain.gemspec +2 -0
- data/lib/k_domain/domain_model/load.rb +8 -2
- data/lib/k_domain/domain_model/transform.rb +30 -3
- data/lib/k_domain/domain_model/transform_steps/_.rb +2 -0
- data/lib/k_domain/domain_model/transform_steps/step.rb +38 -0
- data/lib/k_domain/domain_model/transform_steps/step1_attach_db_schema.rb +1 -1
- data/lib/k_domain/domain_model/transform_steps/step4_attach_erd_files.rb +5 -2
- data/lib/k_domain/domain_model/transform_steps/step5_attach_dictionary.rb +5 -2
- data/lib/k_domain/domain_model/transform_steps/step8_rails_resource_models.rb +44 -0
- data/lib/k_domain/domain_model/transform_steps/step9_rails_structure_models.rb +33 -0
- data/lib/k_domain/rails_code_extractor/extract_model.rb +21 -0
- data/lib/k_domain/rails_code_extractor/load_shim.rb +32 -0
- data/lib/k_domain/raw_db_schema/load.rb +8 -2
- data/lib/k_domain/raw_db_schema/transform.rb +4 -5
- data/lib/k_domain/schemas/_.rb +15 -0
- data/lib/k_domain/{raw_db_schema/dtos → schemas/database}/_.rb +0 -7
- data/lib/k_domain/{raw_db_schema/dtos → schemas/database}/foreign_key.rb +1 -1
- data/lib/k_domain/{raw_db_schema/dtos → schemas/database}/index.rb +1 -1
- data/lib/k_domain/schemas/database/schema.rb +31 -0
- data/lib/k_domain/schemas/database/table.rb +32 -0
- data/lib/k_domain/schemas/dictionary.rb +19 -0
- data/lib/k_domain/{domain_model/dtos → schemas/domain}/_.rb +1 -24
- data/lib/k_domain/{domain_model/dtos → schemas/domain}/domain.rb +1 -1
- data/lib/k_domain/schemas/domain/erd_file.rb +82 -0
- data/lib/k_domain/{domain_model/dtos → schemas/domain}/models/column.rb +0 -0
- data/lib/k_domain/{domain_model/dtos → schemas/domain}/models/model.rb +0 -0
- data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/belongs_to.rb +0 -0
- data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/column_old.rb +0 -0
- data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/domain_statistics.rb +0 -0
- data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/entity.rb +0 -0
- data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/entity_statistics.rb +0 -0
- data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/foreign_key.rb +0 -0
- data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/has_and_belongs_to_many.rb +0 -0
- data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/has_many.rb +0 -0
- data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/has_one.rb +0 -0
- data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/name_options.rb +0 -0
- data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/rails_controller.rb +0 -0
- data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/rails_model.rb +0 -0
- data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/related_entity.rb +0 -0
- data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/statistics.rb +0 -0
- data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/validate.rb +0 -0
- data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/validates.rb +0 -0
- data/lib/k_domain/schemas/domain_model.rb +14 -0
- data/lib/k_domain/schemas/investigate.rb +15 -0
- data/lib/k_domain/schemas/rails_resource.rb +16 -0
- data/lib/k_domain/version.rb +1 -1
- data/lib/k_domain.rb +14 -2
- data/templates/active_record_shims.rb +355 -0
- data/templates/fake_module_shims.rb +42 -0
- data/{lib/k_domain/raw_db_schema/template.rb → templates/load_schema.rb} +4 -4
- metadata +54 -35
- data/lib/k_domain/domain_model/dtos/dictionary/dictionary.rb +0 -17
- data/lib/k_domain/domain_model/dtos/investigate/investigate.rb +0 -10
- data/lib/k_domain/domain_model/dtos/investigate/issue.rb +0 -13
- data/lib/k_domain/domain_model/dtos/schema.rb +0 -12
- data/lib/k_domain/raw_db_schema/dtos/column.rb +0 -16
- data/lib/k_domain/raw_db_schema/dtos/database.rb +0 -11
- data/lib/k_domain/raw_db_schema/dtos/schema.rb +0 -18
- data/lib/k_domain/raw_db_schema/dtos/table.rb +0 -21
- data/lib/k_domain/raw_db_schema/dtos/unique_key.rb +0 -14
@@ -11,7 +11,7 @@ class LoadSchema
|
|
11
11
|
indexes: [],
|
12
12
|
meta: {
|
13
13
|
rails: @rails_version,
|
14
|
-
|
14
|
+
db_info: {
|
15
15
|
type: 'postgres',
|
16
16
|
version: nil, # TODO
|
17
17
|
extensions: []
|
@@ -50,14 +50,14 @@ class LoadSchema
|
|
50
50
|
sort
|
51
51
|
# code to time
|
52
52
|
|
53
|
-
# log.kv 'extensions', schema[:
|
53
|
+
# log.kv 'extensions', schema[:db_info][:extensions].length
|
54
54
|
# log.kv 'tables', schema[:tables].length
|
55
55
|
# log.kv 'indexes', schema[:indexes].length
|
56
56
|
# # a low foreign_keys count is indicative of not using SQL referential integrity
|
57
57
|
# log.kv 'foreign_keys', schema[:foreign_keys].length
|
58
58
|
# log.kv 'Time Taken', (finish - start)
|
59
59
|
|
60
|
-
# puts schema[:
|
60
|
+
# puts schema[:db_info][:extensions]
|
61
61
|
# print_unique_keys(type: :foreign_keys, title: 'unique options for foreign_keys')
|
62
62
|
# print_unique_keys(type: :columns, title: 'unique options for columns')
|
63
63
|
# print_unique_keys(type: :fields, category: :integer , title: 'unique options for column - integer')
|
@@ -74,7 +74,7 @@ class LoadSchema
|
|
74
74
|
|
75
75
|
def enable_extension(name)
|
76
76
|
# puts "enable_extension(#{name})"
|
77
|
-
schema[:meta][:
|
77
|
+
schema[:meta][:db_info][:extensions] << name
|
78
78
|
end
|
79
79
|
|
80
80
|
def create_table(name, **opts)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: k_domain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: peeky
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.0.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.0.0
|
55
69
|
description: " K Domain builds complex domain schemas by combining the database
|
56
70
|
schema with a rich entity relationship DSLs\n"
|
57
71
|
email:
|
@@ -81,30 +95,6 @@ files:
|
|
81
95
|
- hooks/update-version
|
82
96
|
- k_domain.gemspec
|
83
97
|
- lib/k_domain.rb
|
84
|
-
- lib/k_domain/domain_model/dtos/_.rb
|
85
|
-
- lib/k_domain/domain_model/dtos/belongs_to.rb
|
86
|
-
- lib/k_domain/domain_model/dtos/column_old.rb
|
87
|
-
- lib/k_domain/domain_model/dtos/dictionary/dictionary.rb
|
88
|
-
- lib/k_domain/domain_model/dtos/domain.rb
|
89
|
-
- lib/k_domain/domain_model/dtos/domain_statistics.rb
|
90
|
-
- lib/k_domain/domain_model/dtos/entity.rb
|
91
|
-
- lib/k_domain/domain_model/dtos/entity_statistics.rb
|
92
|
-
- lib/k_domain/domain_model/dtos/foreign_key.rb
|
93
|
-
- lib/k_domain/domain_model/dtos/has_and_belongs_to_many.rb
|
94
|
-
- lib/k_domain/domain_model/dtos/has_many.rb
|
95
|
-
- lib/k_domain/domain_model/dtos/has_one.rb
|
96
|
-
- lib/k_domain/domain_model/dtos/investigate/investigate.rb
|
97
|
-
- lib/k_domain/domain_model/dtos/investigate/issue.rb
|
98
|
-
- lib/k_domain/domain_model/dtos/models/column.rb
|
99
|
-
- lib/k_domain/domain_model/dtos/models/model.rb
|
100
|
-
- lib/k_domain/domain_model/dtos/name_options.rb
|
101
|
-
- lib/k_domain/domain_model/dtos/rails_controller.rb
|
102
|
-
- lib/k_domain/domain_model/dtos/rails_model.rb
|
103
|
-
- lib/k_domain/domain_model/dtos/related_entity.rb
|
104
|
-
- lib/k_domain/domain_model/dtos/schema.rb
|
105
|
-
- lib/k_domain/domain_model/dtos/statistics.rb
|
106
|
-
- lib/k_domain/domain_model/dtos/validate.rb
|
107
|
-
- lib/k_domain/domain_model/dtos/validates.rb
|
108
98
|
- lib/k_domain/domain_model/load.rb
|
109
99
|
- lib/k_domain/domain_model/transform.rb
|
110
100
|
- lib/k_domain/domain_model/transform_steps/_.rb
|
@@ -114,18 +104,47 @@ files:
|
|
114
104
|
- lib/k_domain/domain_model/transform_steps/step3_attach_columns.rb
|
115
105
|
- lib/k_domain/domain_model/transform_steps/step4_attach_erd_files.rb
|
116
106
|
- lib/k_domain/domain_model/transform_steps/step5_attach_dictionary.rb
|
117
|
-
- lib/k_domain/
|
118
|
-
- lib/k_domain/
|
119
|
-
- lib/k_domain/
|
120
|
-
- lib/k_domain/
|
121
|
-
- lib/k_domain/raw_db_schema/dtos/index.rb
|
122
|
-
- lib/k_domain/raw_db_schema/dtos/schema.rb
|
123
|
-
- lib/k_domain/raw_db_schema/dtos/table.rb
|
124
|
-
- lib/k_domain/raw_db_schema/dtos/unique_key.rb
|
107
|
+
- lib/k_domain/domain_model/transform_steps/step8_rails_resource_models.rb
|
108
|
+
- lib/k_domain/domain_model/transform_steps/step9_rails_structure_models.rb
|
109
|
+
- lib/k_domain/rails_code_extractor/extract_model.rb
|
110
|
+
- lib/k_domain/rails_code_extractor/load_shim.rb
|
125
111
|
- lib/k_domain/raw_db_schema/load.rb
|
126
|
-
- lib/k_domain/raw_db_schema/template.rb
|
127
112
|
- lib/k_domain/raw_db_schema/transform.rb
|
113
|
+
- lib/k_domain/schemas/_.rb
|
114
|
+
- lib/k_domain/schemas/database/_.rb
|
115
|
+
- lib/k_domain/schemas/database/foreign_key.rb
|
116
|
+
- lib/k_domain/schemas/database/index.rb
|
117
|
+
- lib/k_domain/schemas/database/schema.rb
|
118
|
+
- lib/k_domain/schemas/database/table.rb
|
119
|
+
- lib/k_domain/schemas/dictionary.rb
|
120
|
+
- lib/k_domain/schemas/domain/_.rb
|
121
|
+
- lib/k_domain/schemas/domain/domain.rb
|
122
|
+
- lib/k_domain/schemas/domain/erd_file.rb
|
123
|
+
- lib/k_domain/schemas/domain/models/column.rb
|
124
|
+
- lib/k_domain/schemas/domain/models/model.rb
|
125
|
+
- lib/k_domain/schemas/domain/old/belongs_to.rb
|
126
|
+
- lib/k_domain/schemas/domain/old/column_old.rb
|
127
|
+
- lib/k_domain/schemas/domain/old/domain_statistics.rb
|
128
|
+
- lib/k_domain/schemas/domain/old/entity.rb
|
129
|
+
- lib/k_domain/schemas/domain/old/entity_statistics.rb
|
130
|
+
- lib/k_domain/schemas/domain/old/foreign_key.rb
|
131
|
+
- lib/k_domain/schemas/domain/old/has_and_belongs_to_many.rb
|
132
|
+
- lib/k_domain/schemas/domain/old/has_many.rb
|
133
|
+
- lib/k_domain/schemas/domain/old/has_one.rb
|
134
|
+
- lib/k_domain/schemas/domain/old/name_options.rb
|
135
|
+
- lib/k_domain/schemas/domain/old/rails_controller.rb
|
136
|
+
- lib/k_domain/schemas/domain/old/rails_model.rb
|
137
|
+
- lib/k_domain/schemas/domain/old/related_entity.rb
|
138
|
+
- lib/k_domain/schemas/domain/old/statistics.rb
|
139
|
+
- lib/k_domain/schemas/domain/old/validate.rb
|
140
|
+
- lib/k_domain/schemas/domain/old/validates.rb
|
141
|
+
- lib/k_domain/schemas/domain_model.rb
|
142
|
+
- lib/k_domain/schemas/investigate.rb
|
143
|
+
- lib/k_domain/schemas/rails_resource.rb
|
128
144
|
- lib/k_domain/version.rb
|
145
|
+
- templates/active_record_shims.rb
|
146
|
+
- templates/fake_module_shims.rb
|
147
|
+
- templates/load_schema.rb
|
129
148
|
homepage: http://appydave.com/gems/k-domain
|
130
149
|
licenses:
|
131
150
|
- MIT
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Domain class holds a dictionary entry
|
4
|
-
module KDomain
|
5
|
-
module DomainModel
|
6
|
-
class Dictionary < Dry::Struct
|
7
|
-
attribute :name , Types::Strict::String
|
8
|
-
attribute :type , Types::Strict::String
|
9
|
-
attribute :label , Types::Strict::String
|
10
|
-
attribute :segment , Types::Strict::String
|
11
|
-
attribute :models , Types::Strict::Array
|
12
|
-
attribute :model_count , Types::Strict::Integer
|
13
|
-
attribute :types , Types::Strict::Array
|
14
|
-
attribute :type_count , Types::Strict::Integer
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Domain class holds an investigation entry
|
4
|
-
module KDomain
|
5
|
-
module DomainModel
|
6
|
-
class Issue < Dry::Struct
|
7
|
-
attribute :step , Types::Strict::String
|
8
|
-
attribute :location , Types::Strict::String
|
9
|
-
attribute :key , Types::Strict::String.optional.default(nil)
|
10
|
-
attribute :message , Types::Strict::String
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# DomainModel holds the entire domain model including database and ancillary information
|
4
|
-
module KDomain
|
5
|
-
module DomainModel
|
6
|
-
class Schema < Dry::Struct
|
7
|
-
attribute :domain , KDomain::DomainModel::Domain
|
8
|
-
attribute :database , KDomain::RawDbSchema::Schema
|
9
|
-
attribute :investigate , KDomain::DomainModel::Investigate
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module KDomain
|
4
|
-
module RawDbSchema
|
5
|
-
class Column < Dry::Struct
|
6
|
-
attribute :name , Types::Strict::String
|
7
|
-
attribute :type , Types::Strict::String
|
8
|
-
attribute :precision? , Types::Strict::Integer.optional.default(nil)
|
9
|
-
attribute :scale? , Types::Strict::Integer.optional.default(nil)
|
10
|
-
attribute :default? , Types::Nominal::Any.optional.default(nil) # Types::Strict::Bool.optional.default(nil) | Types::Strict::Integer.optional.default(nil)
|
11
|
-
attribute :array? , Types::Strict::Bool.optional.default(nil)
|
12
|
-
attribute :null? , Types::Strict::Bool.optional.default(nil)
|
13
|
-
attribute :limit? , Types::Strict::Integer.optional.default(nil)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module KDomain
|
4
|
-
module RawDbSchema
|
5
|
-
class Database < Dry::Struct
|
6
|
-
attribute :type , Types::Strict::String
|
7
|
-
attribute :version , Types::Nominal::Any.optional.default(nil)
|
8
|
-
attribute :extensions , Types::Strict::Array
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module KDomain
|
4
|
-
module RawDbSchema
|
5
|
-
class Schema < Dry::Struct
|
6
|
-
class Meta < Dry::Struct
|
7
|
-
attribute :rails , Types::Strict::Integer
|
8
|
-
attribute :database , KDomain::RawDbSchema::Database
|
9
|
-
attribute :unique_keys , Types::Strict::Array.of(KDomain::RawDbSchema::UniqueKey)
|
10
|
-
end
|
11
|
-
|
12
|
-
attribute :tables , Types::Strict::Array.of(KDomain::RawDbSchema::Table)
|
13
|
-
attribute :foreign_keys? , Types::Strict::Array.of(KDomain::RawDbSchema::ForeignKey)
|
14
|
-
attribute :indexes? , Types::Strict::Array.of(KDomain::RawDbSchema::Index)
|
15
|
-
attribute :meta , KDomain::RawDbSchema::Schema::Meta
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module KDomain
|
4
|
-
module RawDbSchema
|
5
|
-
class Table < Dry::Struct
|
6
|
-
class Meta < Dry::Struct
|
7
|
-
attribute :primary_key , Types::Nominal::Any.optional.default(nil)
|
8
|
-
attribute :id , Types::Nominal::Any.optional.default(nil)
|
9
|
-
attribute :force , Types::Nominal::Any.optional.default(nil)
|
10
|
-
end
|
11
|
-
|
12
|
-
attribute :name , Types::Strict::String
|
13
|
-
attribute :primary_key , Types::Strict::String.optional.default(nil)
|
14
|
-
attribute :primary_key_type , Types::Strict::String.optional.default(nil)
|
15
|
-
attribute :id? , Types::Nominal::Any.optional.default(nil) # Types::Strict::String.optional.default(nil)
|
16
|
-
attribute :columns , Types::Strict::Array.of(KDomain::RawDbSchema::Column)
|
17
|
-
attribute :indexes , Types::Strict::Array.of(KDomain::RawDbSchema::Index)
|
18
|
-
attribute :rails_schema , KDomain::RawDbSchema::Table::Meta
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module KDomain
|
4
|
-
module RawDbSchema
|
5
|
-
# Keep a track of unique keys that appear in the data structures
|
6
|
-
# so that we can track what new attributes to add to the models
|
7
|
-
class UniqueKey < Dry::Struct
|
8
|
-
attribute :type , Types::Strict::String
|
9
|
-
attribute :category , Types::Strict::String.optional
|
10
|
-
attribute :key , Types::Strict::String
|
11
|
-
attribute :keys , Types::Strict::Array
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|