k_domain 0.0.16 → 0.0.26
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.
- checksums.yaml +4 -4
- data/.builders/boot.rb +40 -0
- data/.builders/generators/configuration_generator.rb +22 -0
- data/.builders/run.rb +16 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -2
- data/Guardfile +1 -0
- data/README.md +15 -0
- data/STORIES.md +35 -6
- data/lib/k_domain/config/_.rb +4 -0
- data/lib/k_domain/config/config.rb +19 -0
- data/lib/k_domain/config/configuration.rb +76 -0
- data/lib/k_domain/domain_model/load.rb +41 -0
- data/lib/k_domain/domain_model/transform.rb +27 -55
- data/lib/k_domain/domain_model/transform_steps/_.rb +8 -7
- data/lib/k_domain/domain_model/transform_steps/step.rb +27 -1
- data/lib/k_domain/domain_model/transform_steps/{step1_attach_db_schema.rb → step1_db_schema.rb} +2 -1
- data/lib/k_domain/domain_model/transform_steps/{step5_attach_dictionary.rb → step20_dictionary.rb} +7 -4
- data/lib/k_domain/domain_model/transform_steps/step2_domain_models.rb +123 -0
- data/lib/k_domain/domain_model/transform_steps/{step8_rails_resource_models.rb → step4_rails_resource_models.rb} +4 -4
- data/lib/k_domain/domain_model/transform_steps/step5_rails_resource_routes.rb +36 -0
- data/lib/k_domain/domain_model/transform_steps/step6_rails_structure_models.rb +90 -0
- data/lib/k_domain/domain_model/transform_steps/step7_rails_structure_controllers.rb +111 -0
- data/lib/k_domain/domain_model/transform_steps/step8_domain_columns.rb +99 -0
- data/lib/k_domain/rails_code_extractor/_.rb +5 -0
- data/lib/k_domain/rails_code_extractor/extract_controller.rb +61 -0
- data/lib/k_domain/rails_code_extractor/extract_model.rb +56 -6
- data/lib/k_domain/rails_code_extractor/{load_shim.rb → shim_loader.rb} +3 -5
- data/lib/k_domain/raw_db_schema/load.rb +1 -1
- data/lib/k_domain/raw_db_schema/transform.rb +28 -3
- data/lib/k_domain/schemas/_.rb +6 -3
- data/lib/k_domain/schemas/database.rb +86 -0
- data/lib/k_domain/schemas/domain/erd_file.rb +78 -77
- data/lib/k_domain/schemas/domain.rb +149 -0
- data/lib/k_domain/schemas/domain_model.rb +6 -5
- data/lib/k_domain/schemas/{domain/_.rb → domain_types.rb} +1 -8
- data/lib/k_domain/schemas/rails_resource.rb +43 -6
- data/lib/k_domain/schemas/rails_structure.rb +182 -0
- data/lib/k_domain/version.rb +1 -1
- data/lib/k_domain.rb +4 -2
- data/templates/custom/action_controller.rb +36 -0
- data/templates/custom/controller_interceptors.rb +78 -0
- data/templates/custom/model_interceptors.rb +71 -0
- data/templates/load_schema.rb +7 -0
- data/templates/rails/action_controller.rb +301 -0
- data/templates/{active_record_shims.rb → rails/active_record.rb} +42 -49
- data/templates/ruby_code_extractor/attach_class_info.rb +13 -0
- data/templates/ruby_code_extractor/behaviour_accessors.rb +39 -0
- data/templates/sample_config.rb +47 -0
- data/templates/simple/controller_interceptors.rb +2 -0
- metadata +33 -22
- data/lib/k_domain/domain_model/transform_steps/step2_attach_models.rb +0 -62
- data/lib/k_domain/domain_model/transform_steps/step3_attach_columns.rb +0 -137
- data/lib/k_domain/domain_model/transform_steps/step4_attach_erd_files.rb +0 -457
- data/lib/k_domain/domain_model/transform_steps/step9_rails_structure_models.rb +0 -33
- data/lib/k_domain/schemas/database/_.rb +0 -7
- data/lib/k_domain/schemas/database/foreign_key.rb +0 -14
- data/lib/k_domain/schemas/database/index.rb +0 -14
- data/lib/k_domain/schemas/database/schema.rb +0 -31
- data/lib/k_domain/schemas/database/table.rb +0 -32
- data/lib/k_domain/schemas/domain/domain.rb +0 -11
- data/lib/k_domain/schemas/domain/models/column.rb +0 -49
- data/lib/k_domain/schemas/domain/models/model.rb +0 -111
- data/templates/fake_module_shims.rb +0 -42
| @@ -0,0 +1,182 @@ | |
| 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 | 
            +
             | 
| 55 | 
            +
                    # Not sure if I need to do a behaviours by column names
         | 
| 56 | 
            +
                    # def belongs_to_by(foreign_key: )
         | 
| 57 | 
            +
                    # end
         | 
| 58 | 
            +
                    # def has_one_by(foreign_key: )
         | 
| 59 | 
            +
                    # end
         | 
| 60 | 
            +
                    # def has_many_by(foreign_key: )
         | 
| 61 | 
            +
                    # end
         | 
| 62 | 
            +
                    # def has_and_belongs_to_many_to_by(foreign_key: )
         | 
| 63 | 
            +
                    # end
         | 
| 64 | 
            +
                  end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                  class Method < Dry::Struct
         | 
| 67 | 
            +
                    attribute :name                       , Types::Strict::String
         | 
| 68 | 
            +
                  end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                  class Functions < Dry::Struct
         | 
| 71 | 
            +
                    attribute :class_name?                , Types::Strict::String
         | 
| 72 | 
            +
                    attribute :module_name?               , Types::Strict::String
         | 
| 73 | 
            +
                    attribute :class_full_name?           , Types::Strict::String
         | 
| 74 | 
            +
                    attribute :attr_accessor?             , Types::Array.of(Types::Strict::String)
         | 
| 75 | 
            +
                    attribute :attr_reader?               , Types::Array.of(Types::Strict::String)
         | 
| 76 | 
            +
                    attribute :attr_writer?               , Types::Array.of(Types::Strict::String)
         | 
| 77 | 
            +
                    attribute :klass?                     , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::Method)
         | 
| 78 | 
            +
                    attribute :instance_public?           , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::Method)
         | 
| 79 | 
            +
                    attribute :instance_private?          , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::Method)
         | 
| 80 | 
            +
                  end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                  class Model < Dry::Struct
         | 
| 83 | 
            +
                    attribute :model_name                 , Types::Strict::String
         | 
| 84 | 
            +
                    attribute :table_name                 , Types::Strict::String
         | 
| 85 | 
            +
                    attribute :file                       , Types::Strict::String
         | 
| 86 | 
            +
                    attribute :exist                      , Types::Strict::Bool
         | 
| 87 | 
            +
                    attribute :state                      , Types::Strict::String
         | 
| 88 | 
            +
                    attribute :code                       , Types::Strict::String
         | 
| 89 | 
            +
                    attribute :behaviours?                , KDomain::Schemas::RailsStructure::ModelBehaviours
         | 
| 90 | 
            +
                    attribute :functions?                 , KDomain::Schemas::RailsStructure::Functions
         | 
| 91 | 
            +
                  end
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                  # Controller Behaviours
         | 
| 94 | 
            +
                  class AfterAction                           < KDomain::Schemas::RailsStructure::NameOptsType; end
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                  class AroundAction                          < KDomain::Schemas::RailsStructure::NameOptsType; end
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                  class BeforeAction                          < KDomain::Schemas::RailsStructure::NameOptsType; end
         | 
| 99 | 
            +
             | 
| 100 | 
            +
                  # rubocop:disable Naming/ClassAndModuleCamelCase
         | 
| 101 | 
            +
                  class Prepend_beforeAction                  < KDomain::Schemas::RailsStructure::NameOptsType; end
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                  class Skip_beforeAction                     < KDomain::Schemas::RailsStructure::NameOptsType; end
         | 
