Module: StreamyCsv

Defined in:
lib/streamy_csv.rb,
lib/streamy_csv/version.rb

Constant Summary collapse

CSV_OPERATORS =
['+','-','=','@','%']
UNESCAPED_PIPES_RGX =
/(?<!\\)(?:\\{2})*\K\|/
VERSION =
"0.4.0"

Instance Method Summary collapse

Instance Method Details

#stream_csv(file_name, header_row, sanitize = true, &block) ⇒ Object

stream_csv(‘data.csv’, MyModel.header_row) do |rows|

MyModel.find_each do |my_model|
  rows << my_model.to_csv_row
end

end



15
16
17
18
19
20
21
22
# File 'lib/streamy_csv.rb', line 15

def stream_csv(file_name, header_row, sanitize = true, &block)
  set_streaming_headers
  set_file_headers(file_name)

  response.status = 200

  self.response_body = csv_lines(header_row, sanitize, &block)
end