rails-excel-spreadsheet-strategy 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +20 -0
- data/Rakefile +1 -0
- data/lib/rails-excel-spreadsheet-strategy.rb +2 -0
- data/lib/rails-excel/strategies/spreadsheet.rb +59 -0
- data/lib/rails-excel/strategies/spreadsheet/version.rb +7 -0
- data/rails-excel-spreadsheet-strategy.gemspec +26 -0
- metadata +81 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Rails Excel strategy with [spreadsheet](http://spreadsheet.ch) gem
|
2
|
+
|
3
|
+
Use this gem with [RailsExcel](https://github.com/hallelujah/rails-excel) gem
|
4
|
+
|
5
|
+
In your Gemfile
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'rails-excel'
|
9
|
+
gem 'rails-excel-spreadsheet-strategy'
|
10
|
+
```
|
11
|
+
|
12
|
+
In your config/initializers/rails-excel.rb
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
RailsExcel.configure do |config|
|
16
|
+
config.strategy = :spreadsheet
|
17
|
+
end
|
18
|
+
```
|
19
|
+
|
20
|
+
See [RailsExcel](https://github.com/hallelujah/rails-excel) gem for more information
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spreadsheet'
|
2
|
+
|
3
|
+
module RailsExcel
|
4
|
+
module Strategies
|
5
|
+
|
6
|
+
class Spreadsheet
|
7
|
+
def compile(io, &block)
|
8
|
+
workbook = ::Spreadsheet::Workbook.new
|
9
|
+
yield(workbook)
|
10
|
+
workbook.write(io)
|
11
|
+
end
|
12
|
+
|
13
|
+
RailsExcel.add_strategy :spreadsheet, self
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
# This extends colors for spreadsheet gem
|
21
|
+
# See http://dmcritchie.mvps.org/excel/colors.htm#dpalette
|
22
|
+
|
23
|
+
colors = %w{
|
24
|
+
black brown olive_green dark_green dark_teal dark_blue indigo dark_gray
|
25
|
+
dark_red orange dark__yellow green teal blue blue_gray gray
|
26
|
+
red light_orange lime sea_green aqua light_blue violet light_gray
|
27
|
+
pink gold yellow righ_green turquoise sky_blue plu lite_gray
|
28
|
+
rose tan light_yellow light_green light_turquoise plae_blue lavender white
|
29
|
+
periwinkle plum_plus ivory lite_turquoise dark_purple coral ocean_blue ice_blue
|
30
|
+
dark_blue pink_plus yellow_plus turquoise violet dark_red teal_plus blue_plus
|
31
|
+
}
|
32
|
+
|
33
|
+
color_indexes = %w{
|
34
|
+
1 53 52 51 49 11 55 56
|
35
|
+
9 46 12 10 14 5 47 16
|
36
|
+
3 45 43 50 42 41 13 48
|
37
|
+
7 44 6 4 8 33 54 15
|
38
|
+
38 40 36 35 34 37 39 2
|
39
|
+
17 18 19 20 21 22 23 24
|
40
|
+
25 26 27 28 29 30 31 32
|
41
|
+
}
|
42
|
+
|
43
|
+
color_indexes.each_with_index do |c,i|
|
44
|
+
# Do not override already defined colors
|
45
|
+
color_num = c.to_i + 7
|
46
|
+
Spreadsheet::Excel::Internals::COLOR_CODES[color_num] = colors[i].to_sym unless Spreadsheet::Excel::Internals::COLOR_CODES.key?(color_num)
|
47
|
+
Spreadsheet::Excel::Internals::SEDOC_ROLOC[colors[i].to_sym] = color_num unless Spreadsheet::Excel::Internals::COLOR_CODES.key?(colors[i].to_sym)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Add palette colors but not override existing colors
|
51
|
+
ObjectSpace.each_object(Class) do |m|
|
52
|
+
if m.ancestors.include?(Spreadsheet::Datatypes)
|
53
|
+
m::module_eval do
|
54
|
+
class << self
|
55
|
+
COLORS.replace(COLORS | Spreadsheet::Excel::Internals::SEDOC_ROLOC.keys)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "rails-excel/strategies/spreadsheet/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "rails-excel-spreadsheet-strategy"
|
7
|
+
s.version = RailsExcel::Strategies::Spreadsheet::VERSION
|
8
|
+
s.authors = ["Ramihajamalala Hery"]
|
9
|
+
s.email = ["hery@rails-royce.org"]
|
10
|
+
s.homepage = "https://github.com/hallelujah/rails-excel-spreadsheet-strategy"
|
11
|
+
s.summary = %q{Rails Excel strategy using spreadsheet gem}
|
12
|
+
s.description = %q{Rails Excel strategy using spreadsheet gem}
|
13
|
+
|
14
|
+
s.rubyforge_project = "rails-excel-spreadsheet-strategy"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_dependency 'spreadsheet', '>= 0.6.3.1'
|
22
|
+
s.add_development_dependency "rake"
|
23
|
+
# specify any dependencies here; for example:
|
24
|
+
# s.add_development_dependency "rspec"
|
25
|
+
# s.add_runtime_dependency "rest-client"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails-excel-spreadsheet-strategy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ramihajamalala Hery
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-02 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: spreadsheet
|
16
|
+
requirement: &21744580 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.6.3.1
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *21744580
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
requirement: &21744080 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *21744080
|
36
|
+
description: Rails Excel strategy using spreadsheet gem
|
37
|
+
email:
|
38
|
+
- hery@rails-royce.org
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- Gemfile
|
45
|
+
- README.md
|
46
|
+
- Rakefile
|
47
|
+
- lib/rails-excel-spreadsheet-strategy.rb
|
48
|
+
- lib/rails-excel/strategies/spreadsheet.rb
|
49
|
+
- lib/rails-excel/strategies/spreadsheet/version.rb
|
50
|
+
- rails-excel-spreadsheet-strategy.gemspec
|
51
|
+
homepage: https://github.com/hallelujah/rails-excel-spreadsheet-strategy
|
52
|
+
licenses: []
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
hash: 2310825723484342757
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
hash: 2310825723484342757
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project: rails-excel-spreadsheet-strategy
|
77
|
+
rubygems_version: 1.8.10
|
78
|
+
signing_key:
|
79
|
+
specification_version: 3
|
80
|
+
summary: Rails Excel strategy using spreadsheet gem
|
81
|
+
test_files: []
|