axlsx_rails 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile +9 -6
- data/Gemfile.lock +116 -115
- data/Gemfile.lock.4.0 +66 -67
- data/Gemfile.lock.4.1 +90 -91
- data/Gemfile.lock.4.2 +115 -114
- data/Gemfile.lock.5.0 +259 -0
- data/README.md +37 -4
- data/axlsx_rails.gemspec +36 -0
- data/lib/axlsx_rails/action_controller.rb +5 -1
- data/lib/axlsx_rails/template_handler.rb +1 -1
- data/lib/axlsx_rails/version.rb +1 -1
- data/spec/axlsx_builder_spec.rb +2 -2
- data/spec/axlsx_mailer_spec.rb +3 -3
- data/spec/axlsx_renderer_spec.rb +4 -3
- data/spec/axlsx_request_spec.rb +43 -30
- data/spec/ci.rb +4 -1
- data/spec/dummy/app/mailers/notifier.rb +1 -1
- data/spec/dummy/app/views/users/{mailers/instructions.xlsx.axlsx → send_instructions.xlsx.axlsx} +0 -0
- data/spec/dummy/log/test.log +0 -0
- data/spec/dummy_4/app/mailers/notifier.rb +1 -1
- data/spec/dummy_4/app/views/users/noaction.xlsx.axlsx +1 -0
- data/spec/dummy_4/app/views/users/{mailers/instructions.xlsx.axlsx → send_instructions.xlsx.axlsx} +0 -0
- data/spec/dummy_4/config/routes.rb +1 -0
- data/spec/dummy_4/db/schema.rb +2 -2
- data/spec/dummy_4/db/test.sqlite3 +0 -0
- data/spec/dummy_4/log/test.log +14792 -0
- data/spec/dummy_5/Rakefile +6 -0
- data/spec/dummy_5/app/assets/javascripts/application.js +13 -0
- data/spec/dummy_5/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy_5/app/controllers/application_controller.rb +5 -0
- data/spec/dummy_5/app/controllers/home_controller.rb +56 -0
- data/spec/dummy_5/app/controllers/likes_controller.rb +18 -0
- data/spec/dummy_5/app/controllers/users_controller.rb +27 -0
- data/spec/dummy_5/app/helpers/application_helper.rb +2 -0
- data/spec/dummy_5/app/mailers/notifier.rb +14 -0
- data/spec/dummy_5/app/models/like.rb +3 -0
- data/spec/dummy_5/app/models/user.rb +10 -0
- data/spec/dummy_5/app/views/home/_cover_sheet.xlsx.axlsx +3 -0
- data/spec/dummy_5/app/views/home/index.html.erb +4 -0
- data/spec/dummy_5/app/views/home/index.xlsx.axlsx +8 -0
- data/spec/dummy_5/app/views/home/only_html.html.erb +1 -0
- data/spec/dummy_5/app/views/home/useheader.xlsx.axlsx +8 -0
- data/spec/dummy_5/app/views/home/withpartial.xlsx.axlsx +9 -0
- data/spec/dummy_5/app/views/layouts/application.html.erb +12 -0
- data/spec/dummy_5/app/views/likes/index.html.erb +17 -0
- data/spec/dummy_5/app/views/likes/index.xlsx.axlsx +7 -0
- data/spec/dummy_5/app/views/notifier/instructions.html.erb +14 -0
- data/spec/dummy_5/app/views/notifier/instructions.txt.erb +6 -0
- data/spec/dummy_5/app/views/users/index.html.erb +23 -0
- data/spec/dummy_5/app/views/users/index.xlsx.axlsx +1 -0
- data/spec/dummy_5/app/views/users/noaction.xlsx.axlsx +1 -0
- data/spec/dummy_5/app/views/users/respond_with.xlsx.axlsx +8 -0
- data/spec/dummy_5/app/views/users/send_instructions.xlsx.axlsx +5 -0
- data/spec/dummy_5/bin/bundle +3 -0
- data/spec/dummy_5/bin/rails +4 -0
- data/spec/dummy_5/bin/rake +4 -0
- data/spec/dummy_5/config.ru +4 -0
- data/spec/dummy_5/config/application.rb +23 -0
- data/spec/dummy_5/config/boot.rb +5 -0
- data/spec/dummy_5/config/database.yml +25 -0
- data/spec/dummy_5/config/environment.rb +5 -0
- data/spec/dummy_5/config/environments/development.rb +37 -0
- data/spec/dummy_5/config/environments/production.rb +83 -0
- data/spec/dummy_5/config/environments/test.rb +40 -0
- data/spec/dummy_5/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy_5/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy_5/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy_5/config/initializers/inflections.rb +16 -0
- data/spec/dummy_5/config/initializers/mime_types.rb +4 -0
- data/spec/dummy_5/config/initializers/secret_token.rb +2 -0
- data/spec/dummy_5/config/initializers/session_store.rb +3 -0
- data/spec/dummy_5/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy_5/config/locales/en.yml +23 -0
- data/spec/dummy_5/config/routes.rb +16 -0
- data/spec/dummy_5/config/secrets.yml +22 -0
- data/spec/dummy_5/db/migrate/20120717192452_create_users.rb +12 -0
- data/spec/dummy_5/db/migrate/20121206210955_create_likes.rb +10 -0
- data/spec/dummy_5/db/schema.rb +31 -0
- data/spec/dummy_5/db/test.sqlite3 +0 -0
- data/spec/dummy_5/log/test.log +5738 -0
- data/spec/dummy_5/public/404.html +67 -0
- data/spec/dummy_5/public/422.html +67 -0
- data/spec/dummy_5/public/500.html +66 -0
- data/spec/dummy_5/public/favicon.ico +0 -0
- data/spec/spec_helper.rb +8 -2
- data/spec/test_5.0.sh +16 -0
- metadata +132 -12
- data/spec/dummy/README.rdoc +0 -261
- data/spec/dummy_4/README.rdoc +0 -28
data/Gemfile.lock.5.0
ADDED
@@ -0,0 +1,259 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/straydogstudio/acts_as_xlsx.git
|
3
|
+
revision: 94fc6aa730bb8f252e75c9debdcf64903d33fede
|
4
|
+
specs:
|
5
|
+
acts_as_xlsx (1.0.6)
|
6
|
+
activerecord (>= 2.3.9)
|
7
|
+
axlsx (>= 1.0.13)
|
8
|
+
i18n (>= 0.4.1)
|
9
|
+
|
10
|
+
PATH
|
11
|
+
remote: .
|
12
|
+
specs:
|
13
|
+
axlsx_rails (0.4.0)
|
14
|
+
actionpack (>= 3.1)
|
15
|
+
axlsx (>= 2.0.1)
|
16
|
+
|
17
|
+
GEM
|
18
|
+
remote: http://rubygems.org/
|
19
|
+
specs:
|
20
|
+
actioncable (5.0.0)
|
21
|
+
actionpack (= 5.0.0)
|
22
|
+
nio4r (~> 1.2)
|
23
|
+
websocket-driver (~> 0.6.1)
|
24
|
+
actionmailer (5.0.0)
|
25
|
+
actionpack (= 5.0.0)
|
26
|
+
actionview (= 5.0.0)
|
27
|
+
activejob (= 5.0.0)
|
28
|
+
mail (~> 2.5, >= 2.5.4)
|
29
|
+
rails-dom-testing (~> 2.0)
|
30
|
+
actionpack (5.0.0)
|
31
|
+
actionview (= 5.0.0)
|
32
|
+
activesupport (= 5.0.0)
|
33
|
+
rack (~> 2.0)
|
34
|
+
rack-test (~> 0.6.3)
|
35
|
+
rails-dom-testing (~> 2.0)
|
36
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
37
|
+
actionview (5.0.0)
|
38
|
+
activesupport (= 5.0.0)
|
39
|
+
builder (~> 3.1)
|
40
|
+
erubis (~> 2.7.0)
|
41
|
+
rails-dom-testing (~> 2.0)
|
42
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
43
|
+
activejob (5.0.0)
|
44
|
+
activesupport (= 5.0.0)
|
45
|
+
globalid (>= 0.3.6)
|
46
|
+
activemodel (5.0.0)
|
47
|
+
activesupport (= 5.0.0)
|
48
|
+
activerecord (5.0.0)
|
49
|
+
activemodel (= 5.0.0)
|
50
|
+
activesupport (= 5.0.0)
|
51
|
+
arel (~> 7.0)
|
52
|
+
activesupport (5.0.0)
|
53
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
54
|
+
i18n (~> 0.7)
|
55
|
+
minitest (~> 5.1)
|
56
|
+
tzinfo (~> 1.1)
|
57
|
+
addressable (2.4.0)
|
58
|
+
arel (7.1.0)
|
59
|
+
axlsx (2.0.1)
|
60
|
+
htmlentities (~> 4.3.1)
|
61
|
+
nokogiri (>= 1.4.1)
|
62
|
+
rubyzip (~> 1.0.0)
|
63
|
+
builder (3.2.2)
|
64
|
+
capybara (2.7.1)
|
65
|
+
addressable
|
66
|
+
mime-types (>= 1.16)
|
67
|
+
nokogiri (>= 1.3.3)
|
68
|
+
rack (>= 1.0.0)
|
69
|
+
rack-test (>= 0.5.4)
|
70
|
+
xpath (~> 2.0)
|
71
|
+
coderay (1.1.1)
|
72
|
+
concurrent-ruby (1.0.2)
|
73
|
+
coveralls (0.8.14)
|
74
|
+
json (>= 1.8, < 3)
|
75
|
+
simplecov (~> 0.12.0)
|
76
|
+
term-ansicolor (~> 1.3)
|
77
|
+
thor (~> 0.19.1)
|
78
|
+
tins (~> 1.6.0)
|
79
|
+
daemons (1.2.3)
|
80
|
+
diff-lcs (1.2.5)
|
81
|
+
docile (1.1.5)
|
82
|
+
erubis (2.7.0)
|
83
|
+
eventmachine (1.2.0.1)
|
84
|
+
ffi (1.9.14)
|
85
|
+
formatador (0.2.5)
|
86
|
+
globalid (0.3.6)
|
87
|
+
activesupport (>= 4.1.0)
|
88
|
+
growl (1.0.3)
|
89
|
+
guard (2.14.0)
|
90
|
+
formatador (>= 0.2.4)
|
91
|
+
listen (>= 2.7, < 4.0)
|
92
|
+
lumberjack (~> 1.0)
|
93
|
+
nenv (~> 0.1)
|
94
|
+
notiffany (~> 0.0)
|
95
|
+
pry (>= 0.9.12)
|
96
|
+
shellany (~> 0.0)
|
97
|
+
thor (>= 0.18.1)
|
98
|
+
guard-compat (1.2.1)
|
99
|
+
guard-rspec (4.7.2)
|
100
|
+
guard (~> 2.1)
|
101
|
+
guard-compat (~> 1.1)
|
102
|
+
rspec (>= 2.99.0, < 4.0)
|
103
|
+
htmlentities (4.3.4)
|
104
|
+
i18n (0.7.0)
|
105
|
+
jquery-rails (4.1.1)
|
106
|
+
rails-dom-testing (>= 1, < 3)
|
107
|
+
railties (>= 4.2.0)
|
108
|
+
thor (>= 0.14, < 2.0)
|
109
|
+
json (2.0.1)
|
110
|
+
listen (3.1.5)
|
111
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
112
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
113
|
+
ruby_dep (~> 1.2)
|
114
|
+
loofah (2.0.3)
|
115
|
+
nokogiri (>= 1.5.9)
|
116
|
+
lumberjack (1.0.10)
|
117
|
+
mail (2.6.4)
|
118
|
+
mime-types (>= 1.16, < 4)
|
119
|
+
method_source (0.8.2)
|
120
|
+
mime-types (3.1)
|
121
|
+
mime-types-data (~> 3.2015)
|
122
|
+
mime-types-data (3.2016.0521)
|
123
|
+
mini_portile2 (2.1.0)
|
124
|
+
minitest (5.9.0)
|
125
|
+
nenv (0.3.0)
|
126
|
+
nio4r (1.2.1)
|
127
|
+
nokogiri (1.6.8)
|
128
|
+
mini_portile2 (~> 2.1.0)
|
129
|
+
pkg-config (~> 1.1.7)
|
130
|
+
notiffany (0.1.0)
|
131
|
+
nenv (~> 0.1)
|
132
|
+
shellany (~> 0.0)
|
133
|
+
pkg-config (1.1.7)
|
134
|
+
pry (0.10.4)
|
135
|
+
coderay (~> 1.1.0)
|
136
|
+
method_source (~> 0.8.1)
|
137
|
+
slop (~> 3.4)
|
138
|
+
pry-nav (0.2.4)
|
139
|
+
pry (>= 0.9.10, < 0.11.0)
|
140
|
+
rack (2.0.1)
|
141
|
+
rack-test (0.6.3)
|
142
|
+
rack (>= 1.0)
|
143
|
+
rails (5.0.0)
|
144
|
+
actioncable (= 5.0.0)
|
145
|
+
actionmailer (= 5.0.0)
|
146
|
+
actionpack (= 5.0.0)
|
147
|
+
actionview (= 5.0.0)
|
148
|
+
activejob (= 5.0.0)
|
149
|
+
activemodel (= 5.0.0)
|
150
|
+
activerecord (= 5.0.0)
|
151
|
+
activesupport (= 5.0.0)
|
152
|
+
bundler (>= 1.3.0, < 2.0)
|
153
|
+
railties (= 5.0.0)
|
154
|
+
sprockets-rails (>= 2.0.0)
|
155
|
+
rails-dom-testing (2.0.1)
|
156
|
+
activesupport (>= 4.2.0, < 6.0)
|
157
|
+
nokogiri (~> 1.6.0)
|
158
|
+
rails-html-sanitizer (1.0.3)
|
159
|
+
loofah (~> 2.0)
|
160
|
+
railties (5.0.0)
|
161
|
+
actionpack (= 5.0.0)
|
162
|
+
activesupport (= 5.0.0)
|
163
|
+
method_source
|
164
|
+
rake (>= 0.8.7)
|
165
|
+
thor (>= 0.18.1, < 2.0)
|
166
|
+
rake (11.2.2)
|
167
|
+
rb-fsevent (0.9.7)
|
168
|
+
rb-inotify (0.9.7)
|
169
|
+
ffi (>= 0.5.0)
|
170
|
+
responders (2.2.0)
|
171
|
+
railties (>= 4.2.0, < 5.1)
|
172
|
+
roo (1.13.2)
|
173
|
+
nokogiri
|
174
|
+
rubyzip
|
175
|
+
spreadsheet (> 0.6.4)
|
176
|
+
rspec (3.5.0)
|
177
|
+
rspec-core (~> 3.5.0)
|
178
|
+
rspec-expectations (~> 3.5.0)
|
179
|
+
rspec-mocks (~> 3.5.0)
|
180
|
+
rspec-core (3.5.1)
|
181
|
+
rspec-support (~> 3.5.0)
|
182
|
+
rspec-expectations (3.5.0)
|
183
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
184
|
+
rspec-support (~> 3.5.0)
|
185
|
+
rspec-mocks (3.5.0)
|
186
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
187
|
+
rspec-support (~> 3.5.0)
|
188
|
+
rspec-rails (3.5.1)
|
189
|
+
actionpack (>= 3.0)
|
190
|
+
activesupport (>= 3.0)
|
191
|
+
railties (>= 3.0)
|
192
|
+
rspec-core (~> 3.5.0)
|
193
|
+
rspec-expectations (~> 3.5.0)
|
194
|
+
rspec-mocks (~> 3.5.0)
|
195
|
+
rspec-support (~> 3.5.0)
|
196
|
+
rspec-support (3.5.0)
|
197
|
+
ruby-ole (1.2.12)
|
198
|
+
ruby_dep (1.3.1)
|
199
|
+
rubyzip (1.0.0)
|
200
|
+
shellany (0.0.1)
|
201
|
+
simplecov (0.12.0)
|
202
|
+
docile (~> 1.1.0)
|
203
|
+
json (>= 1.8, < 3)
|
204
|
+
simplecov-html (~> 0.10.0)
|
205
|
+
simplecov-html (0.10.0)
|
206
|
+
slop (3.6.0)
|
207
|
+
spreadsheet (1.1.2)
|
208
|
+
ruby-ole (>= 1.0)
|
209
|
+
sprockets (3.7.0)
|
210
|
+
concurrent-ruby (~> 1.0)
|
211
|
+
rack (> 1, < 3)
|
212
|
+
sprockets-rails (3.1.1)
|
213
|
+
actionpack (>= 4.0)
|
214
|
+
activesupport (>= 4.0)
|
215
|
+
sprockets (>= 3.0.0)
|
216
|
+
sqlite3 (1.3.11)
|
217
|
+
term-ansicolor (1.3.2)
|
218
|
+
tins (~> 1.0)
|
219
|
+
thin (1.7.0)
|
220
|
+
daemons (~> 1.0, >= 1.0.9)
|
221
|
+
eventmachine (~> 1.0, >= 1.0.4)
|
222
|
+
rack (>= 1, < 3)
|
223
|
+
thor (0.19.1)
|
224
|
+
thread_safe (0.3.5)
|
225
|
+
tins (1.6.0)
|
226
|
+
tzinfo (1.2.2)
|
227
|
+
thread_safe (~> 0.1)
|
228
|
+
websocket-driver (0.6.4)
|
229
|
+
websocket-extensions (>= 0.1.0)
|
230
|
+
websocket-extensions (0.1.2)
|
231
|
+
xpath (2.0.0)
|
232
|
+
nokogiri (~> 1.3)
|
233
|
+
|
234
|
+
PLATFORMS
|
235
|
+
ruby
|
236
|
+
|
237
|
+
DEPENDENCIES
|
238
|
+
acts_as_xlsx!
|
239
|
+
axlsx_rails!
|
240
|
+
bundler
|
241
|
+
capybara (~> 2.1)
|
242
|
+
coveralls
|
243
|
+
growl
|
244
|
+
guard-rspec
|
245
|
+
jquery-rails
|
246
|
+
pry
|
247
|
+
pry-nav
|
248
|
+
rails (~> 5.0.0)
|
249
|
+
rake
|
250
|
+
rb-fsevent
|
251
|
+
responders (~> 2.0)
|
252
|
+
roo
|
253
|
+
rspec-rails
|
254
|
+
rubyzip
|
255
|
+
sqlite3
|
256
|
+
thin
|
257
|
+
|
258
|
+
BUNDLED WITH
|
259
|
+
1.10.6
|
data/README.md
CHANGED
@@ -14,14 +14,24 @@ Status](https://coveralls.io/repos/straydogstudio/axlsx_rails/badge.png)](https:
|
|
14
14
|
In your Gemfile:
|
15
15
|
|
16
16
|
```ruby
|
17
|
+
gem 'rubyzip', '~> 1.1.0'
|
18
|
+
gem 'axlsx', '2.1.0.pre'
|
19
|
+
gem 'axlsx_rails'
|
20
|
+
```
|
21
|
+
|
22
|
+
If `rubyzip 1.0.0` is needed:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
gem 'rubyzip', '= 1.0.0'
|
26
|
+
gem 'axlsx', '= 2.0.1'
|
17
27
|
gem 'axlsx_rails'
|
18
28
|
```
|
19
29
|
|
20
30
|
##Requirements
|
21
31
|
|
22
|
-
* Rails 4.1
|
32
|
+
* Rails 4.1, 4.2, or 5 (tested)
|
23
33
|
* For Rails 3.1 or 3.2 use version 3.0
|
24
|
-
* **As of 0.
|
34
|
+
* **As of 0.5.0 requires Axlsx 2.0.1.pre, which requires rubyzip 1.1.0**
|
25
35
|
* As of Rails 4.1 you must use `render_to_string` to render a mail attachment.
|
26
36
|
|
27
37
|
##FYI
|
@@ -180,6 +190,7 @@ class UserMailer < ActionMailer::Base
|
|
180
190
|
def export(users)
|
181
191
|
xlsx = render_to_string handlers: [:axlsx], formats: [:xlsx], template: "users/export", locals: {users: users}
|
182
192
|
attachments["Users.xlsx"] = {mime_type: Mime::XLSX, content: xlsx}
|
193
|
+
# self.instance_variable_set(:@_lookup_context, nil) # If attachments are rendered as content, try this and open an issue
|
183
194
|
...
|
184
195
|
end
|
185
196
|
end
|
@@ -204,6 +215,21 @@ To generate a template within a script, you need to instantiate an ActionView co
|
|
204
215
|
* If it says your template is missing, check that its extension is `.xlsx.axlsx`.
|
205
216
|
* If you get the error `uninitialized constant Mime::XSLX` you have used `format.xslx` instead of `format.xlsx`, or something similar.
|
206
217
|
|
218
|
+
### Mailer Attachments: No content, cannot read
|
219
|
+
|
220
|
+
If you are having problems with rendering a template and attaching it to a template, try a few options:
|
221
|
+
|
222
|
+
* Make sure the attachment template does not have the same name as the mailer.
|
223
|
+
* After you have rendered the template to string, and before you call the mailer, execute `self.instance_variable_set(:@_lookup_context, nil)`. If you must do this, please open an issue.
|
224
|
+
|
225
|
+
If you get this error, please open an issue and share code so the bug can be isolated.
|
226
|
+
|
227
|
+
### Generated Files Can't Be Opened or Invalid Byte Sequence in UTF-8
|
228
|
+
|
229
|
+
Both these errors *appear* to be caused by Rails applying a layout to the template. Passing `layout: false` to `render :xlsx` should fix this issue. Version 0.5.0 attempts to fix this issue.
|
230
|
+
|
231
|
+
If you get this error, please open an issue and share code so the bug can be isolated.
|
232
|
+
|
207
233
|
### Rails 4.2 changes
|
208
234
|
|
209
235
|
Before Rails 4.2 you could call:
|
@@ -250,7 +276,8 @@ Many thanks to [contributors](https://github.com/straydogstudio/axlsx_rails/grap
|
|
250
276
|
* [maxd](https://github.com/maxd)
|
251
277
|
* [firien](https://github.com/firien)
|
252
278
|
* [kaluzny](https://github.com/kaluznyo)
|
253
|
-
|
279
|
+
* [sly7-7](https://github.com/sly7-7)
|
280
|
+
* [kodram](https://github.com/kodram)
|
254
281
|
|
255
282
|
##Donations
|
256
283
|
|
@@ -261,6 +288,12 @@ source:
|
|
261
288
|
|
262
289
|
##Change log
|
263
290
|
|
291
|
+
**July 26st, 2016**: 0.5.0 release
|
292
|
+
|
293
|
+
- Support for Rails 5
|
294
|
+
- **Tested on on Rails 4.0, 4.1, 4.2, and 5.0**
|
295
|
+
- Bug fixes for unreadable files and UTF-8 errors
|
296
|
+
|
264
297
|
**July 13th, 2015**: 0.4.0 release
|
265
298
|
|
266
299
|
- Support for Rails 4.2
|
@@ -321,7 +354,7 @@ source:
|
|
321
354
|
**July 17, 2012**: 0.1.0 release
|
322
355
|
|
323
356
|
- Tests completed
|
324
|
-
- Acts_as_xlsx tested, example in docs
|
357
|
+
- Acts_as_xlsx tested, example in docs
|
325
358
|
|
326
359
|
**July 12, 2012**: 0.0.1 release
|
327
360
|
|
data/axlsx_rails.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
# Maintain your gem's version:
|
4
|
+
require "axlsx_rails/version"
|
5
|
+
|
6
|
+
# Describe your gem and declare its dependencies:
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "axlsx_rails"
|
9
|
+
s.version = AxlsxRails::VERSION
|
10
|
+
s.authors = ["Noel Peden"]
|
11
|
+
s.email = ["noel@peden.biz"]
|
12
|
+
s.homepage = "https://github.com/straydogstudio/axlsx_rails"
|
13
|
+
s.summary = "A simple rails plugin to provide an xlsx renderer using the axlsx gem."
|
14
|
+
s.description = "Axlsx_Rails provides an Axlsx renderer so you can move all your spreadsheet code from your controller into view files. Partials are supported so you can organize any code into reusable chunks (e.g. cover sheets, common styling, etc.) You can use it with acts_as_xlsx, placing the to_xlsx call in a view and adding ':package => xlsx_package' to the parameter list. Now you can keep your controllers thin!"
|
15
|
+
|
16
|
+
s.files = Dir["{app,config,db,lib}/**/*"] + Dir['[A-Z]*'] - ['Guardfile']
|
17
|
+
s.test_files = Dir["spec/**/*"] + ['Guardfile']
|
18
|
+
|
19
|
+
s.add_dependency "actionpack", ">= 3.1"
|
20
|
+
s.add_dependency "axlsx", ">= 2.0.1"
|
21
|
+
|
22
|
+
s.add_development_dependency "bundler"
|
23
|
+
s.add_development_dependency "rake"
|
24
|
+
s.add_development_dependency "rspec-rails"
|
25
|
+
s.add_development_dependency "guard-rspec"
|
26
|
+
s.add_development_dependency "capybara"
|
27
|
+
s.add_development_dependency "acts_as_xlsx"
|
28
|
+
s.add_development_dependency "roo"
|
29
|
+
s.add_development_dependency "rubyzip"
|
30
|
+
s.add_development_dependency "sqlite3"
|
31
|
+
s.add_development_dependency "growl"
|
32
|
+
s.add_development_dependency "rb-fsevent"
|
33
|
+
s.add_development_dependency "coveralls"
|
34
|
+
s.add_development_dependency "pry"
|
35
|
+
s.add_development_dependency "pry-nav"
|
36
|
+
end
|
@@ -23,6 +23,9 @@ ActionController::Renderers.add :xlsx do |filename, options|
|
|
23
23
|
options[:template] = filename.gsub(/^.*\//,'')
|
24
24
|
end
|
25
25
|
|
26
|
+
# force layout false
|
27
|
+
options[:layout] = false
|
28
|
+
|
26
29
|
# disposition / filename
|
27
30
|
disposition = options.delete(:disposition) || 'attachment'
|
28
31
|
if file_name = options.delete(:filename)
|
@@ -39,7 +42,8 @@ ActionController::Renderers.add :xlsx do |filename, options|
|
|
39
42
|
options[:locals][:xlsx_use_shared_strings] = options.delete(:xlsx_use_shared_strings)
|
40
43
|
end
|
41
44
|
|
42
|
-
|
45
|
+
mime = (Rails.version.to_f >= 5) ? Mime[:xlsx] : Mime::XLSX
|
46
|
+
send_data render_to_string(options), :filename => file_name, :type => mime, :disposition => disposition
|
43
47
|
end
|
44
48
|
|
45
49
|
# For respond_to default
|
data/lib/axlsx_rails/version.rb
CHANGED
data/spec/axlsx_builder_spec.rb
CHANGED
@@ -17,7 +17,7 @@ describe 'Axlsx template handler' do
|
|
17
17
|
# end
|
18
18
|
|
19
19
|
it "has xlsx format" do
|
20
|
-
handler.default_format.
|
20
|
+
expect(handler.default_format).to eq(mime_type)
|
21
21
|
end
|
22
22
|
|
23
23
|
it "compiles to an excel spreadsheet" do
|
@@ -25,7 +25,7 @@ describe 'Axlsx template handler' do
|
|
25
25
|
eval( AB.call template )
|
26
26
|
xlsx_package.serialize('/tmp/axlsx_temp.xlsx')
|
27
27
|
expect{ wb = Roo::Excelx.new('/tmp/axlsx_temp.xlsx') }.to_not raise_error
|
28
|
-
wb.cell(2,3).
|
28
|
+
expect(wb.cell(2,3)).to eq('c')
|
29
29
|
end
|
30
30
|
|
31
31
|
#TODO:
|
data/spec/axlsx_mailer_spec.rb
CHANGED
@@ -8,8 +8,8 @@ describe "Mailer", type: :request do
|
|
8
8
|
it "attaches an xlsx file" do
|
9
9
|
visit "/users/#{@user.id}/send_instructions"
|
10
10
|
last_email = ActionMailer::Base.deliveries.last
|
11
|
-
last_email.to.
|
12
|
-
last_email.attachments.first.
|
13
|
-
last_email.attachments.first.content_type.
|
11
|
+
expect(last_email.to).to eq([@user.email])
|
12
|
+
expect(last_email.attachments.first).to be
|
13
|
+
expect(last_email.attachments.first.content_type).to eq(mime_type.to_s)
|
14
14
|
end
|
15
15
|
end
|