xlsxtream_rails 0.5.0 → 0.7.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: 9a54b0cad604244bd9547c4b096192ac193b7e326dc4b013eab909b78edea6c2
4
- data.tar.gz: e565f309ddb38b134d307c1558dad4a2b0696787688af64853923de4bbbde1d9
3
+ metadata.gz: 744d930605ccd3e7d39a90dc38887739001a5725f20ca7a43ef046a52b030945
4
+ data.tar.gz: de0b14ad7f35d31961ce91bc5522dfe380c66b95f0f12857c431bf0580838f56
5
5
  SHA512:
6
- metadata.gz: cac8f0033dd5a7d1b2af96243e011d573da24885a2013ce819d66d806da6b28b88c18d30f6c9cd9bd96d61402df45bdd6081efe57a9ea2b2badcbec67728e66d
7
- data.tar.gz: 1dfa9fffbdc4092d0ae4641d5311eaa27940fcad75af1b28645f75109622ea4543243ec3ef70fb45172c065359158326647d88b80995098243431f61590e1a7d
6
+ metadata.gz: 9f3761bd105dc7f803c1b929e1f402483143eafe4e6c030e4653cc091d395f48a8ed3aa27cae5594c1797eca64ceee2ba5e42425149a30a6c6dd9f5f684a5228
7
+ data.tar.gz: 61a863cbc7e32cf755e92e9ee5d9dfc9fb2fb1ddd56e852dc4d722ea56ce47b9427b5bb077a1dcac94ab30cb4e69b51de8d39f90550f7d9525ed2c5ed47b96ab
@@ -12,7 +12,7 @@ ActionController::Renderers.add :xlsx do |data, options|
12
12
  options[:filename] ||= if defined?(ActiveRecord) && data.is_a?(ActiveRecord::Relation)
13
13
  "#{data.klass.model_name.human}_#{Time.now.to_i}"
14
14
  else
15
- Time.now.to_i
15
+ Time.now.to_i.to_s
16
16
  end
17
17
 
18
18
  options[:filename] = options[:filename] ? options[:filename].strip.sub(/\.xlsx$/i, "") : "data"
@@ -2,7 +2,11 @@ module XlsxtreamRails
2
2
  module ClassMethods
3
3
  # TODO
4
4
  def to_xlsx
5
- column_names.map { |x| x.to_sym }
5
+ (column_names - except_xlsx_columns).map { |x| x.to_sym }
6
+ end
7
+
8
+ def except_xlsx_columns
9
+ []
6
10
  end
7
11
  end
8
12
  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.0"
2
+ VERSION = "0.7.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.0
4
+ version: 0.7.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