rails-excel 0.0.4 → 1.0.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/Changelog +8 -3
- data/README.md +27 -1
- data/TODO.md +1 -2
- data/lib/rails-excel.rb +0 -7
- data/lib/rails-excel/strategies.rb +0 -1
- data/lib/rails-excel/template_handler.rb +10 -10
- data/lib/rails-excel/version.rb +1 -1
- data/rails-excel.gemspec +2 -4
- metadata +4 -41
- data/lib/rails-excel/strategies/spreadsheet.rb +0 -58
- data/lib/rails-excel/strategies/write_excel.rb +0 -14
data/Changelog
CHANGED
@@ -1,13 +1,18 @@
|
|
1
|
-
|
1
|
+
2012-01-02 Hallelujah - Ramihajamalala Hery <hery@rails-royce.org> v0.0.4 v1.0.0
|
2
|
+
|
3
|
+
* Remove builtin strategies
|
4
|
+
* Deprecate Rails::Excel in favor of RailsExcel
|
5
|
+
|
6
|
+
2011-09-26 18:33 Ramihajamalala Hery <hery@rails-royce.org> v0.0.3
|
2
7
|
|
3
8
|
* Compatibility with Rails 3.x (by edpaget)
|
4
9
|
|
5
|
-
2011-08-23 12:19 Ramihajamalala Hery <hery@
|
10
|
+
2011-08-23 12:19 Ramihajamalala Hery <hery@rails-royce.org> v0.0.2
|
6
11
|
|
7
12
|
* Add a todo list
|
8
13
|
* Allow to set excel strategy per action basis
|
9
14
|
|
10
|
-
2011-08-22 10:19 Ramihajamalala Hery <hery@
|
15
|
+
2011-08-22 10:19 Ramihajamalala Hery <hery@rails-royce.org> v0.0.1
|
11
16
|
|
12
17
|
* First working release
|
13
18
|
|
data/README.md
CHANGED
@@ -2,7 +2,19 @@
|
|
2
2
|
|
3
3
|
It adds support of .rxls templates for your rails views
|
4
4
|
|
5
|
-
|
5
|
+
[DEPRECATED]
|
6
|
+
|
7
|
+
Prior to 1.0.0, it comes with two builtin strategies based on the very good gems [writeexcel](https://github.com/cxn03651/writeexcel) and [spreadsheet](http://spreadsheet.rubyforge.org/index.html)
|
8
|
+
|
9
|
+
[IMPORTANT]
|
10
|
+
|
11
|
+
As of 1.0.0, there is no builtin strategy anymore. You should install at least one strategy :
|
12
|
+
|
13
|
+
* [spreadsheet](https://github.com/hallelujah/rails-excel-spreadsheet-strategy)
|
14
|
+
* [write_excel](https://github.com/hallelujah/rails-excel-write_excel-strategy)
|
15
|
+
* [rubyXL](https://github.com/hallelujah/rails-excel-rubyXL-strategy)
|
16
|
+
|
17
|
+
|
6
18
|
|
7
19
|
# Requirements
|
8
20
|
|
@@ -95,6 +107,20 @@ class UsersController < ApplicationController
|
|
95
107
|
end
|
96
108
|
```
|
97
109
|
|
110
|
+
Or you can also override excel_strategy by action like that :
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
class UsersController < ApplicationController
|
114
|
+
self.excel_strategy = :write_excel
|
115
|
+
|
116
|
+
def other_action
|
117
|
+
self.excel_strategy = :rubyXL
|
118
|
+
# ...
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
```
|
123
|
+
|
98
124
|
# Contributors
|
99
125
|
|
100
126
|
* [edpaget](https://github.com/edpaget)
|
data/TODO.md
CHANGED
data/lib/rails-excel.rb
CHANGED
@@ -21,10 +21,6 @@ module Rails
|
|
21
21
|
end
|
22
22
|
|
23
23
|
module RailsExcel
|
24
|
-
BUILTIN_STRATEGIES = {
|
25
|
-
:spreadsheet => RailsExcel::Strategies::Spreadsheet,
|
26
|
-
:write_excel => RailsExcel::Strategies::WriteExcel
|
27
|
-
} unless const_defined?(:BUILTIN_STRATEGIES)
|
28
24
|
|
29
25
|
class << self
|
30
26
|
module_eval do
|
@@ -38,9 +34,6 @@ module RailsExcel
|
|
38
34
|
|
39
35
|
def configure(&block)
|
40
36
|
@available_strategies = Hash.new
|
41
|
-
BUILTIN_STRATEGIES.each do |k,v|
|
42
|
-
add_strategy k, v.new
|
43
|
-
end
|
44
37
|
yield(self)
|
45
38
|
::ActionView::Base.send :include, RailsExcel::Delegation::View
|
46
39
|
::ActionController::Base.send :include,RailsExcel::Delegation::Controller
|
@@ -1,23 +1,23 @@
|
|
1
1
|
require 'action_controller'
|
2
2
|
require 'action_view'
|
3
3
|
module RailsExcel
|
4
|
-
|
4
|
+
class TemplateHandler
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def self.call(template, *args)
|
7
|
+
new.compile(template)
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
def compile(template)
|
11
|
+
%Q{
|
12
12
|
io = StringIO.new
|
13
13
|
RailsExcel.available_strategies[self.excel_strategy].compile(io) do |workbook|
|
14
|
-
|
14
|
+
#{template.source}
|
15
15
|
end
|
16
16
|
self.output_buffer = io.string
|
17
|
-
|
18
|
-
end
|
19
|
-
|
17
|
+
}
|
20
18
|
end
|
19
|
+
|
21
20
|
end
|
21
|
+
end
|
22
22
|
|
23
23
|
::Mime::Type.register "application/vnd.ms-excel", :xls
|
data/lib/rails-excel/version.rb
CHANGED
data/rails-excel.gemspec
CHANGED
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = "rails-excel"
|
7
7
|
s.version = RailsExcel::VERSION
|
8
8
|
s.authors = ["Ramihajamalala Hery"]
|
9
|
-
s.email = ["hery@
|
10
|
-
s.homepage = ""
|
9
|
+
s.email = ["hery@rails-royce.org"]
|
10
|
+
s.homepage = "https://github.com/hallelujah/rails-excel"
|
11
11
|
s.summary = %q{A rails gem to write excel}
|
12
12
|
s.description = %q{Use different strategies to write excel : available are :spreadsheet and :writeexcel
|
13
13
|
This implements rxls template in your rails view
|
@@ -19,8 +19,6 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.add_development_dependency 'rspec', '~> 2.3.0'
|
20
20
|
s.add_development_dependency 'rcov', '~> 0.9.9'
|
21
21
|
s.add_development_dependency 'actionpack', '~> 2.3.0'
|
22
|
-
s.add_dependency 'writeexcel', '>= 0.6.8'
|
23
|
-
s.add_dependency 'spreadsheet', '>= 0.6.3.1'
|
24
22
|
|
25
23
|
s.files = `git ls-files`.split("\n")
|
26
24
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -4,11 +4,11 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
|
+
- 1
|
7
8
|
- 0
|
8
9
|
- 0
|
9
|
-
- 4
|
10
10
|
segments_generated: true
|
11
|
-
version: 0.0
|
11
|
+
version: 1.0.0
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Ramihajamalala Hery
|
@@ -87,44 +87,9 @@ dependencies:
|
|
87
87
|
prerelease: false
|
88
88
|
requirement: *id004
|
89
89
|
type: :development
|
90
|
-
- !ruby/object:Gem::Dependency
|
91
|
-
name: writeexcel
|
92
|
-
version_requirements: &id005 !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
|
-
requirements:
|
95
|
-
- - ">="
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
hash: 23
|
98
|
-
segments:
|
99
|
-
- 0
|
100
|
-
- 6
|
101
|
-
- 8
|
102
|
-
segments_generated: true
|
103
|
-
version: 0.6.8
|
104
|
-
prerelease: false
|
105
|
-
requirement: *id005
|
106
|
-
type: :runtime
|
107
|
-
- !ruby/object:Gem::Dependency
|
108
|
-
name: spreadsheet
|
109
|
-
version_requirements: &id006 !ruby/object:Gem::Requirement
|
110
|
-
none: false
|
111
|
-
requirements:
|
112
|
-
- - ">="
|
113
|
-
- !ruby/object:Gem::Version
|
114
|
-
hash: 113
|
115
|
-
segments:
|
116
|
-
- 0
|
117
|
-
- 6
|
118
|
-
- 3
|
119
|
-
- 1
|
120
|
-
segments_generated: true
|
121
|
-
version: 0.6.3.1
|
122
|
-
prerelease: false
|
123
|
-
requirement: *id006
|
124
|
-
type: :runtime
|
125
90
|
description: "Use different strategies to write excel : available are :spreadsheet and :writeexcel\n This implements rxls template in your rails view\n "
|
126
91
|
email:
|
127
|
-
- hery@
|
92
|
+
- hery@rails-royce.org
|
128
93
|
executables: []
|
129
94
|
|
130
95
|
extensions: []
|
@@ -142,13 +107,11 @@ files:
|
|
142
107
|
- lib/rails-excel.rb
|
143
108
|
- lib/rails-excel/delegation.rb
|
144
109
|
- lib/rails-excel/strategies.rb
|
145
|
-
- lib/rails-excel/strategies/spreadsheet.rb
|
146
|
-
- lib/rails-excel/strategies/write_excel.rb
|
147
110
|
- lib/rails-excel/template_handler.rb
|
148
111
|
- lib/rails-excel/version.rb
|
149
112
|
- rails-excel.gemspec
|
150
113
|
has_rdoc: true
|
151
|
-
homepage:
|
114
|
+
homepage: https://github.com/hallelujah/rails-excel
|
152
115
|
licenses: []
|
153
116
|
|
154
117
|
post_install_message:
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'spreadsheet'
|
2
|
-
|
3
|
-
|
4
|
-
module RailsExcel
|
5
|
-
module Strategies
|
6
|
-
|
7
|
-
class Spreadsheet
|
8
|
-
def compile(io, &block)
|
9
|
-
workbook = ::Spreadsheet::Workbook.new
|
10
|
-
yield(workbook)
|
11
|
-
workbook.write(io)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
# This extends colors for spreadsheet gem
|
20
|
-
# See http://dmcritchie.mvps.org/excel/colors.htm#dpalette
|
21
|
-
|
22
|
-
colors = %w{
|
23
|
-
black brown olive_green dark_green dark_teal dark_blue indigo dark_gray
|
24
|
-
dark_red orange dark__yellow green teal blue blue_gray gray
|
25
|
-
red light_orange lime sea_green aqua light_blue violet light_gray
|
26
|
-
pink gold yellow righ_green turquoise sky_blue plu lite_gray
|
27
|
-
rose tan light_yellow light_green light_turquoise plae_blue lavender white
|
28
|
-
periwinkle plum_plus ivory lite_turquoise dark_purple coral ocean_blue ice_blue
|
29
|
-
dark_blue pink_plus yellow_plus turquoise violet dark_red teal_plus blue_plus
|
30
|
-
}
|
31
|
-
|
32
|
-
color_indexes = %w{
|
33
|
-
1 53 52 51 49 11 55 56
|
34
|
-
9 46 12 10 14 5 47 16
|
35
|
-
3 45 43 50 42 41 13 48
|
36
|
-
7 44 6 4 8 33 54 15
|
37
|
-
38 40 36 35 34 37 39 2
|
38
|
-
17 18 19 20 21 22 23 24
|
39
|
-
25 26 27 28 29 30 31 32
|
40
|
-
}
|
41
|
-
|
42
|
-
color_indexes.each_with_index do |c,i|
|
43
|
-
# Do not override already defined colors
|
44
|
-
color_num = c.to_i + 7
|
45
|
-
Spreadsheet::Excel::Internals::COLOR_CODES[color_num] = colors[i].to_sym unless Spreadsheet::Excel::Internals::COLOR_CODES.key?(color_num)
|
46
|
-
Spreadsheet::Excel::Internals::SEDOC_ROLOC[colors[i].to_sym] = color_num unless Spreadsheet::Excel::Internals::COLOR_CODES.key?(colors[i].to_sym)
|
47
|
-
end
|
48
|
-
|
49
|
-
# Add palette colors but not override existing colors
|
50
|
-
ObjectSpace.each_object(Class) do |m|
|
51
|
-
if m.ancestors.include?(Spreadsheet::Datatypes)
|
52
|
-
m::module_eval do
|
53
|
-
class << self
|
54
|
-
COLORS.replace(COLORS | Spreadsheet::Excel::Internals::SEDOC_ROLOC.keys)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|