csb 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/csb/builder.rb +3 -3
- data/lib/csb/handler.rb +0 -2
- data/lib/csb/template.rb +11 -5
- data/lib/csb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 549b384457905e2f88bfe785d2c9bd241a1c7f18e920962005c41d2d8c0162e8
|
4
|
+
data.tar.gz: e750c534760f3b5d7ca412df629e6e55cdc22b10b416e2352adfa755ab718529
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcf7c87da0ffa9333d8ceff7f4be1c6dba4d3a91001c83b23ce50c74e4668601b3189059c7918e7810141c15158aa94868db478b1942717f6c2500016f0155bb
|
7
|
+
data.tar.gz: 54b1d2903c89cf84ed7d7a1eda786cdc07fceca412e4b076e6eb9688d0a6077574094756bd7796c2e8ee6139de5950132ee398212e7ed332bf73753cf02bb828
|
data/CHANGELOG.md
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/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.11.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-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|