k_domain 0.0.20 → 0.0.27

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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/.builders/boot.rb +40 -0
  3. data/.builders/generators/configuration_generator.rb +22 -0
  4. data/.builders/run.rb +16 -0
  5. data/.github/workflows/main.yml +5 -3
  6. data/.gitignore +2 -0
  7. data/.rubocop.yml +9 -5
  8. data/Gemfile +1 -1
  9. data/Guardfile +1 -0
  10. data/README.md +15 -0
  11. data/k_domain.gemspec +1 -1
  12. data/lib/k_domain/config/_.rb +4 -0
  13. data/lib/k_domain/config/config.rb +19 -0
  14. data/lib/k_domain/config/configuration.rb +76 -0
  15. data/lib/k_domain/domain_model/build_rich_models.rb +64 -0
  16. data/lib/k_domain/domain_model/load.rb +44 -1
  17. data/lib/k_domain/domain_model/transform.rb +28 -16
  18. data/lib/k_domain/domain_model/transform_steps/_.rb +7 -5
  19. data/lib/k_domain/domain_model/transform_steps/step.rb +20 -0
  20. data/lib/k_domain/domain_model/transform_steps/{step1_attach_db_schema.rb → step1_db_schema.rb} +2 -1
  21. data/lib/k_domain/domain_model/transform_steps/{step6_attach_dictionary.rb → step20_dictionary.rb} +6 -6
  22. data/lib/k_domain/domain_model/transform_steps/step2_domain_models.rb +123 -0
  23. data/lib/k_domain/domain_model/transform_steps/step4_rails_resource_models.rb +3 -3
  24. data/lib/k_domain/domain_model/transform_steps/step5_rails_resource_routes.rb +36 -0
  25. data/lib/k_domain/domain_model/transform_steps/step6_rails_structure_models.rb +91 -0
  26. data/lib/k_domain/domain_model/transform_steps/step7_rails_structure_controllers.rb +114 -0
  27. data/lib/k_domain/domain_model/transform_steps/step8_domain_columns.rb +99 -0
  28. data/lib/k_domain/queries/_.rb +4 -0
  29. data/lib/k_domain/queries/base_query.rb +13 -0
  30. data/lib/k_domain/queries/domain_model_query.rb +88 -0
  31. data/lib/k_domain/rails_code_extractor/_.rb +5 -0
  32. data/lib/k_domain/rails_code_extractor/extract_controller.rb +61 -0
  33. data/lib/k_domain/rails_code_extractor/extract_model.rb +21 -8
  34. data/lib/k_domain/rails_code_extractor/shim_loader.rb +4 -1
  35. data/lib/k_domain/raw_db_schema/load.rb +1 -1
  36. data/lib/k_domain/raw_db_schema/transform.rb +28 -3
  37. data/lib/k_domain/schemas/_.rb +5 -3
  38. data/lib/k_domain/schemas/database.rb +86 -0
  39. data/lib/k_domain/schemas/domain/erd_file.rb +78 -77
  40. data/lib/k_domain/schemas/domain.rb +153 -0
  41. data/lib/k_domain/schemas/{domain/_.rb → domain_types.rb} +1 -8
  42. data/lib/k_domain/schemas/{domain_model.rb → main_dataset.rb} +4 -4
  43. data/lib/k_domain/schemas/rails_resource.rb +43 -6
  44. data/lib/k_domain/schemas/rails_structure.rb +104 -14
  45. data/lib/k_domain/version.rb +1 -1
  46. data/lib/k_domain.rb +7 -3
  47. data/templates/custom/action_controller.rb +7 -0
  48. data/templates/custom/controller_interceptors.rb +80 -0
  49. data/templates/custom/model_interceptors.rb +95 -0
  50. data/templates/load_schema.rb +7 -0
  51. data/templates/rails/action_controller.rb +301 -0
  52. data/templates/{active_record_shims.rb → rails/active_record.rb} +23 -41
  53. data/templates/ruby_code_extractor/attach_class_info.rb +13 -0
  54. data/templates/ruby_code_extractor/behaviour_accessors.rb +39 -0
  55. data/templates/sample_config.rb +47 -0
  56. data/templates/simple/controller_interceptors.rb +2 -0
  57. metadata +36 -21
  58. data/lib/k_domain/domain_model/transform_steps/step2_attach_models.rb +0 -62
  59. data/lib/k_domain/domain_model/transform_steps/step3_attach_columns.rb +0 -137
  60. data/lib/k_domain/domain_model/transform_steps/step5_rails_models.rb +0 -71
  61. data/lib/k_domain/schemas/database/_.rb +0 -7
  62. data/lib/k_domain/schemas/database/foreign_key.rb +0 -14
  63. data/lib/k_domain/schemas/database/index.rb +0 -14
  64. data/lib/k_domain/schemas/database/schema.rb +0 -31
  65. data/lib/k_domain/schemas/database/table.rb +0 -32
  66. data/lib/k_domain/schemas/domain/domain.rb +0 -11
  67. data/lib/k_domain/schemas/domain/models/column.rb +0 -49
  68. data/lib/k_domain/schemas/domain/models/model.rb +0 -111
  69. data/templates/fake_module_shims.rb +0 -42
@@ -0,0 +1,301 @@
1
+ # Implement data capture methods for the Rails Action Controller class
2
+ #
3
+ # This Shim will intercept any DSL methods and convert their paramaters into a data hash
4
+ module ActionController
5
+ extend RubyCodeExtractor::AttachClassInfo
6
+
7
+ class Base
8
+ extend RubyCodeExtractor::BehaviourAccessors
9
+
10
+ def self.singleton_class
11
+ Class.new do
12
+ def send(*_p, **_o); end
13
+ end.new
14
+ end
15
+
16
+ def self.class_info
17
+ return ActionController.class_info if ActionController.class_info
18
+
19
+ ActionController.class_info = {
20
+ class_name: name
21
+ }
22
+ end
23
+
24
+ def self.after_action(name, **opts)
25
+ add(:after_action, {
26
+ name: name,
27
+ opts: opts
28
+ })
29
+ end
30
+
31
+ def self.around_action(name, **opts)
32
+ add(:around_action, {
33
+ name: name,
34
+ opts: opts
35
+ })
36
+ end
37
+
38
+ def self.before_action(name, **opts)
39
+ add(:before_action, {
40
+ name: name,
41
+ opts: opts
42
+ })
43
+ end
44
+
45
+ def self.prepend_before_action(name, **opts)
46
+ add(:prepend_before_action, {
47
+ name: name,
48
+ opts: opts
49
+ })
50
+ end
51
+
52
+ def self.skip_before_action(name, **opts)
53
+ add(:skip_before_action, {
54
+ name: name,
55
+ opts: opts
56
+ })
57
+ end
58
+
59
+ def self.before_filter(name, **opts)
60
+ add(:before_filter, {
61
+ name: name,
62
+ opts: opts
63
+ })
64
+ end
65
+
66
+ def self.skip_before_filter(name, **opts)
67
+ add(:skip_before_filter, {
68
+ name: name,
69
+ opts: opts
70
+ })
71
+ end
72
+
73
+ def self.layout(name, **opts)
74
+ set(:layout, {
75
+ name: name,
76
+ opts: opts
77
+ })
78
+ end
79
+
80
+ def self.rescue_from(type)#, &block)
81
+ # block_source = nil
82
+ # block_source = lambda_source(block, 'default_scope') if block_given?
83
+
84
+ add(:rescue_from, {
85
+ type: type#,
86
+ # block: block_source
87
+ })
88
+ end
89
+
90
+ # TODO: https://apidock.com/rails/ActionController/Helpers/ClassMethods/helper_method (MAYBE DEPRECATED?)
91
+ def self.helper_method(*names)
92
+ add(:helper_method, {
93
+ names: names
94
+ })
95
+ end
96
+
97
+ # TODO: https://apidock.com/rails/ActionController/Helpers/ClassMethods/helper
98
+ def self.helper(name)
99
+ add(:helper, {
100
+ name: name
101
+ })
102
+ end
103
+
104
+ def self.http_basic_authenticate_with(**opts)
105
+ set(:http_basic_authenticate_with, {
106
+ opts: opts
107
+ })
108
+ end
109
+
110
+ def self.protect_from_forgery(**opts)
111
+ set(:protect_from_forgery, {
112
+ opts: opts
113
+ })
114
+ end
115
+ end
116
+ end
117
+
118
+ # after_action
119
+ # after_filter
120
+ # append_after_action
121
+ # append_after_filter
122
+ # append_around_action
123
+ # append_around_filter
124
+ # append_before_action
125
+ # append_before_filter
126
+ # append_view_path
127
+ # around_action
128
+ # around_filter
129
+ # before_action
130
+ # before_filter
131
+ # controller_name
132
+ # controller_path
133
+ # helper
134
+ # helper_attr
135
+ # helper_method
136
+ # helpers
137
+ # helpers_path
138
+ # hide_action
139
+ # http_basic_authenticate_with
140
+ # layout
141
+ # prepend_after_action
142
+ # prepend_after_filter
143
+ # prepend_around_action
144
+ # prepend_around_filter
145
+ # prepend_before_action
146
+ # prepend_before_filter
147
+ # prepend_view_path
148
+ # protect_from_forgery
149
+ # protected_instance_variables
150
+ # rescue_from
151
+ # reset_callbacks
152
+ # skip_action_callback
153
+ # skip_after_action
154
+ # skip_after_filter
155
+ # skip_around_action
156
+ # skip_around_filter
157
+ # skip_before_action
158
+ # skip_before_filter
159
+ # skip_callback
160
+ # skip_filter
161
+
162
+ # METHOD LIST - Just from running self.class.methods - Object.methods on a running controller
163
+ # action
164
+ # action_methods
165
+ # add_flash_types
166
+ # after_action
167
+ # after_filter
168
+ # all_helpers_from_path
169
+ # allow_forgery_protection
170
+ # allow_forgery_protection=
171
+ # append_after_action
172
+ # append_after_filter
173
+ # append_around_action
174
+ # append_around_filter
175
+ # append_before_action
176
+ # append_before_filter
177
+ # append_view_path
178
+ # around_action
179
+ # around_filter
180
+ # asset_host
181
+ # asset_host=
182
+ # assets_dir
183
+ # assets_dir=
184
+ # before_action
185
+ # before_filter
186
+ # cache_store
187
+ # cache_store=
188
+ # call
189
+ # clear_action_methods!
190
+ # clear_helpers
191
+ # clear_respond_to
192
+ # config
193
+ # config_accessor
194
+ # configure
195
+ # controller_name
196
+ # controller_path
197
+ # default_asset_host_protocol
198
+ # default_asset_host_protocol=
199
+ # default_static_extension
200
+ # default_static_extension=
201
+ # default_url_options
202
+ # default_url_options=
203
+ # default_url_options?
204
+ # define_callbacks
205
+ # devise_group
206
+ # direct_descendants
207
+ # etag
208
+ # etag_with_template_digest
209
+ # etag_with_template_digest=
210
+ # etag_with_template_digest?
211
+ # etaggers
212
+ # etaggers=
213
+ # etaggers?
214
+ # force_ssl
215
+ # forgery_protection_strategy
216
+ # forgery_protection_strategy=
217
+ # get_callbacks
218
+ # helper
219
+ # helper_attr
220
+ # helper_method
221
+ # helpers
222
+ # helpers_path
223
+ # helpers_path=
224
+ # helpers_path?
225
+ # hidden_actions
226
+ # hidden_actions=
227
+ # hidden_actions?
228
+ # hide_action
229
+ # http_basic_authenticate_with
230
+ # include_all_helpers
231
+ # include_all_helpers=
232
+ # include_all_helpers?
233
+ # inherited
234
+ # internal_methods
235
+ # javascripts_dir
236
+ # javascripts_dir=
237
+ # layout
238
+ # log_process_action
239
+ # log_warning_on_csrf_failure
240
+ # log_warning_on_csrf_failure=
241
+ # logger
242
+ # logger=
243
+ # method_added
244
+ # middleware
245
+ # middleware_stack
246
+ # middleware_stack=
247
+ # middleware_stack?
248
+ # mimes_for_respond_to
249
+ # mimes_for_respond_to=
250
+ # mimes_for_respond_to?
251
+ # modules_for_helpers
252
+ # normalize_callback_params
253
+ # perform_caching
254
+ # perform_caching=
255
+ # prepend_after_action
256
+ # prepend_after_filter
257
+ # prepend_around_action
258
+ # prepend_around_filter
259
+ # prepend_before_action
260
+ # prepend_before_filter
261
+ # prepend_view_path
262
+ # protect_from_forgery
263
+ # protected_instance_variables
264
+ # relative_url_root
265
+ # relative_url_root=
266
+ # request_forgery_protection_token
267
+ # request_forgery_protection_token=
268
+ # rescue_from
269
+ # rescue_handlers
270
+ # rescue_handlers=
271
+ # rescue_handlers?
272
+ # reset_callbacks
273
+ # respond_to
274
+ # responder
275
+ # responder=
276
+ # responder?
277
+ # responders
278
+ # set_callback
279
+ # set_callbacks
280
+ # skip_action_callback
281
+ # skip_after_action
282
+ # skip_after_filter
283
+ # skip_around_action
284
+ # skip_around_filter
285
+ # skip_before_action
286
+ # skip_before_filter
287
+ # skip_callback
288
+ # skip_filter
289
+ # stylesheets_dir
290
+ # stylesheets_dir=
291
+ # supports_path?
292
+ # use
293
+ # use_renderer
294
+ # use_renderers
295
+ # view_cache_dependency
296
+ # view_context_class
297
+ # view_paths
298
+ # view_paths=
299
+ # visible_action?
300
+ # without_modules
301
+ # wrap_parameters
@@ -1,13 +1,11 @@
1
1
  module ActiveRecord
