active_record_mysql_repl 0.1.11 → 0.1.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb6fc1b3f679c3d78bad8a6541aedf64f60c754f01bc74e6d44bcea63ea28dff
4
- data.tar.gz: a73b8b96f89a055be12bd21ff0c702f43d83526fef7cd414215c7e4da9c3f171
3
+ metadata.gz: 160466e890cc14e62324cc901b40a0c6d6e763975acfb63277c986be775ebf59
4
+ data.tar.gz: aada8ca1327db2781938c15d4d0856fd5145873ab4a94bb280342d619f7eac7a
5
5
  SHA512:
6
- metadata.gz: fec7d990aa73ecb706a85c087ffb9ea35dc95f9cf75d5478f4cd5307fccd9aa119b1095aee49660e71ca932c9109221ad022a3ab42f1a9f5fea63467869dab2e
7
- data.tar.gz: 94ca47f50670cb1ee908708dd1cd17567b8bc97104204546566fd237afa45ef989af5675dee9f0c453726b91a1d14fcc1bb95f4ed4792e6c2fd54b2e2e1a9427
6
+ metadata.gz: 59f475c00a2f0dfcb62353e32c7737109a73beccfd9b1a43e98b8f7539828b4959555de4f3178d82701cbc14d66ddbbe5d58c4b43aa97fa85e7169cd93ea9923
7
+ data.tar.gz: e584f60bdb9eb7928873ca8ef0bda40ce7444111ac3ef122dee096de5c8dd520185dac482cf5126a380d437c297392c6a6d7fa8b4055d2f05bc9d4993af2f936
@@ -18,17 +18,15 @@ module ActiverecordMysqlRepl
18
18
  end
19
19
 
20
20
  arr = arr.map do |e|
21
- if e.is_a?(::ActiveRecord::Base)
22
- values = e.attributes.transform_values do |v|
23
- next JSON.pretty_generate(v) if v.is_a?(Enumerable) && v.size > 0
24
- next v.to_time if v.is_a?(Time) || v.is_a?(Date)
25
- next "NULL" if v.nil?
26
- next '""' if v == ""
27
- v.to_s
28
- end
29
- next values
21
+ e = e.attributes if e.is_a?(::ActiveRecord::Base)
22
+ next e unless e.is_a?(Hash)
23
+ next e.transform_values do |v|
24
+ next JSON.pretty_generate(v) if v.is_a?(Enumerable) && v.size > 0
25
+ next v.to_time if v.is_a?(Time) || v.is_a?(Date)
26
+ next "NULL" if v.nil?
27
+ next '""' if v == ""
28
+ v.to_s
30
29
  end
31
- e
32
30
  end
33
31
 
34
32
  raise "#{arr} is not an array of hash".red unless arr.all? { |e| e.is_a?(Hash) }
@@ -55,10 +53,12 @@ module ActiverecordMysqlRepl
55
53
  t.rows = arr.map(&:values)
56
54
 
57
55
  when :vertical
58
- t.headings = ["Name", "Value"]
59
- arr.each.with_index do |row, i|
60
- row.each { |col, val| t.add_row [col, val] }
61
- t.add_separator if i < arr.size - 1
56
+ headings = ["Column", arr.map.with_index { |_, i| "Record#{i+1}" }].flatten
57
+ t.headings = headings
58
+
59
+ arr.first.keys.each_with_index do |col|
60
+ cols = [col, arr.map { |r| r[col] }].flatten
61
+ t.add_row cols
62
62
  end
63
63
  end
64
64
 
@@ -79,17 +79,15 @@ module ActiverecordMysqlRepl
79
79
  end
80
80
 
81
81
  arr = arr.map do |e|
82
- if e.is_a?(::ActiveRecord::Base)
83
- values = e.attributes.transform_values do |v|
84
- next JSON.pretty_generate(v) if v.is_a?(Enumerable) && v.size > 0
85
- next v.to_time if v.is_a?(Time) || v.is_a?(Date)
86
- next "NULL" if v.nil?
87
- next '""' if v == ""
88
- v.to_s
89
- end
90
- next values
82
+ e = e.attributes if e.is_a?(::ActiveRecord::Base)
83
+ next e unless e.is_a?(Hash)
84
+ next e.transform_values do |v|
85
+ next JSON.pretty_generate(v) if v.is_a?(Enumerable) && v.size > 0
86
+ next v.to_time if v.is_a?(Time) || v.is_a?(Date)
87
+ next "NULL" if v.nil?
88
+ next '""' if v == ""
89
+ v.to_s
91
90
  end
92
- e
93
91
  end
94
92
 
95
93
  raise "#{arr} is not an array of hash".red unless arr.all? { |e| e.is_a?(Hash) }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecordMysqlRepl
4
- VERSION = "0.1.11"
4
+ VERSION = "0.1.13"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_mysql_repl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroki Kishi
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-04-07 00:00:00.000000000 Z
10
+ date: 2025-09-16 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: byebug