axlsx_styler 1.0.0 → 1.1.0
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/CHANGELOG.md +3 -0
- data/README.md +13 -1
- data/lib/axlsx_styler/axlsx_styles.rb +21 -21
- data/lib/axlsx_styler/axlsx_workbook.rb +4 -2
- data/lib/axlsx_styler/axlsx_worksheet.rb +27 -10
- data/lib/axlsx_styler/version.rb +1 -1
- data/test/dummy_app/app/assets/config/manifest.js +3 -0
- data/test/dummy_app/config/application.rb +0 -7
- data/test/dummy_app/db/test.sqlite3 +0 -0
- data/test/dummy_app/log/test.log +768 -494
- data/test/test_helper.rb +3 -2
- data/test/unit/regresssions_test.rb +44 -0
- metadata +30 -30
- data/test/custom_assertions.rb +0 -21
- data/test/unit/general_test.rb +0 -84
data/test/test_helper.rb
CHANGED
@@ -3,7 +3,9 @@ ENV["RAILS_ENV"] = "test"
|
|
3
3
|
require File.expand_path("../dummy_app/config/environment.rb", __FILE__)
|
4
4
|
|
5
5
|
migration_path = Rails.root.join('db/migrate')
|
6
|
-
if ActiveRecord.gem_version >= ::Gem::Version.new("
|
6
|
+
if ActiveRecord.gem_version >= ::Gem::Version.new("6.0.0")
|
7
|
+
ActiveRecord::MigrationContext.new(migration_path, ActiveRecord::SchemaMigration).migrate
|
8
|
+
elsif ActiveRecord.gem_version >= ::Gem::Version.new("5.2.0")
|
7
9
|
ActiveRecord::MigrationContext.new(migration_path).migrate
|
8
10
|
else
|
9
11
|
ActiveRecord::Migrator.migrate(migration_path)
|
@@ -21,7 +23,6 @@ end
|
|
21
23
|
require 'minitest/reporters'
|
22
24
|
Minitest::Reporters.use!
|
23
25
|
|
24
|
-
require 'custom_assertions'
|
25
26
|
require 'helper_methods'
|
26
27
|
|
27
28
|
### Cleanup old test spreadsheets
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RegressionsTest < MiniTest::Test
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@axlsx = Axlsx::Package.new
|
7
|
+
@workbook = @axlsx.workbook
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_dxf_cell
|
11
|
+
@workbook.add_worksheet do |sheet|
|
12
|
+
sheet.add_row (1..2).to_a
|
13
|
+
sheet.add_style "A1:A1", { bg_color: "AA0000" }
|
14
|
+
|
15
|
+
sheet.add_row (1..2).to_a
|
16
|
+
sheet.add_style "B1:B1", { bg_color: "CC0000" }
|
17
|
+
|
18
|
+
sheet.add_row (1..2).to_a
|
19
|
+
sheet.add_style "A3:B3", { bg_color: "00FF00" }
|
20
|
+
|
21
|
+
highlight = @workbook.styles.add_style(bg_color: "0000FF", type: :dxf)
|
22
|
+
|
23
|
+
sheet.add_conditional_formatting(
|
24
|
+
"A2:B2",
|
25
|
+
{
|
26
|
+
type: :cellIs,
|
27
|
+
operator: :greaterThan,
|
28
|
+
formula: "1",
|
29
|
+
dxfId: highlight,
|
30
|
+
priority: 1
|
31
|
+
}
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
serialize("test_dxf_cell")
|
36
|
+
|
37
|
+
#puts @workbook.styles.dxfs.map{|x| x.to_xml_string}
|
38
|
+
assert_equal @workbook.styles.dxfs.count, 1
|
39
|
+
|
40
|
+
#puts @workbook.styles.cellXfs.map{|x| x.to_xml_string}
|
41
|
+
assert_equal @workbook.styles.cellXfs.count, 6
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: axlsx_styler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Weston Ganger
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-08-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: caxlsx
|
@@ -158,8 +158,8 @@ files:
|
|
158
158
|
- lib/axlsx_styler/axlsx_worksheet.rb
|
159
159
|
- lib/axlsx_styler/border_creator.rb
|
160
160
|
- lib/axlsx_styler/version.rb
|
161
|
-
- test/custom_assertions.rb
|
162
161
|
- test/dummy_app/Rakefile
|
162
|
+
- test/dummy_app/app/assets/config/manifest.js
|
163
163
|
- test/dummy_app/app/assets/javascripts/application.js
|
164
164
|
- test/dummy_app/app/assets/stylesheets/application.css
|
165
165
|
- test/dummy_app/app/controllers/application_controller.rb
|
@@ -192,8 +192,8 @@ files:
|
|
192
192
|
- test/test_helper.rb
|
193
193
|
- test/unit/borders_test.rb
|
194
194
|
- test/unit/examples_test.rb
|
195
|
-
- test/unit/general_test.rb
|
196
195
|
- test/unit/merge_styles_test.rb
|
196
|
+
- test/unit/regresssions_test.rb
|
197
197
|
- test/unit/serialize_test.rb
|
198
198
|
- test/unit/to_stream_test.rb
|
199
199
|
homepage: https://github.com/axlsx-styler-gem/axlsx_styler
|
@@ -215,47 +215,47 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
215
|
- !ruby/object:Gem::Version
|
216
216
|
version: '0'
|
217
217
|
requirements: []
|
218
|
-
rubygems_version: 3.
|
218
|
+
rubygems_version: 3.1.2
|
219
219
|
signing_key:
|
220
220
|
specification_version: 4
|
221
221
|
summary: Build clean and maintainable styles for your axlsx spreadsheets. Build your
|
222
222
|
spreadsheeet with data and then apply styles later.
|
223
223
|
test_files:
|
224
|
-
- test/
|
225
|
-
- test/
|
226
|
-
- test/
|
227
|
-
- test/
|
228
|
-
- test/
|
224
|
+
- test/integration/application_test.rb
|
225
|
+
- test/test_helper.rb
|
226
|
+
- test/unit/examples_test.rb
|
227
|
+
- test/unit/borders_test.rb
|
228
|
+
- test/unit/merge_styles_test.rb
|
229
|
+
- test/unit/regresssions_test.rb
|
230
|
+
- test/unit/serialize_test.rb
|
231
|
+
- test/unit/to_stream_test.rb
|
229
232
|
- test/dummy_app/app/models/application_record.rb
|
230
|
-
- test/dummy_app/app/views/layouts/application.html.erb
|
231
233
|
- test/dummy_app/app/views/spreadsheets/test.xlsx.axlsx
|
232
|
-
- test/dummy_app/
|
233
|
-
- test/dummy_app/
|
234
|
+
- test/dummy_app/app/views/layouts/application.html.erb
|
235
|
+
- test/dummy_app/app/assets/stylesheets/application.css
|
236
|
+
- test/dummy_app/app/assets/config/manifest.js
|
237
|
+
- test/dummy_app/app/assets/javascripts/application.js
|
238
|
+
- test/dummy_app/app/controllers/spreadsheets_controller.rb
|
239
|
+
- test/dummy_app/app/controllers/application_controller.rb
|
240
|
+
- test/dummy_app/config.ru
|
241
|
+
- test/dummy_app/log/test.log
|
234
242
|
- test/dummy_app/config/database.yml
|
235
|
-
- test/dummy_app/config/environment.rb
|
236
|
-
- test/dummy_app/config/environments/development.rb
|
237
243
|
- test/dummy_app/config/environments/production.rb
|
238
244
|
- test/dummy_app/config/environments/test.rb
|
239
|
-
- test/dummy_app/config/
|
245
|
+
- test/dummy_app/config/environments/development.rb
|
246
|
+
- test/dummy_app/config/routes.rb
|
247
|
+
- test/dummy_app/config/environment.rb
|
248
|
+
- test/dummy_app/config/locales/en.yml
|
249
|
+
- test/dummy_app/config/boot.rb
|
250
|
+
- test/dummy_app/config/initializers/secret_token.rb
|
240
251
|
- test/dummy_app/config/initializers/inflections.rb
|
241
252
|
- test/dummy_app/config/initializers/mime_types.rb
|
242
|
-
- test/dummy_app/config/initializers/secret_token.rb
|
243
253
|
- test/dummy_app/config/initializers/session_store.rb
|
244
254
|
- test/dummy_app/config/initializers/wrap_parameters.rb
|
245
|
-
- test/dummy_app/config/
|
246
|
-
- test/dummy_app/config/routes.rb
|
255
|
+
- test/dummy_app/config/initializers/backtrace_silencers.rb
|
247
256
|
- test/dummy_app/config/secrets.yml
|
248
|
-
- test/dummy_app/config.
|
257
|
+
- test/dummy_app/config/application.rb
|
258
|
+
- test/dummy_app/Rakefile
|
249
259
|
- test/dummy_app/db/schema.rb
|
250
260
|
- test/dummy_app/db/test.sqlite3
|
251
|
-
- test/dummy_app/log/test.log
|
252
|
-
- test/dummy_app/Rakefile
|
253
261
|
- test/helper_methods.rb
|
254
|
-
- test/integration/application_test.rb
|
255
|
-
- test/test_helper.rb
|
256
|
-
- test/unit/borders_test.rb
|
257
|
-
- test/unit/examples_test.rb
|
258
|
-
- test/unit/general_test.rb
|
259
|
-
- test/unit/merge_styles_test.rb
|
260
|
-
- test/unit/serialize_test.rb
|
261
|
-
- test/unit/to_stream_test.rb
|
data/test/custom_assertions.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
def assert_changed(expression, &block)
|
2
|
-
if expression.respond_to?(:call)
|
3
|
-
e = expression
|
4
|
-
else
|
5
|
-
e = lambda{ eval(expression, block.binding) }
|
6
|
-
end
|
7
|
-
old = e.call
|
8
|
-
block.call
|
9
|
-
assert_not_equal old, e.call
|
10
|
-
end
|
11
|
-
|
12
|
-
def assert_not_changed(expression, &block)
|
13
|
-
if expression.respond_to?(:call)
|
14
|
-
e = expression
|
15
|
-
else
|
16
|
-
e = lambda{ eval(expression, block.binding) }
|
17
|
-
end
|
18
|
-
old = e.call
|
19
|
-
block.call
|
20
|
-
assert_equal old, e.call
|
21
|
-
end
|
data/test/unit/general_test.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class GeneralTest < MiniTest::Test
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@axlsx = Axlsx::Package.new
|
7
|
-
@workbook = @axlsx.workbook
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_adding_styled_cells
|
11
|
-
p = Axlsx::Package.new
|
12
|
-
wb = p.workbook
|
13
|
-
wb.add_styled_cell 'Cell 1'
|
14
|
-
wb.add_styled_cell 'Cell 2'
|
15
|
-
assert_equal ['Cell 1', 'Cell 2'].to_set, wb.styled_cells
|
16
|
-
assert_nil wb.styles_applied
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_can_add_style
|
20
|
-
p = Axlsx::Package.new
|
21
|
-
wb = p.workbook
|
22
|
-
sheet = wb.add_worksheet
|
23
|
-
row = sheet.add_row ["x", "y"]
|
24
|
-
cell = row.cells.first
|
25
|
-
|
26
|
-
cell.add_style b: true
|
27
|
-
assert_equal({b: true}, cell.raw_style)
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_table_with_num_fmt
|
31
|
-
filename = 'num_fmt_test'
|
32
|
-
t = Time.now
|
33
|
-
day = 24 * 60 * 60
|
34
|
-
@workbook.add_worksheet do |sheet|
|
35
|
-
sheet.add_row %w(Date Count Percent)
|
36
|
-
sheet.add_row [t - 2 * day, 2, 2.to_f.round(2) / 11]
|
37
|
-
sheet.add_row [t - 1 * day, 3, 3.to_f.round(2) / 11]
|
38
|
-
sheet.add_row [t, 6, 6.to_f.round(2) / 11]
|
39
|
-
|
40
|
-
sheet.add_style 'A1:B1', b: true
|
41
|
-
sheet.add_style 'A2:A4', format_code: 'YYYY-MM-DD hh:mm:ss'
|
42
|
-
end
|
43
|
-
serialize(filename)
|
44
|
-
assert_equal 2, @workbook.styles.style_index.count
|
45
|
-
assert_equal 2 + 2, @workbook.styles.style_index.keys.max
|
46
|
-
assert_equal 5, @workbook.styled_cells.count
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_duplicate_styles
|
50
|
-
filename = 'duplicate_styles'
|
51
|
-
@workbook.add_worksheet do |sheet|
|
52
|
-
sheet.add_row %w(Index City)
|
53
|
-
sheet.add_row [1, 'Ottawa']
|
54
|
-
sheet.add_row [2, 'Boston']
|
55
|
-
|
56
|
-
sheet.add_border 'A1:B1', [:bottom]
|
57
|
-
sheet.add_border 'A1:B1', [:bottom]
|
58
|
-
sheet.add_style 'A1:A3', b: true
|
59
|
-
sheet.add_style 'A1:A3', b: true
|
60
|
-
end
|
61
|
-
serialize(filename)
|
62
|
-
assert_equal 4, @workbook.styled_cells.count
|
63
|
-
assert_equal 3, @workbook.styles.style_index.count
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_multiple_named_styles
|
67
|
-
filename = 'multiple_named_styles'
|
68
|
-
bold_blue = { b: true, fg_color: '0000FF' }
|
69
|
-
large = { sz: 16 }
|
70
|
-
red = { fg_color: 'FF0000' }
|
71
|
-
@workbook.add_worksheet do |sheet|
|
72
|
-
sheet.add_row %w(Index City)
|
73
|
-
sheet.add_row [1, 'Ottawa']
|
74
|
-
sheet.add_row [2, 'Boston']
|
75
|
-
|
76
|
-
sheet.add_style 'A1:B1', bold_blue, large
|
77
|
-
sheet.add_style 'A1:A3', red
|
78
|
-
end
|
79
|
-
serialize(filename)
|
80
|
-
assert_equal 4, @workbook.styled_cells.count
|
81
|
-
assert_equal 3, @workbook.styles.style_index.count
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|