2
- def self.current_class
3
- @current_class ||= nil
4
- end
5
-
6
- def self.current_class=(value)
7
- @current_class = value
8
- end
2
+ extend RubyCodeExtractor::AttachClassInfo
9
3
 
10
4
  class Base
5
+ extend RubyCodeExtractor::BehaviourAccessors
6
+
7
+ def self.require(*_p, **_o); end
8
+
11
9
  def self.singleton_class
12
10
  Class.new do
13
11
  def send(*_p, **_o); end
@@ -15,42 +13,22 @@ module ActiveRecord
15
13
  end
16
14
 
17
15
  def self.class_info
18
- return ActiveRecord.current_class if ActiveRecord.current_class
16
+ return ActiveRecord.class_info if ActiveRecord.class_info
19
17
 
20
- ActiveRecord.current_class = {
18
+ ActiveRecord.class_info = {
21
19
  class_name: name
22
20
  }
23
21
  end
24
22
 
25
- def self.set(key, value)
26
- class_info[key] = class_info[key] || {}
27
- class_info[key] = value
28
- end
23
+ # -------------------------
24
+ # Intercept methods
25
+ # -------------------------
29
26
 
30
- def self.add(key, value)
31
- class_info[key] = class_info[key] || []
32
- if value.is_a?(Array)
33
- class_info[key] = class_info[key] + value
34
- else
35
- class_info[key] << value
36
- end
37
- end
27
+ def self.clear_active_connections!; end
38
28
 
39
- def self.custom_set(key, value = {})
40
- class_info[:custom] = {} unless class_info[:custom]
41
- class_info[:custom][key] = class_info[:custom][key] || {}
42
- class_info[:custom][key] = value
43
- end
44
-
45
- def self.custom_add(key, value)
46
- class_info[:custom] = {} unless class_info[:custom]
47
- class_info[:custom][key] = class_info[:custom][key] || []
48
- if value.is_a?(Array)
49
- class_info[:custom][key] = class_info[:custom][key] + value
50
- else
51
- class_info[:custom][key] << value
52
- end
53
- end
29
+ # -------------------------
30
+ # Behaviour storage methods
31
+ # -------------------------
54
32
 
55
33
  # examples:
56
34
  # enum status: { active: 0, archived: 1 }
@@ -133,11 +111,15 @@ module ActiveRecord
133
111
  def self.belongs_to(name, on_the_lamb = nil, **opts)
134
112
  lamb_source = lambda_source(on_the_lamb, "belongs_to :#{name},")
135
113
 
136
- add(:belongs_to, {
137
- name: name,
138
- opts: opts,
139
- block: lamb_source
140
- })
114
+ value = {
115
+ name: name,
116
+ opts: opts,
117
+ block: lamb_source
118
+ }
119
+
120
+ value[:opts][:foreign_key] = "#{name}_id" unless value[:opts][:foreign_key]
121
+
122
+ add(:belongs_to, value)
141
123
  end
142
124
 
143
125
  def self.has_many(name, on_the_lamb = nil, **opts)
@@ -0,0 +1,13 @@
1
+ module RubyCodeExtractor
2
+ # Class Info hash that contains the class name and any other key/values
3
+ # that could be useful when capturing Class information.
4
+ module AttachClassInfo
5
+ def class_info
6
+ @class_info ||= nil
7
+ end
8
+
9
+ def class_info=(value)
10
+ @class_info = value
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,39 @@
1
+ module RubyCodeExtractor
2
+ # When you intercept a method call, you can persist the captured paramaters
3
+ # into a Hash, the Hash Key should be the method name and the value should
4
+ # be a Hash with captured values.
5
+ #
6
+ # Use set/add for standard Rails DSL methods
7
+ # Use custom_set/custom_add for non standard or 3rd party GEM methods
8
+ module BehaviourAccessors
9
+ def set(key, value)
10
+ class_info[key] = class_info[key] || {}
11
+ class_info[key] = value
12
+ end
13
+
14
+ def add(key, value)
15
+ class_info[key] = class_info[key] || []
16
+ if value.is_a?(Array)
17
+ class_info[key] = class_info[key] + value
18
+ else
19
+ class_info[key] << value
20
+ end
21
+ end
22
+
23
+ def custom_set(key, value = {})
24
+ class_info[:custom] = {} unless class_info[:custom]
25
+ class_info[:custom][key] = class_info[:custom][key] || {}
26
+ class_info[:custom][key] = value
27
+ end
28
+
29
+ def custom_add(key, value)
30
+ class_info[:custom] = {} unless class_info[:custom]
31
+ class_info[:custom][key] = class_info[:custom][key] || []
32
+ if value.is_a?(Array)
33
+ class_info[:custom][key] = class_info[:custom][key] + value
34
+ else
35
+ class_info[:custom][key] << value
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,47 @@
1
+ KDomain.configure do |config|
2
+ config.default_main_key = nil
3
+ config.default_traits = %i[
4
+ trait1
5
+ trait2
6
+ trait3
7
+ ]
8
+
9
+ config.fallback_keys = %i[
10
+ name
11
+ category
12
+ description
13
+ global
14
+ key
15
+ klass
16
+ message
17
+ lead_source
18
+ body
19
+ status
20
+ subject
21
+ ]
22
+
23
+ config.register_entity(:action_log , main_key: :action)
24
+ config.register_entity(:backup , main_key: :filename)
25
+ config.register_entity(:campaign_calendar_entry , main_key: :date)
26
+ config.register_entity(:campaign_count , main_key: :total_count)
27
+ config.register_entity(:comment , main_key: :title)
28
+ config.register_entity(:contact_group , main_key: :email)
29
+ config.register_entity(:email_alias , main_key: :email)
30
+ config.register_entity(:unsubscribe , main_key: :email)
31
+ config.register_entity(:email_credential , main_key: :credentials)
32
+ config.register_entity(:email_soft_bounce , main_key: :email_address)
33
+ config.register_entity(:suppressed_address , main_key: :email_address)
34
+ config.register_entity(:email_template_value , main_key: :value)
35
+ config.register_entity(:email_validation , main_key: :address)
36
+ config.register_entity(:enterprise_togglefield , main_key: :field)
37
+ config.register_entity(:event_stat , main_key: :event_type)
38
+ config.register_entity(:holiday_date , main_key: :date)
39
+ config.register_entity(:job_stat , main_key: :job_name)
40
+ config.register_entity(:original_user , main_key: :target_user_id)
41
+ config.register_entity(:pending_attachment , main_key: :file_name)
42
+ config.register_entity(:sales_base_tax , main_key: :total)
43
+ config.register_entity(:shared_user , main_key: :shared_id)
44
+ config.register_entity(:task_repeat , main_key: :repeat_type)
45
+ config.register_entity(:user , main_key: :username)
46
+ config.register_entity(:token , main_key: :gmail_history_id)
47
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::Base
2
+ end
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.20
4
+ version: 0.0.27
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-10-04 00:00:00.000000000 Z
11
+ date: 2022-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -74,6 +74,9 @@ executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
+ - ".builders/boot.rb"
78
+ - ".builders/generators/configuration_generator.rb"
79
+ - ".builders/run.rb"
77
80
  - ".github/workflows/main.yml"
78
81
  - ".gitignore"
79
82
  - ".rspec"
@@ -95,32 +98,36 @@ files:
95
98
  - hooks/update-version
96
99
  - k_domain.gemspec
97
100
  - lib/k_domain.rb
101
+ - lib/k_domain/config/_.rb
102
+ - lib/k_domain/config/config.rb
103
+ - lib/k_domain/config/configuration.rb
104
+ - lib/k_domain/domain_model/build_rich_models.rb
98
105
  - lib/k_domain/domain_model/load.rb
99
106
  - lib/k_domain/domain_model/transform.rb
100
107
  - lib/k_domain/domain_model/transform_steps/_.rb
101
108
  - lib/k_domain/domain_model/transform_steps/step.rb
102
- - lib/k_domain/domain_model/transform_steps/step1_attach_db_schema.rb
103
- - lib/k_domain/domain_model/transform_steps/step2_attach_models.rb
104
- - lib/k_domain/domain_model/transform_steps/step3_attach_columns.rb
109
+ - lib/k_domain/domain_model/transform_steps/step1_db_schema.rb
110
+ - lib/k_domain/domain_model/transform_steps/step20_dictionary.rb
111
+ - lib/k_domain/domain_model/transform_steps/step2_domain_models.rb
105
112
  - lib/k_domain/domain_model/transform_steps/step4_rails_resource_models.rb
106
- - lib/k_domain/domain_model/transform_steps/step5_rails_models.rb
107
- - lib/k_domain/domain_model/transform_steps/step6_attach_dictionary.rb
113
+ - lib/k_domain/domain_model/transform_steps/step5_rails_resource_routes.rb
114
+ - lib/k_domain/domain_model/transform_steps/step6_rails_structure_models.rb
115
+ - lib/k_domain/domain_model/transform_steps/step7_rails_structure_controllers.rb
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
120
+ - lib/k_domain/rails_code_extractor/_.rb
121
+ - lib/k_domain/rails_code_extractor/extract_controller.rb
108
122
  - lib/k_domain/rails_code_extractor/extract_model.rb
109
123
  - lib/k_domain/rails_code_extractor/shim_loader.rb
110
124
  - lib/k_domain/raw_db_schema/load.rb
111
125
  - lib/k_domain/raw_db_schema/transform.rb
112
126
  - lib/k_domain/schemas/_.rb
113
- - lib/k_domain/schemas/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
127
+ - lib/k_domain/schemas/database.rb
118
128
  - lib/k_domain/schemas/dictionary.rb
119
- - lib/k_domain/schemas/domain/_.rb
120
- - lib/k_domain/schemas/domain/domain.rb
129
+ - lib/k_domain/schemas/domain.rb
121
130
  - lib/k_domain/schemas/domain/erd_file.rb
122
- - lib/k_domain/schemas/domain/models/column.rb
123
- - lib/k_domain/schemas/domain/models/model.rb
124
131
  - lib/k_domain/schemas/domain/old/belongs_to.rb
125
132
  - lib/k_domain/schemas/domain/old/column_old.rb
126
133
  - lib/k_domain/schemas/domain/old/domain_statistics.rb
@@ -137,14 +144,22 @@ files:
137
144
  - lib/k_domain/schemas/domain/old/statistics.rb
138
145
  - lib/k_domain/schemas/domain/old/validate.rb
139
146
  - lib/k_domain/schemas/domain/old/validates.rb
140
- - lib/k_domain/schemas/domain_model.rb
147
+ - lib/k_domain/schemas/domain_types.rb
141
148
  - lib/k_domain/schemas/investigate.rb
149
+ - lib/k_domain/schemas/main_dataset.rb
142
150
  - lib/k_domain/schemas/rails_resource.rb
143
151
  - lib/k_domain/schemas/rails_structure.rb
144
152
  - lib/k_domain/version.rb
145
- - templates/active_record_shims.rb
146
- - templates/fake_module_shims.rb
153
+ - templates/custom/action_controller.rb
154
+ - templates/custom/controller_interceptors.rb
155
+ - templates/custom/model_interceptors.rb
147
156
  - templates/load_schema.rb
157
+ - templates/rails/action_controller.rb
158
+ - templates/rails/active_record.rb
159
+ - templates/ruby_code_extractor/attach_class_info.rb
160
+ - templates/ruby_code_extractor/behaviour_accessors.rb
161
+ - templates/sample_config.rb
162
+ - templates/simple/controller_interceptors.rb
148
163
  homepage: http://appydave.com/gems/k-domain
149
164
  licenses:
150
165
  - MIT
@@ -160,14 +175,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
175
  requirements:
161
176
  - - ">="
162
177
  - !ruby/object:Gem::Version
163
- version: '2.5'
178
+ version: '2.7'
164
179
  required_rubygems_version: !ruby/object:Gem::Requirement
165
180
  requirements:
166
181
  - - ">="
167
182
  - !ruby/object:Gem::Version
168
183
  version: '0'
169
184
  requirements: []
170
- rubygems_version: 3.2.7
185
+ rubygems_version: 3.2.33
171
186
  signing_key:
172
187
  specification_version: 4
173
188
  summary: K Domain builds complex domain schemas by combining the database schema with
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Loop through the db_schema tables and build up a
4
- # basic model for each table
5
- class Step2AttachModels < KDomain::DomainModel::Step
6
- # Map database schema to domain model
7
- def call
8
- raise 'ERD path not supplied' if opts[:erd_path].nil?
9
-
10
- # Schema is re-shaped into a format designed for domain modeling
11
- domain[:models] = database_tables.map { |table| model(table) }
12
- end
13
-
14
- def model(table)
15
- table_name = table[:name].to_s
16
- model_name = table_name.singularize
17
-
18
- {
19
- name: model_name,
20
- name_plural: table_name, # need to check if this is correct as I know it is wrong for account_history_datum
21
- table_name: table_name,
22
- pk: primary_key(table),
23
- erd_location: location(table_name, model_name),
24
- statistics: {}, # Load in future step
25
- columns: [] # Load in future step
26
- }
27
- end
28
-
29
- def primary_key(table)
30
- {
31
- name: table[:primary_key],
32
- type: table[:primary_key_type],
33
- exist: !table[:primary_key].nil?
34
- }
35
- end
36
-
37
- # Location of source code
38
- def location(table_name, model_name)
39
- file_normal = File.join(opts[:erd_path], "#{model_name}.rb")
40
- file_custom = File.join(opts[:erd_path], "#{table_name}.rb")
41
- file_exist = true
42
- state = []
43
-
44
- if File.exist?(file_normal)
45
- file = file_normal
46
- state.push(:has_ruby_model)
47
- elsif File.exist?(file_custom)
48
- file = file_custom
49
- state.push(:has_ruby_model)
50
- state.push(:nonconventional_name)
51
- else
52
- file = ''
53
- file_exist = false
54
- end
55
-
56
- {
57
- file: file,
58
- exist: file_exist,
59
- state: state # display_state: state.join(' ')
60
- }
61
- end
62
- end