csb 0.4.0 → 0.6.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: abfc516a242c529b3b1726b6846609df41e8f617a9b9ceba69ae02d7b28d4026
4
- data.tar.gz: d40c9e5d581bad2b10559b41f4935a772943c139432b7ce06837dc88ba65900f
3
+ metadata.gz: ebfa286a10ca2da877e857c5776f926ea880459db3f1b8dffcb81f9a7d1f983d
4
+ data.tar.gz: 10b428315a27b32f201fec24ff3ae492280235ff812ee76686f8e713b7c6f269
5
5
  SHA512:
6
- metadata.gz: d98d4bfa10070f589622deb111c38a90b4eedcd6df222edb7fe4eb52f807b11a3c8d1dd684f92a2c07c21929c687adb632ce65dd9aacdca3bb2a8d7b4a911447
7
- data.tar.gz: fb3283a59df41d2e0e5adcf26d260dc955d4094357aacd39320291000e84e5fb128d2b81550d5efa5e0d56587474fa8bacd118030cfd77ecfcf53f02c9f0166e
6
+ metadata.gz: 0badfeec8fb05c47872138b774b3cdaaaeb7ff34f22210224bb086664626b35a080630a0b1588083e4763b7a34ab02abf1ab0708da8ec3e7a3ecb746bcfdabc8
7
+ data.tar.gz: ab70fdda6260d8173e9adb97cc77db2de466afa971108635ed96b90afcda71c14169bb493c23191265b9584ec786ce6a49f9e0d1ca0a61b1a40c2768e463e64d
@@ -2,46 +2,36 @@ name: Build
2
2
 
3
3
  on:
4
4
  push:
5
- branches: [ master ]
5
+ branches: [master]
6
6
  pull_request:
7
7
 
8
8
  jobs:
9
9
  rspec:
10
-
11
10
  runs-on: ubuntu-latest
12
11
  env:
13
12
  BUNDLE_JOBS: 4
14
13
  BUNDLE_RETRY: 3
14
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
15
15
  strategy:
16
16
  fail-fast: false
17
17
  matrix:
18
- ruby: [2.6, 2.7]
19
- gemfile: [
20
- "gemfiles/rails52.gemfile",
21
- "gemfiles/rails60.gemfile",
22
- ]
18
+ ruby: ["2.6", "2.7", "3.0", "3.1"]
19
+ gemfile: ["rails60", "rails61", "rails70"]
20
+ exclude:
21
+ - ruby: "2.6"
22
+ gemfile: "rails70"
23
+ - ruby: "3.1"
24
+ gemfile: "rails60"
25
+ - ruby: "3.1"
26
+ gemfile: "rails61"
23
27
  steps:
24
- - name: Install packages
25
- run: |
26
- sudo apt update -y
27
- sudo apt install -y libsqlite3-dev
28
- - uses: actions/checkout@v2
29
- - uses: actions/cache@v1
30
- with:
31
- path: /home/runner/bundle
32
- key: bundle-${{ matrix.ruby }}-${{ matrix.gemfile }}-${{ hashFiles(matrix.gemfile) }}-${{ hashFiles('**/*.gemspec') }}
33
- restore-keys: |
34
- bundle-${{ matrix.ruby }}-${{ matrix.gemfile }}-
35
- - name: Set up Ruby
36
- uses: ruby/setup-ruby@v1
37
- with:
38
- ruby-version: ${{ matrix.ruby }}
39
- - name: Install dependencies
40
- run: |
41
- bundle config path /home/runner/bundle
42
- bundle config --global gemfile ${{ matrix.gemfile }}
43
- bundle install
44
- bundle update
45
- bundle clean
46
- - name: Run rspec
47
- run: bundle exec rspec
28
+ - uses: actions/checkout@v2
29
+
30
+ - name: Set up Ruby
31
+ uses: ruby/setup-ruby@v1
32
+ with:
33
+ ruby-version: ${{ matrix.ruby }}
34
+ bundler-cache: true
35
+
36
+ - name: Run rspec
37
+ run: bundle exec rspec
data/.gitignore CHANGED
@@ -11,3 +11,4 @@
11
11
  .rspec_status
12
12
  Gemfile.lock
13
13
  /vendor/bundle
14
+ .vscode/settings.json
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## 0.6.0
2
+
3
+ - Drop support for ruby 2.6
4
+ - Drop support for rails 5.1
5
+
6
+ ## 0.5.1
7
+
8
+ - Update dependency
9
+
10
+ ## 0.5.0
11
+
12
+ - Add `as_table` testing helper
13
+
1
14
  ## 0.4.0
2
15
 
3
16
  - Csb::Cols#initialize supports block arguments
data/README.md CHANGED
@@ -5,6 +5,13 @@
5
5
 
6
6
  A simple and streaming support CSV template engine for Ruby on Rails.
7
7
 
8
+ ## Features
9
+
10
+ - Support for streaming downloads
11
+ - Output in UTF-8 with BOM
12
+ - Readable code
13
+ - High testability
14
+
8
15
  ## Usage
9
16
 
10
17
  ### Template handler
@@ -21,9 +28,13 @@ In app/views/reports/index.csv.csb:
21
28
 
22
29
  ```ruby
23
30
  csv.items = @reports
31
+
24
32
  # When there are many records
25
33
  # csv.items = @reports.find_each
26
34
 
35
+ # When there are many records with decorator
36
+ # csv.items = @reports.find_each.lazy.map(&:decorate)
37
+
27
38
  # csv.filename = "reports_#{Time.current.to_i}.csv"
28
39
  # csv.streaming = false
29
40
 
@@ -68,7 +79,7 @@ csv.cols = Article.csb_cols
68
79
 
69
80
  # Your Model
70
81
  def self.csb_cols
71
- Csb.cols.new do |cols|
82
+ Csb::Cols.new do |cols|
72
83
  cols.add('Update date') { |r| I18n.l(r.updated_at.to_date) }
73
84
  cols.add('Categories') { |r| r.categories.pluck(:name).join(' ') }
74
85
  cols.add('Title', :title)
@@ -83,6 +94,12 @@ expect(Article.csb_cols.col_pairs(article)).to eq [
83
94
  ['Categories', 'test rspec'],
84
95
  ['Title', 'Testing'],
85
96
  ]
97
+
98
+ expect(Article.csb_cols.as_table(articles)).to eq [
99
+ ['Update date', 'Categories', 'Title'],
100
+ ['2020-01-01', 'test rspec', 'Testing'],
101
+ ['2020-02-01', 'rails gem', 'Rails 6.2'],
102
+ ]
86
103
  ```
87
104
 
88
105
  ## Installation
data/csb.gemspec CHANGED
@@ -22,7 +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.add_dependency "rails", ">= 5.2.4.2"
25
+ spec.required_ruby_version = '>= 2.7.0'
26
+
27
+ spec.add_dependency "rails", ">= 6.0.5"
26
28
  spec.add_dependency "csv"
27
29
 
28
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.3.1'
3
+ gem 'rails', '6.0.4.1'
4
4
 
5
5
  gemspec path: '../'
@@ -1,5 +1,5 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem 'rails', '5.2.4.3'
3
+ gem 'rails', '6.1.4'
4
4
 
5
5
  gemspec path: '../'
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rails', '~> 7.0.0'
4
+
5
+ gemspec path: '../'
data/lib/csb/testing.rb CHANGED
@@ -3,5 +3,9 @@ module Csb
3
3
  def col_pairs(item)
4
4
  headers.zip(values(item))
5
5
  end
6
+
7
+ def as_table(items)
8
+ [headers] + items.map { |item| values(item) }
9
+ end
6
10
  end
7
11
  end
data/lib/csb/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Csb
2
- VERSION = '0.4.0'
2
+ VERSION = '0.6.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.4.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - aki77
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-13 00:00:00.000000000 Z
11
+ date: 2022-05-17 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: 5.2.4.2
19
+ version: 6.0.5
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: 5.2.4.2
26
+ version: 6.0.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: csv
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -90,7 +90,6 @@ files:
90
90
  - ".github/workflows/rspec.yml"
91
91
  - ".gitignore"
92
92
  - ".rspec"
93
- - ".travis.yml"
94
93
  - CHANGELOG.md
95
94
  - CODE_OF_CONDUCT.md
96
95
  - Gemfile
@@ -100,8 +99,9 @@ files:
100
99
  - bin/console
101
100
  - bin/setup
102
101
  - csb.gemspec
103
- - gemfiles/rails52.gemfile
104
102
  - gemfiles/rails60.gemfile
103
+ - gemfiles/rails61.gemfile
104
+ - gemfiles/rails70.gemfile
105
105
  - lib/csb.rb
106
106
  - lib/csb/builder.rb
107
107
  - lib/csb/col.rb
@@ -124,7 +124,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
124
  requirements:
125
125
  - - ">="
126
126
  - !ruby/object:Gem::Version
127
- version: '0'
127
+ version: 2.7.0
128
128
  required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - ">="
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6.3
7
- before_install: gem install bundler -v 2.0.1