brick 1.0.95 → 1.0.96

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: ebb01aca7fcf3fa8cfbb699e48fa85601341df79645d4f3d6ebc5a43351c3d29
4
- data.tar.gz: 2bca81242ee8eaa5bbfd477b39df8eb969f8999abe680329e2ae9b1b4ef928a7
3
+ metadata.gz: 0061ad25b22deee43d1939b6541257924a61a67b3b8b004fb6a0072302746ca2
4
+ data.tar.gz: 99968b9de834f73c60842bf5da03b5bddd750f1ff8c3ac1dac294078f0eb2358
5
5
  SHA512:
6
- metadata.gz: 566f2e6925b918fb8c7b3bf545dc8fd98f840b35fdf875e0f7812de3f127dae21e2fd4b9a2f3e9faba5255ec83d76b0651657e0051aa8e9706429354dee4d012
7
- data.tar.gz: b07ce93b35464f516e3f03b1c8c98d215b3fa2db1051af5d6d41131313d694e483cc7cc40a063b6fd6b70e6d5eb2afb99fb9cc47914a81e6dc0a2392a5b2602c
6
+ metadata.gz: 4958e2b0c18522be75134ab29df481213594189b4addd6ef9368ae8677aba603cbb278176c57c51217a49c0042e98927cb33465995bc4aae01f3af59b2d64f15
7
+ data.tar.gz: 1d486886f30ce384edc7d84a441617906b26b001c7c3562558289eedfd4b0c12e2a860c587f71acb6e6727649a3756223f1240c07f4e1013029cfe5b67a9c117
data/lib/brick/config.rb CHANGED
@@ -304,12 +304,12 @@ module Brick
304
304
  true
305
305
  end
306
306
 
307
- def license_key
308
- @mutex.synchronize { @license_key }
307
+ def license
308
+ @mutex.synchronize { @license }
309
309
  end
310
310
 
311
- def license_key=(key)
312
- @mutex.synchronize { @license_key = key }
311
+ def license=(key)
312
+ @mutex.synchronize { @license = key }
313
313
  end
314
314
  end
315
315
  end
@@ -1097,10 +1097,10 @@ erDiagram
1097
1097
  end
1098
1098
 
1099
1099
  when 'crosstab'
1100
- if is_crosstab && ::Brick.config.license_key
1100
+ if is_crosstab && ::Brick.config.license
1101
1101
  decipher = OpenSSL::Cipher::AES256.new(:CBC).decrypt
1102
1102
  decipher.iv = "\xB4,\r2\x19\xF5\xFE/\aR\x1A\x8A\xCFV\v\x8C"
1103
- decipher.key = Digest::SHA256.hexdigest(::Brick.config.license_key).scan(/../).map { |x| x.hex }.pack('c*')
1103
+ decipher.key = Digest::SHA256.hexdigest(::Brick.config.license).scan(/../).map { |x| x.hex }.pack('c*')
1104
1104
  decipher.update(File.binread("/Users/aga/brick/lib/brick/frameworks/rails/crosstab.brk"))[16..-1]
1105
1105
  else
1106
1106
  'Crosstab Charting not yet activated -- enter a valid license key in brick.rb'
@@ -5,7 +5,7 @@ module Brick
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 0
8
- TINY = 95
8
+ TINY = 96
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
@@ -466,8 +466,8 @@ module Brick
466
466
  Brick.config.default_route_fallback = resource_name
467
467
  end
468
468
 
469
- def license_key=(key)
470
- Brick.config.license_key = key
469
+ def license=(key)
470
+ Brick.config.license = key
471
471
  end
472
472
 
473
473
  # Load additional references (virtual foreign keys)
@@ -1257,65 +1257,67 @@ module ActiveRecord
1257
1257
  # For AR >= 4.2
1258
1258
  if self.const_defined?('JoinDependency')
1259
1259
  class JoinDependency
1260
- # An intelligent .eager_load() and .includes() that creates t0_r0 style aliases only for the columns
1261
- # used in .select(). To enable this behaviour, include the flag :_brick_eager_load as the first
1262
- # entry in your .select().
1263
- # More information: https://discuss.rubyonrails.org/t/includes-and-select-for-joined-data/81640
1264
- def apply_column_aliases(relation)
1265
- used_cols = {}
1266
- if (sel_vals = relation.select_values.map(&:to_s)).first == '_brick_eager_load'
1267
- # Find and expand out all column names being used in select(...)
1268
- new_select_values = sel_vals.each_with_object([]) do |col, s|
1269
- next if col == '_brick_eager_load'
1270
-
1271
- if col.include?(' ') # Some expression? (No chance for a simple column reference)
1272
- s << col # Just pass it through
1260
+ if ActiveRecord.version >= ::Gem::Version.new('6.0')
1261
+ # An intelligent .eager_load() and .includes() that creates t0_r0 style aliases only for the columns
1262
+ # used in .select(). To enable this behaviour, include the flag :_brick_eager_load as the first
1263
+ # entry in your .select().
1264
+ # More information: https://discuss.rubyonrails.org/t/includes-and-select-for-joined-data/81640
1265
+ def apply_column_aliases(relation)
1266
+ used_cols = {}
1267
+ if (sel_vals = relation.select_values.map(&:to_s)).first == '_brick_eager_load'
1268
+ # Find and expand out all column names being used in select(...)
1269
+ new_select_values = sel_vals.each_with_object([]) do |col, s|
1270
+ next if col == '_brick_eager_load'
1271
+
1272
+ if col.include?(' ') # Some expression? (No chance for a simple column reference)
1273
+ s << col # Just pass it through
1274
+ else
1275
+ col = if (col_parts = col.split('.')).length == 1
1276
+ [col]
1277
+ else
1278
+ [col_parts[0..-2].join('.'), col_parts.last]
1279
+ end
1280
+ used_cols[col] = nil
1281
+ end
1282
+ end
1283
+ if new_select_values.present?
1284
+ relation.select_values = new_select_values
1273
1285
  else
