as_csv 3.0.0 → 3.0.1

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: de71beec63d08a1f5458d90b0c1467356f2fa04ee5c2ba4fc02677567c9ddbe3
4
- data.tar.gz: f2be9c1aa77fcbd6d3bbfc8b2a47df0581cd34aa4540ed9a885801cbff698de8
3
+ metadata.gz: 8af870672a5c660bf534d462e8bc5cb16b4212a944c6ea471196f54cc5c422f6
4
+ data.tar.gz: fb419f709a93da5293e05315b2ffa0cb41c3adb9d3dc81b61534717198e3dfbd
5
5
  SHA512:
6
- metadata.gz: 740b0966dfe962994b91c0989d776f9cc638b9bd03246ff1f352aab3d056a5385f5f95178c455b1703c0acca420d8702b8c4ddbd7ae9b244f9acba9a1581327c
7
- data.tar.gz: e6ef60c4b2334f72c091d627ec297081b334e6b0796becca4d1bfe36b65e4cdfc268882f01a469e20f1bd8f4b15f9648e41bb05e856cd037e1d12a5539130105
6
+ metadata.gz: 821778f8b9ba8e2ec23297361cd1d5311a824a9c153fabf1a5c2bbe6a9c669ef62c28f3b45825e1496ace0fd2e866a17dd51613a81f74fefeb4ef5550cc83567
7
+ data.tar.gz: 3057fef0b1dea2f0d353e2094a377544527d0e1209ca2139e7cfe6019c425dab4f0262d7069b45437c2b84b33b8e4c8cff44c39c792d1d1e8d3d86ff0029c390
data/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [3.0.1] - 2022-11-08
7
+
8
+ ### Fixed
9
+
10
+ - Improved support for Rails 7 by using a proper Railtie.
11
+
6
12
  ## [3.0.0] - 2022-11-08
7
13
 
8
14
  ### Added
@@ -1,8 +1,27 @@
1
1
  require 'as_csv/active_model/serialization/csv'
2
2
 
3
- ActiveModel::Serialization.send :include, AsCSV::ActiveModel::Serialization::CSV
3
+ # Use the Railtie to hook into the Rails initialization process
4
+ module AsCsv
5
+ class Railtie < Rails::Railtie
4
6
 
5
- ActionController::Renderers.add :csv do |obj, options|
6
- response.headers['Content-Disposition'] = 'attachment'
7
- obj.respond_to?(:to_csv) ? obj.to_csv(options) : obj
7
+ initializer "as_csv" do
8
+
9
+ # Include the CSV serialization module into ActiveRecord::Base and
10
+ # ActiveModel::Serialization
11
+ ActiveSupport.on_load :active_record do
12
+ ActiveRecord::Base.send :include, AsCSV::ActiveModel::Serialization::CSV
13
+ ActiveModel::Serialization.send :include, AsCSV::ActiveModel::Serialization::CSV
14
+ end
15
+
16
+ # Add a :csv renderer to ActionController::Renderers
17
+ ActiveSupport.on_load :action_controller do
18
+ ActionController::Renderers.add :csv do |obj, options|
19
+ response.headers['Content-Disposition'] = 'attachment'
20
+ obj.respond_to?(:to_csv) ? obj.to_csv(options) : obj
21
+ end
22
+ end
23
+
24
+ end
25
+
26
+ end
8
27
  end
@@ -1,3 +1,3 @@
1
1
  module AsCSV
2
- VERSION = "3.0.0"
2
+ VERSION = "3.0.1"
3
3
  end
data/lib/as_csv.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  require "as_csv/version"
2
2
  require "as_csv/core_ext/array"
3
3
  require "as_csv/core_ext/enumerable"
4
- require "as_csv/railtie"
4
+ require "as_csv/railtie" if defined?(Rails)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: as_csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Fone
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-08 00:00:00.000000000 Z
11
+ date: 2023-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  requirements: []
133
- rubygems_version: 3.3.22
133
+ rubygems_version: 3.3.23
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: Instant CSV support for Rails