xlsxtream_rails 0.3.0 → 0.5.1

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: abbdd2ed40b9778899f75dcf87ded14f9a1f1f8b0d9d1644123ef93e4bbc6bb3
4
- data.tar.gz: a91d3281e92d57977011198a4f19a656fb17f22fd0569df6d6d14868c63efe49
3
+ metadata.gz: c8badf4f76488f1191f935438668b77dd0150fbb82897f0d01282417f33a3f0d
4
+ data.tar.gz: 333216c1f8364794d41091bc18b4c946a9fe2bbd4c26e6a7fdf94eb064f054b5
5
5
  SHA512:
6
- metadata.gz: 2e65e4414b26b6147e3a1b15d0a9ecde53c858ace2a1fa47063e91c346a278fb90cac60b8aeb926441c66afa13208fe328836578546dfd516f432c559eccedbe
7
- data.tar.gz: 5722f6a0e4ca69c813bbe872f9fc7be16860eef3b17399d1690cb821b1ea090d1fd54f429f212e508c9584fa735e7b943be1be24ccd08515af859bf07cb997ad
6
+ metadata.gz: 9d1d1cbf6ab63615dfa6be3e99fe4d4e6dc96017d513eb35c61e8e20d33b1a77c00cc9302ac5f2be0355809a236c95264f6044ed32b22faea0a757dab82a1c33
7
+ data.tar.gz: 7da464c44a4053a4ab1be7b604d8543391f47e0d285e27f902d3f2aa97e8008d47bd2dfbdfaeeb18f6f1b83eb50744e5049079c6c9b738f1bd982929f4c2f2ab
@@ -9,8 +9,10 @@ ActionController::Renderers.add :xlsx do |data, options|
9
9
  # disposition / filename
10
10
  options[:disposition] = options.delete(:disposition) || "attachment"
11
11
 
12
- if defined?(ActiveRecord) && data.is_a?(ActiveRecord::Relation)
13
- options[:filename] ||= data.klass.name.pluralize
12
+ options[:filename] ||= if defined?(ActiveRecord) && data.is_a?(ActiveRecord::Relation)
13
+ "#{data.klass.model_name.human}_#{Time.now.to_i}"
14
+ else
15
+ Time.now.to_i.to_s
14
16
  end
15
17
 
16
18
  options[:filename] = options[:filename] ? options[:filename].strip.sub(/\.xlsx$/i, "") : "data"
@@ -0,0 +1,8 @@
1
+ module XlsxtreamRails
2
+ module ClassMethods
3
+ # TODO
4
+ def to_xlsx
5
+ column_names.map { |x| x.to_sym }
6
+ end
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module XlsxtreamRails
2
- VERSION = "0.3.0"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -1,11 +1,15 @@
1
1
  require "xlsxtream"
2
+ require "xlsxtream_rails/class_methods"
2
3
  require "xlsxtream_rails/utils"
3
4
  require "xlsxtream_rails/version"
4
5
  require "xlsxtream_rails/railtie"
5
6
 
6
7
  module XlsxtreamRails
8
+ def self.included(base)
9
+ base.send(:extend, ClassMethods)
10
+ end
11
+
7
12
  def xlsx_columns(opts = {})
8
- column_names = self.class.column_names
9
- column_names.map { |x| x.to_sym }
13
+ self.class.to_xlsx
10
14
  end
11
15
  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.3.0
4
+ version: 0.5.1
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-22 00:00:00.000000000 Z
11
+ date: 2022-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -51,6 +51,7 @@ files:
51
51
  - lib/tasks/xlsxtream_rails_tasks.rake
52
52
  - lib/xlsxtream_rails.rb
53
53
  - lib/xlsxtream_rails/action_controller.rb
54
+ - lib/xlsxtream_rails/class_methods.rb
54
55
  - lib/xlsxtream_rails/railtie.rb
55
56
  - lib/xlsxtream_rails/utils.rb
56
57
  - lib/xlsxtream_rails/version.rb