1274
- col = if (col_parts = col.split('.')).length == 1
1275
- [col]
1276
- else
1277
- [col_parts[0..-2].join('.'), col_parts.last]
1278
- end
1279
- used_cols[col] = nil
1286
+ relation.select_values.clear
1280
1287
  end
1281
1288
  end
1282
- if new_select_values.present?
1283
- relation.select_values = new_select_values
1284
- else
1285
- relation.select_values.clear
1286
- end
1287
- end
1288
1289
 
1289
- @aliases ||= Aliases.new(join_root.each_with_index.map do |join_part, i|
1290
- join_alias = join_part.table&.table_alias || join_part.table_name
1291
- keys = [join_part.base_klass.primary_key] # Always include the primary key
1290
+ @aliases ||= Aliases.new(join_root.each_with_index.map do |join_part, i|
1291
+ join_alias = join_part.table&.table_alias || join_part.table_name
1292
+ keys = [join_part.base_klass.primary_key] # Always include the primary key
1292
1293
 
1293
- # # %%% Optional to include all foreign keys:
1294
- # keys.concat(join_part.base_klass.reflect_on_all_associations.select { |a| a.belongs_to? }.map(&:foreign_key))
1294
+ # # %%% Optional to include all foreign keys:
1295
+ # keys.concat(join_part.base_klass.reflect_on_all_associations.select { |a| a.belongs_to? }.map(&:foreign_key))
1295
1296
 
1296
- # Add foreign keys out to referenced tables that we belongs_to
1297
- join_part.children.each { |child| keys << child.reflection.foreign_key if child.reflection.belongs_to? }
1297
+ # Add foreign keys out to referenced tables that we belongs_to
1298
+ join_part.children.each { |child| keys << child.reflection.foreign_key if child.reflection.belongs_to? }
1298
1299
 
1299
- # Add the foreign key that got us here -- "the train we rode in on" -- if we arrived from
1300
- # a has_many or has_one:
1301
- if join_part.is_a?(ActiveRecord::Associations::JoinDependency::JoinAssociation) &&
1302
- !join_part.reflection.belongs_to?
1303
- keys << join_part.reflection.foreign_key
1304
- end
1305
- keys = keys.compact # In case we're using composite_primary_keys
1306
- j = 0
1307
- columns = join_part.column_names.each_with_object([]) do |column_name, s|
1308
- # Include columns chosen in select(...) as well as the PK and any relevant FKs
1309
- if used_cols.keys.find { |c| (c.length == 1 || c.first == join_alias) && c.last == column_name } ||
1310
- keys.find { |c| c == column_name }
1311
- s << Aliases::Column.new(column_name, "t#{i}_r#{j}")
1300
+ # Add the foreign key that got us here -- "the train we rode in on" -- if we arrived from
1301
+ # a has_many or has_one:
1302
+ if join_part.is_a?(ActiveRecord::Associations::JoinDependency::JoinAssociation) &&
1303
+ !join_part.reflection.belongs_to?
1304
+ keys << join_part.reflection.foreign_key
1312
1305
  end
1313
- j += 1
1314
- end
1315
- Aliases::Table.new(join_part, columns)
1316
- end)
1306
+ keys = keys.compact # In case we're using composite_primary_keys
1307
+ j = 0
1308
+ columns = join_part.column_names.each_with_object([]) do |column_name, s|
1309
+ # Include columns chosen in select(...) as well as the PK and any relevant FKs
1310
+ if used_cols.keys.find { |c| (c.length == 1 || c.first == join_alias) && c.last == column_name } ||
1311
+ keys.find { |c| c == column_name }
1312
+ s << Aliases::Column.new(column_name, "t#{i}_r#{j}")
1313
+ end
1314
+ j += 1
1315
+ end
1316
+ Aliases::Table.new(join_part, columns)
1317
+ end)
1317
1318
 
1318
- relation._select!(-> { @aliases.columns })
1319
+ relation._select!(-> { @aliases.columns })
1320
+ end
1319
1321
  end
1320
1322
 
1321
1323
  private
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.95
4
+ version: 1.0.96
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-11-24 00:00:00.000000000 Z
11
+ date: 2022-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord