Permalink
Browse files

Initial version

  • Loading branch information...
1 parent ed742a9 commit a33ba47be1311864c11e0bd81256b8078c68c37d Aditya Sanghi committed Nov 15, 2010
Showing with 91 additions and 4 deletions.
  1. +3 −3 Rakefile
  2. +1 −1 VERSION
  3. +50 −0 excel_rails.gemspec
  4. +1 −0 init.rb
  5. +35 −0 lib/excel_rails.rb
  6. +1 −0 rails/init.rb
View
@@ -5,12 +5,12 @@ begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "excel_rails"
- gem.summary = %Q{TODO: one-line summary of your gem}
- gem.description = %Q{TODO: longer description of your gem}
+ gem.summary = %Q{Hook rxls to generate Excel documents in Rails 3}
+ gem.description = %Q{Allows you to program spreadsheets using .rxls views}
gem.email = "asanghi@me.com"
gem.homepage = "http://github.com/asanghi/excel_rails"
gem.authors = ["Aditya Sanghi"]
- gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
+ # gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
end
Jeweler::GemcutterTasks.new
View
@@ -1 +1 @@
-0.0.0
+0.1.0
View
@@ -0,0 +1,50 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{excel_rails}
+ s.version = "0.1.0"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Aditya Sanghi"]
+ s.date = %q{2010-11-15}
+ s.description = %q{Allows you to program spreadsheets using .rxls views}
+ s.email = %q{asanghi@me.com}
+ s.extra_rdoc_files = [
+ "LICENSE",
+ "README.rdoc"
+ ]
+ s.files = [
+ ".document",
+ ".gitignore",
+ "LICENSE",
+ "README.rdoc",
+ "Rakefile",
+ "VERSION",
+ "lib/excel_rails.rb",
+ "test/helper.rb",
+ "test/test_excel_rails.rb"
+ ]
+ s.homepage = %q{http://github.com/asanghi/excel_rails}
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.3.7}
+ s.summary = %q{Hook rxls to generate Excel documents in Rails 3}
+ s.test_files = [
+ "test/helper.rb",
+ "test/test_excel_rails.rb"
+ ]
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ else
+ end
+ else
+ end
+end
+
View
@@ -0,0 +1 @@
+require 'excel_rails'
View
@@ -0,0 +1,35 @@
+require 'spreadsheet'
+
+module Spreadsheet
+ module Rails
+ module SpreadsheetHelper
+
+ def excel_document(opts={})
+ download = opts.delete(:force_download)
+ filename = opts.delete(:filename)
+ workbook = Spreadsheet::Workbook.new
+ yield(workbook)
+ disposition(download, filename) if (download || filename)
+ workbook
+ end
+
+ def disposition(download, filename)
+ download = true if (filename && download == nil)
+ disposition = download ? "attachment;" : "inline;"
+ disposition += " filename=#{filename}" if filename
+ headers["Content-Disposition"]=disposition
+ end
+ end
+
+ class TemplateHandler < ActionView::Template::Handler
+ self.default_format = :xls
+ def self.call(template)
+ "sio = StringIO.new; #{template.source.strip}.write(sio); sio.string"
+ end
+ end
+ end
+end
+
+Mime::Type.register_alias "application/xls", :xls
+ActionView::Template.register_template_handler(:rxls, Spreadsheet::Rails::TemplateHandler)
+ActionView::Base.send(:include, Spreadsheet::Rails::SpreadsheetHelper)
View
@@ -0,0 +1 @@
+require 'excel_rails'

0 comments on commit a33ba47

Please sign in to comment.