k_domain 0.0.14 → 0.0.23

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 (59) hide show
  1. checksums.yaml +4 -4
  2. data/.builders/config/_.rb +3 -0
  3. data/.builders/setup.rb +30 -0
  4. data/.gitignore +1 -0
  5. data/.rubocop.yml +4 -3
  6. data/Gemfile +1 -1
  7. data/Guardfile +1 -0
  8. data/README.md +15 -0
  9. data/STORIES.md +35 -6
  10. data/k_domain.gemspec +1 -1
  11. data/lib/k_domain/domain_model/load.rb +8 -2
  12. data/lib/k_domain/domain_model/transform.rb +34 -51
  13. data/lib/k_domain/domain_model/transform_steps/_.rb +8 -6
  14. data/lib/k_domain/domain_model/transform_steps/step.rb +47 -2
  15. data/lib/k_domain/domain_model/transform_steps/{step1_attach_db_schema.rb → step1_db_schema.rb} +2 -1
  16. data/lib/k_domain/domain_model/transform_steps/{step5_attach_dictionary.rb → step20_dictionary.rb} +7 -3
  17. data/lib/k_domain/domain_model/transform_steps/step2_domain_models.rb +123 -0
  18. data/lib/k_domain/domain_model/transform_steps/{step8_locate_rails_models.rb → step4_rails_resource_models.rb} +4 -4
  19. data/lib/k_domain/domain_model/transform_steps/step5_rails_resource_routes.rb +36 -0
  20. data/lib/k_domain/domain_model/transform_steps/step6_rails_structure_models.rb +90 -0
  21. data/lib/k_domain/domain_model/transform_steps/step7_rails_structure_controllers.rb +109 -0
  22. data/lib/k_domain/domain_model/transform_steps/{step3_attach_columns.rb → step8_domain_columns.rb} +40 -73
  23. data/lib/k_domain/rails_code_extractor/_.rb +5 -0
  24. data/lib/k_domain/rails_code_extractor/extract_controller.rb +59 -0
  25. data/lib/k_domain/rails_code_extractor/extract_model.rb +69 -0
  26. data/lib/k_domain/rails_code_extractor/shim_loader.rb +30 -0
  27. data/lib/k_domain/raw_db_schema/load.rb +8 -2
  28. data/lib/k_domain/raw_db_schema/transform.rb +9 -8
  29. data/lib/k_domain/schemas/_.rb +3 -2
  30. data/lib/k_domain/schemas/database.rb +86 -0
  31. data/lib/k_domain/schemas/domain/erd_file.rb +2 -0
  32. data/lib/k_domain/schemas/domain.rb +154 -0
  33. data/lib/k_domain/schemas/domain_model.rb +6 -5
  34. data/lib/k_domain/schemas/rails_resource.rb +43 -6
  35. data/lib/k_domain/schemas/rails_structure.rb +172 -0
  36. data/lib/k_domain/version.rb +1 -1
  37. data/lib/k_domain.rb +2 -0
  38. data/templates/custom/action_controller.rb +36 -0
  39. data/templates/custom/controller_interceptors.rb +78 -0
  40. data/templates/custom/model_interceptors.rb +71 -0
  41. data/templates/load_schema.rb +7 -0
  42. data/templates/old_printspeek_schema copy.rb +231 -0
  43. data/templates/old_printspeek_schema.rb +233 -0
  44. data/templates/rails/action_controller.rb +301 -0
  45. data/templates/rails/active_record.rb +348 -0
  46. data/templates/ruby_code_extractor/attach_class_info.rb +13 -0
  47. data/templates/ruby_code_extractor/behaviour_accessors.rb +39 -0
  48. data/templates/simple/controller_interceptors.rb +2 -0
  49. metadata +30 -17
  50. data/lib/k_domain/domain_model/transform_steps/step2_attach_models.rb +0 -62
  51. data/lib/k_domain/domain_model/transform_steps/step4_attach_erd_files.rb +0 -454
  52. data/lib/k_domain/schemas/database/_.rb +0 -7
  53. data/lib/k_domain/schemas/database/foreign_key.rb +0 -14
  54. data/lib/k_domain/schemas/database/index.rb +0 -14
  55. data/lib/k_domain/schemas/database/schema.rb +0 -31
  56. data/lib/k_domain/schemas/database/table.rb +0 -32
  57. data/lib/k_domain/schemas/domain/domain.rb +0 -11
  58. data/lib/k_domain/schemas/domain/models/column.rb +0 -49
  59. data/lib/k_domain/schemas/domain/models/model.rb +0 -111
@@ -3,6 +3,7 @@
3
3
  # Domain class holds a list of the entities
4
4
  module KDomain
5
5
  module DomainModel
6
+ # rubocop:disable Metrics/BlockLength
6
7
  class ErdFile < Dry::Struct
7
8
  attribute :name , Types::Strict::String
8
9
  attribute :name_plural , Types::Strict::String
@@ -76,5 +77,6 @@ module KDomain
76
77
  end
77
78
  end
78
79
  end
80
+ # rubocop:enable Metrics/BlockLength
79
81
  end
80
82
  end
@@ -0,0 +1,154 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Domain class holds a list of the entities
4
+ module KDomain
5
+ module Schemas
6
+ class Domain < Dry::Struct
7
+ class Model < Dry::Struct
8
+ class Column < Dry::Struct
9
+ attribute :name , Types::Strict::String # "source_account_id"
10
+ attribute :name_plural , Types::Strict::String # "source_account_ids"
11
+ attribute :type , Types::Coercible::Symbol # "integer"
12
+ attribute :precision , Types::Strict::Integer.optional.default(nil) # null
13
+ attribute :scale , Types::Strict::Integer.optional.default(nil) # null
14
+ attribute :default , Types::Nominal::Any.optional.default(nil) # null
15
+ attribute :null , Types::Nominal::Any.optional.default(nil) # null
16
+ attribute :limit , Types::Strict::Integer.optional.default(nil) # null
17
+ attribute :array , Types::Strict::Bool.optional.default(nil) # null
18
+
19
+ # Calculated value
20
+ attribute :structure_type , Types::Coercible::Symbol #
21
+ # attribute :foreign_key , Types::Strict::Bool.optional.default(nil) #
22
+ # attribute :foreign_table , Types::Strict::String #
23
+ # attribute :foreign_table_plural , Types::Strict::String #
24
+
25
+ # def data_column
26
+ # @columns_data ||= structure_type?(:data)
27
+ # end
28
+
29
+ # def structure_type?(*structure_types)
30
+ # structure_types.include?(column.structure_type)
31
+ # end
32
+
33
+ def db_type
34
+ return @db_type if defined? @db_type
35
+
36
+ @db_type = DB_TYPE[type] || '******'
37
+ end
38
+
39
+ def ruby_type
40
+ return @ruby_type if defined? @ruby_type
41
+
42
+ @ruby_type = RUBY_TYPE[type] || '******'
43
+ end
44
+
45
+ def csharp_type
46
+ return @csharp_type if defined? @csharp_type
47
+
48
+ @csharp_type = CSHARP_TYPE[type] || '******'
49
+ end
50
+ end
51
+
52
+ class Pk < Dry::Struct
53
+ attribute :name , Types::Strict::String.optional.default(nil)
54
+ attribute :type , Types::Strict::String.optional.default(nil)
55
+ attribute :exist , Types::Strict::Bool
56
+ end
57
+
58
+ attribute :name , Types::Strict::String
59
+ attribute :name_plural , Types::Strict::String
60
+ attribute :table_name , Types::Strict::String
61
+ # Model type - :entity, :basic_user, :admin_user, possibly: m2m, agg_root
62
+ attribute :type , Types::Strict::Symbol.optional.default(:entity)
63
+ attribute :pk , KDomain::Schemas::Domain::Model::Pk
64
+ attribute :columns , Types::Strict::Array.of(KDomain::Schemas::Domain::Model::Column)
65
+ attribute :file , Types::Strict::String.optional.default(nil)
66
+
67
+ def ruby?
68
+ file && File.exist?(file)
69
+ end
70
+
71
+ def pk?
72
+ pk.exist
73
+ end
74
+
75
+ # If filled in, the model has a main field that is useful for rendering and may be used for unique constraint, may also be called display_name
76
+ def main_key
77
+ @main_key ||= MainKey.lookup(name, columns_data)
78
+ end
79
+
80
+ def traits
81
+ @traits ||= Traits.lookup(name)
82
+ end
83
+
84
+ # def where()
85
+ # end
86
+
87
+ # def columns_where()
88
+ # end
89
+
90
+ # Column filters
91
+
92
+ def columns_data
93
+ @columns_data ||= columns_for_structure_types(:data)
94
+ end
95
+
96
+ # def columns_data_optional
97
+ # @columns_data_optional ||= columns_for_structure_types(:data).select { |c| true }
98
+ # end
99
+
100
+ # def columns_data_required
101
+ # @columns_data_required ||= columns_for_structure_types(:data).select { |c| false }
102
+ # end
103
+
104
+ def columns_primary
105
+ @columns_primary ||= columns_for_structure_types(:primary_key)
106
+ end
107
+
108
+ def columns_foreign
109
+ @columns_foreign ||= columns_for_structure_types(:foreign_key)
110
+ end
111
+
112
+ def columns_timestamp
113
+ @columns_data_timestamp ||= columns_for_structure_types(:timestamp)
114
+ end
115
+
116
+ def columns_deleted_at
117
+ @columns_data_deleted_at ||= columns_for_structure_types(:deleted_at)
118
+ end
119
+
120
+ def columns_virtual
121
+ @columns_virtual ||= columns_for_structure_types(:timestamp, :deleted_at)
122
+ end
123
+
124
+ def columns_data_foreign
125
+ @columns_data_foreign ||= columns_for_structure_types(:data, :foreign_key)
126
+ end
127
+ alias rows_fields_and_fk columns_data_foreign
128
+
129
+ def columns_data_primary
130
+ @columns_data_primary ||= columns_for_structure_types(:data, :primary_key)
131
+ end
132
+ alias rows_fields_and_pk columns_data_primary
133
+
134
+ def columns_data_virtual
135
+ @columns_data_virtual ||= columns_for_structure_types(:data, :timestamp, :deleted_at)
136
+ end
137
+ alias rows_fields_and_virtual columns_data_virtual
138
+
139
+ def columns_data_foreign_virtual
140
+ @columns_data_foreign_virtual ||= columns_for_structure_types(:data, :foreign_key, :timestamp, :deleted_at)
141
+ end
142
+
143
+ private
144
+
145
+ def columns_for_structure_types(*structure_types)
146
+ columns.select { |column| structure_types.include?(column.structure_type) }
147
+ end
148
+ end
149
+
150
+ attribute :models , Types::Strict::Array.of(KDomain::Schemas::Domain::Model)
151
+ # attribute :erd_files , Types::Strict::Array.of(KDomain::DomainModel::ErdFile)
152
+ end
153
+ end
154
+ end
@@ -4,11 +4,12 @@
4
4
  module KDomain
5
5
  module Schemas
6
6
  class DomainModel < Dry::Struct
7
- attribute :domain , KDomain::DomainModel::Domain
8
- attribute :database , KDomain::Database::Schema
9
- attribute :dictionary , KDomain::Schemas::Dictionary
10
- attribute :rails_resource , KDomain::Schemas::RailsResource
11
- attribute :investigate , KDomain::Schemas::Investigate
7
+ attribute :domain , KDomain::Schemas::Domain
8
+ attribute :database , KDomain::Schemas::Database
9
+ attribute :dictionary , KDomain::Schemas::Dictionary
10
+ attribute :rails_resource , KDomain::Schemas::RailsResource
11
+ attribute :rails_structure , KDomain::Schemas::RailsStructure
12
+ attribute :investigate , KDomain::Schemas::Investigate
12
13
  end
13
14
  end
14
15
  end
@@ -3,13 +3,50 @@
3
3
  # Domain class holds a dictionary entry
4
4
  module KDomain
5
5
  module Schemas
6
+ # Route related files
7
+ module Types
8
+ include Dry.Types()
9
+
10
+ Verb = Strict::String.enum('', 'GET', 'PATCH', 'POST', 'PUT', 'DELETE')
11
+ end
12
+
13
+ class Route < Dry::Struct
14
+ attribute :name , Types::String
15
+ attribute :controller_name , Types::String
16
+ attribute :controller_path , Types::String
17
+ attribute :controller_namespace , Types::String
18
+ attribute :controller_file , Types::String
19
+ attribute :controller_exist , Types::Bool
20
+ attribute :action , Types::String.optional
21
+ attribute :uri_path , Types::String
22
+ attribute :mime_match , Types::String
23
+ attribute :verbs , Types.Array(Types::Verb)
24
+ attribute :file , Types::String
25
+ attribute :exist , Types::Bool
26
+ attribute :duplicate_verb , Types::Bool
27
+ end
28
+
29
+ # Model related files
30
+ class Model < Dry::Struct
31
+ attribute :model_name , Types::String
32
+ attribute :table_name , Types::String
33
+ attribute :file , Types::String
34
+ attribute :exist , Types::Bool
35
+ attribute :state , Types::String
36
+ end
37
+
6
38
  class RailsResource < Dry::Struct
7
- attribute :models , Types::Strict::Array do
8
- attribute :model_name , Types::Strict::String
9
- attribute :table_name , Types::Strict::String
10
- attribute :file , Types::Strict::String
11
- attribute :exist , Types::Strict::Bool
12
- attribute :state , Types::Strict::String
39
+ attribute :models, Types.Array(Model)
40
+ attribute :routes, Types.Array(Route)
41
+
42
+ # def find_route(name)
43
+ # name = name.to_s
44
+ # routes.find { |route| route.name.to_s == name }
45
+ # end
46
+
47
+ def find_model(name)
48
+ name = name.to_s
49
+ models.find { |model| model.model_name.to_s == name }
13
50
  end
14
51
  end
15
52
  end
@@ -0,0 +1,172 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Domain class holds a dictionary entry
4
+ module KDomain
5
+ module Schemas
6
+ class RailsStructure < Dry::Struct
7
+ class DefaultScope < Dry::Struct
8
+ attribute :block? , Types::Strict::String
9
+ end
10
+
11
+ class NameOptsType < Dry::Struct
12
+ attribute :name? , Types::Strict::String | Types::Strict::Bool
13
+ attribute :opts? , Types::Strict::Hash
14
+ attribute :block? , Types::Strict::String.optional.default(nil)
15
+ end
16
+
17
+ class OptsType < Dry::Struct
18
+ attribute :opts? , Types::Strict::Hash
19
+ end
20
+
21
+ # Model Behaviours
22
+ class Scope < KDomain::Schemas::RailsStructure::NameOptsType; end
23
+
24
+ class BelongsTo < KDomain::Schemas::RailsStructure::NameOptsType; end
25
+
26
+ class HasOne < KDomain::Schemas::RailsStructure::NameOptsType; end
27
+
28
+ class HasMany < KDomain::Schemas::RailsStructure::NameOptsType; end
29
+
30
+ class HasAndBelongsToMany < KDomain::Schemas::RailsStructure::NameOptsType; end
31
+
32
+ class Validate < Dry::Struct
33
+ attribute :names? , Types::Array.of(Types::Strict::String)
34
+ attribute :opts? , Types::Strict::Hash
35
+ attribute :block? , Types::Strict::String.optional.default(nil)
36
+ end
37
+
38
+ class Validates < KDomain::Schemas::RailsStructure::NameOptsType
39
+ end
40
+
41
+ class ModelBehaviours < Dry::Struct
42
+ attribute :class_name? , Types::Strict::String
43
+ attribute :default_scope? , KDomain::Schemas::RailsStructure::DefaultScope
44
+ attribute :scopes? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::Scope)
45
+ attribute :belongs_to? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::BelongsTo)
46
+ attribute :has_one? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::HasOne)
47
+ attribute :has_many? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::HasMany)
48
+ attribute :has_and_belongs_to_many? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::HasAndBelongsToMany)
49
+ attribute :validate? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::Validate)
50
+ attribute :validates? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::Validates)
51
+ attribute :attr_accessor? , Types::Array.of(Types::Strict::String)
52
+ attribute :attr_reader? , Types::Array.of(Types::Strict::String)
53
+ attribute :attr_writer? , Types::Array.of(Types::Strict::String)
54
+ end
55
+
56
+ class Method < Dry::Struct
57
+ attribute :name , Types::Strict::String
58
+ end
59
+
60
+ class Functions < Dry::Struct
61
+ attribute :class_name? , Types::Strict::String
62
+ attribute :module_name? , Types::Strict::String
63
+ attribute :class_full_name? , Types::Strict::String
64
+ attribute :attr_accessor? , Types::Array.of(Types::Strict::String)
65
+ attribute :attr_reader? , Types::Array.of(Types::Strict::String)
66
+ attribute :attr_writer? , Types::Array.of(Types::Strict::String)
67
+ attribute :klass? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::Method)
68
+ attribute :instance_public? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::Method)
69
+ attribute :instance_private? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::Method)
70
+ end
71
+
72
+ class Model < Dry::Struct
73
+ attribute :model_name , Types::Strict::String
74
+ attribute :table_name , Types::Strict::String
75
+ attribute :file , Types::Strict::String
76
+ attribute :exist , Types::Strict::Bool
77
+ attribute :state , Types::Strict::String
78
+ attribute :code , Types::Strict::String
79
+ attribute :behaviours? , KDomain::Schemas::RailsStructure::ModelBehaviours
80
+ attribute :functions? , KDomain::Schemas::RailsStructure::Functions
81
+ end
82
+
83
+ # Controller Behaviours
84
+ class AfterAction < KDomain::Schemas::RailsStructure::NameOptsType; end
85
+
86
+ class AroundAction < KDomain::Schemas::RailsStructure::NameOptsType; end
87
+
88
+ class BeforeAction < KDomain::Schemas::RailsStructure::NameOptsType; end
89
+
90
+ # rubocop:disable Naming/ClassAndModuleCamelCase
91
+ class Prepend_beforeAction < KDomain::Schemas::RailsStructure::NameOptsType; end
92
+
93
+ class Skip_beforeAction < KDomain::Schemas::RailsStructure::NameOptsType; end
94
+ # rubocop:enable Naming/ClassAndModuleCamelCase
95
+
96
+ class BeforeFilter < KDomain::Schemas::RailsStructure::NameOptsType; end
97
+
98
+ class SkipBeforeFilter < KDomain::Schemas::RailsStructure::NameOptsType; end
99
+
100
+ class Layout < KDomain::Schemas::RailsStructure::NameOptsType; end
101
+
102
+ class HttpBasicAuthenticateWith < KDomain::Schemas::RailsStructure::OptsType; end
103
+
104
+ class ProtectFromForgery < KDomain::Schemas::RailsStructure::OptsType; end
105
+
106
+ class RescueFrom < Dry::Struct
107
+ attribute :type , Types::Strict::String
108
+ end
109
+
110
+ class HelperMethod < Dry::Struct
111
+ attribute :names , Types::Strict::Array.of(Types::Strict::String)
112
+ end
113
+
114
+ class Helper < Dry::Struct
115
+ attribute :name , Types::Strict::String
116
+ end
117
+
118
+ class ControllerBehaviours < Dry::Struct
119
+ attribute :class_name? , Types::Strict::String
120
+ attribute :after_action? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::AfterAction)
121
+ attribute :around_action? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::AroundAction)
122
+ attribute :before_action? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::BeforeAction)
123
+ attribute :prepend_before_action? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::Prepend_beforeAction)
124
+ attribute :skip_before_action? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::Skip_beforeAction)
125
+ attribute :before_filter? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::BeforeFilter)
126
+ attribute :skip_before_filter? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::SkipBeforeFilter)
127
+ attribute :layout? , KDomain::Schemas::RailsStructure::Layout
128
+ attribute :http_basic_authenticate_with? , KDomain::Schemas::RailsStructure::OptsType
129
+ attribute :protect_from_forgery? , KDomain::Schemas::RailsStructure::OptsType
130
+
131
+ attribute :rescue_from? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::RescueFrom)
132
+ attribute :helper_method? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::HelperMethod)
133
+ attribute :helper? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::Helper)
134
+ end
135
+
136
+ class ControllerActions < Dry::Struct
137
+ attribute :route_name? , Types::Strict::String
138
+ attribute :action? , Types::String.optional
139
+ attribute :uri_path? , Types::String
140
+ attribute :mime_match? , Types::String
141
+ attribute :verbs? , Types.Array(Types::Verb)
142
+ end
143
+
144
+ class Controller < Dry::Struct
145
+ attribute :name , Types::String
146
+ attribute :path , Types::String
147
+ attribute :namespace , Types::String
148
+ attribute :file , Types::String
149
+ attribute :exist , Types::Bool
150
+ attribute :full_file , Types::String
151
+ attribute :behaviours? , KDomain::Schemas::RailsStructure::ControllerBehaviours
152
+ attribute :functions? , KDomain::Schemas::RailsStructure::Functions
153
+ attribute :actions? , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::ControllerActions)
154
+ end
155
+
156
+ attribute :models , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::Model)
157
+ attribute :controllers , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::Controller)
158
+
159
+ def find_controller(path)
160
+ path = path.to_s
161
+ controllers.find { |controller| controller.path.to_s == path }
162
+ end
163
+
164
+ def find_model(name)
165
+ name = name.to_s
166
+ models.find { |model| model.model_name.to_s == name }
167
+ end
168
+ end
169
+ end
170
+ end
171
+
172
+ # attribute :domain , KDomain::DomainModel::Domain
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KDomain
4
- VERSION = '0.0.14'
4
+ VERSION = '0.0.23'
5
5
  end
data/lib/k_domain.rb CHANGED
@@ -11,6 +11,7 @@ require 'k_domain/raw_db_schema/load'
11
11
  require 'k_domain/domain_model/transform'
12
12
  require 'k_domain/domain_model/transform_steps/_'
13
13
  require 'k_domain/domain_model/load'
14
+ require 'k_domain/rails_code_extractor/_'
14
15
 
15
16
  # # This is useful if you want to initialize structures via Hash
16
17
  # class SymbolizeStruct < Dry::Struct
@@ -25,6 +26,7 @@ module KDomain
25
26
  def self.root
26
27
  File.expand_path('..', File.dirname(__FILE__))
27
28
  end
29
+
28
30
  def self.resource(resource_path)
29
31
  File.join(root, resource_path)
30
32
  end
@@ -0,0 +1,36 @@
1
+ module ActionController
2
+ class Base
3
+ def self.require(require)
4
+ add(:require, require)
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
+ end
36
+ end
@@ -0,0 +1,78 @@
1
+ class Rails
2
+ def self.env; end
3
+
4
+ def self.application
5
+ OpenStruct.new(
6
+ secrets: OpenStruct.new(
7
+ credentials_secret_key: Base64.encode64('ABC'),
8
+ aws_secret_access_key: Base64.encode64('ABC')
9
+ )
10
+ )
11
+ end
12
+ end
13
+ class RegionConfig
14
+ def self.require_value(*_p, **_o, &block); end
15
+ end
16
+
17
+ class ApplicationController < ActionController::Base
18
+ end
19
+
20
+ module Admin
21
+ class BaseController < ActionController::Base
22
+ end
23
+ end
24
+
25
+ module Api
26
+ module V1
27
+ class BaseController < ActionController::Base
28
+ end
29
+ end
30
+ end
31
+
32
+ module Enterprises
33
+ class BaseController < ActionController::Base
34
+ end
35
+ end
36
+
37
+ module Portal
38
+ class BaseController < ApplicationController
39
+ end
40
+ end
41
+
42
+ module ActiveRecord
43
+ class RecordNotFound
44
+ end
45
+ end
46
+
47
+ module Aws
48
+ class Credentials
49
+ def initialize(*_p, **_o, &block); end
50
+ end
51
+ module S3
52
+ class Client
53
+ def initialize(*_p, **_o, &block); end
54
+ end
55
+ end
56
+ end
57
+
58
+ module Devise
59
+ class SessionsController < ActionController::Base
60
+ end
61
+ class Mapping
62
+ def self.find_scope!(*_p, **_o); end
63
+ end
64
+ end
65
+
66
+ module Respondable; end
67
+ module ContactUpdateable; end
68
+ module SalesRepUpdateable; end
69
+ module MIME; end
70
+ module MaterialIconsHelper; end
71
+ module LocationUpdateable; end
72
+ module WantedByUpdateable; end
73
+ module FollowUpUpdateable; end
74
+ module EstimateArchiveUpdateable; end
75
+ module ContextContactUpdateable; end
76
+ module ProofDateUpdateable; end
77
+ module PoUpdateable; end
78
+ module SalesRepUpdateable; end
@@ -0,0 +1,71 @@
1
+ class Rails
2
+ def self.env; end
3
+
4
+ def self.application
5
+ OpenStruct.new(secrets: OpenStruct.new(credentials_secret_key: Base64.encode64('ABC')))
6
+ end
7
+ end
8
+
9
+ module ActsAsCommentable
10
+ module Comment
11
+ end
12
+ end
13
+
14
+ module Scopes
15
+ module CompanyScopes
16
+ end
17
+ end
18
+
19
+ class Thread
20
+ def initialize(*_p, **_o, &block); end
21
+ end
22
+
23
+ class ApplicationRecord < ActiveRecord::Base
24
+ end
25
+
26
+ class Email < ActiveRecord::Base
27
+ def self.ses_send(*_p, **_o); end
28
+ end
29
+
30
+ module Emails
31
+ class Task
32
+ def new_task(*_p, **_o); end
33
+ end
34
+ class Salesrep
35
+ def change_sales_rep(*_p, **_o); end
36
+ end
37
+ end
38
+
39
+ module EstimateConvertable; end
40
+ module ApiLoggable; end
41
+ module Excludable; end
42
+ module Bookmarkable; end
43
+ module Categorizable; end
44
+ module PgSearch; end
45
+ module Excludable; end
46
+ module JsonbStore; end
47
+
48
+ module ActionView
49
+ module Helpers
50
+ module NumberHelper
51
+ end
52
+ end
53
+ end
54
+
55
+ module RailsUpgrade
56
+ def rails4?
57
+ true
58
+ end
59
+
60
+ def rails5?
61
+ true
62
+ end
63
+
64
+ def rails6?
65
+ true
66
+ end
67
+
68
+ def belongs_to_required
69
+ {}
70
+ end
71
+ end
@@ -1,6 +1,7 @@
1
1
  class LoadSchema
2
2
  attr_reader :schema
3
3
 
4
+ # XMEN
4
5
  def initialize
5
6
  @unique_keys = {}
6
7
  @current_table = nil
@@ -9,6 +10,7 @@ class LoadSchema
9
10
  tables: [],
10
11
  foreign_keys: [],
11
12
  indexes: [],
13
+ views: [],
12
14
  meta: {
13
15
  rails: @rails_version,
14
16
  db_info: {
@@ -131,6 +133,11 @@ class LoadSchema
131
133
  add_index(name, fields, **opts)
132
134
  end
133
135
 
136
+ def create_view(name, **opts)
137
+ row = { name: name, **opts }
138
+ schema[:views] << row
139
+ add_unique_keys(row.keys, type: :views)
140
+ end
134
141
 
135
142
  def add_foreign_key(left_table, right_table, **opts)
136
143
  # puts "add_foreign_key(#{left_table}, #{right_table})"