| 104 | 
            +
                  # rubocop:enable Naming/ClassAndModuleCamelCase
         | 
| 105 | 
            +
             | 
| 106 | 
            +
                  class BeforeFilter                          < KDomain::Schemas::RailsStructure::NameOptsType; end
         | 
| 107 | 
            +
             | 
| 108 | 
            +
                  class SkipBeforeFilter                      < KDomain::Schemas::RailsStructure::NameOptsType; end
         | 
| 109 | 
            +
             | 
| 110 | 
            +
                  class Layout                                < KDomain::Schemas::RailsStructure::NameOptsType; end
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                  class HttpBasicAuthenticateWith             < KDomain::Schemas::RailsStructure::OptsType; end
         | 
| 113 | 
            +
             | 
| 114 | 
            +
                  class ProtectFromForgery                    < KDomain::Schemas::RailsStructure::OptsType; end
         | 
| 115 | 
            +
             | 
| 116 | 
            +
                  class RescueFrom < Dry::Struct
         | 
| 117 | 
            +
                    attribute :type                           , Types::Strict::String
         | 
| 118 | 
            +
                  end
         | 
| 119 | 
            +
             | 
| 120 | 
            +
                  class HelperMethod < Dry::Struct
         | 
| 121 | 
            +
                    attribute :names                          , Types::Strict::Array.of(Types::Strict::String)
         | 
| 122 | 
            +
                  end
         | 
| 123 | 
            +
             | 
| 124 | 
            +
                  class Helper < Dry::Struct
         | 
| 125 | 
            +
                    attribute :name                           , Types::Strict::String
         | 
| 126 | 
            +
                  end
         | 
| 127 | 
            +
             | 
| 128 | 
            +
                  class ControllerBehaviours < Dry::Struct
         | 
| 129 | 
            +
                    attribute :class_name?                    , Types::Strict::String
         | 
| 130 | 
            +
                    attribute :after_action?                  , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::AfterAction)
         | 
| 131 | 
            +
                    attribute :around_action?                 , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::AroundAction)
         | 
| 132 | 
            +
                    attribute :before_action?                 , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::BeforeAction)
         | 
| 133 | 
            +
                    attribute :prepend_before_action?         , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::Prepend_beforeAction)
         | 
| 134 | 
            +
                    attribute :skip_before_action?            , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::Skip_beforeAction)
         | 
| 135 | 
            +
                    attribute :before_filter?                 , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::BeforeFilter)
         | 
| 136 | 
            +
                    attribute :skip_before_filter?            , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::SkipBeforeFilter)
         | 
| 137 | 
            +
                    attribute :layout?                        , KDomain::Schemas::RailsStructure::Layout
         | 
| 138 | 
            +
                    attribute :http_basic_authenticate_with?  , KDomain::Schemas::RailsStructure::OptsType
         | 
| 139 | 
            +
                    attribute :protect_from_forgery?          , KDomain::Schemas::RailsStructure::OptsType
         | 
| 140 | 
            +
             | 
| 141 | 
            +
                    attribute :rescue_from?                   , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::RescueFrom)
         | 
| 142 | 
            +
                    attribute :helper_method?                 , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::HelperMethod)
         | 
| 143 | 
            +
                    attribute :helper?                        , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::Helper)
         | 
| 144 | 
            +
                  end
         | 
| 145 | 
            +
             | 
| 146 | 
            +
                  class ControllerActions < Dry::Struct
         | 
| 147 | 
            +
                    attribute :route_name?                    , Types::Strict::String
         | 
| 148 | 
            +
                    attribute :action?                        , Types::String.optional
         | 
| 149 | 
            +
                    attribute :uri_path?                      , Types::String
         | 
| 150 | 
            +
                    attribute :mime_match?                    , Types::String
         | 
| 151 | 
            +
                    attribute :verbs?                         , Types.Array(Types::Verb)
         | 
| 152 | 
            +
                  end
         | 
| 153 | 
            +
             | 
| 154 | 
            +
                  class Controller < Dry::Struct
         | 
