91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
# File 'lib/csv_builder/template_handler.rb', line 91
def self.call(template, source = nil)
source ||= template.source
" begin\n\n unless defined?(ActionMailer) && defined?(ActionMailer::Base) && controller.is_a?(ActionMailer::Base)\n @filename ||= \"\\\#{controller.action_name}.csv\"\n if controller.request.env['HTTP_USER_AGENT'] =~ /msie/i\n response.headers['Pragma'] = 'must-revalidate'\n response.headers[\"Content-type\"] = \"text/plain\"\n response.headers['Cache-Control'] = 'must-revalidate, post-check=0, pre-check=0'\n response.headers['Content-Disposition'] = \"attachment; filename=\\\\\"\\\#{@filename}\\\\\"\"\n response.headers['Expires'] = \"0\"\n else\n response.headers[\"Content-Type\"] ||= 'text/csv'\n response.headers[\"Content-Disposition\"] = \"attachment; filename=\\\\\"\\\#{@filename}\\\\\"\"\n response.headers[\"Content-Transfer-Encoding\"] = \"binary\"\n end\n end\n\n if @streaming\n template = Proc.new {|csv|\n \#{source}\n }\n CsvBuilder::Streamer.new(template)\n else\n output = CsvBuilder::CSV_LIB.generate(@csv_options || {}) do |faster_csv|\n csv = CsvBuilder::TransliteratingFilter.new(faster_csv, @input_encoding || 'UTF-8', @output_encoding || 'ISO-8859-1')\n \#{source}\n end\n output\n end\n rescue Exception => e\n Rails.logger.warn(\"Exception \\\#{e} \\\#{e.message} with class \\\#{e.class.name} thrown when rendering CSV\")\n raise e\n end\n EOV\nend\n"
|