k_domain 0.0.5 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +8 -0
  3. data/Gemfile +10 -0
  4. data/STORIES.md +15 -0
  5. data/k_domain.gemspec +1 -0
  6. data/lib/k_domain/domain_model/transform.rb +14 -0
  7. data/lib/k_domain/domain_model/transform_steps/_.rb +1 -0
  8. data/lib/k_domain/domain_model/transform_steps/step.rb +19 -0
  9. data/lib/k_domain/domain_model/transform_steps/step4_attach_erd_files.rb +2 -2
  10. data/lib/k_domain/domain_model/transform_steps/step8_locate_rails_models.rb +42 -0
  11. data/lib/k_domain/raw_db_schema/load.rb +1 -1
  12. data/lib/k_domain/raw_db_schema/transform.rb +4 -4
  13. data/lib/k_domain/{raw_db_schema/dtos → schemas/database}/_.rb +0 -0
  14. data/lib/k_domain/{raw_db_schema/dtos → schemas/database}/column.rb +1 -1
  15. data/lib/k_domain/{raw_db_schema/dtos → schemas/database}/database.rb +1 -1
  16. data/lib/k_domain/{raw_db_schema/dtos → schemas/database}/foreign_key.rb +1 -1
  17. data/lib/k_domain/{raw_db_schema/dtos → schemas/database}/index.rb +1 -1
  18. data/lib/k_domain/{raw_db_schema/dtos → schemas/database}/schema.rb +7 -7
  19. data/lib/k_domain/{raw_db_schema/dtos → schemas/database}/table.rb +4 -4
  20. data/lib/k_domain/{raw_db_schema/dtos → schemas/database}/unique_key.rb +1 -1
  21. data/lib/k_domain/{domain_model/dtos → schemas/domain}/_.rb +3 -23
  22. data/lib/k_domain/{domain_model/dtos/dictionary → schemas/domain}/dictionary.rb +0 -0
  23. data/lib/k_domain/{domain_model/dtos → schemas/domain}/domain.rb +1 -0
  24. data/lib/k_domain/schemas/domain/erd_file.rb +80 -0
  25. data/lib/k_domain/schemas/domain/investigate.rb +15 -0
  26. data/lib/k_domain/{domain_model/dtos → schemas/domain}/models/column.rb +0 -0
  27. data/lib/k_domain/{domain_model/dtos → schemas/domain}/models/model.rb +0 -0
  28. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/belongs_to.rb +0 -0
  29. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/column_old.rb +0 -0
  30. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/domain_statistics.rb +0 -0
  31. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/entity.rb +0 -0
  32. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/entity_statistics.rb +0 -0
  33. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/foreign_key.rb +0 -0
  34. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/has_and_belongs_to_many.rb +0 -0
  35. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/has_many.rb +0 -0
  36. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/has_one.rb +0 -0
  37. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/name_options.rb +0 -0
  38. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/rails_controller.rb +0 -0
  39. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/rails_model.rb +0 -0
  40. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/related_entity.rb +0 -0
  41. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/statistics.rb +0 -0
  42. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/validate.rb +0 -0
  43. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/validates.rb +0 -0
  44. data/lib/k_domain/{domain_model/dtos → schemas/domain}/schema.rb +2 -1
  45. data/lib/k_domain/version.rb +1 -1
  46. data/lib/k_domain.rb +4 -2
  47. metadata +49 -34
  48. data/lib/k_domain/domain_model/dtos/investigate/investigate.rb +0 -10
  49. data/lib/k_domain/domain_model/dtos/investigate/issue.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92aebc822bef5bff0524221c4ca53f3bccdf4f3b4a134c2bcdd207f7c58e5609
4
- data.tar.gz: db850d6a8d98ee6a5fd77f1cfe5a9e87d5da262ebec598c84f8ca70b3fb5a1cb
3
+ metadata.gz: e0641cc1145379d1ba83cad6765dbf85bd50bb40ce69105a977eb9ced5326046
4
+ data.tar.gz: ac7f352029bcea76171cf87ccf56212e11b3173256519394cc2802e21fd47981
5
5
  SHA512:
