rails-excel 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog ADDED
@@ -0,0 +1,9 @@
1
+ 2011-08-23 12:19 Ramihajamalala Hery <hery@weborama.com> v0.0.2
2
+
3
+ * Add a todo list
4
+ * Allow to set excel strategy per action basis
5
+
6
+ 2011-08-22 10:19 Ramihajamalala Hery <hery@weborama.com> v0.0.1
7
+
8
+ * First working release
9
+
data/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # Rails Excel
2
+
3
+ It adds support of .rxls templates for your rails views
4
+
5
+ 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)
6
+
7
+ # Requirements
8
+
9
+ * rails ~> '2.3.0'
10
+ * ruby ~> '1.8.6'
11
+
12
+
13
+ # Usage
14
+
15
+ In your config/environment.rb
16
+
17
+ config.gem 'rails-excel'
18
+
19
+
20
+ Create an initializer : config/initializers/excel.rb
21
+
22
+ Rails::Excel.configure do |config|
23
+ config.strategy = :spreadsheet # by default or :write_excel
24
+ end
25
+
26
+
27
+ If you wan tot implement your own strategy, here are the requirements :
28
+
29
+ * Must respond to compile
30
+ * First argument of compile takes a StringIo instance where to write the response
31
+ * compile takes a block that yields a workbook instance
32
+
33
+
34
+ Example extracted from code source:
35
+
36
+ # lib/my_strategy.rb
37
+
38
+ class MyStrategy
39
+ def compile(io, &block)
40
+ workbook = ::Spreadsheet::Workbook.new
41
+ yield(workbook)
42
+ workbook.write(io)
43
+ end
44
+ end
45
+
46
+ Then in your config/initializers/excel.rb
47
+
48
+
49
+ require 'my_strategy'
50
+ Rails::Excel.configure do |config|
51
+ config.add_strategy :my_strategy, MyStrategy.new
52
+ # Redefining default strategy
53
+ config.strategy = :my_strategy # by default it was :spreadsheet
54
+ end
55
+
56
+ You can use any object as long as it responds to described `compile` method
57
+
58
+
59
+ The strategy defined in the initializer will be used in all of your controllers
60
+
61
+ To use another strategy you can set it by controller :
62
+
63
+ class UsersController < ApplicationController
64
+ self.excel_strategy = :write_excel
65
+ end
66
+
67
+
68
+ Or you can set strategy per action by redefining instance method excel_strategy
69
+
70
+ class UsersController < ApplicationController
71
+
72
+ self.excel_strategy = :write_excel
73
+
74
+ def index
75
+ # ...
76
+ end
77
+
78
+ def show
79
+ # ...
80
+ end
81
+
82
+ protected
83
+ def excel_strategy
84
+ case action_name
85
+ when 'index'
86
+ :spreadsheet
87
+ else
88
+ self.class.excel_strategy
89
+ end
90
+ end
91
+
92
+ end
data/TODO.md ADDED
@@ -0,0 +1,6 @@
1
+ # TODO list
2
+
3
+ * Implement tests
4
+ * Allow to use with rails >= 2.3.0
5
+ * Add more strategies like roo
6
+
@@ -14,6 +14,14 @@ module Rails
14
14
  def self.included(base)
15
15
  base.module_eval do
16
16
  class_inheritable_accessor :excel_strategy, :instance_writer => false
17
+ def excel_strategy
18
+ @excel_strategy ||= self.class.excel_strategy
19
+ end
20
+
21
+ def excel_strategy=(strategy)
22
+ @excel_strategy = strategy
23
+ end
24
+
17
25
  self.excel_strategy = ::Rails::Excel.strategy
18
26
  end
19
27
 
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module Excel
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-excel
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ramihajamalala Hery
@@ -15,12 +15,13 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-22 00:00:00 +02:00
18
+ date: 2011-08-23 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: rake
23
- version_requirements: &id001 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
24
25
  none: false
25
26
  requirements:
26
27
  - - "="
@@ -31,12 +32,12 @@ dependencies:
31
32
  - 8
32
33
  - 7
33
34
  version: 0.8.7
34
- prerelease: false
35
- requirement: *id001
36
35
  type: :development
36
+ version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rspec
39
- version_requirements: &id002 !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
40
41
  none: false
41
42
  requirements:
42
43
  - - ~>
@@ -47,12 +48,12 @@ dependencies:
47
48
  - 3
48
49
  - 0
49
50
  version: 2.3.0
50
- prerelease: false
51
- requirement: *id002
52
51
  type: :development
52
+ version_requirements: *id002
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: rcov
55
- version_requirements: &id003 !ruby/object:Gem::Requirement
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
56
57
  none: false
57
58
  requirements:
58
59
  - - ~>
@@ -63,12 +64,12 @@ dependencies:
63
64
  - 9
64
65
  - 9
65
66
  version: 0.9.9
66
- prerelease: false
67
- requirement: *id003
68
67
  type: :development
68
+ version_requirements: *id003
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: actionpack
71
- version_requirements: &id004 !ruby/object:Gem::Requirement
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
72
73
  none: false
73
74
  requirements:
74
75
  - - ~>
@@ -79,12 +80,12 @@ dependencies:
79
80
  - 3
80
81
  - 0
81
82
  version: 2.3.0
82
- prerelease: false
83
- requirement: *id004
84
83
  type: :development
84
+ version_requirements: *id004
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: writeexcel
87
- version_requirements: &id005 !ruby/object:Gem::Requirement
87
+ prerelease: false
88
+ requirement: &id005 !ruby/object:Gem::Requirement
88
89
  none: false
89
90
  requirements:
90
91
  - - ">="
@@ -95,12 +96,12 @@ dependencies:
95
96
  - 6
96
97
  - 8
97
98
  version: 0.6.8
98
- prerelease: false
99
- requirement: *id005
100
99
  type: :runtime
100
+ version_requirements: *id005
101
101
  - !ruby/object:Gem::Dependency
102
102
  name: spreadsheet
103
- version_requirements: &id006 !ruby/object:Gem::Requirement
103
+ prerelease: false
104
+ requirement: &id006 !ruby/object:Gem::Requirement
104
105
  none: false
105
106
  requirements:
106
107
  - - ">="
@@ -112,9 +113,8 @@ dependencies:
112
113
  - 3
113
114
  - 1
114
115
  version: 0.6.3.1
115
- prerelease: false
116
- requirement: *id006
117
116
  type: :runtime
117
+ version_requirements: *id006
118
118
  description: "Use different strategies to write excel : available are :spreadsheet and :writeexcel\n This implements rxls template in your rails view\n "
119
119
  email:
120
120
  - hery@weborama.com
@@ -127,8 +127,11 @@ extra_rdoc_files: []
127
127
  files:
128
128
  - .gitignore
129
129
  - .rvmrc
130
+ - Changelog
130
131
  - Gemfile
132
+ - README.md
131
133
  - Rakefile
134
+ - TODO.md
132
135
  - lib/rails-excel.rb
133
136
  - lib/rails-excel/delegation.rb
134
137
  - lib/rails-excel/strategies.rb