breathing 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/breathing.gemspec +1 -1
- data/lib/breathing/excel.rb +14 -44
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e0db4001a0d83c74be3f2adcf49f754ea0c39837ecb17c13e2fbf016dc73ad8
|
4
|
+
data.tar.gz: 31cc6bd7ad4391573b64c909ea713dea43260a5b1e379405396e24f8bf29da18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 802fb8542d7b310d40c8ca066c603416a5976f6729d4d4e6bcd4942b383a517ee75500c99503093b2d70226592d7fbc83aab14bd92930d84183255e7a1319b92
|
7
|
+
data.tar.gz: 783595b5a3faa2d5934ba2cfe1b5baa95c37c6d1131ffadcbaf54cb3ba120642c5c93d9932081916710a5e48ef2e002ba2c7e1e7fff046d8a198e3bb43dbb30c
|
data/breathing.gemspec
CHANGED
data/lib/breathing/excel.rb
CHANGED
@@ -26,9 +26,8 @@ module Breathing
|
|
26
26
|
end
|
27
27
|
add_body_rows(sheet, rows, column_widths)
|
28
28
|
|
29
|
-
column_widths.each.with_index
|
30
|
-
|
31
|
-
end
|
29
|
+
column_widths.each.with_index { |size, i| sheet.change_column_width(i, size + 2) }
|
30
|
+
|
32
31
|
add_style(sheet)
|
33
32
|
end
|
34
33
|
|
@@ -38,56 +37,27 @@ module Breathing
|
|
38
37
|
private
|
39
38
|
|
40
39
|
def add_header_row(sheet, row, column_widths)
|
41
|
-
|
42
|
-
|
43
|
-
cell.
|
44
|
-
end
|
45
|
-
sheet.add_cell(0, 1, 'change_logs.created_at').tap do |cell|
|
46
|
-
cell.change_font_bold(true)
|
47
|
-
cell.change_fill('ddedf3') # color: blue
|
48
|
-
end
|
49
|
-
sheet.add_cell(0, 2, 'action').tap do |cell|
|
50
|
-
cell.change_font_bold(true)
|
51
|
-
cell.change_fill('ddedf3') # color: blue
|
52
|
-
end
|
53
|
-
sheet.add_cell(0, 3, 'id').tap do |cell|
|
40
|
+
header_color = 'ddedf3' # blue
|
41
|
+
row.data_attributes.keys.each.with_index do |header_column, column_index|
|
42
|
+
cell = sheet.add_cell(0, column_index, header_column)
|
54
43
|
cell.change_font_bold(true)
|
55
|
-
cell.change_fill(
|
56
|
-
end
|
44
|
+
cell.change_fill(header_color)
|
57
45
|
|
58
|
-
|
59
|
-
column_widths << 'change_logs.created_at'.size
|
60
|
-
column_widths << 'action'.size
|
61
|
-
column_widths << 'id'.size
|
62
|
-
|
63
|
-
row.data_column_names.each.with_index(3) do |column_name, i|
|
64
|
-
cell = sheet.add_cell(0, i, column_name)
|
65
|
-
cell.change_font_bold(true)
|
66
|
-
cell.change_fill('ddedf3') # color: blue
|
67
|
-
column_widths << column_name.size
|
46
|
+
column_widths << header_column.size
|
68
47
|
end
|
69
48
|
end
|
70
49
|
|
71
50
|
def add_body_rows(sheet, rows, column_widths)
|
72
|
-
rows.each.with_index(1) do |row,
|
73
|
-
|
74
|
-
|
75
|
-
sheet.add_cell(i, 0, row.id)
|
76
|
-
sheet.add_cell(i, 1, row.created_at.to_s(:db))
|
77
|
-
sheet.add_cell(i, 2, row.action)
|
78
|
-
sheet.add_cell(i, 3, row.transaction_id)
|
79
|
-
|
80
|
-
data = row.action == 'DELETE' ? row.before_data : row.after_data
|
81
|
-
|
82
|
-
row.data_column_names.each.with_index(3) do |column_name, j|
|
83
|
-
value = data[column_name].to_s
|
84
|
-
column_widths[j] = value.size if column_widths[j] < value.size
|
85
|
-
cell_object = sheet.add_cell(i, j, value)
|
51
|
+
rows.each.with_index(1) do |row, row_number|
|
52
|
+
row.data_attributes.each.with_index do |(column_name, value), column_index|
|
53
|
+
cell = sheet.add_cell(row_number, column_index, value)
|
86
54
|
if row.action == 'UPDATE' && column_name != 'updated_at' && row.changed_attribute_columns.include?(column_name)
|
87
|
-
|
55
|
+
cell.change_fill('ffff00') # color: yellow
|
88
56
|
elsif row.action == 'DELETE'
|
89
|
-
|
57
|
+
cell.change_fill('d9d9d9') # color: grey
|
90
58
|
end
|
59
|
+
|
60
|
+
column_widths[column_index] = value.to_s.size if column_widths[column_index] < value.to_s.size
|
91
61
|
end
|
92
62
|
end
|
93
63
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: breathing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Kusumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|