6
- metadata.gz: d31d1bd2e461d1a86b938eb043c9dda1c5f553e3a8a1ddd759e0ff24b349da2100f934feb0ac8b001da137086862145aa575be1a2b32a6070f1f82b5ff63a837
7
- data.tar.gz: acd57f1f859401f1d0ff8f39fc7cc3eb69ee128a0c91b94f5ce92bb275ff82924663ce00beb58a25c19752934e2ccc70f1cf04a83e1b8de429e70bd403fb48eb
6
+ metadata.gz: d2b9ce5ced5669eb620f9c3735fbbaf06e12b6c9f9e5eb6507d3526aefcfe5eb624ce5361a14bc39c2c8449eaa31b3e0caa082b6fca07fba23b166be550fc023
7
+ data.tar.gz: a22f3ee11a7b7ef9a9793d01237c5e14f0ed89972d91ede7ed87c29c260b57fca1445ea1bac92830d2299767335e49dc41f2f7b6917a7e08ffb5f8383bbf2ed4
data/.rubocop.yml CHANGED
@@ -14,6 +14,7 @@ Metrics/PerceivedComplexity:
14
14
  Exclude:
15
15
  - "lib/k_domain/domain_model/transform_steps/*.rb"
16
16
  - "lib/k_domain/domain_model/dtos/entity.rb"
17
+ - "lib/k_domain/domain_model/dtos/old/entity.rb"
17
18
 
18
19
  Metrics/AbcSize:
19
20
  Exclude:
@@ -21,16 +22,21 @@ Metrics/AbcSize:
21
22
  - "lib/k_domain/domain_model/dtos/rails_model.rb"
22
23
  - "lib/k_domain/domain_model/dtos/entity.rb"
23
24
  - "lib/k_domain/domain_model/dtos/column_old.rb"
25
+ - "lib/k_domain/domain_model/dtos/old/column_old.rb"
26
+ - "lib/k_domain/domain_model/dtos/old/rails_model.rb"
27
+ - "lib/k_domain/domain_model/dtos/old/entity.rb"
24
28
 
25
29
  Metrics/CyclomaticComplexity:
26
30
  Exclude:
27
31
  - "lib/k_domain/domain_model/transform_steps/*.rb"
28
32
  - "lib/k_domain/domain_model/dtos/entity.rb"
33
+ - "lib/k_domain/domain_model/dtos/old/entity.rb"
29
34
 
30
35
  Metrics/BlockLength:
31
36
  Exclude:
32
37
  - "**/spec/**/*"
33
38
  - "*.gemspec"
39
+ - 'lib/k_domain/domain_model/dtos/erd_file.rb'
34
40
  IgnoredMethods:
35
41
  - configure
36
42
  - context
@@ -56,6 +62,8 @@ Metrics/MethodLength:
56
62
  Exclude:
57
63
  - "lib/k_domain/domain_model/transform_steps/*.rb"
58
64
  - "lib/k_domain/domain_model/dtos/rails_model.rb"
65
+ - "lib/k_domain/domain_model/dtos/old/entity.rb"
66
+ - "lib/k_domain/domain_model/dtos/old/rails_model.rb"
59
67
 
60
68
  Layout/LineLength:
61
69
  Max: 200
data/Gemfile CHANGED
@@ -23,3 +23,13 @@ group :development, :test do
23
23
  gem 'rubocop-rake', require: false
24
24
  gem 'rubocop-rspec', require: false
25
25
  end
26
+
27
+ # If local dependency
28
+ if ENV['KLUE_LOCAL_GEMS']&.to_s&.downcase == 'true'
29
+ group :development, :test do
30
+ puts 'Using Local GEMs'
31
+ gem 'peeky' , path: '../peeky'
32
+ gem 'k_log' , path: '../k_log'
33
+ gem 'k_util' , path: '../k_util'
34
+ end
35
+ end
data/STORIES.md CHANGED
@@ -16,6 +16,21 @@ As a Developer, I can customize domain configuration, so that I can have opinion
16
16
 
17
17
  - Handle traits
18
18
 
19
+ As a Developer, I can read native rails model data, so that I can leverage existing rails applications for ERD modeling
20
+
21
+ - Use Meta Programming and re-implement ActiveRecord::Base
22
+
23
+ ### Tasks next on list
24
+
25
+ Refactor / Simply
26
+
27
+ - Replace complex objects an with structs for ancillary data structures such as investigate
28
+
29
+ User acceptance testing
30
+
31
+ - Provide sample printers for each data structure to visually check data is loading
32
+ - Point raw_db_schema loader towards a complex ERD and check how it performs
33
+
19
34
  ## Stories and tasks
20
35
 
21
36
  ### Tasks - completed
data/k_domain.gemspec CHANGED
@@ -41,4 +41,5 @@ Gem::Specification.new do |spec|
41
41
  spec.add_dependency 'activesupport' , '~> 6'
42
42
  spec.add_dependency 'dry-struct', '~> 1'
43
43
  spec.add_dependency 'k_log' , '~> 0.0.0'
44
+ spec.add_dependency 'peeky' , '~> 0.0.0'
44
45
  end
@@ -27,6 +27,7 @@ module KDomain
27
27
  valid &&= step3
28
28
  valid &&= step4
29
29
  valid &&= step5
30
+ valid &&= step8 # NOT SURE WHERE THIS BELONGS
30
31
 
31
32
  raise 'DomainModal transform failed' unless valid
32
33
 
@@ -60,6 +61,11 @@ module KDomain
60
61
  write(step: '5-attach-dictionary')
61
62
  end
62
63
 
64
+ def step8
65
+ Step8LocateRailsModels.run(domain_data, erd_path: erd_path)
66
+ write(step: '8-rails-files-models')
67
+ end
68
+
63
69
  def write(step: nil)
64
70
  file = if step.nil?
65
71
  target_file
@@ -78,6 +84,14 @@ module KDomain
78
84
  erd_files: [],
79
85
  dictionary: []
80
86
  },
87
+ rails: {
88
+ models: [],
89
+ controllers: [],
90
+ },
91
+ rails_files: {
92
+ models: [],
93
+ controllers: [],
94
+ },
81
95
  database: {
82
96
  tables: [],
83
97
  indexes: [],
@@ -7,3 +7,4 @@ require_relative './step2_attach_models'
7
7
  require_relative './step3_attach_columns'
8
8
  require_relative './step4_attach_erd_files'
9
9
  require_relative './step5_attach_dictionary'
10
+ require_relative './step8_locate_rails_models'
@@ -43,6 +43,25 @@ module KDomain
43
43
  domain[:models]
44
44
  end
45
45
 
46
+ # Rails File Accessor/Helpers
47
+ def rails_files
48
+ guard('rails_files is missing') if domain_data[:rails_files].nil?
49
+
50
+ domain_data[:rails_files]
51
+ end
52
+
53
+ def rails_files_models
54
+ rails_files[:models]
55
+ end
56
+
57
+ def rails_files_models=(value)
58
+ rails_files[:models] = value
59
+ end
60
+
61
+ def rails_files_controllers
62
+ rails_files[:controllers]
63
+ end
64
+
46
65
  # Database Accessor/Helpers
47
66
  def database=(value)
48
67
  domain_data[:database] = value
@@ -58,7 +58,7 @@ class Step4AttachErdFiles < KDomain::DomainModel::Step
58
58
  ruby: ruby_code,
59
59
  public: public_code,
60
60
  private: private_code,
61
- methods: grab_methods(public_code, private_code)
61
+ all_methods: grab_methods(public_code, private_code)
62
62
  }
63
63
  end
64
64
 
@@ -348,7 +348,7 @@ class Step4AttachErdFiles < KDomain::DomainModel::Step
348
348
  instance_private = all_instance.select { |method| method[:scope] == :private }
349
349
 
