csb 0.6.0 → 0.8.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: ebfa286a10ca2da877e857c5776f926ea880459db3f1b8dffcb81f9a7d1f983d
4
- data.tar.gz: 10b428315a27b32f201fec24ff3ae492280235ff812ee76686f8e713b7c6f269
3
+ metadata.gz: 65631a79f4d83eb7a03b39ec88084daf60fb32249894116d4362c009bee3d9ff
4
+ data.tar.gz: '04825902e66e259ea488c97884f9b0bb4540d0ec1f2b2d58e087fc84b3491516'
5
5
  SHA512:
6
- metadata.gz: 0badfeec8fb05c47872138b774b3cdaaaeb7ff34f22210224bb086664626b35a080630a0b1588083e4763b7a34ab02abf1ab0708da8ec3e7a3ecb746bcfdabc8
7
- data.tar.gz: ab70fdda6260d8173e9adb97cc77db2de466afa971108635ed96b90afcda71c14169bb493c23191265b9584ec786ce6a49f9e0d1ca0a61b1a40c2768e463e64d
6
+ metadata.gz: 9bed968513f2be918b5c0fcefa1d711bc86858c118fa2561c5b5ec80d36de41460712ff82079ca006338d2ef2ce64c87b66a1252681aea964c80f2bf3b4ea6d6
7
+ data.tar.gz: 567168271617cd1f96665dec7c9d5acd7e9f1dfb4ce017fefd95ceccc4ff40cbb8a94b58ca4fb989af7299d98abe2d1ca5f8ca8c638eb0d86d7a347d4f38c42a
@@ -15,17 +15,13 @@ jobs:
15
15
  strategy:
16
16
  fail-fast: false
17
17
  matrix:
18
- ruby: ["2.6", "2.7", "3.0", "3.1"]
19
- gemfile: ["rails60", "rails61", "rails70"]
18
+ ruby: ["3.0", "3.1", "3.2", "3.3"]
19
+ gemfile: ["rails61", "rails70"]
20
20
  exclude:
21
- - ruby: "2.6"
22
- gemfile: "rails70"
23
- - ruby: "3.1"
24
- gemfile: "rails60"
25
21
  - ruby: "3.1"
26
22
  gemfile: "rails61"
27
23
  steps:
28
- - uses: actions/checkout@v2
24
+ - uses: actions/checkout@v3
29
25
 
30
26
  - name: Set up Ruby
31
27
  uses: ruby/setup-ruby@v1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 0.8.0
