brick 1.0.177 → 1.0.179
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/lib/brick/extensions.rb +11 -1
- data/lib/brick/frameworks/rails/engine.rb +42 -4
- data/lib/brick/version_number.rb +1 -1
- data/lib/brick.rb +32 -1
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 54b14ce2c9b998599c3fd529f0a718a85365c49f7405a97e698155e2b9cf22be
|
|
4
|
+
data.tar.gz: e1337a86afb957dc8a5545090dc667534bbf792266e82f4654a55611b92b7e18
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c0bee060354c43c662e41e247957f896d7680af9b11cd4109e4ad32ef4b5b8bf907f64d2ed66d32bb59522addb540d1dc3a9e4812f2fdfc1dd6eb6a4da6e516a
|
|
7
|
+
data.tar.gz: a44dc906d317e74100463a1ffb18935e91ee7a818727131fa4813f5329cbc0db07f7995d08246d32052239d4a6bae15db8db4de51cfcdb0c3d250b08e341d4ee
|
data/lib/brick/extensions.rb
CHANGED
|
@@ -1911,6 +1911,16 @@ class Object
|
|
|
1911
1911
|
instance_variable_set(:@resources, ::Brick.get_status_of_resources)
|
|
1912
1912
|
add_csp_hash
|
|
1913
1913
|
end
|
|
1914
|
+
self.define_method :schema_create do
|
|
1915
|
+
if (base_class = (model = params['modelName']&.constantize).base_class) &&
|
|
1916
|
+
base_class.column_names.exclude?(col_name = params['colName'])
|
|
1917
|
+
ActiveRecord::Base.connection.add_column(base_class.table_name.to_sym, col_name, (col_type = params['colType']).to_sym)
|
|
1918
|
+
base_class.reset_column_information
|
|
1919
|
+
::Brick.relations[base_class.table_name]&.fetch(:cols, nil)&.[]=(col_name, [col_type, nil, false, false])
|
|
1920
|
+
# instance_variable_set(:@schema, ::Brick.find_schema(::Brick.set_db_schema(params).first))
|
|
1921
|
+
add_csp_hash
|
|
1922
|
+
end
|
|
1923
|
+
end
|
|
1914
1924
|
self.define_method :orphans do
|
|
1915
1925
|
instance_variable_set(:@orphans, ::Brick.find_orphans(::Brick.set_db_schema(params).first))
|
|
1916
1926
|
add_csp_hash
|
|
@@ -2581,7 +2591,7 @@ end.class_exec do
|
|
|
2581
2591
|
if arca::AbstractAdapter.private_instance_methods.include?(:with_raw_connection)
|
|
2582
2592
|
db_statements.define_method(:begin_db_transaction) do
|
|
2583
2593
|
log("begin immediate transaction", "TRANSACTION") do
|
|
2584
|
-
with_raw_connection(allow_retry: true,
|
|
2594
|
+
with_raw_connection(allow_retry: true, materialize_transactions: false) do |conn|
|
|
2585
2595
|
conn.transaction(:immediate)
|
|
2586
2596
|
end
|
|
2587
2597
|
end
|
|
@@ -793,7 +793,7 @@ window.addEventListener(\"popstate\", linkSchemas);
|
|
|
793
793
|
end.html_safe
|
|
794
794
|
table_options << "<option value=\"#{prefix}brick_status\">(Status)</option>".html_safe if ::Brick.config.add_status
|
|
795
795
|
table_options << "<option value=\"#{prefix}brick_orphans\">(Orphans)</option>".html_safe if is_orphans
|
|
796
|
-
table_options << "<option value=\"#{prefix}
|
|
796
|
+
table_options << "<option value=\"#{prefix}brick_crosstab\">(Crosstab)</option>".html_safe if is_crosstab
|
|
797
797
|
css = +"<style>
|
|
798
798
|
#titleSticky {
|
|
799
799
|
position: sticky;
|
|
@@ -1063,6 +1063,8 @@ document.querySelectorAll(\"input[type=submit][data-confirm]\").forEach(function
|
|
|
1063
1063
|
}
|
|
1064
1064
|
function doFetch(method, payload, success) {
|
|
1065
1065
|
payload.authenticity_token = <%= session[:_csrf_token].inspect.html_safe %>;
|
|
1066
|
+
var action = payload._brick_action || location.href;
|
|
1067
|
+
delete payload._brick_action;
|
|
1066
1068
|
if (!success) {
|
|
1067
1069
|
success = function (p) {p.text().then(function (response) {
|
|
1068
1070
|
var result = JSON.parse(response).result;
|
|
@@ -1071,7 +1073,7 @@ function doFetch(method, payload, success) {
|
|
|
1071
1073
|
}
|
|
1072
1074
|
var options = {method: method, headers: {\"Content-Type\": \"application/json\"}};
|
|
1073
1075
|
if (payload) options.body = JSON.stringify(payload);
|
|
1074
|
-
return fetch(
|
|
1076
|
+
return fetch(action, options).then(success);
|
|
1075
1077
|
}
|
|
1076
1078
|
|
|
1077
1079
|
// Cause descriptive text to use the same font as the resource
|
|
@@ -1088,7 +1090,8 @@ if (window.brickFontFamily) {
|
|
|
1088
1090
|
end %>"
|
|
1089
1091
|
|
|
1090
1092
|
erd_markup = if @_brick_model
|
|
1091
|
-
"<div id=\"mermaidErd\"
|
|
1093
|
+
"<div id=\"mermaidErd\">
|
|
1094
|
+
<div id=\"mermaidDiagram\" class=\"mermaid\">
|
|
1092
1095
|
erDiagram
|
|
1093
1096
|
<% def sidelinks(shown_classes, klass)
|
|
1094
1097
|
links = []
|
|
@@ -1168,6 +1171,40 @@ erDiagram
|
|
|
1168
1171
|
# callback < %= cb_k % > erdClick
|
|
1169
1172
|
@_brick_monetized_attributes = model.respond_to?(:monetized_attributes) ? model.monetized_attributes.values : {}
|
|
1170
1173
|
%>
|
|
1174
|
+
</div>#{
|
|
1175
|
+
add_column = nil
|
|
1176
|
+
# Make into a server control with a javascript snippet
|
|
1177
|
+
# Have post back go to a common "brick_schema" endpoint, this one for add_column
|
|
1178
|
+
"
|
|
1179
|
+
<table style=\"position: relative; z-index: 2; border: 2px solid blue;\"><tr>
|
|
1180
|
+
<td rowspan=\"2\">Add<br>Column</td>
|
|
1181
|
+
<td style=\"padding-bottom: 0px\">Type</td><td style=\"padding-bottom: 0px\">Name</td>
|
|
1182
|
+
<td rowspan=\"2\"><input type=\"button\" id=\"btnAddCol\" value=\"+\"></td>
|
|
1183
|
+
</tr><tr><td style=\"padding-top: 0px\">
|
|
1184
|
+
<select id=\"ddlColType\">
|
|
1185
|
+
<option value=\"string\">String</option>
|
|
1186
|
+
<option value=\"text\">Text</option>
|
|
1187
|
+
<option value=\"integer\">Integer</option>
|
|
1188
|
+
<option value=\"bool\">Boolean</option>
|
|
1189
|
+
</select></td>
|
|
1190
|
+
<td style=\"padding-top: 0px\"><input id=\"txtColName\"></td>
|
|
1191
|
+
</tr></table>
|
|
1192
|
+
<script>
|
|
1193
|
+
var btnAddCol = document.getElementById(\"btnAddCol\");
|
|
1194
|
+
btnAddCol.addEventListener(\"click\", function () {
|
|
1195
|
+
var txtColName = document.getElementById(\"txtColName\");
|
|
1196
|
+
var ddlColType = document.getElementById(\"ddlColType\");
|
|
1197
|
+
doFetch(\"POST\", {modelName: \"#{@_brick_model.name}\",
|
|
1198
|
+
colName: txtColName.value, colType: ddlColType.value,
|
|
1199
|
+
_brick_action: \"/#{prefix}brick_schema\"},
|
|
1200
|
+
function () { // If it returns successfully, do a page refresh
|
|
1201
|
+
location.href = location.href;
|
|
1202
|
+
}
|
|
1203
|
+
);
|
|
1204
|
+
});
|
|
1205
|
+
</script>
|
|
1206
|
+
" unless add_column == false}
|
|
1207
|
+
|
|
1171
1208
|
</div>
|
|
1172
1209
|
"
|
|
1173
1210
|
end
|
|
@@ -1489,7 +1526,8 @@ end
|
|
|
1489
1526
|
decipher = OpenSSL::Cipher::AES256.new(:CBC).decrypt
|
|
1490
1527
|
decipher.iv = "\xB4,\r2\x19\xF5\xFE/\aR\x1A\x8A\xCFV\v\x8C"
|
|
1491
1528
|
decipher.key = Digest::SHA256.hexdigest(::Brick.config.license).scan(/../).map { |x| x.hex }.pack('c*')
|
|
1492
|
-
|
|
1529
|
+
brick_path = Gem::Specification.find_by_name('brick').gem_dir
|
|
1530
|
+
decipher.update(File.binread("#{brick_path}/lib/brick/frameworks/rails/crosstab.brk"))[16..-1]
|
|
1493
1531
|
else
|
|
1494
1532
|
'Crosstab Charting not yet activated -- enter a valid license key in brick.rb'
|
|
1495
1533
|
end
|
data/lib/brick/version_number.rb
CHANGED
data/lib/brick.rb
CHANGED
|
@@ -89,7 +89,7 @@ end
|
|
|
89
89
|
# is first established), and then automatically creates models, controllers, views,
|
|
90
90
|
# and routes based on those available relations.
|
|
91
91
|
require 'brick/config'
|
|
92
|
-
if Gem::Specification.all_names.any? { |g| g.start_with?('rails-') && g[6..-1] =~ /^([0-9]|\.)+(?:|rc1|beta1)$/ }
|
|
92
|
+
if Gem::Specification.all_names.any? { |g| g.start_with?('rails-') && g[6..-1] =~ /^([0-9]|\.)+(?:|rc1|rc2|beta1)$/ }
|
|
93
93
|
require 'rails'
|
|
94
94
|
require 'brick/frameworks/rails'
|
|
95
95
|
end
|
|
@@ -1089,6 +1089,15 @@ In config/initializers/brick.rb appropriate entries would look something like:
|
|
|
1089
1089
|
get("/#{controller_prefix}brick_status", to: 'brick_gem#status', as: status_as.to_s)
|
|
1090
1090
|
end
|
|
1091
1091
|
|
|
1092
|
+
# ::Brick.config.add_schema &&
|
|
1093
|
+
if (schema_as = "#{controller_prefix.tr('/', '_')}brick_schema".to_sym)
|
|
1094
|
+
(
|
|
1095
|
+
!(schema_route = instance_variable_get(:@set).named_routes.find { |route| route.first == schema_as }&.last) ||
|
|
1096
|
+
!schema_route.ast.to_s.include?("/#{controller_prefix}brick_schema/")
|
|
1097
|
+
)
|
|
1098
|
+
post("/#{controller_prefix}brick_schema", to: 'brick_gem#schema_create', as: schema_as.to_s)
|
|
1099
|
+
end
|
|
1100
|
+
|
|
1092
1101
|
if ::Brick.config.add_orphans && (orphans_as = "#{controller_prefix.tr('/', '_')}brick_orphans".to_sym)
|
|
1093
1102
|
(
|
|
1094
1103
|
!(orphans_route = instance_variable_get(:@set).named_routes.find { |route| route.first == orphans_as }&.last) ||
|
|
@@ -2026,6 +2035,28 @@ if ActiveRecord.version < ::Gem::Version.new('6.0') && ruby_version >= ::Gem::Ve
|
|
|
2026
2035
|
end
|
|
2027
2036
|
end
|
|
2028
2037
|
|
|
2038
|
+
# AR >= 5.0 on Ruby >= 3.0
|
|
2039
|
+
::ActiveRecord::Type::AdapterSpecificRegistry.class_exec do
|
|
2040
|
+
alias :_brick_add_modifier :add_modifier
|
|
2041
|
+
def add_modifier(*args, **kwargs)
|
|
2042
|
+
kwargs.merge!(args.pop) if args.length > 2 && args.last.is_a?(Hash)
|
|
2043
|
+
_brick_add_modifier(*args, **kwargs)
|
|
2044
|
+
end
|
|
2045
|
+
end
|
|
2046
|
+
|
|
2047
|
+
# AR >= 5.0 on Ruby >= 3.0
|
|
2048
|
+
arca = ::ActiveRecord::ConnectionAdapters
|
|
2049
|
+
require 'active_record/connection_adapters/postgresql/column'
|
|
2050
|
+
if arca.const_defined?('PostgreSQLColumn')
|
|
2051
|
+
arca::PostgreSQLColumn.class_exec do
|
|
2052
|
+
alias :_brick_initialize :initialize
|
|
2053
|
+
def initialize(*args, **kwargs)
|
|
2054
|
+
kwargs.merge!(args.pop) if args.last.is_a?(Hash)
|
|
2055
|
+
_brick_initialize(*args, **kwargs)
|
|
2056
|
+
end
|
|
2057
|
+
end
|
|
2058
|
+
end
|
|
2059
|
+
|
|
2029
2060
|
require 'active_model'
|
|
2030
2061
|
begin
|
|
2031
2062
|
require 'active_model/type'
|
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.
|
|
4
|
+
version: 1.0.179
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lorin Thwaits
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-
|
|
11
|
+
date: 2023-10-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -165,19 +165,19 @@ dependencies:
|
|
|
165
165
|
- !ruby/object:Gem::Version
|
|
166
166
|
version: 1.42.0
|
|
167
167
|
- !ruby/object:Gem::Dependency
|
|
168
|
-
name:
|
|
168
|
+
name: mysql2
|
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
|
170
170
|
requirements:
|
|
171
|
-
- - "
|
|
171
|
+
- - "~>"
|
|
172
172
|
- !ruby/object:Gem::Version
|
|
173
|
-
version: '0'
|
|
173
|
+
version: '0.5'
|
|
174
174
|
type: :development
|
|
175
175
|
prerelease: false
|
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
|
177
177
|
requirements:
|
|
178
|
-
- - "
|
|
178
|
+
- - "~>"
|
|
179
179
|
- !ruby/object:Gem::Version
|
|
180
|
-
version: '0'
|
|
180
|
+
version: '0.5'
|
|
181
181
|
- !ruby/object:Gem::Dependency
|
|
182
182
|
name: pg
|
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|