Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

DefV-csv_builder

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

DefV-csv_builder

  • 0.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= CSV Builder

The CSV Builder Rails plugin provides a simple templating system for serving dynamically generated CSV files from your application.

== Requirements

CSV Builder requires Rails v2.1.

It also depends upon the FasterCSV gem http://fastercsv.rubyforge.org, which you can install with

$ sudo gem install fastercsv

== Example

CSV template files are suffixed with '.csv.csvbuilder', for example 'index.csv.csvbuilder'

Add rows to your CSV file in the template by pushing arrays of columns into the csv object.

First row

csv << [ 'cell 1', 'cell 2' ]

Second row

csv << [ 'another cell value', 'and another' ]

etc...

You can set the default filename for that a browser will use for 'save as' by setting @filename instance variable in your controller's action method e.g.

@filename = 'report.csv'

You can also set the input encoding and output encoding by setting @input_encoding and @output_encoding instance variables. These default to 'UTF-8' and 'LATIN1' respectively. e.g.

@output_encoding = 'UTF-8'

You can also attach a csv file to mail sent out by your application by including a snippet like the following in your mailer method

attachment "text/csv" do |attachment| attachment.body = render(:file => 'example/index.csv.csvbuilder') attachment.filename = 'report.csv' end

Copyright (c) 2008 Econsultancy.com, released under the MIT license

FAQs

Package last updated on 11 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc