active_record_to_excel 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.autotest +0 -0
- data/.document +5 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/Gemfile +23 -0
- data/Gemfile.lock +117 -0
- data/LICENSE.txt +20 -0
- data/README.md +34 -0
- data/Rakefile +57 -0
- data/active_record_to_excel.gemspec +130 -0
- data/lib/active_record_to_excel.rb +30 -0
- data/lib/active_record_to_excel/version.rb +11 -0
- data/spec/active_record_to_excel_spec.rb +53 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/user.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +26 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +35 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20110903180904_create_users.rb +14 -0
- data/spec/dummy/db/schema.rb +22 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +60 -0
- data/spec/dummy/log/production.log +0 -0
- data/spec/dummy/log/server.log +0 -0
- data/spec/dummy/log/test.log +36 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/controls.js +965 -0
- data/spec/dummy/public/javascripts/dragdrop.js +974 -0
- data/spec/dummy/public/javascripts/effects.js +1123 -0
- data/spec/dummy/public/javascripts/prototype.js +6001 -0
- data/spec/dummy/public/javascripts/rails.js +191 -0
- data/spec/dummy/public/report.xls +0 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/spec_helper.rb +21 -0
- metadata +320 -0
data/.autotest
ADDED
|
File without changes
|
data/.document
ADDED
data/.rspec
ADDED
data/.rvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rvm --create use 1.8.7@ar_excel
|
data/Gemfile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
source "http://rubygems.org"
|
|
2
|
+
# Add dependencies required to use your gem here.
|
|
3
|
+
# Example:
|
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
|
5
|
+
|
|
6
|
+
# Add dependencies to develop your gem here.
|
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
|
8
|
+
|
|
9
|
+
gem 'spreadsheet', '= 0.6.5.8'
|
|
10
|
+
|
|
11
|
+
group :development do
|
|
12
|
+
gem "rspec", "~> 2.3.0"
|
|
13
|
+
gem "rails", "~> 3.0.10"
|
|
14
|
+
gem "sqlite3"
|
|
15
|
+
gem "ZenTest", "~> 4.4.2"
|
|
16
|
+
gem "bundler", "~> 1.0.0"
|
|
17
|
+
gem "jeweler", "~> 1.6.4"
|
|
18
|
+
gem "rcov", ">= 0"
|
|
19
|
+
gem "autotest-fsevent"
|
|
20
|
+
gem "autotest-growl"
|
|
21
|
+
gem "ruby-debug"
|
|
22
|
+
gem "spreadsheet", "0.6.5.8"
|
|
23
|
+
end
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
GEM
|
|
2
|
+
remote: http://rubygems.org/
|
|
3
|
+
specs:
|
|
4
|
+
ZenTest (4.4.2)
|
|
5
|
+
abstract (1.0.0)
|
|
6
|
+
actionmailer (3.0.10)
|
|
7
|
+
actionpack (= 3.0.10)
|
|
8
|
+
mail (~> 2.2.19)
|
|
9
|
+
actionpack (3.0.10)
|
|
10
|
+
activemodel (= 3.0.10)
|
|
11
|
+
activesupport (= 3.0.10)
|
|
12
|
+
builder (~> 2.1.2)
|
|
13
|
+
erubis (~> 2.6.6)
|
|
14
|
+
i18n (~> 0.5.0)
|
|
15
|
+
rack (~> 1.2.1)
|
|
16
|
+
rack-mount (~> 0.6.14)
|
|
17
|
+
rack-test (~> 0.5.7)
|
|
18
|
+
tzinfo (~> 0.3.23)
|
|
19
|
+
activemodel (3.0.10)
|
|
20
|
+
activesupport (= 3.0.10)
|
|
21
|
+
builder (~> 2.1.2)
|
|
22
|
+
i18n (~> 0.5.0)
|
|
23
|
+
activerecord (3.0.10)
|
|
24
|
+
activemodel (= 3.0.10)
|
|
25
|
+
activesupport (= 3.0.10)
|
|
26
|
+
arel (~> 2.0.10)
|
|
27
|
+
tzinfo (~> 0.3.23)
|
|
28
|
+
activeresource (3.0.10)
|
|
29
|
+
activemodel (= 3.0.10)
|
|
30
|
+
activesupport (= 3.0.10)
|
|
31
|
+
activesupport (3.0.10)
|
|
32
|
+
arel (2.0.10)
|
|
33
|
+
autotest-fsevent (0.2.5)
|
|
34
|
+
sys-uname
|
|
35
|
+
autotest-growl (0.2.9)
|
|
36
|
+
builder (2.1.2)
|
|
37
|
+
columnize (0.3.4)
|
|
38
|
+
diff-lcs (1.1.3)
|
|
39
|
+
erubis (2.6.6)
|
|
40
|
+
abstract (>= 1.0.0)
|
|
41
|
+
git (1.2.5)
|
|
42
|
+
i18n (0.5.0)
|
|
43
|
+
jeweler (1.6.4)
|
|
44
|
+
bundler (~> 1.0)
|
|
45
|
+
git (>= 1.2.5)
|
|
46
|
+
rake
|
|
47
|
+
linecache (0.46)
|
|
48
|
+
rbx-require-relative (> 0.0.4)
|
|
49
|
+
mail (2.2.19)
|
|
50
|
+
activesupport (>= 2.3.6)
|
|
51
|
+
i18n (>= 0.4.0)
|
|
52
|
+
mime-types (~> 1.16)
|
|
53
|
+
treetop (~> 1.4.8)
|
|
54
|
+
mime-types (1.16)
|
|
55
|
+
polyglot (0.3.2)
|
|
56
|
+
rack (1.2.3)
|
|
57
|
+
rack-mount (0.6.14)
|
|
58
|
+
rack (>= 1.0.0)
|
|
59
|
+
rack-test (0.5.7)
|
|
60
|
+
rack (>= 1.0)
|
|
61
|
+
rails (3.0.10)
|
|
62
|
+
actionmailer (= 3.0.10)
|
|
63
|
+
actionpack (= 3.0.10)
|
|
64
|
+
activerecord (= 3.0.10)
|
|
65
|
+
activeresource (= 3.0.10)
|
|
66
|
+
activesupport (= 3.0.10)
|
|
67
|
+
bundler (~> 1.0)
|
|
68
|
+
railties (= 3.0.10)
|
|
69
|
+
railties (3.0.10)
|
|
70
|
+
actionpack (= 3.0.10)
|
|
71
|
+
activesupport (= 3.0.10)
|
|
72
|
+
rake (>= 0.8.7)
|
|
73
|
+
rdoc (~> 3.4)
|
|
74
|
+
thor (~> 0.14.4)
|
|
75
|
+
rake (0.9.2)
|
|
76
|
+
rbx-require-relative (0.0.5)
|
|
77
|
+
rcov (0.9.10)
|
|
78
|
+
rdoc (3.9.4)
|
|
79
|
+
rspec (2.3.0)
|
|
80
|
+
rspec-core (~> 2.3.0)
|
|
81
|
+
rspec-expectations (~> 2.3.0)
|
|
82
|
+
rspec-mocks (~> 2.3.0)
|
|
83
|
+
rspec-core (2.3.1)
|
|
84
|
+
rspec-expectations (2.3.0)
|
|
85
|
+
diff-lcs (~> 1.1.2)
|
|
86
|
+
rspec-mocks (2.3.0)
|
|
87
|
+
ruby-debug (0.10.4)
|
|
88
|
+
columnize (>= 0.1)
|
|
89
|
+
ruby-debug-base (~> 0.10.4.0)
|
|
90
|
+
ruby-debug-base (0.10.4)
|
|
91
|
+
linecache (>= 0.3)
|
|
92
|
+
ruby-ole (1.2.11.1)
|
|
93
|
+
spreadsheet (0.6.5.8)
|
|
94
|
+
ruby-ole (>= 1.0)
|
|
95
|
+
sqlite3 (1.3.4)
|
|
96
|
+
sys-uname (0.8.6)
|
|
97
|
+
thor (0.14.6)
|
|
98
|
+
treetop (1.4.10)
|
|
99
|
+
polyglot
|
|
100
|
+
polyglot (>= 0.3.1)
|
|
101
|
+
tzinfo (0.3.29)
|
|
102
|
+
|
|
103
|
+
PLATFORMS
|
|
104
|
+
ruby
|
|
105
|
+
|
|
106
|
+
DEPENDENCIES
|
|
107
|
+
ZenTest (~> 4.4.2)
|
|
108
|
+
autotest-fsevent
|
|
109
|
+
autotest-growl
|
|
110
|
+
bundler (~> 1.0.0)
|
|
111
|
+
jeweler (~> 1.6.4)
|
|
112
|
+
rails (~> 3.0.10)
|
|
113
|
+
rcov
|
|
114
|
+
rspec (~> 2.3.0)
|
|
115
|
+
ruby-debug
|
|
116
|
+
spreadsheet (= 0.6.5.8)
|
|
117
|
+
sqlite3
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2011 Rubén Dávila Santos
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# active_record_to_excel
|
|
2
|
+
|
|
3
|
+
active_record_to_excel is a litle tool for generate simple MS Excel
|
|
4
|
+
reports based on the results returned from your ActiveRecord queries.
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
|
|
8
|
+
### In your Gemfile:
|
|
9
|
+
|
|
10
|
+
gem 'active_record_to_excel'
|
|
11
|
+
|
|
12
|
+
### Generating reports:
|
|
13
|
+
|
|
14
|
+
```ruby
|
|
15
|
+
User.all.to_excel({ :name => 'Name', :email => 'Email' })
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
That line of code creates a report.xls file under the public folder of your rails app.
|
|
19
|
+
|
|
20
|
+
The keys on the hash are methods of you ActiveRecord object that returns the value required, the values
|
|
21
|
+
are the labels of the columns on the Excel sheet.
|
|
22
|
+
|
|
23
|
+
You can pass optionally two arguments: **:filename** and **:path**
|
|
24
|
+
|
|
25
|
+
```ruby
|
|
26
|
+
User.all.to_excel({ :name => 'Name', :email => 'Email', :path => '~/reports', :filename => 'users.xls' })
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
It will create a **users.xls** file in your $HOME/reports directory.
|
|
30
|
+
|
|
31
|
+
## Copyright
|
|
32
|
+
|
|
33
|
+
Copyright © 2011 [Rubén Dávila](http://rubenonrails.com)
|
|
34
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'bundler'
|
|
5
|
+
require File.expand_path('../lib/active_record_to_excel/version', __FILE__)
|
|
6
|
+
|
|
7
|
+
begin
|
|
8
|
+
Bundler.setup(:default, :development)
|
|
9
|
+
rescue Bundler::BundlerError => e
|
|
10
|
+
$stderr.puts e.message
|
|
11
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
|
12
|
+
exit e.status_code
|
|
13
|
+
end
|
|
14
|
+
require 'rake'
|
|
15
|
+
|
|
16
|
+
require 'jeweler'
|
|
17
|
+
Jeweler::Tasks.new do |gem|
|
|
18
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
|
19
|
+
gem.name = "active_record_to_excel"
|
|
20
|
+
gem.homepage = "http://github.com/rdavila/active_record_to_excel"
|
|
21
|
+
gem.license = "MIT"
|
|
22
|
+
gem.summary = %Q{Excel generator based on ActiveRecord queries}
|
|
23
|
+
gem.description = %Q{
|
|
24
|
+
This tool allows you to generate quick and simple
|
|
25
|
+
Excel reports based on the array of records returned by your
|
|
26
|
+
ActiveRecord queries
|
|
27
|
+
}
|
|
28
|
+
gem.email = "ruben.grunge84@gmail.com"
|
|
29
|
+
gem.authors = ["Rubén Dávila Santos"]
|
|
30
|
+
gem.version = ActiveRecordToExcel::Version::STRING
|
|
31
|
+
gem.add_dependency 'spreadsheet', '= 0.6.5.8'
|
|
32
|
+
# dependencies defined in Gemfile
|
|
33
|
+
end
|
|
34
|
+
Jeweler::RubygemsDotOrgTasks.new
|
|
35
|
+
|
|
36
|
+
require 'rspec/core'
|
|
37
|
+
require 'rspec/core/rake_task'
|
|
38
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
39
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
|
43
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
|
44
|
+
spec.rcov = true
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
task :default => :spec
|
|
48
|
+
|
|
49
|
+
require 'rake/rdoctask'
|
|
50
|
+
Rake::RDocTask.new do |rdoc|
|
|
51
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
|
52
|
+
|
|
53
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
54
|
+
rdoc.title = "active_record_to_excel #{version}"
|
|
55
|
+
rdoc.rdoc_files.include('README*')
|
|
56
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
57
|
+
end
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Generated by jeweler
|
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
|
+
# -*- encoding: utf-8 -*-
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = "active_record_to_excel"
|
|
8
|
+
s.version = "0.1.0"
|
|
9
|
+
|
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
|
+
s.authors = ["Rub\303\251n D\303\241vila Santos"]
|
|
12
|
+
s.date = "2011-09-20"
|
|
13
|
+
s.description = "\n This tool allows you to generate quick and simple\n Excel reports based on the array of records returned by your \n ActiveRecord queries\n "
|
|
14
|
+
s.email = "ruben.grunge84@gmail.com"
|
|
15
|
+
s.extra_rdoc_files = [
|
|
16
|
+
"LICENSE.txt",
|
|
17
|
+
"README.md"
|
|
18
|
+
]
|
|
19
|
+
s.files = [
|
|
20
|
+
".autotest",
|
|
21
|
+
".document",
|
|
22
|
+
".rspec",
|
|
23
|
+
".rvmrc",
|
|
24
|
+
"Gemfile",
|
|
25
|
+
"Gemfile.lock",
|
|
26
|
+
"LICENSE.txt",
|
|
27
|
+
"README.md",
|
|
28
|
+
"Rakefile",
|
|
29
|
+
"active_record_to_excel.gemspec",
|
|
30
|
+
"lib/active_record_to_excel.rb",
|
|
31
|
+
"lib/active_record_to_excel/version.rb",
|
|
32
|
+
"spec/active_record_to_excel_spec.rb",
|
|
33
|
+
"spec/dummy/Rakefile",
|
|
34
|
+
"spec/dummy/app/controllers/application_controller.rb",
|
|
35
|
+
"spec/dummy/app/helpers/application_helper.rb",
|
|
36
|
+
"spec/dummy/app/models/user.rb",
|
|
37
|
+
"spec/dummy/app/views/layouts/application.html.erb",
|
|
38
|
+
"spec/dummy/config.ru",
|
|
39
|
+
"spec/dummy/config/application.rb",
|
|
40
|
+
"spec/dummy/config/boot.rb",
|
|
41
|
+
"spec/dummy/config/database.yml",
|
|
42
|
+
"spec/dummy/config/environment.rb",
|
|
43
|
+
"spec/dummy/config/environments/development.rb",
|
|
44
|
+
"spec/dummy/config/environments/production.rb",
|
|
45
|
+
"spec/dummy/config/environments/test.rb",
|
|
46
|
+
"spec/dummy/config/initializers/backtrace_silencers.rb",
|
|
47
|
+
"spec/dummy/config/initializers/inflections.rb",
|
|
48
|
+
"spec/dummy/config/initializers/mime_types.rb",
|
|
49
|
+
"spec/dummy/config/initializers/secret_token.rb",
|
|
50
|
+
"spec/dummy/config/initializers/session_store.rb",
|
|
51
|
+
"spec/dummy/config/locales/en.yml",
|
|
52
|
+
"spec/dummy/config/routes.rb",
|
|
53
|
+
"spec/dummy/db/development.sqlite3",
|
|
54
|
+
"spec/dummy/db/migrate/20110903180904_create_users.rb",
|
|
55
|
+
"spec/dummy/db/schema.rb",
|
|
56
|
+
"spec/dummy/db/test.sqlite3",
|
|
57
|
+
"spec/dummy/log/development.log",
|
|
58
|
+
"spec/dummy/log/production.log",
|
|
59
|
+
"spec/dummy/log/server.log",
|
|
60
|
+
"spec/dummy/log/test.log",
|
|
61
|
+
"spec/dummy/public/404.html",
|
|
62
|
+
"spec/dummy/public/422.html",
|
|
63
|
+
"spec/dummy/public/500.html",
|
|
64
|
+
"spec/dummy/public/favicon.ico",
|
|
65
|
+
"spec/dummy/public/javascripts/application.js",
|
|
66
|
+
"spec/dummy/public/javascripts/controls.js",
|
|
67
|
+
"spec/dummy/public/javascripts/dragdrop.js",
|
|
68
|
+
"spec/dummy/public/javascripts/effects.js",
|
|
69
|
+
"spec/dummy/public/javascripts/prototype.js",
|
|
70
|
+
"spec/dummy/public/javascripts/rails.js",
|
|
71
|
+
"spec/dummy/public/report.xls",
|
|
72
|
+
"spec/dummy/public/stylesheets/.gitkeep",
|
|
73
|
+
"spec/dummy/script/rails",
|
|
74
|
+
"spec/spec_helper.rb"
|
|
75
|
+
]
|
|
76
|
+
s.homepage = "http://github.com/rdavila/active_record_to_excel"
|
|
77
|
+
s.licenses = ["MIT"]
|
|
78
|
+
s.require_paths = ["lib"]
|
|
79
|
+
s.rubygems_version = "1.8.10"
|
|
80
|
+
s.summary = "Excel generator based on ActiveRecord queries"
|
|
81
|
+
|
|
82
|
+
if s.respond_to? :specification_version then
|
|
83
|
+
s.specification_version = 3
|
|
84
|
+
|
|
85
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
86
|
+
s.add_runtime_dependency(%q<spreadsheet>, ["= 0.6.5.8"])
|
|
87
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
|
88
|
+
s.add_development_dependency(%q<rails>, ["~> 3.0.10"])
|
|
89
|
+
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
|
90
|
+
s.add_development_dependency(%q<ZenTest>, ["~> 4.4.2"])
|
|
91
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
92
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
|
93
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
|
94
|
+
s.add_development_dependency(%q<autotest-fsevent>, [">= 0"])
|
|
95
|
+
s.add_development_dependency(%q<autotest-growl>, [">= 0"])
|
|
96
|
+
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
|
97
|
+
s.add_development_dependency(%q<spreadsheet>, ["= 0.6.5.8"])
|
|
98
|
+
s.add_runtime_dependency(%q<spreadsheet>, ["= 0.6.5.8"])
|
|
99
|
+
else
|
|
100
|
+
s.add_dependency(%q<spreadsheet>, ["= 0.6.5.8"])
|
|
101
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
|
102
|
+
s.add_dependency(%q<rails>, ["~> 3.0.10"])
|
|
103
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
|
104
|
+
s.add_dependency(%q<ZenTest>, ["~> 4.4.2"])
|
|
105
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
106
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
|
107
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
|
108
|
+
s.add_dependency(%q<autotest-fsevent>, [">= 0"])
|
|
109
|
+
s.add_dependency(%q<autotest-growl>, [">= 0"])
|
|
110
|
+
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
|
111
|
+
s.add_dependency(%q<spreadsheet>, ["= 0.6.5.8"])
|
|
112
|
+
s.add_dependency(%q<spreadsheet>, ["= 0.6.5.8"])
|
|
113
|
+
end
|
|
114
|
+
else
|
|
115
|
+
s.add_dependency(%q<spreadsheet>, ["= 0.6.5.8"])
|
|
116
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
|
117
|
+
s.add_dependency(%q<rails>, ["~> 3.0.10"])
|
|
118
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
|
119
|
+
s.add_dependency(%q<ZenTest>, ["~> 4.4.2"])
|
|
120
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
121
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
|
122
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
|
123
|
+
s.add_dependency(%q<autotest-fsevent>, [">= 0"])
|
|
124
|
+
s.add_dependency(%q<autotest-growl>, [">= 0"])
|
|
125
|
+
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
|
126
|
+
s.add_dependency(%q<spreadsheet>, ["= 0.6.5.8"])
|
|
127
|
+
s.add_dependency(%q<spreadsheet>, ["= 0.6.5.8"])
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require "rubygems"
|
|
2
|
+
require "spreadsheet"
|
|
3
|
+
|
|
4
|
+
class Array
|
|
5
|
+
def to_excel(options)
|
|
6
|
+
filename = options.delete(:filename)
|
|
7
|
+
path = options.delete(:path)
|
|
8
|
+
|
|
9
|
+
generate_excel(filename, path, options)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def generate_excel(filename, path, options)
|
|
15
|
+
labels = options.values
|
|
16
|
+
|
|
17
|
+
Spreadsheet.client_encoding = 'LATIN1//TRANSLIT//IGNORE'
|
|
18
|
+
book = Spreadsheet::Workbook.new
|
|
19
|
+
sheet = book.create_worksheet
|
|
20
|
+
sheet.row(0).concat(labels)
|
|
21
|
+
|
|
22
|
+
self.each_with_index do |record, i|
|
|
23
|
+
labels.each_with_index do |label, j|
|
|
24
|
+
sheet[i+1,j] = record.send(options.find{ |k, v| v == label }.first)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
book.write File.join(File.expand_path(path || Rails.public_path), filename || 'report.xls')
|
|
29
|
+
end
|
|
30
|
+
end
|