streamy_csv 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +29 -2
  2. data/lib/streamy_csv/version.rb +1 -1
  3. metadata +1 -1
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # StreamyCsv
2
2
 
3
- TODO: Write a gem description
3
+ Streams CSV files one row at a time as live data is generated instead of waiting for the whole file to be created and then sent to the client. Works on most standard web servers including Nginx, Passenger, Unicorn, Thin etc., but does NOT work on Webrick.
4
4
 
5
5
  ## Installation
6
6
 
@@ -17,8 +17,35 @@ Or install it yourself as:
17
17
  $ gem install streamy_csv
18
18
 
19
19
  ## Usage
20
+ In your model:
20
21
 
21
- TODO: Write usage instructions here
22
+ class MyModel
23
+
24
+ def self.header_row
25
+ CSV::Row([:name, :title], ['Name', 'Title'], true)
26
+ end
27
+
28
+ def to_csv_row
29
+ CSV::Row(name: name, title: title)
30
+ end
31
+
32
+ end
33
+
34
+
35
+ In your controller:
36
+
37
+ Class ExportsController
38
+
39
+ def index
40
+
41
+ stream_csv('data.csv', MyModel.header_row) do |rows|
42
+ MyModel.find_each do |my_model|
43
+ rows << my_model.to_csv_row
44
+ end
45
+ end
46
+
47
+ end
48
+ end
22
49
 
23
50
  ## Contributing
24
51
 
@@ -1,3 +1,3 @@
1
1
  module StreamyCsv
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: streamy_csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: