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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3805656cea8c630b1d46c799071fb70a59af525
4
- data.tar.gz: 5e6dd96156d8c2370a4872015b92ad16ad591981
3
+ metadata.gz: 4bc57309fcab7adf511b3466ac8c9c095de7f712
4
+ data.tar.gz: e8801558b0e62a7c554035eb73cbbfd1581238db
5
5
  SHA512:
6
- metadata.gz: 5a948b1d5efb0ec4fec949624bf37c74826a1c9fa80a31bd28630084d4193561ffd28b6dcab6cbcf8f229da208298f76f9730cc5ed0efc93ce9594d5f6f81a74
7
- data.tar.gz: '031396a9a012d1b8bc3b6562d5c9350cc68e37372a943c4dfb7b5c03434835dd5b05686f0ce86c3c119d8d94a43944e0b528c92256fc2813a7204d5891b17abb'
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 ENV["RAILS_ENV"] == "test" # WTF WTF without this the stream isn't closed in test mode??? WTF WTF
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(&:to_csv).join
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
@@ -1,3 +1,3 @@
1
1
  module Decisive
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decisive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel