decisive 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -0
- data/lib/decisive/template_handler.rb +6 -4
- data/lib/decisive/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bc57309fcab7adf511b3466ac8c9c095de7f712
|
4
|
+
data.tar.gz: e8801558b0e62a7c554035eb73cbbfd1581238db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5dbe6515ca10e2e2563ebe01794241ce94b23de34b10b508eda20110ac50df1ccdb29987edb159ff6601f9eef2807988193f8498869b88926f99ad5554498aa
|
7
|
+
data.tar.gz: 614171337be8cf6a2b74fbfaeb735c8ad9b333a437a4078164a281e8fcb1d3ab3afdfb1b80c56b855ff6c0896a1dad0b22300182931025545f5ce45a5e07c081
|
data/README.md
CHANGED
@@ -70,6 +70,28 @@ Visiting /users.csv will render a file named "users-2010_01_01.csv" with the fol
|
|
70
70
|
| frodo@example.com | Frodo Baggins | Yes | | 2002-06-19 |
|
71
71
|
| sam@example.com | Samwise Gamgee | | Frodo | 2008-10-13 |
|
72
72
|
|
73
|
+
### Debugging
|
74
|
+
|
75
|
+
Errors in your decisive template will often be swallowed while streaming is enabled, resulting in only some of the csv being rendered, without any explanation. You can temporarily switch decisive into non-streaming mode to see these errors:
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
# decisive template
|
79
|
+
|
80
|
+
csv @records, filename: "report.csv", stream: false do
|
81
|
+
...
|
82
|
+
end
|
83
|
+
```
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
# controller
|
87
|
+
|
88
|
+
class ReportController < ApplicationController
|
89
|
+
# include ActionController::Live
|
90
|
+
|
91
|
+
...
|
92
|
+
end
|
93
|
+
```
|
94
|
+
|
73
95
|
## Development
|
74
96
|
|
75
97
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -20,9 +20,9 @@ module Decisive
|
|
20
20
|
if controller.respond_to?(:new_controller_thread) # has AC::Live mixed in
|
21
21
|
begin
|
22
22
|
context.each do |row|
|
23
|
-
response.stream.write row.to_csv
|
23
|
+
response.stream.write row.to_csv(force_quotes: true)
|
24
24
|
end
|
25
|
-
raise if
|
25
|
+
raise if Rails.env.test? # WTF WTF without this the stream isn't closed in test mode??? WTF WTF
|
26
26
|
ensure
|
27
27
|
response.stream.close
|
28
28
|
end
|
@@ -91,8 +91,10 @@ module Decisive
|
|
91
91
|
end
|
92
92
|
|
93
93
|
class RenderContext < Struct.new(:records, :filename, :block)
|
94
|
-
def to_csv
|
95
|
-
(header + body).map
|
94
|
+
def to_csv(*args, **kwargs)
|
95
|
+
(header + body).map do |row|
|
96
|
+
row.to_csv(*args, **kwargs)
|
97
|
+
end.join
|
96
98
|
end
|
97
99
|
|
98
100
|
private
|
data/lib/decisive/version.rb
CHANGED