| 155 | 
            +
                    attribute :name                       , Types::String
         | 
| 156 | 
            +
                    attribute :path                       , Types::String
         | 
| 157 | 
            +
                    attribute :namespace                  , Types::String
         | 
| 158 | 
            +
                    attribute :file                       , Types::String
         | 
| 159 | 
            +
                    attribute :exist                      , Types::Bool
         | 
| 160 | 
            +
                    attribute :full_file                  , Types::String
         | 
| 161 | 
            +
                    attribute :behaviours?                , KDomain::Schemas::RailsStructure::ControllerBehaviours
         | 
| 162 | 
            +
                    attribute :functions?                 , KDomain::Schemas::RailsStructure::Functions
         | 
| 163 | 
            +
                    attribute :actions?                   , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::ControllerActions)
         | 
| 164 | 
            +
                  end
         | 
| 165 | 
            +
             | 
| 166 | 
            +
                  attribute :models                       , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::Model)
         | 
| 167 | 
            +
                  attribute :controllers                  , Types::Strict::Array.of(KDomain::Schemas::RailsStructure::Controller)
         | 
| 168 | 
            +
             | 
| 169 | 
            +
                  def find_controller(path)
         | 
| 170 | 
            +
                    path = path.to_s
         | 
| 171 | 
            +
                    controllers.find { |controller| controller.path.to_s == path }
         | 
| 172 | 
            +
                  end
         | 
| 173 | 
            +
             | 
| 174 | 
            +
                  def find_model(name)
         | 
| 175 | 
            +
                    name = name.to_s
         | 
| 176 | 
            +
                    models.find { |model| model.model_name.to_s == name }
         | 
| 177 | 
            +
                  end
         | 
| 178 | 
            +
                end
         | 
| 179 | 
            +
              end
         | 
| 180 | 
            +
            end
         | 
| 181 | 
            +
             | 
| 182 | 
            +
            # attribute :domain           , KDomain::DomainModel::Domain
         | 
    
        data/lib/k_domain/version.rb
    CHANGED
    
    
    
        data/lib/k_domain.rb
    CHANGED
    
    | @@ -5,14 +5,14 @@ require 'dry-struct' | |
| 5 5 | 
             
            require 'k_log'
         | 
| 6 6 | 
             
            require 'peeky'
         | 
| 7 7 | 
             
            require 'k_domain/version'
         | 
| 8 | 
            +
            require 'k_domain/config/_'
         | 
| 8 9 | 
             
            require 'k_domain/schemas/_'
         | 
| 9 10 | 
             
            require 'k_domain/raw_db_schema/transform'
         | 
| 10 11 | 
             
            require 'k_domain/raw_db_schema/load'
         | 
| 11 12 | 
             
            require 'k_domain/domain_model/transform'
         | 
| 12 13 | 
             
            require 'k_domain/domain_model/transform_steps/_'
         | 
| 13 14 | 
             
            require 'k_domain/domain_model/load'
         | 
| 14 | 
            -
            require 'k_domain/rails_code_extractor/ | 
| 15 | 
            -
            # require 'k_domain/rails_code_extractor/extract_model'
         | 
| 15 | 
            +
            require 'k_domain/rails_code_extractor/_'
         | 
| 16 16 |  | 
| 17 17 | 
             
            # # This is useful if you want to initialize structures via Hash
         | 
| 18 18 | 
             
            # class SymbolizeStruct < Dry::Struct
         | 
| @@ -20,6 +20,8 @@ require 'k_domain/rails_code_extractor/load_shim' | |
| 20 20 | 
             
            # end
         | 
| 21 21 |  | 
| 22 22 | 
             
            module KDomain
         | 
| 23 | 
            +
              extend KDomain::Config
         | 
| 24 | 
            +
             | 
| 23 25 | 
             
              # raise KDomain::Error, 'Sample message'
         | 
| 24 26 | 
             
              class Error < StandardError; end
         | 
| 25 27 |  | 
| @@ -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
         | 
    
        data/templates/load_schema.rb
    CHANGED
    
    | @@ -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})"
         |