acts_as_caxlsx 1.0.8 → 1.0.10

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: 448c5c50dbff1b5d6a745ae7335f445069fab20539b98df37d257edda4f8c9a9
4
- data.tar.gz: d64c0d7721f2b13f6fc6c67f088b4f8ab4c38252aa5c3fbe9bd883b3356bd2b5
3
+ metadata.gz: 929a9ff3b96cbc95728446948d62a6f254fea46612a919c66f21c7dbcf5b57a6
4
+ data.tar.gz: a89a4d43599dd1d1d74a76a1d902ed9b61b76e8dc07671304a84474dd41e9a3b
5
5
  SHA512:
6
- metadata.gz: c624c6baa51827f86e78fdd32d334b44fa2d23ced1fcf7f301a4635ad16ed26158d4f71b331e5030e652ceb9a4aaa69e70077da7ef882eaea4f291767a580d08
7
- data.tar.gz: 2f93f2401e12d28d56577b3b07f59d3056b8097a88b5cd9ea6b46f08dd8d6a847de50821d5128d3068a4129e0525595b53caac9f74ed0ae817d56029d8c1efdf
6
+ metadata.gz: a2b1f3c42a937f4ae39e8771ae5a2c0cc8406f0e21eba4b12fd2f1dbc469e6df1d1c4600b8264d51f41097f4ad67381746f988fd6c019a19916f5a02e2c13f4c
7
+ data.tar.gz: 6a23a8a5fc3452e4a091f31aba50d60b93fdd5dc98baaa7e71990fe7c1b0ef81ac92774f0c7eac9e68d51f0bdfb6de0f4481217d1d39070374592fcdf6b4e851
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  CHANGELOG
2
2
  ---------
3
3
 
4
+ - **Unreleased**
5
+
6
+
7
+ - **April.7.26**: 1.0.10
8
+ - Add Github CI with modern Ruby versions
9
+ - Use Rubygem's trusted publishing
10
+ - Compability fixes
11
+
4
12
  - **July.27.12**: 1.0.6
5
13
  - conditionaly register XLSX mime type
6
14
 
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # Acts as XLSX
1
+ # Acts as Caxlsx
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/caxlsx/acts_as_caxlsx.png)](http://travis-ci.org/caxlsx/acts_as_caxlsx/)
3
+ [![Test](https://github.com/caxlsx/acts_as_caxlsx/actions/workflows/test.yml/badge.svg)](https://github.com/caxlsx/acts_as_caxlsx/actions/workflows/test.yml)
4
+ [![Gem Version](https://badge.fury.io/rb/acts_as_caxlsx.svg)](https://badge.fury.io/rb/acts_as_caxlsx)
5
+ ![downloads](https://img.shields.io/gem/dt/acts_as_caxlsx?label=downloads)
4
6
 
5
7
  ## Notice: Community Axlsx Organization
6
8
 
@@ -12,7 +14,7 @@ http://github.com/caxlsx
12
14
 
13
15
  ## Synopsis
14
16
 
15
- Acts_as_xlsx is an active record plugin for automatic Office Open XML Spreadsheet Generation using Axlsx. It makes generating excel spreadsheets from any subclass of ActiveRecord::Base as simple as a couple of lines of code.
17
+ Acts_as_caxlsx is an active record plugin for automatic Office Open XML Spreadsheet Generation using Caxlsx. It makes generating excel spreadsheets from any subclass of ActiveRecord::Base as simple as a couple of lines of code.
16
18
 
17
19
  ## Feature List
18
20
 
@@ -26,13 +28,11 @@ Acts_as_xlsx is an active record plugin for automatic Office Open XML Spreadshee
26
28
 
27
29
  5. Lets you specify columns and methods chains you want to call to populate your table in one go.
28
30
 
29
- 6. Gives you access to the axlsx package so you can add styles, charts and pictures to satisfy those flashy sales guys.
30
-
31
- 7. Plays nicely with both ruby 1.8.7 + rails 2.3 as well as ruby 1.9.3 + rails 3
31
+ 6. Gives you access to the Caxlsx package so you can add styles, charts and pictures to satisfy those flashy sales guys.
32
32
 
33
33
  8. Automatically registers xlsx Mime type for use in respond_to web-service support.
34
34
 
35
- 9. Allows you to specify the Axlsx package to add your data to so you can create a single workbook with a sheet for each to_xlsx call.
35
+ 9. Allows you to specify the Caxlsx package to add your data to so you can create a single workbook with a sheet for each to_xlsx call.
36
36
 
37
37
 
38
38
  ## Install
@@ -40,7 +40,7 @@ Acts_as_xlsx is an active record plugin for automatic Office Open XML Spreadshee
40
40
  To install, add the following to your Gemfile:
41
41
 
42
42
  ```ruby
43
- gem 'acts_as_xlsx', git: 'https://github.com/caxlsx/acts_as_xlsx.git'
43
+ gem 'acts_as_caxlsx'
44
44
  ```
45
45
 
46
46
 
@@ -56,7 +56,7 @@ The following Usage guides need to be extracted and added to this README
56
56
 
57
57
  Detailed documentation is available at:
58
58
 
59
- [https://www.rubydoc.info/gems/acts_as_xlsx/](https://www.rubydoc.info/gems/acts_as_xlsx/)
59
+ [https://www.rubydoc.info/gems/acts_as_caxlsx/](https://www.rubydoc.info/gems/acts_as_caxlsx/)
60
60
 
61
61
 
62
62
  ## Credits
@@ -65,4 +65,4 @@ Originally created by Randy Morgan - @randym
65
65
 
66
66
  Forked in 2019, to enable the community to maintain the Axlsx ecosystem - http://github.com/caxlsx
67
67
 
68
- Open source software is a community effort. None of this could have been done without the help of [our Contributors](https://github.com/caxlsx/acts_as_xlsx/graphs/contributors).
68
+ Open source software is a community effort. None of this could have been done without the help of [our Contributors](https://github.com/caxlsx/acts_as_caxlsx/graphs/contributors).
data/Rakefile CHANGED
@@ -1,14 +1,13 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/lib/acts_as_xlsx/version.rb')
2
2
 
3
- task :build => :gendoc do
4
- system "gem build acts_as_xlsx.gemspec"
5
- end
3
+ require 'bundler'
4
+ Bundler::GemHelper.install_tasks
6
5
 
7
- task :gendoc do
6
+ task :gendoc do
8
7
  system "yardoc"
9
8
  end
10
9
 
11
- task :test do
10
+ task :test do
12
11
  require 'rake/testtask'
13
12
  Rake::TestTask.new do |t|
14
13
  t.libs << 'test'
@@ -17,8 +16,4 @@ task :test do
17
16
  end
18
17
  end
19
18
 
20
- task :release => :build do
21
- system "gem push acts_as_xlsx-#{Axlsx::Ar::VERSION}.gem"
22
- end
23
-
24
- task :default => :test
19
+ task :default => :test
@@ -54,36 +54,50 @@ module Axlsx
54
54
  header_style = options.delete(:header_style) || row_style
55
55
  types = [options.delete(:types) || []].flatten
56
56
 
57
- i18n = options.delete(:i18n) || self.xlsx_i18n
58
- columns = options.delete(:columns) || self.xlsx_columns
57
+ i18n = if options.key?(:i18n)
58
+ options.delete(:i18n)
59
+ else
60
+ self.xlsx_i18n
61
+ end
62
+
63
+ # columns => [["column_name", "header"], [...], ...]
64
+ columns = Array.wrap(options.delete(:columns) || self.xlsx_columns).flat_map { |col|
65
+ col.is_a?(Hash) ? col.to_a : [[col, nil]]
66
+ }
67
+
68
+ headers = options.delete(:headers)
69
+ headers||= columns.map { |(col_name, col_header)|
70
+ if col_header
71
+ col_header
72
+ elsif i18n == true
73
+ self.human_attribute_name(col_name)
74
+ elsif i18n
75
+ I18n.t("#{i18n_key}.#{self.name.underscore}.#{col_name}", default: col_name.to_s.humanize)
76
+ else
77
+ col_name.to_s.humanize
78
+ end
79
+ }
59
80
 
60
81
  p = options.delete(:package) || Package.new
61
82
  row_style = p.workbook.styles.add_style(row_style) unless row_style.nil?
62
83
  header_style = p.workbook.styles.add_style(header_style) unless header_style.nil?
63
- i18n = self.xlsx_i18n == true ? 'activerecord.attributes' : i18n
64
- sheet_name = options.delete(:name) || (i18n ? (self.xlsx_i18n == true ? self.model_name.human : I18n.t("#{i18n}.#{table_name.underscore}")) : table_name.humanize)
84
+ i18n_key = i18n == true ? 'activerecord.attributes' : i18n
85
+ sheet_name = options.delete(:name) || (i18n ? (i18n == true ? self.model_name.human : I18n.t("#{i18n_key}.#{table_name.underscore}", default: table_name.humanize)) : table_name.humanize)
65
86
  data = options.delete(:data) || where(options[:where]).order(options[:order]).to_a
66
87
  data = data.compact.flatten
67
88
 
68
89
 
69
90
  return p if data.empty?
70
91
  p.workbook.add_worksheet(:name=>sheet_name) do |sheet|
71
-
72
- col_labels = if i18n
73
- columns.map { |c| self.xlsx_i18n == true ? self.human_attribute_name(c) : I18n.t("#{i18n}.#{self.name.underscore}.#{c}") }
74
- else
75
- columns.map { |c| c.to_s.humanize }
76
- end
77
-
78
- sheet.add_row col_labels, :style=>header_style
92
+ sheet.add_row headers, :style=>header_style
79
93
 
80
94
  data.each do |r|
81
- row_data = columns.map do |c|
82
- if c.to_s =~ /\./
83
- v = r; c.to_s.split('.').each { |method| !v.nil? ? v = v.send(method) : v = ""; }; v
84
- else
85
- r.send(c)
95
+ row_data = columns.map do |(column_name, _column_header)|
96
+ v = r
97
+ column_name.to_s.split('.').each do |method|
98
+ !v.nil? ? v = v.send(method) : v = nil
86
99
  end
100
+ v
87
101
  end
88
102
  sheet.add_row row_data, :style=>row_style, :types=>types
89
103
  end
@@ -1,6 +1,6 @@
1
1
  module Axlsx
2
2
  module Ar
3
3
  # The current version of the gem
4
- VERSION = "1.0.8"
4
+ VERSION = "1.0.10"
5
5
  end
6
6
  end
@@ -70,7 +70,14 @@ class TestToXlsx < Test::Unit::TestCase
70
70
  assert_equal(Post.last.comments.last.author.name, sheet.rows.last.cells.last.value)
71
71
  end
72
72
 
73
-
73
+ def test_complex_columns
74
+ p = Post.to_xlsx columns: [{name: "CUSTOM NAME HEADER", votes: "CUSTOM VOTES HEADER"}, :content, ranking: "CUSTOM RANKING HEADER"]
75
+ sheet = p.workbook.worksheets.first
76
+ assert_equal("CUSTOM NAME HEADER", sheet.rows.first.cells[0].value)
77
+ assert_equal("CUSTOM VOTES HEADER", sheet.rows.first.cells[1].value)
78
+ assert_equal("Content", sheet.rows.first.cells[2].value)
79
+ assert_equal("CUSTOM RANKING HEADER", sheet.rows.first.cells[3].value)
80
+ end
74
81
 
75
82
  end
76
83
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_caxlsx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Randy Morgan
8
8
  - Noel Peden
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-14 00:00:00.000000000 Z
11
+ date: 2026-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: caxlsx
@@ -71,7 +71,7 @@ files:
71
71
  - lib/acts_as_xlsx/version.rb
72
72
  - test/database.yml
73
73
  - test/helper.rb
74
- - test/tc_acts_as_xlsx.rb
74
+ - test/tc_acts_as_xlsx_test.rb
75
75
  homepage: https://github.com/caxlsx/acts_as_caxlsx
76
76
  licenses: []
77
77
  metadata: {}
@@ -82,17 +82,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
82
  requirements:
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
- version: '2.3'
85
+ version: '2.6'
86
86
  required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - ">="
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  requirements: []
92
- rubygems_version: 3.6.7
92
+ rubygems_version: 4.0.6
93
93
  specification_version: 4
94
94
  summary: ActiveRecord support for Axlsx
95
95
  test_files:
96
96
  - test/database.yml
97
97
  - test/helper.rb
98
- - test/tc_acts_as_xlsx.rb
98
+ - test/tc_acts_as_xlsx_test.rb