2
+
3
+ - Add `csv_options` as an option to pass to `CSV.generate_line` (#18)
4
+
5
+ ## 0.7.0
6
+
7
+ - Drop support for ruby 2.7
8
+ - Drop support for rails 6.0
9
+
1
10
  ## 0.6.0
2
11
 
3
12
  - Drop support for ruby 2.6
data/README.md CHANGED
@@ -37,6 +37,7 @@ csv.items = @reports
37
37
 
38
38
  # csv.filename = "reports_#{Time.current.to_i}.csv"
39
39
  # csv.streaming = false
40
+ # csv.csv_options = { col_sep: "\t" }
40
41
 
41
42
  csv.cols.add('Update date') { |r| l(r.updated_at.to_date) }
42
43
  csv.cols.add('Categories') { |r| r.categories.pluck(:name).join(' ') }
@@ -130,6 +131,7 @@ In `config/initializers/csb.rb`, you can configure the following values.
130
131
  Csb.configure do |config|
131
132
  config.utf8_bom = true # default: false
132
133
  config.streaming = false # default: true
134
+ config.csv_options = { col_sep: "\t" } # default: {}
133
135
  config.after_streaming_error = ->(error) do # default: nil
134
136
  Rails.logger.error(error)
135
137
  Bugsnag.notify(error)
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 = '>= 2.7.0'
25
+ spec.required_ruby_version = '>= 3.0.0'
26
26
 
27
- spec.add_dependency "rails", ">= 6.0.5"
27
+ spec.add_dependency "rails", ">= 6.1.0"
28
28
  spec.add_dependency "csv"
29
29
 
30
30
  spec.add_development_dependency "bundler", "~> 2.0"
@@ -1,5 +1,5 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem 'rails', '6.0.4.1'
3
+ gem 'rails', '~> 6.0.0'
4
4
 
5
5
  gemspec path: '../'
@@ -1,5 +1,5 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem 'rails', '6.1.4'
3
+ gem 'rails', '~> 6.1.0'
4
4
 
5
5
  gemspec path: '../'
data/lib/csb/builder.rb CHANGED
@@ -5,21 +5,22 @@ module Csb
5
5
  class Builder
6
6
  UTF8_BOM = "\xEF\xBB\xBF".freeze
7
7
 
8
- attr_reader :output, :utf8_bom, :items, :cols
8
+ attr_reader :output, :utf8_bom, :items, :cols, :csv_options
9
9
  attr_accessor :items
10
10
 
11
- def initialize(output = '', items: [], utf8_bom: false)
11
+ def initialize(output = '', items: [], utf8_bom: false, csv_options: {})
12
12
  @output = output
13
13
  @utf8_bom = utf8_bom
14
14
  @cols = Cols.new
15
15
  @items = items
16
+ @csv_options = csv_options
16
17
  end
17
18
 
18
19
  def build
19
20
  output << UTF8_BOM if utf8_bom
20
- output << CSV.generate_line(cols.headers)
21
+ output << CSV.generate_line(cols.headers, **csv_options)
21
22
  items.each do |item|
22
- output << CSV.generate_line(cols.values_by_item(item))
23
+ output << CSV.generate_line(cols.values_by_item(item), **csv_options)
23
24
  rescue => error
24
25
  break if Csb.configuration.ignore_class_names.include?(error.class.name)
25
26
 
@@ -1,10 +1,11 @@
1
1
  module Csb
2
2
  class Configuration
3
- attr_accessor :utf8_bom, :streaming, :after_streaming_error, :ignore_class_names
3
+ attr_accessor :utf8_bom, :streaming, :after_streaming_error, :ignore_class_names, :csv_options
4
4
 
5
5
  def initialize
6
6
  @utf8_bom = false
7
7
  @streaming = true
8
+ @csv_options = {}
8
9
  @ignore_class_names = %w[Puma::ConnectionError]
9
10
  end
10
11
  end
data/lib/csb/handler.rb CHANGED
@@ -14,6 +14,7 @@ module Csb
14
14
  csv = ::Csb::Template.new(
15
15
  utf8_bom: ::Csb.configuration.utf8_bom,
16
16
  streaming: ::Csb.configuration.streaming,
17
+ csv_options: ::Csb.configuration.csv_options,
17
18
  )
18
19
  #{source}
19
20
  controller.send(:send_file_headers!, type: 'text/csv', filename: csv.filename)
data/lib/csb/template.rb CHANGED
@@ -1,10 +1,11 @@
1
1
  module Csb
2
2
  class Template
3
- attr_accessor :utf8_bom, :filename, :streaming, :items, :cols
3
+ attr_accessor :utf8_bom, :filename, :streaming, :items, :cols, :csv_options
4
4
 
5
- def initialize(utf8_bom:, streaming:)
5
+ def initialize(utf8_bom:, streaming:, csv_options:)
6
6
  @utf8_bom = utf8_bom
7
7
  @streaming = streaming
8
+ @csv_options = csv_options
8
9
  @cols = Cols.new
9
10
  @items = []
10
11
  end
@@ -20,7 +21,7 @@ module Csb
20
21
  private
21
22
 
22
23
  def build_string
23
- builder = Builder.new(utf8_bom: utf8_bom, items: items)
24
+ builder = Builder.new(utf8_bom: utf8_bom, items: items, csv_options: csv_options)
24
25
  builder.cols.copy!(cols)
25
26
  builder.build
26
27
  end
@@ -28,7 +29,7 @@ module Csb
28
29
  def build_enumerator
29
30
  Enumerator.new do |y|
30
31
  begin
31
- builder = Builder.new(y, utf8_bom: utf8_bom, items: items)
32
+ builder = Builder.new(y, utf8_bom: utf8_bom, items: items, csv_options: csv_options)
32
33
  builder.cols.copy!(cols)
33
34
  builder.build
34
35
  rescue => error
data/lib/csb/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Csb
2
- VERSION = '0.6.0'
2
+ VERSION = '0.8.0'
3
3
  end
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.6.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - aki77
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-17 00:00:00.000000000 Z
11
+ date: 2024-04-12 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: 6.0.5
19
+ version: 6.1.0
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: 6.0.5
26
+ version: 6.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: csv
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -116,7 +116,7 @@ homepage: https://github.com/aki77/csb
116
116
  licenses:
117
117
  - MIT
118
118
  metadata: {}
119
- post_install_message:
119
+ post_install_message:
120
120
  rdoc_options: []
121
121
  require_paths:
122
122
  - lib
@@ -124,15 +124,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
124
  requirements:
125
125
  - - ">="
126
126
  - !ruby/object:Gem::Version
127
- version: 2.7.0
127
+ version: 3.0.0
128
128
  required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - ">="
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  requirements: []
134
- rubygems_version: 3.1.2
135
- signing_key:
134
+ rubygems_version: 3.4.10
135
+ signing_key:
136
136
  specification_version: 4
137
137
  summary: A simple and streaming support CSV template engine for Ruby on Rails.
138
138
  test_files: []