xlsxtream_rails 0.5.1 → 0.8.0

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: c8badf4f76488f1191f935438668b77dd0150fbb82897f0d01282417f33a3f0d
4
- data.tar.gz: 333216c1f8364794d41091bc18b4c946a9fe2bbd4c26e6a7fdf94eb064f054b5
3
+ metadata.gz: f2d0c21cedd9e6ad0db1e0901c8aa34c6f807af2a6ff74f7c2cc9f0ad73e55e9
4
+ data.tar.gz: 5472a61f18f68506ed8b5c223223408dfe8e34ae3f8cece760e721ae5827926d
5
5
  SHA512:
6
- metadata.gz: 9d1d1cbf6ab63615dfa6be3e99fe4d4e6dc96017d513eb35c61e8e20d33b1a77c00cc9302ac5f2be0355809a236c95264f6044ed32b22faea0a757dab82a1c33
7
- data.tar.gz: 7da464c44a4053a4ab1be7b604d8543391f47e0d285e27f902d3f2aa97e8008d47bd2dfbdfaeeb18f6f1b83eb50744e5049079c6c9b738f1bd982929f4c2f2ab
6
+ metadata.gz: e5fe3f222f21df6d7ba3cc9e676e4e4502f1f5faca10382a937db0085f79ebfef2c32fa795903ba160a0f5009a6e240966158b319919a5d11dc35fbeed75ca67
7
+ data.tar.gz: 3871dedd5b52ee8bd034a1e48129071cd36345dbfe8d22b325b3fc9d0913ee0cbeec27bc2fe15b0b8e8890adffbb063d4c776cf40cae5f9fa1a6c7c0a293f069
@@ -1,8 +1,8 @@
1
1
  module XlsxtreamRails
2
2
  module ClassMethods
3
- # TODO
4
3
  def to_xlsx
5
- column_names.map { |x| x.to_sym }
4
+ except_columns = respond_to?(:xlsx_except_columns) ? xlsx_except_columns : []
5
+ (column_names - except_columns).map { |x| x.to_sym }
6
6
  end
7
7
  end
8
8
  end
@@ -10,13 +10,13 @@ module XlsxtreamRails
10
10
  instance_cols = instance.xlsx_columns
11
11
  instance_cols.each_with_index do |x, i|
12
12
  if x.is_a?(Array)
13
- headers.push(x[0].to_s) if needs_headers
13
+ headers.push(i18n_attr(instance, x[0])) if needs_headers
14
14
  row_data.push(x[1].is_a?(Symbol) ? instance.send(x[1]) : x[1])
15
15
  if needs_column_types
16
16
  column_types[i] = x[2]
17
17
  end
18
18
  else
19
- headers.push(str_titleize(x.to_s)) if needs_headers
19
+ headers.push(i18n_attr(instance, x)) if needs_headers
20
20
  row_data.push(x.is_a?(Symbol) ? instance.send(x) : x)
21
21
  end
22
22
  end
@@ -27,11 +27,9 @@ module XlsxtreamRails
27
27
  end
28
28
  end
29
29
 
30
- def self.str_titleize(str)
31
- str.sub(/\A_+/, "")
32
- .gsub(/[_.]/, " ")
33
- .sub(" rescue nil", "")
34
- .gsub(/(\A|\ )\w/) { |x| x.upcase }
30
+ def self.i18n_attr(instance, attr)
31
+ attr = attr.is_a?(Symbol) ? attr : attr.to_sym
32
+ instance.class.human_attribute_name(attr)
35
33
  end
36
34
  end
37
35
  end
@@ -1,3 +1,3 @@
1
1
  module XlsxtreamRails
2
- VERSION = "0.5.1"
2
+ VERSION = "0.8.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xlsxtream_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - doabit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-23 00:00:00.000000000 Z
11
+ date: 2022-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails