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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6108eb021949faaaaf3d08037dddd7dee71d4fe53592ed5991bc29c4ef9f724
4
- data.tar.gz: 36219756e661c52c19879a0510e9452bacdd34bef21f7cb767dcf37e46d14ba0
3
+ metadata.gz: 1e0db4001a0d83c74be3f2adcf49f754ea0c39837ecb17c13e2fbf016dc73ad8
4
+ data.tar.gz: 31cc6bd7ad4391573b64c909ea713dea43260a5b1e379405396e24f8bf29da18
5
5
  SHA512:
6
- metadata.gz: 4e4d6f883ef9e715b52ca09cf3d69135c7f8c49eb7ada7da157ec6164ccb39321c3a9217547541cfe8040bae2c2480328ad9568694f227ba10ae3e72d1246c58
7
- data.tar.gz: 05b8557f1c107daf79c00e086554daddb51e8987327dfb8dafd5f030f85e25cca6b8df53e1192fd2902fd3e62820b2cacc8019227c5f07c27ac3ab02f835a628
6
+ metadata.gz: 802fb8542d7b310d40c8ca066c603416a5976f6729d4d4e6bcd4942b383a517ee75500c99503093b2d70226592d7fbc83aab14bd92930d84183255e7a1319b92
7
+ data.tar.gz: 783595b5a3faa2d5934ba2cfe1b5baa95c37c6d1131ffadcbaf54cb3ba120642c5c93d9932081916710a5e48ef2e002ba2c7e1e7fff046d8a198e3bb43dbb30c
@@ -2,7 +2,7 @@ $:.push File.expand_path('lib', __dir__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'breathing'
5
- s.version = '0.0.6'
5
+ s.version = '0.0.7'
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ['Akira Kusumoto']
8
8
  s.email = ['akirakusumo10@gmail.com']
@@ -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(0) do |size, i|
30
- sheet.change_column_width(i, size + 2)
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
- sheet.add_cell(0, 0, 'change_logs.id').tap do |cell|
42
- cell.change_font_bold(true)
43
- cell.change_fill('ddedf3') # color: blue
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('ddedf3') # color: blue
56
- end
44
+ cell.change_fill(header_color)
57
45
 
58
- column_widths << 'change_logs.id'.size
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, i|
73
- column_widths[0] = row.id.to_s.size if column_widths[0] < row.id.to_s.size
74
- column_widths[2] = row.transaction_id.to_s.size if column_widths[2] < row.transaction_id.to_s.size
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
- cell_object.change_fill('ffff00') # color: yellow
55
+ cell.change_fill('ffff00') # color: yellow
88
56
  elsif row.action == 'DELETE'
89
- cell_object.change_fill('d9d9d9') # color: grey
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.6
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-18 00:00:00.000000000 Z
11
+ date: 2020-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor