k_domain 0.0.26 → 0.0.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +5 -3
- data/.gitignore +1 -0
- data/.rubocop.yml +8 -3
- data/Gemfile +2 -2
- data/k_domain.gemspec +4 -4
- data/lib/k_domain/domain_model/build_rich_models.rb +85 -0
- data/lib/k_domain/domain_model/load.rb +3 -1
- data/lib/k_domain/domain_model/transform.rb +13 -11
- data/lib/k_domain/domain_model/transform_steps/step6_rails_structure_models.rb +1 -0
- data/lib/k_domain/domain_model/transform_steps/step7_rails_structure_controllers.rb +3 -0
- data/lib/k_domain/queries/_.rb +4 -0
- data/lib/k_domain/queries/base_query.rb +13 -0
- data/lib/k_domain/queries/domain_model_query.rb +88 -0
- data/lib/k_domain/rails_code_extractor/shim_loader.rb +4 -2
- data/lib/k_domain/schemas/_.rb +1 -1
- data/lib/k_domain/schemas/domain.rb +50 -2
- data/lib/k_domain/schemas/{domain_model.rb → main_dataset.rb} +2 -2
- data/lib/k_domain/version.rb +1 -1
- data/lib/k_domain.rb +3 -1
- data/templates/custom/action_controller.rb +0 -29
- data/templates/custom/controller_interceptors.rb +9 -7
- data/templates/custom/model_interceptors.rb +48 -3
- data/templates/rails/active_record.rb +2 -0
- metadata +15 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4d9da64cb89b7d2ee8ddd67e025ebcb34d617f0631b243368204c2cf904ec7b
|
4
|
+
data.tar.gz: 8168edbaf51175596d36d36a031e5f3a97ffc7c3bb13c1586fb8a6cf52646673
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd639a6ee4f496b05a6b0772b6782daa25866ad5f97321813c58e09c0b98a6f214c7cb88444e5d1e48d46f0566e352c6f48a44693d7ba742117bc8661df982a7
|
7
|
+
data.tar.gz: e733532923f3ae06191d6a037e11a9cf5e8dcb5939b08c9fe5f128e82fc75d6636e2727961b726e5761fd26db304fe5c6cef4082175d8539cbd4835828456a2d
|
data/.github/workflows/main.yml
CHANGED
@@ -25,7 +25,9 @@ jobs:
|
|
25
25
|
run: |
|
26
26
|
gem install bundler -v 2.2.5
|
27
27
|
bundle install
|
28
|
-
- name: Run tests
|
29
|
-
run: bundle exec rspec
|
30
28
|
- name: Run rubocop
|
31
|
-
run:
|
29
|
+
run: |
|
30
|
+
bundle exec rubocop -v
|
31
|
+
bundle exec rubocop
|
32
|
+
- name: Run tests
|
33
|
+
run: bundle exec rspec --tag ~skip_on_gha
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# require: rubocop-rake
|
2
2
|
AllCops:
|
3
|
-
TargetRubyVersion: 2.
|
3
|
+
TargetRubyVersion: 2.7
|
4
4
|
DisplayCopNames: true
|
5
5
|
ExtraDetails: true
|
6
6
|
NewCops: enable
|
@@ -10,6 +10,7 @@ AllCops:
|
|
10
10
|
- "templates/**/*"
|
11
11
|
- "lib/k_domain/schemas/domain/old/**/*"
|
12
12
|
- "spec/k_domain/ruby_loader/**/*"
|
13
|
+
- "hooks/**/*"
|
13
14
|
|
14
15
|
Metrics/PerceivedComplexity:
|
15
16
|
Exclude:
|
@@ -68,8 +69,6 @@ Metrics/MethodLength:
|
|
68
69
|
|
69
70
|
Layout/LineLength:
|
70
71
|
Max: 200
|
71
|
-
# Ignores annotate output
|
72
|
-
IgnoredPatterns: ['\A# \*\*']
|
73
72
|
IgnoreCopDirectives: true
|
74
73
|
Exclude:
|
75
74
|
- "lib/k_domain/domain_model/transform_steps/*.rb"
|
@@ -116,6 +115,12 @@ Style/FormatStringToken:
|
|
116
115
|
Style/Documentation:
|
117
116
|
Enabled: false
|
118
117
|
|
118
|
+
Style/OpenStructUse:
|
119
|
+
Enabled: false
|
120
|
+
|
119
121
|
Layout/SpaceBeforeComma:
|
120
122
|
Enabled: false
|
123
|
+
|
124
|
+
Gemspec/RequireMFA:
|
125
|
+
Enabled: false
|
121
126
|
# My Preferences - End
|
data/Gemfile
CHANGED
@@ -16,7 +16,7 @@ group :development, :test do
|
|
16
16
|
gem 'guard-bundler'
|
17
17
|
gem 'guard-rspec'
|
18
18
|
gem 'guard-rubocop'
|
19
|
-
gem 'rake'
|
19
|
+
gem 'rake'
|
20
20
|
gem 'rake-compiler', require: false
|
21
21
|
gem 'rspec', '~> 3.0'
|
22
22
|
gem 'rubocop'
|
@@ -25,7 +25,7 @@ group :development, :test do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
# If local dependency
|
28
|
-
if ENV
|
28
|
+
if ENV.fetch('KLUE_LOCAL_GEMS', 'false').downcase == 'true'
|
29
29
|
group :development, :test do
|
30
30
|
puts 'Using Local GEMs'
|
31
31
|
gem 'k_log' , path: '../k_log'
|
data/k_domain.gemspec
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative 'lib/k_domain/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.required_ruby_version = '>= 2.
|
6
|
+
spec.required_ruby_version = '>= 2.7'
|
7
7
|
spec.name = 'k_domain'
|
8
8
|
spec.version = KDomain::VERSION
|
9
9
|
spec.authors = ['David Cruwys']
|
@@ -39,8 +39,8 @@ Gem::Specification.new do |spec|
|
|
39
39
|
spec.require_paths = ['lib']
|
40
40
|
# spec.extensions = ['ext/k_domain/extconf.rb']
|
41
41
|
|
42
|
-
spec.add_dependency 'activesupport'
|
42
|
+
spec.add_dependency 'activesupport', '~> 7'
|
43
43
|
spec.add_dependency 'dry-struct', '~> 1'
|
44
|
-
spec.add_dependency 'k_log' , '~> 0
|
45
|
-
spec.add_dependency 'peeky' , '~> 0
|
44
|
+
spec.add_dependency 'k_log' , '~> 0'
|
45
|
+
spec.add_dependency 'peeky' , '~> 0'
|
46
46
|
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Loads the db schema object and works through a series of enrichment steps to
|
4
|
+
# that builds the domain modal
|
5
|
+
|
6
|
+
module KDomain
|
7
|
+
module DomainModel
|
8
|
+
class BuildRichModels
|
9
|
+
include KLog::Logging
|
10
|
+
|
11
|
+
attr_reader :db_schema
|
12
|
+
attr_reader :target_folder
|
13
|
+
attr_reader :query
|
14
|
+
|
15
|
+
def initialize(domain_model:, target_folder:)
|
16
|
+
@domain_model = domain_model
|
17
|
+
@target_folder = target_folder
|
18
|
+
@query = KDomain::Queries::DomainModelQuery.new(domain_model)
|
19
|
+
end
|
20
|
+
|
21
|
+
def call
|
22
|
+
FileUtils.mkdir_p(target_folder)
|
23
|
+
|
24
|
+
export_domain_models(query.all) # .take(3))
|
25
|
+
end
|
26
|
+
|
27
|
+
def export_domain_models(models)
|
28
|
+
puts 'export domain models'
|
29
|
+
models.each do |model|
|
30
|
+
# write a single dot to the console in the color red
|
31
|
+
print "\e[31m.\e[0m"
|
32
|
+
|
33
|
+
json = JSON.pretty_generate(build_rich_model(model))
|
34
|
+
target_file = File.join(target_folder, "#{model.name}.json")
|
35
|
+
File.write(target_file, json)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
40
|
+
def build_rich_model(model)
|
41
|
+
{
|
42
|
+
name: model.name,
|
43
|
+
name_plural: model.name_plural,
|
44
|
+
table_name: model.table_name,
|
45
|
+
type: model.type,
|
46
|
+
pk: model.pk.to_h,
|
47
|
+
file: model.file,
|
48
|
+
exist: model.ruby?,
|
49
|
+
create_update_timestamp: model.create_update_timestamp?,
|
50
|
+
main_key: model.main_key,
|
51
|
+
traits: model.traits,
|
52
|
+
column_names: {
|
53
|
+
all: model.columns.map(&:name),
|
54
|
+
data: model.columns_data.map(&:name),
|
55
|
+
primary: model.columns_primary.map(&:name),
|
56
|
+
foreign_key: model.columns_foreign_key.map(&:name),
|
57
|
+
foreign_type: model.columns_foreign_type.map(&:name),
|
58
|
+
timestamp: model.columns_timestamp.map(&:name),
|
59
|
+
deleted_at: model.columns_deleted_at.map(&:name),
|
60
|
+
virtual: model.columns_virtual.map(&:name),
|
61
|
+
data_foreign: model.columns_data_foreign.map(&:name),
|
62
|
+
data_primary: model.columns_data_primary.map(&:name),
|
63
|
+
data_virtual: model.columns_data_virtual.map(&:name),
|
64
|
+
data_foreign_virtual: model.columns_data_foreign_virtual.map(&:name)
|
65
|
+
},
|
66
|
+
columns: {
|
67
|
+
all: model.columns.map(&:to_h),
|
68
|
+
data: model.columns_data.map(&:to_h),
|
69
|
+
primary: model.columns_primary.map(&:to_h),
|
70
|
+
foreign_key: model.columns_foreign_key.map(&:to_h),
|
71
|
+
foreign_type: model.columns_foreign_type.map(&:to_h),
|
72
|
+
timestamp: model.columns_timestamp.map(&:to_h),
|
73
|
+
deleted_at: model.columns_deleted_at.map(&:to_h),
|
74
|
+
virtual: model.columns_virtual.map(&:to_h),
|
75
|
+
data_foreign: model.columns_data_foreign.map(&:to_h),
|
76
|
+
data_primary: model.columns_data_primary.map(&:to_h),
|
77
|
+
data_virtual: model.columns_data_virtual.map(&:to_h),
|
78
|
+
data_foreign_virtual: model.columns_data_foreign_virtual.map(&:to_h)
|
79
|
+
}
|
80
|
+
}
|
81
|
+
end
|
82
|
+
# rubocop:enable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -22,8 +22,10 @@ module KDomain
|
|
22
22
|
json = File.read(source_file)
|
23
23
|
@raw_data = KUtil.data.json_parse(json, as: :hash_symbolized)
|
24
24
|
|
25
|
-
|
25
|
+
# This line is slow on big datasets
|
26
|
+
@data = KDomain::Schemas::MainDataset.new(@raw_data)
|
26
27
|
|
28
|
+
# This line is also slow on big datasets
|
27
29
|
enrichment
|
28
30
|
end
|
29
31
|
|
@@ -14,17 +14,19 @@ module KDomain
|
|
14
14
|
attr_reader :model_path
|
15
15
|
attr_reader :controller_path
|
16
16
|
attr_reader :route_path
|
17
|
-
attr_reader :
|
17
|
+
attr_reader :model_shim_loader
|
18
|
+
attr_reader :controller_shim_loader
|
18
19
|
|
19
20
|
# rubocop:disable Metrics/ParameterLists
|
20
|
-
def initialize(db_schema: , target_file: , target_step_file: , model_path:, route_path:, controller_path:,
|
21
|
-
@db_schema
|
22
|
-
@target_step_file
|
23
|
-
@target_file
|
24
|
-
@model_path
|
25
|
-
@controller_path
|
26
|
-
@route_path
|
27
|
-
@
|
21
|
+
def initialize(db_schema: , target_file: , target_step_file: , model_path:, route_path:, controller_path:, model_shim_loader: nil, controller_shim_loader: nil)
|
22
|
+
@db_schema = db_schema
|
23
|
+
@target_step_file = target_step_file
|
24
|
+
@target_file = target_file
|
25
|
+
@model_path = model_path
|
26
|
+
@controller_path = controller_path
|
27
|
+
@route_path = route_path
|
28
|
+
@model_shim_loader = model_shim_loader
|
29
|
+
@controller_shim_loader = controller_shim_loader
|
28
30
|
end
|
29
31
|
# rubocop:enable Metrics/ParameterLists
|
30
32
|
|
@@ -35,8 +37,8 @@ module KDomain
|
|
35
37
|
valid &&= Step2DomainModels.run(domain_data, model_path: model_path, step_file: step_file('02-domain-model'))
|
36
38
|
valid &&= Step4RailsResourceModels.run(domain_data, model_path: model_path, step_file: step_file('04-rails-resource-models'))
|
37
39
|
valid &&= Step5RailsResourceRoutes.run(domain_data, route_path: route_path, controller_path: controller_path, step_file: step_file('05-rails-resource-routes'))
|
38
|
-
valid &&= Step6RailsStructureModels.run(domain_data, model_path: model_path, step_file: step_file('06-rails-structure-models'), shim_loader:
|
39
|
-
valid &&= Step7RailsStructureControllers.run(domain_data, controller_path: controller_path, step_file: step_file('07-rails-structure-controllers'), shim_loader:
|
40
|
+
valid &&= Step6RailsStructureModels.run(domain_data, model_path: model_path, step_file: step_file('06-rails-structure-models'), shim_loader: model_shim_loader)
|
41
|
+
valid &&= Step7RailsStructureControllers.run(domain_data, controller_path: controller_path, step_file: step_file('07-rails-structure-controllers'), shim_loader: controller_shim_loader)
|
40
42
|
valid &&= Step8DomainColumns.run(domain_data, step_file: step_file('08-domain-columns'))
|
41
43
|
valid &&= Step20Dictionary.run(domain_data, step_file: step_file('20-dictionary'))
|
42
44
|
|
@@ -37,6 +37,7 @@ class Step6RailsStructureModels < KDomain::DomainModel::Step
|
|
37
37
|
|
38
38
|
def attach_behavior_and_functions
|
39
39
|
rails_structure_models.select { |model| model[:exist] }.each do |model|
|
40
|
+
# puts "model: #{model[:model_name]}"
|
40
41
|
model[:behaviours] = extract_behavior(model[:file])
|
41
42
|
klass_name = model[:behaviours][:class_name]
|
42
43
|
model[:functions] = extract_functions(klass_name)
|
@@ -58,7 +58,10 @@ class Step7RailsStructureControllers < KDomain::DomainModel::Step
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def attach_behavior_and_functions
|
61
|
+
rails_structure_controllers.sort_by! { |controller| controller[:full_file] }
|
62
|
+
|
61
63
|
rails_structure_controllers.select { |controller| controller[:exist] }.each do |controller|
|
64
|
+
# puts "controller: #{controller[:full_file]}"
|
62
65
|
unless File.exist?(controller[:full_file])
|
63
66
|
log.error 'Controller apparently exists but no file found, this means that you need re-run rake routes'
|
64
67
|
puts controller[:full_file]
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module KDomain
|
4
|
+
module Queries
|
5
|
+
# Query models found on the domain model
|
6
|
+
# by
|
7
|
+
# has ruby file
|
8
|
+
# has primary key
|
9
|
+
# column count
|
10
|
+
# data column count
|
11
|
+
# foreign key column count
|
12
|
+
# has timestamp (created_at, updated_at) columns
|
13
|
+
# has created_at
|
14
|
+
# has updated_at
|
15
|
+
# has deleted_at
|
16
|
+
# has polymorphic foreign keys
|
17
|
+
# has virtual columns
|
18
|
+
# virtual column filters (token, encrypted_password, etc)
|
19
|
+
class DomainModelQuery < BaseQuery
|
20
|
+
def all
|
21
|
+
domain_model.domain.models
|
22
|
+
end
|
23
|
+
|
24
|
+
def query(**filters)
|
25
|
+
@query = all.clone
|
26
|
+
|
27
|
+
filters.each do |key, value|
|
28
|
+
send("filter_#{key}", value)
|
29
|
+
end
|
30
|
+
|
31
|
+
@query
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def filter_ruby(value)
|
37
|
+
@query.select! { |model| model.ruby? == value }
|
38
|
+
end
|
39
|
+
|
40
|
+
def filter_pk(value)
|
41
|
+
@query.select! { |model| model.pk.exist? == value }
|
42
|
+
end
|
43
|
+
|
44
|
+
def filter_column_count(block)
|
45
|
+
@query.select! { |model| block.call(model.columns.count) }
|
46
|
+
end
|
47
|
+
|
48
|
+
def filter_data_column_count(block)
|
49
|
+
@query.select! { |model| block.call(model.columns_data.count) }
|
50
|
+
end
|
51
|
+
|
52
|
+
def filter_foreign_key_column_count(block)
|
53
|
+
@query.select! { |model| block.call(model.columns_foreign_key.count) }
|
54
|
+
end
|
55
|
+
alias filter_fk_column_count filter_foreign_key_column_count
|
56
|
+
alias filter_fk_count filter_foreign_key_column_count
|
57
|
+
|
58
|
+
def filter_polymorphic_foreign_key_column_count(block)
|
59
|
+
@query.select! { |model| block.call(model.columns_foreign_type.count) }
|
60
|
+
end
|
61
|
+
alias filter_poly_fk_column_count filter_polymorphic_foreign_key_column_count
|
62
|
+
alias filter_poly_fk_count filter_polymorphic_foreign_key_column_count
|
63
|
+
|
64
|
+
def filter_timestamp(value)
|
65
|
+
@query.select! { |model| (model.columns_timestamp.count == 2) == value }
|
66
|
+
end
|
67
|
+
|
68
|
+
def filter_created_at(value)
|
69
|
+
@query.select! { |model| (model.columns.any? { |column| column.name == 'created_at' } == value) }
|
70
|
+
end
|
71
|
+
|
72
|
+
def filter_updated_at(value)
|
73
|
+
@query.select! { |model| (model.columns.any? { |column| column.name == 'updated_at' } == value) }
|
74
|
+
end
|
75
|
+
|
76
|
+
def filter_deleted_at(value)
|
77
|
+
@query.select! { |model| (model.columns.any? { |column| column.name == 'deleted_at' } == value) }
|
78
|
+
end
|
79
|
+
# has virtual columns
|
80
|
+
# virtual column filters (token, encrypted_password, etc)
|
81
|
+
|
82
|
+
# # HELP: this filter affects table rows, eg. if a table has less the 2 columns then include the table
|
83
|
+
# low_column: -> (model) { model.columns.length < 5 },
|
84
|
+
# suspected_m2m: -> (model) { model.columns_foreign.length == 2 && model.columns_data.length < 3 },
|
85
|
+
# invalid_types: -> (model) { model.columns.any? { |c| [c.db_type, c.csharp_type, c.ruby_type].include?('******') } },
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -18,8 +18,10 @@ module KDomain
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def call
|
21
|
-
|
22
|
-
|
21
|
+
shim_files.select { |sf| sf[:exist] }.each do |sf|
|
22
|
+
require sf[:file]
|
23
|
+
end
|
24
|
+
nil
|
23
25
|
end
|
24
26
|
|
25
27
|
def register(name, file)
|
data/lib/k_domain/schemas/_.rb
CHANGED
@@ -47,12 +47,53 @@ module KDomain
|
|
47
47
|
|
48
48
|
@csharp_type = KDomain::Schemas::CSHARP_TYPE[type] || '******'
|
49
49
|
end
|
50
|
+
|
51
|
+
# rubocop:disable Metrics/AbcSize
|
52
|
+
def to_h
|
53
|
+
{
|
54
|
+
name: name,
|
55
|
+
name_plural: name_plural,
|
56
|
+
type: type,
|
57
|
+
precision: precision,
|
58
|
+
scale: scale,
|
59
|
+
default: default,
|
60
|
+
default_as_code: value_as_code(default),
|
61
|
+
null: null,
|
62
|
+
null_as_code: value_as_code(null), # handlebars does not like null property name
|
63
|
+
limit: limit,
|
64
|
+
array: array,
|
65
|
+
array_as_code: value_as_code(array),
|
66
|
+
db_type: db_type,
|
67
|
+
ruby_type: ruby_type,
|
68
|
+
csharp_type: csharp_type,
|
69
|
+
structure_type: structure_type,
|
70
|
+
relationships: relationships
|
71
|
+
}
|
72
|
+
end
|
73
|
+
# rubocop:enable Metrics/AbcSize
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def value_as_code(value)
|
78
|
+
return value if value.nil?
|
79
|
+
|
80
|
+
case value
|
81
|
+
when String # , Hash
|
82
|
+
"'#{value}'"
|
83
|
+
else
|
84
|
+
value.to_s
|
85
|
+
end
|
86
|
+
end
|
50
87
|
end
|
51
88
|
|
52
89
|
class Pk < Dry::Struct
|
53
90
|
attribute :name , Types::Strict::String.optional.default(nil)
|
54
91
|
attribute :type , Types::Strict::String.optional.default(nil)
|
55
92
|
attribute :exist , Types::Strict::Bool
|
93
|
+
|
94
|
+
def exist?
|
95
|
+
exist
|
96
|
+
end
|
56
97
|
end
|
57
98
|
|
58
99
|
attribute :name , Types::Strict::String
|
@@ -75,6 +116,12 @@ module KDomain
|
|
75
116
|
pk.exist
|
76
117
|
end
|
77
118
|
|
119
|
+
def create_update_timestamp?
|
120
|
+
names = columns_timestamp.map(&:name)
|
121
|
+
|
122
|
+
(names & %w[created_at updated_at]).any?
|
123
|
+
end
|
124
|
+
|
78
125
|
# Custom model configurations such as main_key and traits
|
79
126
|
def config
|
80
127
|
@config ||= KDomain.configuration.find_model(name.to_sym)
|
@@ -97,10 +144,11 @@ module KDomain
|
|
97
144
|
@columns_primary ||= columns_for_structure_types(:primary_key)
|
98
145
|
end
|
99
146
|
|
100
|
-
def
|
147
|
+
def columns_foreign_key
|
101
148
|
@columns_foreign ||= columns_for_structure_types(:foreign_key)
|
102
149
|
end
|
103
150
|
|
151
|
+
# polymorphic foreign keys
|
104
152
|
def columns_foreign_type
|
105
153
|
@columns_foreign_type ||= columns_for_structure_types(:foreign_type)
|
106
154
|
end
|
@@ -118,7 +166,7 @@ module KDomain
|
|
118
166
|
end
|
119
167
|
|
120
168
|
def columns_data_foreign
|
121
|
-
@columns_data_foreign ||= columns_for_structure_types(:data, :foreign_key)
|
169
|
+
@columns_data_foreign ||= columns_for_structure_types(:data, :foreign_key, :foreign_type)
|
122
170
|
end
|
123
171
|
alias rows_fields_and_fk columns_data_foreign
|
124
172
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# MainDataset holds the entire domain model including database and ancillary information
|
4
4
|
module KDomain
|
5
5
|
module Schemas
|
6
|
-
class
|
6
|
+
class MainDataset < Dry::Struct
|
7
7
|
attribute :domain , KDomain::Schemas::Domain
|
8
8
|
attribute :database , KDomain::Schemas::Database
|
9
9
|
attribute :dictionary , KDomain::Schemas::Dictionary
|
data/lib/k_domain/version.rb
CHANGED
data/lib/k_domain.rb
CHANGED
@@ -12,7 +12,9 @@ require 'k_domain/raw_db_schema/load'
|
|
12
12
|
require 'k_domain/domain_model/transform'
|
13
13
|
require 'k_domain/domain_model/transform_steps/_'
|
14
14
|
require 'k_domain/domain_model/load'
|
15
|
+
require 'k_domain/domain_model/build_rich_models'
|
15
16
|
require 'k_domain/rails_code_extractor/_'
|
17
|
+
require 'k_domain/queries/_'
|
16
18
|
|
17
19
|
# # This is useful if you want to initialize structures via Hash
|
18
20
|
# class SymbolizeStruct < Dry::Struct
|
@@ -38,7 +40,7 @@ module KDomain
|
|
38
40
|
# Your code goes here...
|
39
41
|
end
|
40
42
|
|
41
|
-
if ENV
|
43
|
+
if ENV.fetch('KLUE_DEBUG', 'false').downcase == 'true'
|
42
44
|
namespace = 'KDomain::Version'
|
43
45
|
file_path = $LOADED_FEATURES.find { |f| f.include?('k_domain/version') }
|
44
46
|
version = KDomain::VERSION.ljust(9)
|
@@ -3,34 +3,5 @@ module ActionController
|
|
3
3
|
def self.require(require)
|
4
4
|
add(:require, require)
|
5
5
|
end
|
6
|
-
# def self.rescue_from(type)#, &block)
|
7
|
-
# # block_source = nil
|
8
|
-
# # block_source = lambda_source(block, 'default_scope') if block_given?
|
9
|
-
|
10
|
-
# add(:rescue_from, {
|
11
|
-
# type: type#,
|
12
|
-
# # block: block_source
|
13
|
-
# })
|
14
|
-
# end
|
15
|
-
# def self.helper_method(*names)
|
16
|
-
# add(:helper_method, {
|
17
|
-
# names: names
|
18
|
-
# })
|
19
|
-
# end
|
20
|
-
# def self.helper(name)
|
21
|
-
# add(:helper, {
|
22
|
-
# name: name
|
23
|
-
# })
|
24
|
-
# end
|
25
|
-
# def self.http_basic_authenticate_with(**opts)
|
26
|
-
# add(:http_basic_authenticate_with, {
|
27
|
-
# opts: opts
|
28
|
-
# })
|
29
|
-
# end
|
30
|
-
# def self.protect_from_forgery(**opts)
|
31
|
-
# add(:protect_from_forgery, {
|
32
|
-
# opts: opts
|
33
|
-
# })
|
34
|
-
# end
|
35
6
|
end
|
36
7
|
end
|
@@ -10,18 +10,14 @@ class Rails
|
|
10
10
|
)
|
11
11
|
end
|
12
12
|
end
|
13
|
-
class RegionConfig
|
14
|
-
def self.require_value(*_p, **_o, &block); end
|
15
|
-
end
|
16
|
-
|
17
13
|
class ApplicationController < ActionController::Base
|
14
|
+
def self.require(*_p, **_o); end
|
18
15
|
end
|
19
16
|
|
20
17
|
module Admin
|
21
18
|
class BaseController < ActionController::Base
|
22
19
|
end
|
23
20
|
end
|
24
|
-
|
25
21
|
module Api
|
26
22
|
module V1
|
27
23
|
class BaseController < ActionController::Base
|
@@ -38,12 +34,18 @@ module Portal
|
|
38
34
|
class BaseController < ApplicationController
|
39
35
|
end
|
40
36
|
end
|
41
|
-
|
42
37
|
module ActiveRecord
|
43
38
|
class RecordNotFound
|
44
39
|
end
|
45
40
|
end
|
46
|
-
|
41
|
+
class RegionConfig < ActiveRecord::Base
|
42
|
+
def self.require_value(*_p, **_o, &block)
|
43
|
+
return 'ABC'
|
44
|
+
end
|
45
|
+
def self.get_value
|
46
|
+
return 'ABC'
|
47
|
+
end
|
48
|
+
end
|
47
49
|
module Aws
|
48
50
|
class Credentials
|
49
51
|
def initialize(*_p, **_o, &block); end
|
@@ -11,11 +11,32 @@ module ActsAsCommentable
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
|
14
15
|
module Scopes
|
15
16
|
module CompanyScopes
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
20
|
+
module DeIdentifiable
|
21
|
+
def deidentifiable(*_p, **_o); end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Company < ActiveRecord::Base
|
25
|
+
extend DeIdentifiable
|
26
|
+
end
|
27
|
+
class Estimate < ActiveRecord::Base
|
28
|
+
extend DeIdentifiable
|
29
|
+
end
|
30
|
+
class Invoice < ActiveRecord::Base
|
31
|
+
extend DeIdentifiable
|
32
|
+
end
|
33
|
+
class Address < ActiveRecord::Base
|
34
|
+
extend DeIdentifiable
|
35
|
+
end
|
36
|
+
class Contact < ActiveRecord::Base
|
37
|
+
extend DeIdentifiable
|
38
|
+
end
|
39
|
+
|
19
40
|
class Thread
|
20
41
|
def initialize(*_p, **_o, &block); end
|
21
42
|
end
|
@@ -41,17 +62,41 @@ module ApiLoggable; end
|
|
41
62
|
module Excludable; end
|
42
63
|
module Bookmarkable; end
|
43
64
|
module Categorizable; end
|
44
|
-
module PgSearch
|
65
|
+
module PgSearch
|
66
|
+
module Model
|
67
|
+
end
|
68
|
+
end
|
45
69
|
module Excludable; end
|
46
|
-
module JsonbStore
|
70
|
+
module JsonbStore
|
71
|
+
def self.included(klass)
|
72
|
+
klass.extend(ClassMethods)
|
73
|
+
end
|
47
74
|
|
75
|
+
module ClassMethods
|
76
|
+
def jsonb_store(*_p, **_o); end
|
77
|
+
end
|
78
|
+
end
|
48
79
|
module ActionView
|
49
80
|
module Helpers
|
50
81
|
module NumberHelper
|
51
82
|
end
|
52
83
|
end
|
53
84
|
end
|
54
|
-
|
85
|
+
module PrintSpeak
|
86
|
+
class Application
|
87
|
+
def self.google_oath_secret_key
|
88
|
+
'ABC'
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
class RegionConfig < ActiveRecord::Base
|
93
|
+
def self.require_value(*_p, **_o, &block)
|
94
|
+
'ABC'
|
95
|
+
end
|
96
|
+
def self.get_value
|
97
|
+
return 'ABC'
|
98
|
+
end
|
99
|
+
end
|
55
100
|
module RailsUpgrade
|
56
101
|
def rails4?
|
57
102
|
true
|
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.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '7'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: dry-struct
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,28 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0
|
47
|
+
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: peeky
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0
|
61
|
+
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0
|
68
|
+
version: '0'
|
69
69
|
description: " K Domain builds complex domain schemas by combining the database
|
70
70
|
schema with a rich entity relationship DSLs\n"
|
71
71
|
email:
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- lib/k_domain/config/_.rb
|
102
102
|
- lib/k_domain/config/config.rb
|
103
103
|
- lib/k_domain/config/configuration.rb
|
104
|
+
- lib/k_domain/domain_model/build_rich_models.rb
|
104
105
|
- lib/k_domain/domain_model/load.rb
|
105
106
|
- lib/k_domain/domain_model/transform.rb
|
106
107
|
- lib/k_domain/domain_model/transform_steps/_.rb
|
@@ -113,6 +114,9 @@ files:
|
|
113
114
|
- lib/k_domain/domain_model/transform_steps/step6_rails_structure_models.rb
|
114
115
|
- lib/k_domain/domain_model/transform_steps/step7_rails_structure_controllers.rb
|
115
116
|
- lib/k_domain/domain_model/transform_steps/step8_domain_columns.rb
|
117
|
+
- lib/k_domain/queries/_.rb
|
118
|
+
- lib/k_domain/queries/base_query.rb
|
119
|
+
- lib/k_domain/queries/domain_model_query.rb
|
116
120
|
- lib/k_domain/rails_code_extractor/_.rb
|
117
121
|
- lib/k_domain/rails_code_extractor/extract_controller.rb
|
118
122
|
- lib/k_domain/rails_code_extractor/extract_model.rb
|
@@ -140,9 +144,9 @@ files:
|
|
140
144
|
- lib/k_domain/schemas/domain/old/statistics.rb
|
141
145
|
- lib/k_domain/schemas/domain/old/validate.rb
|
142
146
|
- lib/k_domain/schemas/domain/old/validates.rb
|
143
|
-
- lib/k_domain/schemas/domain_model.rb
|
144
147
|
- lib/k_domain/schemas/domain_types.rb
|
145
148
|
- lib/k_domain/schemas/investigate.rb
|
149
|
+
- lib/k_domain/schemas/main_dataset.rb
|
146
150
|
- lib/k_domain/schemas/rails_resource.rb
|
147
151
|
- lib/k_domain/schemas/rails_structure.rb
|
148
152
|
- lib/k_domain/version.rb
|
@@ -171,14 +175,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
171
175
|
requirements:
|
172
176
|
- - ">="
|
173
177
|
- !ruby/object:Gem::Version
|
174
|
-
version: '2.
|
178
|
+
version: '2.7'
|
175
179
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
180
|
requirements:
|
177
181
|
- - ">="
|
178
182
|
- !ruby/object:Gem::Version
|
179
183
|
version: '0'
|
180
184
|
requirements: []
|
181
|
-
rubygems_version: 3.
|
185
|
+
rubygems_version: 3.1.6
|
182
186
|
signing_key:
|
183
187
|
specification_version: 4
|
184
188
|
summary: K Domain builds complex domain schemas by combining the database schema with
|