csb 0.10.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +2 -2
- data/CHANGELOG.md +9 -0
- data/csb.gemspec +2 -2
- data/gemfiles/rails71.gemfile +1 -1
- data/gemfiles/{rails70.gemfile → rails72.gemfile} +1 -1
- data/lib/csb/builder.rb +3 -3
- data/lib/csb/handler.rb +0 -2
- data/lib/csb/railtie.rb +0 -28
- data/lib/csb/template.rb +11 -5
- data/lib/csb/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be1d1fb195f30b6b728b3dc97803f656f826e7049ca1a935194b82893810e4ae
|
4
|
+
data.tar.gz: 9d3a0b882bfd9ebadee139b7dcfd4b22ceda492d304d16cf4c4822105b92937a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd21b2f4a24c65f7b038b83e499384b088b1d26640653571324843259a5f09f06784195044b7ac7d952c16fdae19a1a8724d8c95ea5f948d34505aeb54fe8b7b
|
7
|
+
data.tar.gz: 0726e686a4a1bd439dd29315fe93f58cdc70010a3a9677e3fd10fb5a6a997a020da35fedd02620029dbb400470fdb8e3ce5b8b7fb0430f2a877632609e8475f7
|
data/.github/workflows/rspec.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/csb.gemspec
CHANGED
@@ -22,9 +22,9 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
-
spec.required_ruby_version = '>= 3.
|
25
|
+
spec.required_ruby_version = '>= 3.1.0'
|
26
26
|
|
27
|
-
spec.add_dependency "rails", ">= 7.
|
27
|
+
spec.add_dependency "rails", ">= 7.1.4"
|
28
28
|
spec.add_dependency "csv"
|
29
29
|
|
30
30
|
spec.add_development_dependency "bundler", "~> 2.0"
|
data/gemfiles/rails71.gemfile
CHANGED
data/lib/csb/builder.rb
CHANGED
@@ -8,12 +8,12 @@ module Csb
|
|
8
8
|
attr_reader :output, :utf8_bom, :items, :cols, :csv_options
|
9
9
|
attr_accessor :items
|
10
10
|
|
11
|
-
def initialize(output = '', items: [],
|
11
|
+
def initialize(output = '', items: [], **kwargs)
|
12
12
|
@output = output
|
13
|
-
@utf8_bom = utf8_bom
|
14
13
|
@cols = Cols.new
|
15
14
|
@items = items
|
16
|
-
@
|
15
|
+
@utf8_bom = kwargs.fetch(:utf8_bom) { Csb.configuration.utf8_bom }
|
16
|
+
@csv_options = kwargs.fetch(:csv_options) { Csb.configuration.csv_options }
|
17
17
|
end
|
18
18
|
|
19
19
|
def build
|
data/lib/csb/handler.rb
CHANGED
@@ -12,9 +12,7 @@ module Csb
|
|
12
12
|
|
13
13
|
<<~RUBY
|
14
14
|
csv = ::Csb::Template.new(
|
15
|
-
utf8_bom: ::Csb.configuration.utf8_bom,
|
16
15
|
streaming: ::Csb.configuration.streaming,
|
17
|
-
csv_options: ::Csb.configuration.csv_options,
|
18
16
|
)
|
19
17
|
#{source}
|
20
18
|
controller.send(:send_file_headers!, type: 'text/csv', filename: csv.filename)
|
data/lib/csb/railtie.rb
CHANGED
@@ -6,34 +6,6 @@ module Csb
|
|
6
6
|
ActiveSupport.on_load :action_view do
|
7
7
|
require 'csb/handler'
|
8
8
|
ActionView::Template.register_template_handler :csb, Csb::Handler
|
9
|
-
|
10
|
-
# SEE: https://github.com/rails/rails/pull/51023
|
11
|
-
rails_version = Gem::Version.new(Rails.version)
|
12
|
-
if rails_version >= Gem::Version.new('7.1.0') && rails_version < Gem::Version.new('7.1.4')
|
13
|
-
ActionView::Template.prepend(Module.new do
|
14
|
-
# SEE: https://github.com/Shopify/rails/blob/0601929486398954a17b1985fcf7f9f0611d2d55/actionview/lib/action_view/template.rb#L262C5-L281C8
|
15
|
-
def render(view, locals, buffer = nil, implicit_locals: [], add_to_stack: true, &block)
|
16
|
-
instrument_render_template do
|
17
|
-
compile!(view)
|
18
|
-
|
19
|
-
if strict_locals? && @strict_local_keys && !implicit_locals.empty?
|
20
|
-
locals_to_ignore = implicit_locals - @strict_local_keys
|
21
|
-
locals.except!(*locals_to_ignore)
|
22
|
-
end
|
23
|
-
|
24
|
-
if buffer
|
25
|
-
view._run(method_name, self, locals, buffer, add_to_stack: add_to_stack, has_strict_locals: strict_locals?, &block)
|
26
|
-
nil
|
27
|
-
else
|
28
|
-
result = view._run(method_name, self, locals, ActionView::OutputBuffer.new, add_to_stack: add_to_stack, has_strict_locals: strict_locals?, &block)
|
29
|
-
result.is_a?(ActionView::OutputBuffer) ? result.to_s : result
|
30
|
-
end
|
31
|
-
end
|
32
|
-
rescue => e
|
33
|
-
handle_render_error(view, e)
|
34
|
-
end
|
35
|
-
end)
|
36
|
-
end
|
37
9
|
end
|
38
10
|
end
|
39
11
|
end
|
data/lib/csb/template.rb
CHANGED
@@ -2,10 +2,8 @@ module Csb
|
|
2
2
|
class Template
|
3
3
|
attr_accessor :utf8_bom, :filename, :streaming, :items, :cols, :csv_options
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@utf8_bom = utf8_bom
|
5
|
+
def initialize(streaming:)
|
7
6
|
@streaming = streaming
|
8
|
-
@csv_options = csv_options
|
9
7
|
@cols = Cols.new
|
10
8
|
@items = []
|
11
9
|
end
|
@@ -20,8 +18,16 @@ module Csb
|
|
20
18
|
|
21
19
|
private
|
22
20
|
|
21
|
+
def builder_options
|
22
|
+
{
|
23
|
+
items: items,
|
24
|
+
utf8_bom: utf8_bom,
|
25
|
+
csv_options: csv_options,
|
26
|
+
}.compact
|
27
|
+
end
|
28
|
+
|
23
29
|
def build_string
|
24
|
-
builder = Builder.new(
|
30
|
+
builder = Builder.new(**builder_options)
|
25
31
|
builder.cols.copy!(cols)
|
26
32
|
builder.build
|
27
33
|
end
|
@@ -29,7 +35,7 @@ module Csb
|
|
29
35
|
def build_enumerator
|
30
36
|
Enumerator.new do |y|
|
31
37
|
begin
|
32
|
-
builder = Builder.new(y,
|
38
|
+
builder = Builder.new(y, **builder_options)
|
33
39
|
builder.cols.copy!(cols)
|
34
40
|
builder.build
|
35
41
|
rescue => error
|
data/lib/csb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aki77
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 7.
|
19
|
+
version: 7.1.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 7.
|
26
|
+
version: 7.1.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: csv
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,8 +99,8 @@ files:
|
|
99
99
|
- bin/console
|
100
100
|
- bin/setup
|
101
101
|
- csb.gemspec
|
102
|
-
- gemfiles/rails70.gemfile
|
103
102
|
- gemfiles/rails71.gemfile
|
103
|
+
- gemfiles/rails72.gemfile
|
104
104
|
- lib/csb.rb
|
105
105
|
- lib/csb/builder.rb
|
106
106
|
- lib/csb/col.rb
|
@@ -123,7 +123,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
123
|
requirements:
|
124
124
|
- - ">="
|
125
125
|
- !ruby/object:Gem::Version
|
126
|
-
version: 3.
|
126
|
+
version: 3.1.0
|
127
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - ">="
|