k_domain 0.0.5 → 0.0.16

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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +11 -1
  3. data/Gemfile +10 -0
  4. data/Rakefile +3 -1
  5. data/STORIES.md +15 -0
  6. data/k_domain.gemspec +2 -0
  7. data/lib/k_domain/domain_model/load.rb +8 -2
  8. data/lib/k_domain/domain_model/transform.rb +30 -3
  9. data/lib/k_domain/domain_model/transform_steps/_.rb +2 -0
  10. data/lib/k_domain/domain_model/transform_steps/step.rb +38 -0
  11. data/lib/k_domain/domain_model/transform_steps/step1_attach_db_schema.rb +1 -1
  12. data/lib/k_domain/domain_model/transform_steps/step4_attach_erd_files.rb +5 -2
  13. data/lib/k_domain/domain_model/transform_steps/step5_attach_dictionary.rb +5 -2
  14. data/lib/k_domain/domain_model/transform_steps/step8_rails_resource_models.rb +44 -0
  15. data/lib/k_domain/domain_model/transform_steps/step9_rails_structure_models.rb +33 -0
  16. data/lib/k_domain/rails_code_extractor/extract_model.rb +21 -0
  17. data/lib/k_domain/rails_code_extractor/load_shim.rb +32 -0
  18. data/lib/k_domain/raw_db_schema/load.rb +8 -2
  19. data/lib/k_domain/raw_db_schema/transform.rb +4 -5
  20. data/lib/k_domain/schemas/_.rb +15 -0
  21. data/lib/k_domain/{raw_db_schema/dtos → schemas/database}/_.rb +0 -7
  22. data/lib/k_domain/{raw_db_schema/dtos → schemas/database}/foreign_key.rb +1 -1
  23. data/lib/k_domain/{raw_db_schema/dtos → schemas/database}/index.rb +1 -1
  24. data/lib/k_domain/schemas/database/schema.rb +31 -0
  25. data/lib/k_domain/schemas/database/table.rb +32 -0
  26. data/lib/k_domain/schemas/dictionary.rb +19 -0
  27. data/lib/k_domain/{domain_model/dtos → schemas/domain}/_.rb +1 -24
  28. data/lib/k_domain/{domain_model/dtos → schemas/domain}/domain.rb +1 -1
  29. data/lib/k_domain/schemas/domain/erd_file.rb +82 -0
  30. data/lib/k_domain/{domain_model/dtos → schemas/domain}/models/column.rb +0 -0
  31. data/lib/k_domain/{domain_model/dtos → schemas/domain}/models/model.rb +0 -0
  32. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/belongs_to.rb +0 -0
  33. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/column_old.rb +0 -0
  34. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/domain_statistics.rb +0 -0
  35. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/entity.rb +0 -0
  36. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/entity_statistics.rb +0 -0
  37. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/foreign_key.rb +0 -0
  38. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/has_and_belongs_to_many.rb +0 -0
  39. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/has_many.rb +0 -0
  40. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/has_one.rb +0 -0
  41. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/name_options.rb +0 -0
  42. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/rails_controller.rb +0 -0
  43. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/rails_model.rb +0 -0
  44. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/related_entity.rb +0 -0
  45. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/statistics.rb +0 -0
  46. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/validate.rb +0 -0
  47. data/lib/k_domain/{domain_model/dtos → schemas/domain/old}/validates.rb +0 -0
  48. data/lib/k_domain/schemas/domain_model.rb +14 -0
  49. data/lib/k_domain/schemas/investigate.rb +15 -0
  50. data/lib/k_domain/schemas/rails_resource.rb +16 -0
  51. data/lib/k_domain/version.rb +1 -1
  52. data/lib/k_domain.rb +14 -2
  53. data/templates/active_record_shims.rb +355 -0
  54. data/templates/fake_module_shims.rb +42 -0
  55. data/{lib/k_domain/raw_db_schema/template.rb → templates/load_schema.rb} +4 -4
  56. metadata +54 -35
  57. data/lib/k_domain/domain_model/dtos/dictionary/dictionary.rb +0 -17
  58. data/lib/k_domain/domain_model/dtos/investigate/investigate.rb +0 -10
  59. data/lib/k_domain/domain_model/dtos/investigate/issue.rb +0 -13
  60. data/lib/k_domain/domain_model/dtos/schema.rb +0 -12
  61. data/lib/k_domain/raw_db_schema/dtos/column.rb +0 -16
  62. data/lib/k_domain/raw_db_schema/dtos/database.rb +0 -11
  63. data/lib/k_domain/raw_db_schema/dtos/schema.rb +0 -18
  64. data/lib/k_domain/raw_db_schema/dtos/table.rb +0 -21
  65. data/lib/k_domain/raw_db_schema/dtos/unique_key.rb +0 -14