350
350
  {
351
- class: class_methods,
351
+ klass: class_methods,
352
352
  instance: all_instance,
353
353
  instance_public: instance_public,
354
354
  instance_private: instance_private
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Locate rails model files
4
+ class Step8LocateRailsModels < KDomain::DomainModel::Step
5
+ attr_accessor :ruby_code
6
+
7
+ def call
8
+ raise 'ERD path not supplied' if opts[:erd_path].nil?
9
+
10
+ self.rails_files_models = domain_models.map { |model| locate_rails_model(model[:name], model[:table_name]) }
11
+ end
12
+
13
+ private
14
+
15
+ def locate_rails_model(table_name, model_name)
16
+ file_normal = File.join(opts[:erd_path], "#{model_name}.rb")
17
+ file_custom = File.join(opts[:erd_path], "#{table_name}.rb")
18
+ file_exist = true
19
+ state = []
20
+
21
+ if File.exist?(file_normal)
22
+ file = file_normal
23
+ state.push(:has_ruby_model)
24
+ elsif File.exist?(file_custom)
25
+ file = file_custom
26
+ state.push(:has_ruby_model)
27
+ state.push(:non_conventional_name)
28
+ else
29
+ file = ''
30
+ file_exist = false
31
+ state.push(:model_not_found)
32
+ end
33
+
34
+ {
35
+ model_name: model_name,
36
+ table_name: table_name,
37
+ file: file,
38
+ exist: file_exist,
39
+ state: state.join(', ')
40
+ }
41
+ end
42
+ end
@@ -22,7 +22,7 @@ module KDomain
22
22
  json = File.read(source_file)
23
23
  data = KUtil.data.json_parse(json, as: :hash_symbolized)
24
24
 
25
- @data = KDomain::RawDbSchema::Schema.new(data)
25
+ @data = KDomain::Database::Schema.new(data)
26
26
  end
27
27
  end
28
28
  end
@@ -14,7 +14,6 @@ module KDomain
14
14
  attr_reader :template_file
15
15
  attr_reader :schema_loader
16
16
 
17
- # , target_file)
18
17
  def initialize(source_file)
19
18
  @source_file = source_file
20
19
  @template_file = 'lib/k_domain/raw_db_schema/template.rb'
@@ -70,12 +69,13 @@ module KDomain
70
69
  return
71
70
  end
72
71
 
73
- # load target_file
74
- eval schema_loader
72
+ eval(schema_loader)#, __FILE__, __LINE__)
75
73
 
76
74
  loader = LoadSchema.new
77
75
  loader.load_schema
78
- loader.schema
76
+ return loader.schema
77
+ rescue => ex
78
+ log.exception(ex)
79
79
  end
80
80
  # rubocop:enable Security/Eval
81
81
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KDomain
4
- module RawDbSchema
4
+ module Database
5
5
  class Column < Dry::Struct
6
6
  attribute :name , Types::Strict::String
7
7
  attribute :type , Types::Strict::String
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KDomain
4
- module RawDbSchema
4
+ module Database
5
5
  class Database < Dry::Struct
6
6
  attribute :type , Types::Strict::String
7
7
  attribute :version , Types::Nominal::Any.optional.default(nil)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KDomain
4
- module RawDbSchema
4
+ module Database
5
5
  class ForeignKey < Dry::Struct
6
6
  attribute :left , Types::Strict::String
7
7
  attribute :right , Types::Strict::String
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KDomain
4
- module RawDbSchema
4
+ module Database
5
5
  class Index < Dry::Struct
6
6
  attribute :name , Types::Strict::String
7
7
  attribute :fields , Types::Nominal::Any.optional.default('xxxxx1')
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KDomain
4
- module RawDbSchema
4
+ module Database
5
5
  class Schema < Dry::Struct
6
6
  class Meta < Dry::Struct
7
7
  attribute :rails , Types::Strict::Integer
8
- attribute :database , KDomain::RawDbSchema::Database
9
- attribute :unique_keys , Types::Strict::Array.of(KDomain::RawDbSchema::UniqueKey)
8
+ attribute :database , KDomain::Database::Database
9
+ attribute :unique_keys , Types::Strict::Array.of(KDomain::Database::UniqueKey)
10
10
  end
11
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
12
+ attribute :tables , Types::Strict::Array.of(KDomain::Database::Table)
13
+ attribute :foreign_keys? , Types::Strict::Array.of(KDomain::Database::ForeignKey)
14
+ attribute :indexes? , Types::Strict::Array.of(KDomain::Database::Index)
15
+ attribute :meta , KDomain::Database::Schema::Meta
16
16
  end
17
17
  end
18
18
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KDomain
4
- module RawDbSchema
4
+ module Database
5
5
  class Table < Dry::Struct
6
6
  class Meta < Dry::Struct
7
7
  attribute :primary_key , Types::Nominal::Any.optional.default(nil)
@@ -13,9 +13,9 @@ module KDomain
13
13
  attribute :primary_key , Types::Strict::String.optional.default(nil)
14
14
  attribute :primary_key_type , Types::Strict::String.optional.default(nil)
15
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
16
+ attribute :columns , Types::Strict::Array.of(KDomain::Database::Column)
17
+ attribute :indexes , Types::Strict::Array.of(KDomain::Database::Index)
18
+ attribute :rails_schema , KDomain::Database::Table::Meta
19
19
  end
20
20
  end
21
21
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KDomain
4
- module RawDbSchema
4
+ module Database
5
5
  # Keep a track of unique keys that appear in the data structures
6
6
  # so that we can track what new attributes to add to the models
7
7
  class UniqueKey < Dry::Struct
@@ -2,34 +2,14 @@
2
2
 
3
3
  # log.warn 'models->domain' if AppDebug.require?
4
4
 
5
- require_relative './dictionary/dictionary'
6
- require_relative './investigate/issue'
7
- require_relative './investigate/investigate'
5
+ require_relative './dictionary'
6
+ require_relative './investigate'
8
7
  require_relative './models/column'
9
8
  require_relative './models/model'
9
+ require_relative './erd_file'
10
10
  require_relative './domain'
11
11
  require_relative './schema'
12
12
 
13
- # require_relative './helper/domain_config'
14
- # require_relative './helper/main_key'
15
- # require_relative './helper/traits'
16
-
17
- # require_relative './belongs_to'
18
- # require_relative './domain_statistics'
19
- # # require_relative './domain_mapper'
20
- # require_relative './entity'
21
- # require_relative './entity_statistics'
22
- # require_relative './foreign_key'
23
- # require_relative './has_and_belongs_to_many'
24
- # require_relative './has_many'
25
- # require_relative './has_one'
26
- # require_relative './name_options'
27
- # require_relative './rails_model'
28
- # require_relative './related_entity'
29
- # require_relative './statistics'
30
- # require_relative './validate'
31
- # require_relative './validates'
32
-
33
13
  module KDomain
34
14
  module DomainModel
35
15
  RUBY_TYPE = {
@@ -5,6 +5,7 @@ module KDomain
5
5
  module DomainModel
6
6
  class Domain < Dry::Struct
7
7
  attribute :models , Types::Strict::Array.of(KDomain::DomainModel::Model)
8
+ attribute :erd_files , Types::Strict::Array.of(KDomain::DomainModel::ErdFile)
8
9
  attribute :dictionary , Types::Strict::Array.of(KDomain::DomainModel::Dictionary)
9
10
  end
10
11
  end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Domain class holds a list of the entities
4
+ module KDomain
5
+ module DomainModel
6
+ class ErdFile < Dry::Struct
7
+ attribute :name , Types::Strict::String
8
+ attribute :name_plural , Types::Strict::String
9
+ attribute :dsl_file , Types::Strict::String
10
+
11
+ attribute? :source , Dry::Struct.optional.default(nil) do
12
+ attribute :ruby , Types::Strict::String
13
+ attribute :public , Types::Strict::String.optional.default(nil)
14
+ attribute :private , Types::Strict::String.optional.default(nil)
15
+
16
+ attribute? :all_methods , Dry::Struct.optional.default(nil) do
17
+ attribute? :klass , Types::Strict::Array do
18
+ attribute :name , Types::Strict::String
19
+ attribute :scope , Types::Strict::String # .optional.default(nil)
20
+ attribute :class_method , Types::Strict::Bool
21
+ attribute :arguments , Types::Strict::String
22
+ end
23
+ attribute? :instance , Types::Strict::Array do
24
+ attribute :name , Types::Strict::String
25
+ attribute :scope , Types::Strict::String # .optional.default(nil)
26
+ attribute :class_method , Types::Strict::Bool
27
+ attribute :arguments , Types::Strict::String
28
+ end
29
+ attribute? :instance_public , Types::Strict::Array do
30
+ attribute :name , Types::Strict::String
31
+ attribute :scope , Types::Strict::String # .optional.default(nil)
32
+ attribute :class_method , Types::Strict::Bool
33
+ attribute :arguments , Types::Strict::String
34
+ end
35
+ attribute? :instance_private , Types::Strict::Array do
36
+ attribute :name , Types::Strict::String
37
+ attribute :scope , Types::Strict::String # .optional.default(nil)
38
+ attribute :class_method , Types::Strict::Bool
39
+ attribute :arguments , Types::Strict::String
40
+ end
41
+ end
42
+ end
43
+ attribute? :dsl , Dry::Struct.optional.default(nil) do
44
+ attribute :default_scope , Types::Strict::String.optional.default(nil)
45
+
46
+ attribute? :scopes , Types::Strict::Array do
47
+ attribute :name , Types::Strict::String
48
+ attribute :scope , Types::Strict::String # .optional.default(nil)
49
+ end
50
+ attribute? :belongs_to , Types::Strict::Array do
51
+ attribute :name , Types::Strict::String
52
+ attribute :options , Types::Strict::Hash.optional.default({}.freeze)
53
+ attribute :raw_options , Types::Strict::String
54
+ end
55
+ attribute? :has_one , Types::Strict::Array do
56
+ attribute :name , Types::Strict::String
57
+ attribute :options , Types::Strict::Hash.optional.default({}.freeze)
58
+ attribute :raw_options , Types::Strict::String
59
+ end
60
+ attribute? :has_many , Types::Strict::Array do
61
+ attribute :name , Types::Strict::String
62
+ attribute :options , Types::Strict::Hash.optional.default({}.freeze)
63
+ attribute :raw_options , Types::Strict::String
64
+ end
65
+ attribute? :has_and_belongs_to_many , Types::Strict::Array do
66
+ attribute :name , Types::Strict::String
67
+ attribute :options , Types::Strict::Hash.optional.default({}.freeze)
68
+ attribute :raw_options , Types::Strict::String
69
+ end
70
+ attribute? :validate_on , Types::Strict::Array do
71
+ attribute :line , Types::Strict::String
72
+ end
73
+ attribute? :validates_on , Types::Strict::Array do
74
+ attribute :name , Types::Strict::String
75
+ attribute :raw_options , Types::Strict::String
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Domain class holds a dictionary entry
4
+ module KDomain
5
+ module DomainModel
6
+ class Investigate < Dry::Struct
7
+ attribute :issues , Types::Strict::Array do
8
+ attribute :step , Types::Strict::String
9
+ attribute :location , Types::Strict::String
10
+ attribute :key , Types::Strict::String.optional.default(nil)
11
+ attribute :message , Types::Strict::String
12
+ end
13
+ end
14
+ end
15
+ end
@@ -5,7 +5,8 @@ module KDomain
5
5
  module DomainModel
6
6
  class Schema < Dry::Struct
7
7
  attribute :domain , KDomain::DomainModel::Domain
8
- attribute :database , KDomain::RawDbSchema::Schema
8
+ attribute :database , KDomain::Database::Schema
9
+ # attribute :rails_files , KDomain::RailsFiles::Schema
9
10
  attribute :investigate , KDomain::DomainModel::Investigate
10
11
  end
11
12
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KDomain
4
- VERSION = '0.0.5'
4
+ VERSION = '0.0.11'
5
5
  end
data/lib/k_domain.rb CHANGED
@@ -3,11 +3,13 @@
3
3
  require 'active_support/core_ext/string'
4
4
  require 'dry-struct'
5
5
  require 'k_log'
6
+ require 'peeky'
6
7
  require 'k_domain/version'
7
- require 'k_domain/raw_db_schema/dtos/_'
8
+ require 'k_domain/schemas/database/_'
9
+ require 'k_domain/schemas/domain/_'
10
+
8
11
  require 'k_domain/raw_db_schema/transform'
9
12
  require 'k_domain/raw_db_schema/load'
10
- require 'k_domain/domain_model/dtos/_'
11
13
  require 'k_domain/domain_model/transform'
12
14
  require 'k_domain/domain_model/transform_steps/_'
13
15
  require 'k_domain/domain_model/load'
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.5
4
+ version: 0.0.11
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-09-28 00:00:00.000000000 Z
11
+ date: 2021-10-01 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,17 +104,42 @@ 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/raw_db_schema/dtos/_.rb
118
- - lib/k_domain/raw_db_schema/dtos/column.rb
119
- - lib/k_domain/raw_db_schema/dtos/database.rb
120
- - lib/k_domain/raw_db_schema/dtos/foreign_key.rb
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_locate_rails_models.rb
125
108
  - lib/k_domain/raw_db_schema/load.rb
126
109
  - lib/k_domain/raw_db_schema/template.rb
127
110
  - lib/k_domain/raw_db_schema/transform.rb
111
+ - lib/k_domain/schemas/database/_.rb
112
+ - lib/k_domain/schemas/database/column.rb
113
+ - lib/k_domain/schemas/database/database.rb
114
+ - lib/k_domain/schemas/database/foreign_key.rb
115
+ - lib/k_domain/schemas/database/index.rb
116
+ - lib/k_domain/schemas/database/schema.rb
117
+ - lib/k_domain/schemas/database/table.rb
118
+ - lib/k_domain/schemas/database/unique_key.rb
119
+ - lib/k_domain/schemas/domain/_.rb
120
+ - lib/k_domain/schemas/domain/dictionary.rb
121
+ - lib/k_domain/schemas/domain/domain.rb
122
+ - lib/k_domain/schemas/domain/erd_file.rb
123
+ - lib/k_domain/schemas/domain/investigate.rb
124
+ - lib/k_domain/schemas/domain/models/column.rb
125
+ - lib/k_domain/schemas/domain/models/model.rb
126
+ - lib/k_domain/schemas/domain/old/belongs_to.rb
127
+ - lib/k_domain/schemas/domain/old/column_old.rb
128
+ - lib/k_domain/schemas/domain/old/domain_statistics.rb
129
+ - lib/k_domain/schemas/domain/old/entity.rb
130
+ - lib/k_domain/schemas/domain/old/entity_statistics.rb
131
+ - lib/k_domain/schemas/domain/old/foreign_key.rb
132
+ - lib/k_domain/schemas/domain/old/has_and_belongs_to_many.rb
133
+ - lib/k_domain/schemas/domain/old/has_many.rb
134
+ - lib/k_domain/schemas/domain/old/has_one.rb
135
+ - lib/k_domain/schemas/domain/old/name_options.rb
136
+ - lib/k_domain/schemas/domain/old/rails_controller.rb
137
+ - lib/k_domain/schemas/domain/old/rails_model.rb
138
+ - lib/k_domain/schemas/domain/old/related_entity.rb
139
+ - lib/k_domain/schemas/domain/old/statistics.rb
140
+ - lib/k_domain/schemas/domain/old/validate.rb
141
+ - lib/k_domain/schemas/domain/old/validates.rb
142
+ - lib/k_domain/schemas/domain/schema.rb
128
143
  - lib/k_domain/version.rb
129
144
  homepage: http://appydave.com/gems/k-domain
130
145
  licenses:
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Domain class holds a dictionary entry
4
- module KDomain
5
- module DomainModel
6
- class Investigate < Dry::Struct
7
- attribute :issues , Types::Strict::Array.of(KDomain::DomainModel::Issue)
8
- end
9
- end
10
- 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