No commit activity in last 3 years
No release in over 3 years
Allows file streaming where files are enumerables
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.10
~> 10.0
>= 0
 Project Readme

Rails::StreamFile

Installation

Add this line to your application's Gemfile:

gem 'rails_stream_file', git: 'https://github.com/berfarah/rails_stream_file', require: "rails/stream_file"

And then execute:

$ bundle

Usage

Adds stream_file method to rails which takes an enumerator to output a binary file. Example usage below:

require "csv"
class EnumerableObject
  def each(&block)
    block.call %w(My Headers Go Here).to_csv
    block.call [1, 2, 3, 4].to_csv
    [
      [123, 123, 123, 123],
      [123, 123, 123, 123]
    ].each { |e| block.call(e.to_csv) }
  end
end

class MyController < ActionController::Base
  def show
    stream_file EnumerableObject.new, filename: "example.csv", mimetype: "text/csv"
  end
end

Development

After checking out the repo, run bundle to install dependencies. Then, run rake rspec to run the tests.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.