@@ -2,33 +2,10 @@
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'
8
5
  require_relative './models/column'
9
6
  require_relative './models/model'
7
+ require_relative './erd_file'
10
8
  require_relative './domain'
11
- require_relative './schema'
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
9
 
33
10
  module KDomain
34
11
  module DomainModel
@@ -5,7 +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 :dictionary , Types::Strict::Array.of(KDomain::DomainModel::Dictionary)
8
+ attribute :erd_files , Types::Strict::Array.of(KDomain::DomainModel::ErdFile)
9
9
  end
10
10
  end
11
11
  end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Domain class holds a list of the entities
4
+ module KDomain
5
+ module DomainModel
6
+ # rubocop:disable Metrics/BlockLength
7
+ class ErdFile < Dry::Struct
8
+ attribute :name , Types::Strict::String
9
+ attribute :name_plural , Types::Strict::String
10
+ attribute :dsl_file , Types::Strict::String
11
+
12
+ attribute? :source , Dry::Struct.optional.default(nil) do
13
+ attribute :ruby , Types::Strict::String
14
+ attribute :public , Types::Strict::String.optional.default(nil)
15
+ attribute :private , Types::Strict::String.optional.default(nil)
16
+
17
+ attribute? :all_methods , Dry::Struct.optional.default(nil) do
18
+ attribute? :klass , Types::Strict::Array do
19
+ attribute :name , Types::Strict::String
20
+ attribute :scope , Types::Strict::String # .optional.default(nil)
21
+ attribute :class_method , Types::Strict::Bool
22
+ attribute :arguments , Types::Strict::String
23
+ end
24
+ attribute? :instance , Types::Strict::Array do
25
+ attribute :name , Types::Strict::String
26
+ attribute :scope , Types::Strict::String # .optional.default(nil)
27
+ attribute :class_method , Types::Strict::Bool
28
+ attribute :arguments , Types::Strict::String
29
+ end
30
+ attribute? :instance_public , Types::Strict::Array do
31
+ attribute :name , Types::Strict::String
32
+ attribute :scope , Types::Strict::String # .optional.default(nil)
33
+ attribute :class_method , Types::Strict::Bool
34
+ attribute :arguments , Types::Strict::String
35
+ end
36
+ attribute? :instance_private , Types::Strict::Array do
37
+ attribute :name , Types::Strict::String
38
+ attribute :scope , Types::Strict::String # .optional.default(nil)
39
+ attribute :class_method , Types::Strict::Bool
40
+ attribute :arguments , Types::Strict::String
41
+ end
42
+ end
43
+ end
44
+ attribute? :dsl , Dry::Struct.optional.default(nil) do
45
+ attribute :default_scope , Types::Strict::String.optional.default(nil)
46
+
47
+ attribute? :scopes , Types::Strict::Array do
48
+ attribute :name , Types::Strict::String
49
+ attribute :scope , Types::Strict::String # .optional.default(nil)
50
+ end
51
+ attribute? :belongs_to , Types::Strict::Array do
52
+ attribute :name , Types::Strict::String
53
+ attribute :options , Types::Strict::Hash.optional.default({}.freeze)
54
+ attribute :raw_options , Types::Strict::String
55
+ end
56
+ attribute? :has_one , Types::Strict::Array do
57
+ attribute :name , Types::Strict::String
58
+ attribute :options , Types::Strict::Hash.optional.default({}.freeze)
59
+ attribute :raw_options , Types::Strict::String
60
+ end
61
+ attribute? :has_many , Types::Strict::Array do
62
+ attribute :name , Types::Strict::String
63
+ attribute :options , Types::Strict::Hash.optional.default({}.freeze)
64
+ attribute :raw_options , Types::Strict::String
65
+ end
66
+ attribute? :has_and_belongs_to_many , Types::Strict::Array do
67
+ attribute :name , Types::Strict::String
68
+ attribute :options , Types::Strict::Hash.optional.default({}.freeze)
69
+ attribute :raw_options , Types::Strict::String
70
+ end
71
+ attribute? :validate_on , Types::Strict::Array do
72
+ attribute :line , Types::Strict::String
73
+ end
74
+ attribute? :validates_on , Types::Strict::Array do
75
+ attribute :name , Types::Strict::String
76
+ attribute :raw_options , Types::Strict::String
77
+ end
78
+ end
79
+ end
80
+ # rubocop:enable Metrics/BlockLength
81
+ end
82
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # DomainModel holds the entire domain model including database and ancillary information
4
+ module KDomain
5
+ module Schemas
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
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Domain class holds a dictionary entry
4
+ module KDomain
5
+ module Schemas
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
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Domain class holds a dictionary entry
4
+ module KDomain
5
+ module Schemas
6
+ 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
13
+ end
14
+ end
15
+ end
16
+ 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.16'
5
5
  end
data/lib/k_domain.rb CHANGED
@@ -3,14 +3,16 @@
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/_'
8
9
  require 'k_domain/raw_db_schema/transform'
9
10
  require 'k_domain/raw_db_schema/load'
10
- require 'k_domain/domain_model/dtos/_'
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/load_shim'
15
+ # require 'k_domain/rails_code_extractor/extract_model'
14
16
 
15
17
  # # This is useful if you want to initialize structures via Hash
16
18
  # class SymbolizeStruct < Dry::Struct
@@ -21,6 +23,16 @@ module KDomain
21
23
  # raise KDomain::Error, 'Sample message'
22
24
  class Error < StandardError; end
23
25
 
26
+ module Gem
27
+ def self.root
28
+ File.expand_path('..', File.dirname(__FILE__))
29
+ end
30
+
31
+ def self.resource(resource_path)
32
+ File.join(root, resource_path)
33
+ end
34
+ end
35
+
24
36
  # Your code goes here...
25
37
  end
26
38
 
@@ -0,0 +1,355 @@
1
+ module ActiveRecord
2
+ def self.all_loaded_classes
3
+ @all_loaded_classes ||= []
4
+ end
5
+
6
+ def self.last_loaded_class
7
+ @last_loaded_class ||= nil
8
+ end
9
+
10
+ class Base
11
+ def self.singleton_class
12
+ Class.new do
13
+ def send(*_p, **_o); end
14
+ end.new
15
+ end
16
+
17
+ def self.class_info
18
+ return @class_info if defined? @class_info
19
+
20
+ ActiveRecord.last_loaded_class = name
21
+
22
+ @class_info = {
23
+ class_name: name
24
+ }
25
+
26
+ ActiveRecord.all_loaded_classes << class_info
27
+
28
+ @class_info
29
+ end
30
+
31
+ def self.set(key, value)
32
+ class_info[key] = class_info[key] || {}
33
+ class_info[key] = value
34
+ end
35
+
36
+ def self.add(key, value)
37
+ class_info[key] = class_info[key] || []
38
+ if value.is_a?(Array)
39
+ class_info[key] = class_info[key] + value
40
+ else
41
+ class_info[key] << value
42
+ end
43
+ end
44
+
45
+ def self.custom_set(key, value = {})
46
+ class_info[:custom] = {} unless class_info[:custom]
47
+ class_info[:custom][key] = class_info[:custom][key] || {}
48
+ class_info[:custom][key] = value
49
+ end
50
+
51
+ def self.custom_add(key, value)
52
+ class_info[:custom] = {} unless class_info[:custom]
53
+ class_info[:custom][key] = class_info[:custom][key] || []
54
+ if value.is_a?(Array)
55
+ class_info[:custom][key] = class_info[:custom][key] + value
56
+ else
57
+ class_info[:custom][key] << value
58
+ end
59
+ end
60
+
61
+ # examples:
62
+ # enum status: { active: 0, archived: 1 }
63
+ # enum status: [:active, :archived]
64
+ # enum status: [:active, :archived], _suffix: true
65
+ # enum comments_status: [:active, :inactive], _prefix: :comments
66
+ def self.enum(**opts)
67
+ add(:enum, opts)
68
+ end
69
+
70
+ def self.attr_accessor(*names)
71
+ add(:attr_accessor, names)
72
+ end
73
+
74
+ def self.attr_reader(*names)
75
+ add(:attr_reader, names)
76
+ end
77
+
78
+ def self.attr_writer(*names)
79
+ add(:attr_writer, names)
80
+ end
81
+
82
+ def self.lambda_source(a_lambda, prefix = nil)
83
+ return nil unless a_lambda
84
+
85
+ puts 'NOT A LAMBDA' unless a_lambda.is_a?(Proc)
86
+
87
+ result = a_lambda&.source&.strip
88
+ result = result&.delete_prefix(prefix) if prefix
89
+ result&.strip
90
+ end
91
+
92
+ # examples
93
+ # default_scope where(:published => true) # NOT supported
94
+ # default_scope { where(:published_at => Time.now - 1.week) }
95
+ # default_scope -> { order(:external_updated_at) }
96
+ # default_scope -> { where(:published => true) }, all_queries: true
97
+ def self.default_scope(**opts, &block)
98
+ block_source = nil
99
+ block_source = lambda_source(block, 'default_scope') if block_given?
100
+
101
+ set(:default_scope, opts.merge(block: block_source))
102
+ end
103
+
104
+ # examples
105
+ # scope :red, where(:color => 'red') # NOT SUPPORTED
106
+ # scope :dry_clean_only, joins(:washing_instructions).where('washing_instructions.dry_clean_only = ?', true) # NOT SUPPORTED
107
+ #
108
+ def self.scope(name, on_the_lamb = nil, **opts)
109
+ lamb_source = lambda_source(on_the_lamb, "scope :#{name},")
110
+
111
+ add(:scopes, {
112
+ name: name,
113
+ opts: opts,
114
+ block: lamb_source
115
+ })
116
+ end
117
+
118
+ def self.belongs_to(name, on_the_lamb = nil, **opts)
119
+ lamb_source = lambda_source(on_the_lamb, "belongs_to :#{name},")
120
+
121
+ add(:belongs_to, {
122
+ name: name,
123
+ opts: opts,
124
+ block: lamb_source
125
+ })
126
+ end
127
+
128
+ def self.has_many(name, on_the_lamb = nil, **opts)
129
+ lamb_source = lambda_source(on_the_lamb, "has_many :#{name},")
130
+
131
+ add(:has_many, {
132
+ name: name,
133
+ opts: opts,
134
+ block: lamb_source
135
+ })
136
+ end
137
+
138
+ def self.has_one(name, on_the_lamb = nil, **opts)
139
+ lamb_source = lambda_source(on_the_lamb, "has_one :#{name},")
140
+
141
+ add(:has_one, {
142
+ name: name,
143
+ opts: opts,
144
+ block: lamb_source
145
+ })
146
+ end
147
+
148
+ def self.has_and_belongs_to_many(name, on_the_lamb = nil, **opts)
149
+ lamb_source = lambda_source(on_the_lamb, "has_and_belongs_to_many :#{name},")
150
+
151
+ add(:has_and_belongs_to_many, {
152
+ name: name,
153
+ opts: opts,
154
+ block: lamb_source
155
+ })
156
+ end
157
+
158
+ def self.validate(*names, **opts, &block)
159
+ block_source = nil
160
+ block_source = lambda_source(block, 'validate') if block_given?
161
+
162
+ set(:default_scope, opts.merge(block: block_source))
163
+
164
+ add(:validate, {
165
+ names: names,
166
+ opts: opts,
167
+ block: block_source
168
+ })
169
+ end
170
+
171
+ def self.validates(name, **opts)
172
+ add(:validates, {
173
+ name: name,
174
+ opts: opts
175
+ })
176
+ end
177
+
178
+ def self.alias_attribute(left, right)
179
+ add(:alias_attribute, {
180
+ left: left,
181
+ right: right
182
+ })
183
+ end
184
+
185
+ def self.before_create(name)
186
+ add(:before_create, {
187
+ name: name
188
+ })
189
+ end
190
+
191
+ def self.before_save(name)
192
+ add(:before_save, {
193
+ name: name
194
+ })
195
+ end
196
+
197
+ def self.before_destroy(name)
198
+ add(:before_destroy, {
199
+ name: name
200
+ })
201
+ end
202
+
203
+ def self.before_validation(name = nil, &block)
204
+ block_source = nil
205
+ block_source = lambda_source(block, 'before_validation') if block_given?
206
+
207
+ add(:before_validation, {
208
+ name: name,
209
+ block: block_source
210
+ })
211
+ end
212
+
213
+ def self.after_create(name)
214
+ add(:after_create, {
215
+ name: name
216
+ })
217
+ end
218
+
219
+ def self.after_save(name)
220
+ add(:after_save, {
221
+ name: name
222
+ })
223
+ end
224
+
225
+ def self.after_destroy(name = nil, &block)
226
+ block_source = nil
227
+ block_source = lambda_source(block, 'after_destroy') if block_given?
228
+
229
+ add(:after_destroy, {
230
+ name: name,
231
+ block: block_source
232
+ })
233
+ end
234
+
235
+ def self.after_commit(name)
236
+ add(:after_commit, {
237
+ name: name
238
+ })
239
+ end
240
+
241
+ def self.accepts_nested_attributes_for(name, **opts)
242
+ add(:accepts_nested_attributes_for, {
243
+ name: name,
244
+ opts: opts
245
+ })
246
+ end
247
+
248
+ def self.has_secure_token(name)
249
+ add(:has_secure_token, {
250
+ name: name
251
+ })
252
+ end
253
+
254
+ # CAN THESE BE AUTOMATED LIKE INCLUDE MODULES
255
+ def self.establish_connection(connection)
256
+ class_info[:establish_connection] = connection
257
+ end
258
+
259
+ def self.store_accessor(*names)
260
+ class_info[:store_accessor] = *names
261
+ end
262
+
263
+ def self.table_name=(table_name)
264
+ class_info[:table_name] = table_name
265
+ end
266
+
267
+ def self.primary_key=(primary_key)
268
+ class_info[:primary_key] = primary_key
269
+ end
270
+
271
+ def self.require(require)
272
+ add(:require, require)
273
+ end
274
+
275
+ def self.devise(*names)
276
+ add(:devise, names)
277
+ end
278
+
279
+ def self.pg_search_scope(name, **opts)
280
+ custom_set(:pg_search_scope, {
281
+ name: name,
282
+ opts: opts
283
+ })
284
+ end
285
+
286
+ def self.acts_as_readable(**opts)
287
+ custom_set(:acts_as_readable, {
288
+ opts: opts
289
+ })
290
+ end
291
+
292
+ def self.acts_as_reader
293
+ custom_set(:acts_as_reader, {})
294
+ end
295
+
296
+ def self.acts_as_commentable
297
+ custom_set(:acts_as_commentable, {})
298
+ end
299
+
300
+ def self.acts_as_list(**opts)
301
+ custom_set(:acts_as_list, {
302
+ opts: opts
303
+ })
304
+ end
305
+
306
+ def self.has_paper_trail
307
+ custom_set(:has_paper_trail)
308
+ end
309
+
310
+ def self.validates_uniqueness_of(name, **opts)
311
+ custom_set(:validates_uniqueness_of, {
312
+ name: name,
313
+ opts: opts
314
+ })
315
+ end
316
+
317
+ def self.validates_presence_of(name, **opts)
318
+ custom_set(:validates_presence_of, {
319
+ name: name,
320
+ opts: opts
321
+ })
322
+ end
323
+
324
+ def self.validates_length_of(name, **opts)
325
+ custom_set(:validates_length_of, {
326
+ name: name,
327
+ opts: opts
328
+ })
329
+ end
330
+
331
+ def self.attr_encrypted(name, **opts)
332
+ custom_set(:attr_encrypted, {
333
+ name: name,
334
+ opts: opts
335
+ })
336
+ end
337
+
338
+ def self.validates_confirmation_of(name, **opts)
339
+ custom_set(:validates_confirmation_of, {
340
+ name: name,
341
+ opts: opts
342
+ })
343
+ end
344
+
345
+ def self.with_options(opts, &block)
346
+ block_source = nil
347
+ block_source = lambda_source(block) if block_given?
348
+
349
+ custom_add(:with_options, {
350
+ opts: opts,
351
+ block: block_source
352
+ })
353
+ end
354
+ end
355
+ end
@@ -0,0 +1,42 @@
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
+ module ActionView
20
+ module Helpers
21
+ module NumberHelper
22
+ end
23
+ end
24
+ end
25
+
26
+ module RailsUpgrade
27
+ def rails4?
28
+ true
29
+ end
30
+
31
+ def rails5?
32
+ true
33
+ end
34
+
35
+ def rails6?
36
+ true
37
+ end
38
+
39
+ def belongs_to_required
40
+ {}
41
+ end
42
+ end