brick 1.0.80 → 1.0.81

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17bf4590fae09ac7d48f3f607996bf6297d530a9b87f338ae4519178431bfa9c
4
- data.tar.gz: 65c67de2f3cadad727971c31d2ce6aba476cdfb28dcfdb8f440028cd1657f3e0
3
+ metadata.gz: 2627490165a63200a49afb7707882489986217bc170491e88f64eb9faf880b6b
4
+ data.tar.gz: f12adff07785ffd5c4a877f555cd7899de859f99ae9b18b84eda6f3d20ac5c15
5
5
  SHA512:
6
- metadata.gz: f96ad491da932e615513d0b92b98dee2ceea3327a5938d1ae1c9f81b0cde29193a465227cf13510bbcb2306a68e72e097a02ce5f2f0f6308c00c6b5bb714fcf9
7
- data.tar.gz: b0058bd2ba86e8d2a89276cf38061a07de63a509d65532d173079f255f73d3293b8550f902d9be00f2ff9962ba76a142691d1ce7fe28b1786de429120f3d9d31
6
+ metadata.gz: f112e1bf44fc39e80bced64a2d9fb4dd16297e2c549f66d0842fb65d7f3644170fa18c3c784c59c5a93db57233a77bfa5f288dca89be1b3dec6172bb670f147b
7
+ data.tar.gz: 0c2061b9b662c00aeb85a76db20fb59962302dd8b6ab17225ded332eadf4485392e3f5e44538b8f99d525666b8a036bb2fbd53a2604bbf7f69aca3ad8400fa4d
@@ -909,7 +909,7 @@ Module.class_exec do
909
909
  # Vabc instead of VABC)
910
910
  singular_class_name = ::Brick.namify(plural_class_name, :underscore).singularize.camelize
911
911
  full_class_name << "::#{singular_class_name}"
912
- if plural_class_name == 'BrickSwagger' ||
912
+ if plural_class_name == 'BrickOpenapi' ||
913
913
  (
914
914
  (::Brick.config.add_status || ::Brick.config.add_orphans) &&
915
915
  plural_class_name == 'BrickGem'
@@ -1312,13 +1312,13 @@ class Object
1312
1312
  instance_variable_set(:@orphans, ::Brick.find_orphans(::Brick.set_db_schema(params)))
1313
1313
  end
1314
1314
  return [new_controller_class, code + "end # BrickGem controller\n"]
1315
- when 'BrickSwagger'
1316
- is_swagger = true
1315
+ when 'BrickOpenapi'
1316
+ is_openapi = true
1317
1317
  end
1318
1318
 
1319
1319
  self.protect_from_forgery unless: -> { self.request.format.js? }
1320
1320
  self.define_method :index do
1321
- if (is_swagger || request.env['REQUEST_PATH'].start_with?(::Brick.api_root)) &&
1321
+ if (is_openapi || request.env['REQUEST_PATH'].start_with?(::Brick.api_root)) &&
1322
1322
  !params&.key?('_brick_schema') &&
1323
1323
  (referrer_params = request.env['HTTP_REFERER']&.split('?')&.last&.split('&')&.map { |x| x.split('=') }).present?
1324
1324
  if params
@@ -1329,7 +1329,7 @@ class Object
1329
1329
  end
1330
1330
  ::Brick.set_db_schema(params || api_params)
1331
1331
 
1332
- if is_swagger
1332
+ if is_openapi
1333
1333
  json = { 'openapi': '3.0.1', 'info': { 'title': Rswag::Ui.config.config_object[:urls].last&.fetch(:name, 'API documentation'), 'version': ::Brick.config.api_version },
1334
1334
  'servers': [
1335
1335
  { 'url': '{scheme}://{defaultHost}', 'variables': {
@@ -1426,7 +1426,7 @@ class Object
1426
1426
  @_brick_erd = params['_brick_erd']&.to_i
1427
1427
  end
1428
1428
 
1429
- unless is_swagger
1429
+ unless is_openapi
1430
1430
  ::Brick.set_db_schema
1431
1431
  _, order_by_txt = model._brick_calculate_ordering(default_ordering(table_name, pk)) if pk
1432
1432
  code << " def index\n"
@@ -1564,7 +1564,7 @@ class Object
1564
1564
  private params_name
1565
1565
  # Get column names for params from relations[model.table_name][:cols].keys
1566
1566
  end
1567
- end # unless is_swagger
1567
+ end # unless is_openapi
1568
1568
  code << "end # #{class_name}\n"
1569
1569
  end # class definition
1570
1570
  [built_controller, code]
@@ -1754,7 +1754,7 @@ module ActiveRecord::ConnectionHandling
1754
1754
  measures = []
1755
1755
  ::Brick.is_oracle = true if ActiveRecord::Base.connection.adapter_name == 'OracleEnhanced'
1756
1756
  case ActiveRecord::Base.connection.adapter_name
1757
- when 'PostgreSQL', 'SQLite', 'SQLServer' # These bring back a hash for each row because the query uses column aliases
1757
+ when 'PostgreSQL', 'SQLite' # These bring back a hash for each row because the query uses column aliases
1758
1758
  # schema ||= 'public' if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
1759
1759
  ActiveRecord::Base.retrieve_schema_and_tables(sql, is_postgres, is_mssql, schema).each do |r|
1760
1760
  # If Apartment gem lists the table as being associated with a non-tenanted model then use whatever it thinks
@@ -1785,7 +1785,7 @@ module ActiveRecord::ConnectionHandling
1785
1785
  # puts "KEY! #{r['relation_name']}.#{col_name} #{r['key']} #{r['const']}" if r['key']
1786
1786
  relation[:col_descrips][col_name] = r['column_description'] if r['column_description']
1787
1787
  end
1788
- else # MySQL2 and OracleEnhanced act a little differently, bringing back an array for each row
1788
+ else # MySQL2, OracleEnhanced, and MSSQL act a little differently, bringing back an array for each row
1789
1789
  schema_and_tables = case ActiveRecord::Base.connection.adapter_name
1790
1790
  when 'OracleEnhanced'
1791
1791
  sql =
@@ -189,8 +189,8 @@ module Brick
189
189
  end.keys.sort.each_with_object(+'') do |v, s|
190
190
  s << "<option value=\"#{prefix}#{v.underscore.gsub('.', '/')}\">#{v}</option>"
191
191
  end.html_safe
192
- table_options << '<option value="brick_status">(Status)</option>'.html_safe if ::Brick.config.add_status
193
- table_options << '<option value="brick_orphans">(Orphans)</option>'.html_safe if is_orphans
192
+ table_options << "<option value=\"#{prefix}brick_status\">(Status)</option>".html_safe if ::Brick.config.add_status
193
+ table_options << "<option value=\"#{prefix}brick_orphans\">(Orphans)</option>".html_safe if is_orphans
194
194
  css = +"<style>
195
195
  h1, h3 {
196
196
  margin-bottom: 0;
@@ -603,7 +603,21 @@ if (headerTop) {
603
603
  erd_markup = if @_brick_model
604
604
  "<div id=\"mermaidErd\" class=\"mermaid\">
605
605
  erDiagram
606
- <% model_short_name = #{@_brick_model.name.split('::').last.inspect}
606
+ <% def sidelinks(shown_classes, klass)
607
+ links = []
608
+ # %%% Not yet showing these as they can get just a bit intense!
609
+ # klass.reflect_on_all_associations.select { |a| shown_classes.key?(a.klass) }.each do |assoc|
610
+ # unless shown_classes[assoc.klass].key?(klass.name)
611
+ # links << \" #\{klass.name.split('::').last} #\{assoc.macro == :belongs_to ? '}o--||' : '||--o{'} #\{assoc.klass.name.split('::').last} : \\\"\\\"\"n\"
612
+ # shown_classes[assoc.klass][klass.name] = nil
613
+ # end
614
+ # end
615
+ # shown_classes[klass] ||= {}
616
+ links.join
617
+ end
618
+
619
+ model_short_name = #{@_brick_model.name.split('::').last.inspect}
620
+ shown_classes = {}
607
621
  @_brick_bt_descrip&.each do |bt|
608
622
  bt_class = bt[1].first.first
609
623
  callbacks[bt_name = bt_class.name.split('::').last] = bt_class
@@ -613,6 +627,7 @@ erDiagram
613
627
  bt_underscored = bt[1].first.first.name.underscore.singularize
614
628
  bt.first unless bt.first.to_s == bt_underscored.split('/').last # Was: bt_underscored.tr('/', '_')
615
629
  }\\\"\".html_safe %>
630
+ <%= sidelinks(shown_classes, bt_class).html_safe %>
616
631
  <% end
617
632
  last_through = nil
618
633
  @_brick_hm_counts&.each do |hm|
@@ -627,6 +642,7 @@ erDiagram
627
642
  %><%= \"\n\"
628
643
  %><% else
629
644
  %> <%= \"#\{model_short_name} ||--o{ #\{through_name}\".html_safe %> : \"\"
645
+ <%= sidelinks(shown_classes, through_assoc.active_record).html_safe %>
630
646
  <% last_through = through
631
647
  end
632
648
  %> <%= \"#\{through_name} }o--|| #\{hm_name}\".html_safe %> : \"\"
@@ -636,6 +652,7 @@ erDiagram
636
652
  hm.first.to_s unless hm.first.to_s.downcase == hm_class.name.underscore.pluralize.tr('/', '_')
637
653
  }\\\"\".html_safe %><%
638
654
  end %>
655
+ <%= sidelinks(shown_classes, hm_class).html_safe %>
639
656
  <% end
640
657
  def dt_lookup(dt)
641
658
  { 'integer' => 'int', }[dt] || dt&.tr(' ', '_') || 'int'
@@ -989,11 +1006,13 @@ erDiagram
989
1006
  <select id=\"tbl\">#{table_options}</select>
990
1007
  <h1>Orphans<%= \" for #\{}\" if false %></h1>
991
1008
  <% @orphans.each do |o|
992
- via = \" (via #\{o[4]})\" unless \"#\{o[2].split('.').last.underscore.singularize}_id\" == o[4] %>
993
- <a href=\"/<%= o[0].split('.').last %>/<%= o[1] %>\">
994
- <%= \"#\{o[0]} #\{o[1]} refers#\{via} to non-existent #\{o[2]} #\{o[3]}#\{\" (in table \\\"#\{o[5]}\\\")\" if o[5]}\" %>
995
- </a><br>
996
- <% end %>
1009
+ if (klass = ::Brick.relations[o[0]]&.fetch(:class_name, nil)&.constantize) %>
1010
+ <%= via = \" (via #\{o[4]})\" unless \"#\{o[2].split('.').last.underscore.singularize}_id\" == o[4]
1011
+ link_to(\"#\{o[0]} #\{o[1]} refers#\{via} to non-existent #\{o[2]} #\{o[3]}#\{\" (in table \\\"#\{o[5]}\\\")\" if o[5]}\",
1012
+ send(\"#\{klass._brick_index(:singular)\}_path\".to_sym, o[1])) %>
1013
+ <br>
1014
+ <% end
1015
+ end %>
997
1016
  #{script}"
998
1017
  end
999
1018
 
@@ -5,7 +5,7 @@ module Brick
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 0
8
- TINY = 80
8
+ TINY = 81
9
9
 
10
10
  # PRE is nil unless it's a pre-release (beta, RC, etc.)
11
11
  PRE = nil
data/lib/brick.rb CHANGED
@@ -612,13 +612,35 @@ In config/initializers/brick.rb appropriate entries would look something like:
612
612
  get("/#{controller_prefix}brick_orphans", to: 'brick_gem#orphans', as: 'brick_orphans')
613
613
  end
614
614
 
615
- if Object.const_defined?('Rswag::Ui') && doc_endpoint = Rswag::Ui.config.config_object[:urls].last
616
- # Serves JSON swagger info from a path such as '/api-docs/v1/swagger.json'
617
- puts "Mounting swagger info endpoint for \"#{doc_endpoint[:name]}\" on #{doc_endpoint[:url]}"
618
- send(:get, doc_endpoint[:url], { to: 'brick_swagger#index' })
619
- end
620
-
621
615
  unless ::Brick.routes_done
616
+ if Object.const_defined?('Rswag::Ui')
617
+ rswag_path = ::Rails.application.routes.routes.find { |r| r.app.app == Rswag::Ui::Engine }&.instance_variable_get(:@path_formatter)&.instance_variable_get(:@parts)&.join
618
+ if (doc_endpoint = Rswag::Ui.config.config_object[:urls]&.last)
619
+ puts "Mounting OpenApi 3.0 documentation endpoint for \"#{doc_endpoint[:name]}\" on #{doc_endpoint[:url]}"
620
+ send(:get, doc_endpoint[:url], { to: 'brick_openapi#index' })
621
+ endpoint_parts = doc_endpoint[:url]&.split('/')
622
+ if rswag_path && endpoint_parts
623
+ puts "API documentation now available when navigating to: /#{endpoint_parts&.find(&:present?)}/index.html"
624
+ else
625
+ puts "In order to make documentation available you can put this into your routes.rb:"
626
+ puts " mount Rswag::Ui::Engine => '/#{endpoint_parts&.find(&:present?) || 'api-docs'}'"
627
+ end
628
+ else
629
+ sample_path = rswag_path || '/api-docs'
630
+ puts
631
+ puts "Brick: rswag-ui gem detected -- to make OpenAPI 3.0 documentation available from a path such as '#{sample_path}/v1/swagger.json',"
632
+ puts ' put code such as this in an initializer:'
633
+ puts ' Rswag::Ui.configure do |config|'
634
+ puts " config.swagger_endpoint '#{sample_path}/v1/swagger.json', 'API V1 Docs'"
635
+ puts ' end'
636
+ unless rswag_path
637
+ puts
638
+ puts ' and put this into your routes.rb:'
639
+ puts " mount Rswag::Ui::Engine => '/api-docs'"
640
+ end
641
+ end
642
+ end
643
+
622
644
  ::Brick.routes_done = true
623
645
  puts "\n" if tables.present? || views.present?
624
646
  if tables.present?
@@ -98,40 +98,40 @@ module Brick
98
98
 
99
99
  bar = case (possible_additional_references = possible_additional_references.values.flatten).length
100
100
  when 0
101
- +"# Brick.additional_references = [['orders', 'customer_id', 'customer'],
102
- # ['customer', 'region_id', 'regions']]"
101
+ +" # Brick.additional_references = [['orders', 'customer_id', 'customer'],
102
+ # ['customer', 'region_id', 'regions']]"
103
103
  when 1
104
- +"# # Here is a possible additional reference that has been auto-identified for the #{ActiveRecord::Base.connection.current_database} database:
105
- # Brick.additional_references = [#{possible_additional_references.first}]"
104
+ +" # # Here is a possible additional reference that has been auto-identified for the #{ActiveRecord::Base.connection.current_database} database:
105
+ # Brick.additional_references = [#{possible_additional_references.first}]"
106
106
  else
107
- +"# # Here are possible additional references that have been auto-identified for the #{ActiveRecord::Base.connection.current_database} database:
108
- # Brick.additional_references = [
109
- # #{possible_additional_references.join(",\n# ")}
110
- # ]"
107
+ +" # # Here are possible additional references that have been auto-identified for the #{ActiveRecord::Base.connection.current_database} database:
108
+ # Brick.additional_references = [
109
+ # #{possible_additional_references.join(",\n # ")}
110
+ # ]"
111
111
  end
112
112
  if resembles_fks.length > 0
113
- bar << "\n# # Columns named somewhat like a foreign key which you may want to consider:
114
- # # #{resembles_fks.join(', ')}"
113
+ bar << "\n # # Columns named somewhat like a foreign key which you may want to consider:
114
+ # # #{resembles_fks.join(', ')}"
115
115
  end
116
116
 
117
117
  poly = case (possible_polymorphics = possible_polymorphics.values.flatten.map { |poss_poly| "#{poss_poly} => nil"}).length
118
118
  when 0
119
119
  " like this:
120
- # Brick.polymorphics = {
121
- # 'comments.commentable' => nil,
122
- # 'images.imageable' => nil
123
- # }"
120
+ # Brick.polymorphics = {
121
+ # 'comments.commentable' => nil,
122
+ # 'images.imageable' => nil
123
+ # }"
124
124
  when 1
125
125
  ".
126
- # # Here is a possible polymorphic association that has been auto-identified for the #{ActiveRecord::Base.connection.current_database} database:
127
- # Brick.polymorphics = { #{possible_additional_references.first} }"
126
+ # # Here is a possible polymorphic association that has been auto-identified for the #{ActiveRecord::Base.connection.current_database} database:
127
+ # Brick.polymorphics = { #{possible_additional_references.first} }"
128
128
 
129
129
  else
130
130
  ".
131
- # # Here are possible polymorphic associations that have been auto-identified for the #{ActiveRecord::Base.connection.current_database} database:
132
- # Brick.polymorphics = {
133
- # #{possible_polymorphics.join(",\n# ")}
134
- # }"
131
+ # # Here are possible polymorphic associations that have been auto-identified for the #{ActiveRecord::Base.connection.current_database} database:
132
+ # Brick.polymorphics = {
133
+ # #{possible_polymorphics.join(",\n # ")}
134
+ # }"
135
135
  end
136
136
 
137
137
  create_file(filename, "# frozen_string_literal: true
@@ -139,161 +139,169 @@ module Brick
139
139
  # # Settings for the Brick gem
140
140
  # # (By default this auto-creates models, controllers, views, and routes on-the-fly.)
141
141
 
142
- # # Custom path prefix to apply to all auto-generated Brick routes. Also causes auto-generated controllers
143
- # # to be created inside a module with the same name.
144
- # ::Brick.path_prefix = 'admin'
145
-
146
- # # Normally all are enabled in development mode, and for security reasons only models are enabled in production
147
- # # and test. This allows you to either (a) turn off models entirely, or (b) enable controllers, views, and routes
148
- # # in production.
149
- # Brick.enable_routes = true # Setting this to \"false\" will disable routes in development
150
- # Brick.enable_models = false
151
- # Brick.enable_controllers = true # Setting this to \"false\" will disable controllers in development
152
- # Brick.enable_views = true # Setting this to \"false\" will disable views in development
153
-
154
- # ::Brick.api_root = '/api/v1/' # Path from which to serve out API resources when the RSwag gem is present
155
-
156
- # # By default models are auto-created for database views, and set to be read-only. This can be skipped.
157
- # Brick.skip_database_views = true
158
-
159
- # # Any tables or views you'd like to skip when auto-creating models
160
- # Brick.exclude_tables = ['custom_metadata', 'version_info']
161
-
162
- # # Class that auto-generated models should inherit from
163
- # Brick.models_inherit_from = ApplicationRecord
164
-
165
- # # When table names have specific prefixes automatically place them in their own module with a table_name_prefix.
166
- # Brick.table_name_prefixes = { 'nav_' => 'Navigation' }
167
-
168
- # # COLUMN SEQUENCING AND INCLUSION / EXCLUSION
169
-
170
- # # By default if there is a primary key present then rows in an index view are ordered by this primary key. To
171
- # # use a different rule for doing ORDER BY, you can override this default ordering done by The Brick, for instance
172
- # # to have the rows in a contact list sorted by email:
173
- # Brick.order = { 'contacts' => { _brick_default: :email } }
174
- # # or by last name then first name:
175
- # Brick.order = { 'contacts' => { _brick_default: [:lastname, :firstname] } }
176
- # # Totally legitimate to have the default order be the name of a belongs_to or has_many association instead of an
177
- # # actual column name, in which case for has_many it just orders by the count of how many records are associated,
178
- # # and for belongs_to it's based on the primary table's DSL if any is defined (since that is what is used to
179
- # # calculate what is shown when a foreign table lists out related records). If contacts relates to addresses,
180
- # # then this is perfectly fine:
181
- # Brick.order = { 'contacts' => { _brick_default: :address } }
182
- # # You can even have a specific custom clause used in the ORDER BY. In this case it is recommended to include a
183
- # # special placeholder for the table name with the sequence \"^^^\". Here is an example of having the default
184
- # # ordering happening on the \"code\" column, and also defining custom sorting to be done, in this case proper
185
- # # ordering if that code is stored as a dotted numeric value:
186
- # Brick.order = { 'document_trees' => { _brick_default: :code,
187
- # code: \"ORDER BY STRING_TO_ARRAY(^^^.code, '.')::int[]\" } }
188
-
189
- # # Sequence of columns for each model. This also allows you to add read-only calculated columns in the same
190
- # # kind of way that they can be added in the include: portion of include/exclude columns, below.
191
- # # Designated by { <table name> => [<column name>, <column name>] }
192
- # Brick.column_sequence = { 'users' => ['email', 'profile.firstname', 'profile.lastname'] }
193
-
194
- # # Specific columns to include or exclude for each model. If there are only inclusions then only those
195
- # # columns show. If there are any exclusions then all non-excluded columns are attempted to be shown,
196
- # # which negates the usefulness of inclusions except to add calculated column detail built from DSL.
197
- # # Designated by <table name>.<column name>
198
- # Brick.column_sequence = { 'users' => { include: ['email', 'profile.firstname', 'profile.lastname'] },
199
- # 'profile' => { exclude: ['birthdate'] } }
200
-
201
- # # EXTRA FOREIGN KEYS AND OTHER HAS_MANY SETTINGS
202
-
203
- # # Additional table references which are used to create has_many / belongs_to associations inside auto-created
204
- # # models. (You can consider these to be \"virtual foreign keys\" if you wish)... You only have to add these
205
- # # in cases where your database for some reason does not have foreign key constraints defined. Sometimes for
206
- # # performance reasons or just out of sheer laziness these might be missing.
207
- # # Each of these virtual foreign keys is defined as an array having three values:
208
- # # foreign table name / foreign key column / primary table name.
209
- # # (We boldly expect that the primary key identified by ActiveRecord on the primary table will be accurate,
210
- # # usually this is \"id\" but there are some good smarts that are used in case some other column has been set
211
- # # to be the primary key.)
142
+ if Object.const_defined?('Brick')
143
+ # # Custom path prefix to apply to all auto-generated Brick routes. Also causes auto-generated controllers
144
+ # # to be created inside a module with the same name.
145
+ # ::Brick.path_prefix = 'admin'
146
+
147
+ # # Normally all are enabled in development mode, and for security reasons only models are enabled in production
148
+ # # and test. This allows you to either (a) turn off models entirely, or (b) enable controllers, views, and routes
149
+ # # in production.
150
+ # Brick.enable_routes = true # Setting this to \"false\" will disable routes in development
151
+ # Brick.enable_models = false
152
+ # Brick.enable_controllers = true # Setting this to \"false\" will disable controllers in development
153
+ # Brick.enable_views = true # Setting this to \"false\" will disable views in development
154
+
155
+ # # If The Brick sees that RSwag gem is present, it allows for API resources to be automatically served out.
156
+ # # You can configure the root path for these resources:
157
+ # ::Brick.api_root = '/api/v1/'
158
+ # # You may also want to add an OpenAPI 3.0 documentation endpoint using Rswag::Ui:
159
+ # Rswag::Ui.configure do |config|
160
+ # config.swagger_endpoint '/api-docs/v1/swagger.json', 'API V1 Docs'
161
+ # end
162
+
163
+ # # By default models are auto-created for database views, and set to be read-only. This can be skipped.
164
+ # Brick.skip_database_views = true
165
+
166
+ # # Any tables or views you'd like to skip when auto-creating models
167
+ # Brick.exclude_tables = ['custom_metadata', 'version_info']
168
+
169
+ # # Class that auto-generated models should inherit from
170
+ # Brick.models_inherit_from = ApplicationRecord
171
+
172
+ # # When table names have specific prefixes automatically place them in their own module with a table_name_prefix.
173
+ # Brick.table_name_prefixes = { 'nav_' => 'Navigation' }
174
+
175
+ # # COLUMN SEQUENCING AND INCLUSION / EXCLUSION
176
+
177
+ # # By default if there is a primary key present then rows in an index view are ordered by this primary key. To
178
+ # # use a different rule for doing ORDER BY, you can override this default ordering done by The Brick, for instance
179
+ # # to have the rows in a contact list sorted by email:
180
+ # Brick.order = { 'contacts' => { _brick_default: :email } }
181
+ # # or by last name then first name:
182
+ # Brick.order = { 'contacts' => { _brick_default: [:lastname, :firstname] } }
183
+ # # Totally legitimate to have the default order be the name of a belongs_to or has_many association instead of an
184
+ # # actual column name, in which case for has_many it just orders by the count of how many records are associated,
185
+ # # and for belongs_to it's based on the primary table's DSL if any is defined (since that is what is used to
186
+ # # calculate what is shown when a foreign table lists out related records). If contacts relates to addresses,
187
+ # # then this is perfectly fine:
188
+ # Brick.order = { 'contacts' => { _brick_default: :address } }
189
+ # # You can even have a specific custom clause used in the ORDER BY. In this case it is recommended to include a
190
+ # # special placeholder for the table name with the sequence \"^^^\". Here is an example of having the default
191
+ # # ordering happening on the \"code\" column, and also defining custom sorting to be done, in this case proper
192
+ # # ordering if that code is stored as a dotted numeric value:
193
+ # Brick.order = { 'document_trees' => { _brick_default: :code,
194
+ # code: \"ORDER BY STRING_TO_ARRAY(^^^.code, '.')::int[]\" } }
195
+
196
+ # # Sequence of columns for each model. This also allows you to add read-only calculated columns in the same
197
+ # # kind of way that they can be added in the include: portion of include/exclude columns, below.
198
+ # # Designated by { <table name> => [<column name>, <column name>] }
199
+ # Brick.column_sequence = { 'users' => ['email', 'profile.firstname', 'profile.lastname'] }
200
+
201
+ # # Specific columns to include or exclude for each model. If there are only inclusions then only those
202
+ # # columns show. If there are any exclusions then all non-excluded columns are attempted to be shown,
203
+ # # which negates the usefulness of inclusions except to add calculated column detail built from DSL.
204
+ # # Designated by <table name>.<column name>
205
+ # Brick.column_sequence = { 'users' => { include: ['email', 'profile.firstname', 'profile.lastname'] },
206
+ # 'profile' => { exclude: ['birthdate'] } }
207
+
208
+ # # EXTRA FOREIGN KEYS AND OTHER HAS_MANY SETTINGS
209
+
210
+ # # Additional table references which are used to create has_many / belongs_to associations inside auto-created
211
+ # # models. (You can consider these to be \"virtual foreign keys\" if you wish)... You only have to add these
212
+ # # in cases where your database for some reason does not have foreign key constraints defined. Sometimes for
213
+ # # performance reasons or just out of sheer laziness these might be missing.
214
+ # # Each of these virtual foreign keys is defined as an array having three values:
215
+ # # foreign table name / foreign key column / primary table name.
216
+ # # (We boldly expect that the primary key identified by ActiveRecord on the primary table will be accurate,
217
+ # # usually this is \"id\" but there are some good smarts that are used in case some other column has been set
218
+ # # to be the primary key.)
212
219
  #{bar}
213
220
 
214
- # # Custom columns to add to a table, minimally defined with a name and DSL string.
215
- # Brick.custom_columns = { 'users' => { messages: ['[COUNT(messages)] messages', 'messages'] },
216
- # 'orders' => { salesperson: '[salesperson.first] [salesperson.last]',
217
- # products: ['[COUNT(order_items.product)] products', 'order_items.product' ] }
218
- # }
219
-
220
- # # Skip creating a has_many association for these (only retain the belongs_to built from this additional_reference).
221
- # # (Uses the same exact three-part format as would define an additional_reference)
222
- # # Say for instance that we didn't care to display the favourite colours that users have:
223
- # Brick.exclude_hms = [['users', 'favourite_colour_id', 'colours']]
224
-
225
- # # Skip showing counts for these specific has_many associations when building auto-generated #index views.
226
- # # When there are related tables with a significant number of records (generally 100,000 or more), this can lessen
227
- # # the load on the database considerably, sometimes fixing what might appear to be an index page that just \"hangs\"
228
- # # for no apparent reason.
229
- # Brick.skip_index_hms = ['User.litany_of_woes']
230
-
231
- # # By default primary tables involved in a foreign key relationship will indicate a \"has_many\" relationship pointing
232
- # # back to the foreign table. In order to represent a \"has_one\" association instead, an override can be provided
233
- # # using the primary model name and the association name which you instead want to have treated as a \"has_one\":
234
- # Brick.has_ones = [['User', 'user_profile']]
235
- # # If you want to use an alternate name for the \"has_one\", such as in the case above calling the association \"profile\"
236
- # # instead of \"user_profile\", then apply that as a third parameter like this:
237
- # Brick.has_ones = [['User', 'user_profile', 'profile']]
238
-
239
- # # We normally don't show the timestamp columns \"created_at\", \"updated_at\", and \"deleted_at\", and also do
240
- # # not consider them when finding associative tables to support an N:M association. (That is, ones that can be a
241
- # # part of a has_many :through association.) If you want to use different exclusion columns than our defaults
242
- # # then this setting resets that list. For instance, here is an override that is useful in the Sakila sample
243
- # # database:
244
- # Brick.metadata_columns = ['last_update']
245
-
246
- # # Columns for which to add a validate presence: true even though the database doesn't have them marked as NOT NULL.
247
- # # Designated by <table name>.<column name>
248
- # Brick.not_nullables = ['users.name']
249
-
250
- # # FRIENDLY DSL
251
-
252
- # # A simple DSL is available to allow more user-friendly display of objects. Normally a user object might be shown
253
- # # as its first non-metadata column, or if that is not available then something like \"User #45\" where 45 is that
254
- # # object's ID. If there is no primary key then even that is not possible, so the object's .to_s method is called.
255
- # # To override these defaults and specify exactly what you want shown, such as first names and last names for a
256
- # # user, then you can use model_descrips like this, putting expressions with property references in square brackets:
257
- # Brick.model_descrips = { 'User' => '[profile.firstname] [profile.lastname]' }
258
-
259
- # # SINGLE TABLE INHERITANCE
260
-
261
- # # Specify STI subclasses either directly by name or as a general module prefix that should always relate to a specific
262
- # # parent STI class. The prefixed :: here for these examples is mandatory. Also having a suffixed :: means instead of
263
- # # a class reference, this is for a general namespace reference. So in this case requests for, say, either of the
264
- # # non-existent classes Animals::Cat or Animals::Goat (or anything else with the module prefix of \"Animals::\" would
265
- # # build a model that inherits from Animal. And a request specifically for the class Snake would build a new model
266
- # # that inherits from Reptile, and no other request would do this -- only specifically for Snake. The ending ::
267
- # # indicates that it's a module prefix instead of a specific class name.
268
- # Brick.sti_namespace_prefixes = { '::Animals::' => 'Animal',
269
- # '::Snake' => 'Reptile' }
270
-
271
- # # Custom inheritance_column to be used for STI. This is by default \"type\", and applies to all models. With this
272
- # # option you can change this either for specific models, or apply a new overall name generally:
273
- # Brick.sti_type_column = 'sti_type'
274
- # Brick.sti_type_column = { 'rails_type' => ['sales.specialoffer'] }
275
-
276
- # # POLYMORPHIC ASSOCIATIONS
277
-
278
- # # Database schema to use when analysing existing data, such as deriving a list of polymorphic classes in the case that
279
- # # it wasn't originally specified.
280
- # Brick.schema_behavior = :namespaced
281
- #{Brick.config.schema_behavior.present? ? "Brick.schema_behavior = { multitenant: { schema_to_analyse: #{
221
+ # # Custom columns to add to a table, minimally defined with a name and DSL string.
222
+ # Brick.custom_columns = { 'users' => { messages: ['[COUNT(messages)] messages', 'messages'] },
223
+ # 'orders' => { salesperson: '[salesperson.first] [salesperson.last]',
224
+ # products: ['[COUNT(order_items.product)] products', 'order_items.product' ] }
225
+ # }
226
+
227
+ # # Skip creating a has_many association for these (only retain the belongs_to built from this additional_reference).
228
+ # # (Uses the same exact three-part format as would define an additional_reference)
229
+ # # Say for instance that we didn't care to display the favourite colours that users have:
230
+ # Brick.exclude_hms = [['users', 'favourite_colour_id', 'colours']]
231
+
232
+ # # Skip showing counts for these specific has_many associations when building auto-generated #index views.
233
+ # # When there are related tables with a significant number of records (generally 100,000 or more), this can lessen
234
+ # # the load on the database considerably, sometimes fixing what might appear to be an index page that just \"hangs\"
235
+ # # for no apparent reason.
236
+ # Brick.skip_index_hms = ['User.litany_of_woes']
237
+
238
+ # # By default primary tables involved in a foreign key relationship will indicate a \"has_many\" relationship pointing
239
+ # # back to the foreign table. In order to represent a \"has_one\" association instead, an override can be provided
240
+ # # using the primary model name and the association name which you instead want to have treated as a \"has_one\":
241
+ # Brick.has_ones = [['User', 'user_profile']]
242
+ # # If you want to use an alternate name for the \"has_one\", such as in the case above calling the association \"profile\"
243
+ # # instead of \"user_profile\", then apply that as a third parameter like this:
244
+ # Brick.has_ones = [['User', 'user_profile', 'profile']]
245
+
246
+ # # We normally don't show the timestamp columns \"created_at\", \"updated_at\", and \"deleted_at\", and also do
247
+ # # not consider them when finding associative tables to support an N:M association. (That is, ones that can be a
248
+ # # part of a has_many :through association.) If you want to use different exclusion columns than our defaults
249
+ # # then this setting resets that list. For instance, here is an override that is useful in the Sakila sample
250
+ # # database:
251
+ # Brick.metadata_columns = ['last_update']
252
+
253
+ # # Columns for which to add a validate presence: true even though the database doesn't have them marked as NOT NULL.
254
+ # # Designated by <table name>.<column name>
255
+ # Brick.not_nullables = ['users.name']
256
+
257
+ # # FRIENDLY DSL
258
+
259
+ # # A simple DSL is available to allow more user-friendly display of objects. Normally a user object might be shown
260
+ # # as its first non-metadata column, or if that is not available then something like \"User #45\" where 45 is that
261
+ # # object's ID. If there is no primary key then even that is not possible, so the object's .to_s method is called.
262
+ # # To override these defaults and specify exactly what you want shown, such as first names and last names for a
263
+ # # user, then you can use model_descrips like this, putting expressions with property references in square brackets:
264
+ # Brick.model_descrips = { 'User' => '[profile.firstname] [profile.lastname]' }
265
+
266
+ # # SINGLE TABLE INHERITANCE
267
+
268
+ # # Specify STI subclasses either directly by name or as a general module prefix that should always relate to a specific
269
+ # # parent STI class. The prefixed :: here for these examples is mandatory. Also having a suffixed :: means instead of
270
+ # # a class reference, this is for a general namespace reference. So in this case requests for, say, either of the
271
+ # # non-existent classes Animals::Cat or Animals::Goat (or anything else with the module prefix of \"Animals::\" would
272
+ # # build a model that inherits from Animal. And a request specifically for the class Snake would build a new model
273
+ # # that inherits from Reptile, and no other request would do this -- only specifically for Snake. The ending ::
274
+ # # indicates that it's a module prefix instead of a specific class name.
275
+ # Brick.sti_namespace_prefixes = { '::Animals::' => 'Animal',
276
+ # '::Snake' => 'Reptile' }
277
+
278
+ # # Custom inheritance_column to be used for STI. This is by default \"type\", and applies to all models. With this
279
+ # # option you can change this either for specific models, or apply a new overall name generally:
280
+ # Brick.sti_type_column = 'sti_type'
281
+ # Brick.sti_type_column = { 'rails_type' => ['sales.specialoffer'] }
282
+
283
+ # # POLYMORPHIC ASSOCIATIONS
284
+
285
+ # # Database schema to use when analysing existing data, such as deriving a list of polymorphic classes in the case that
286
+ # # it wasn't originally specified.
287
+ # Brick.schema_behavior = :namespaced
288
+ #{Brick.config.schema_behavior.present? ? " Brick.schema_behavior = { multitenant: { schema_to_analyse: #{
282
289
  Brick.config.schema_behavior[:multitenant]&.fetch(:schema_to_analyse, nil).inspect}" :
283
- "# Brick.schema_behavior = { multitenant: { schema_to_analyse: 'engineering'"
290
+ " # Brick.schema_behavior = { multitenant: { schema_to_analyse: 'engineering'"
284
291
  } } }
285
292
 
286
- # # Polymorphic associations are set up by providing a model name and polymorphic association name#{poly}
293
+ # # Polymorphic associations are set up by providing a model name and polymorphic association name#{poly}
287
294
 
288
- # # DEFAULT ROOT ROUTE
295
+ # # DEFAULT ROOT ROUTE
289
296
 
290
- # # If a default route is not supplied, Brick attempts to find the most \"central\" table and wires up the default
291
- # # route to go to the :index action for what would be a controller for that table. You can specify any controller
292
- # # name and action you wish in order to override this and have that be the default route when none other has been
293
- # # specified in routes.rb or elsewhere. (Or just use an empty string in order to disable this behaviour.)
294
- # Brick.default_route_fallback = 'customers' # This defaults to \"customers#index\"
295
- # Brick.default_route_fallback = 'orders#outstanding' # Example of a non-RESTful route
296
- # Brick.default_route_fallback = '' # Omits setting a default route in the absence of any other
297
+ # # If a default route is not supplied, Brick attempts to find the most \"central\" table and wires up the default
298
+ # # route to go to the :index action for what would be a controller for that table. You can specify any controller
299
+ # # name and action you wish in order to override this and have that be the default route when none other has been
300
+ # # specified in routes.rb or elsewhere. (Or just use an empty string in order to disable this behaviour.)
301
+ # Brick.default_route_fallback = 'customers' # This defaults to \"customers#index\"
302
+ # Brick.default_route_fallback = 'orders#outstanding' # Example of a non-RESTful route
303
+ # Brick.default_route_fallback = '' # Omits setting a default route in the absence of any other
304
+ end
297
305
  ")
298
306
  end
299
307
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brick
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.80
4
+ version: 1.0.81
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lorin Thwaits
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-17 00:00:00.000000000 Z
11
+ date: 2022-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord