csb 0.4.0 → 0.5.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/README.md +18 -1
- data/lib/csb/testing.rb +4 -0
- 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: 518693b4dfa9ef958beb05143afa99c8bc37a8a61fa8b86ea5619140b4898c66
|
4
|
+
data.tar.gz: a155dc1d962466e7d0ed1421910b4dd964de3e55a79ca1092cbe63e3a82591c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61fff01a75f9ada5135fc20b1cce96949150e4ec88d60862e373f3460f5421e04190315199892163ff9a45e6e15190ba305b315f5b8d014944b0786b27bb9698
|
7
|
+
data.tar.gz: 6cc80f9bbff9d15f844de89ca35429b529fb1054a655246de2f1cfebc55e8769d1560aa6b1f53bedeaac831901f54354fa768cc9d5879526c7fdeba3f060447d
|
data/CHANGELOG.md
CHANGED
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.
|
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/lib/csb/testing.rb
CHANGED
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.5.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-
|
11
|
+
date: 2020-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|