axlsx_rails 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +4 -2
- data/README.md +21 -11
- data/lib/axlsx_rails/action_controller.rb +11 -8
- data/lib/axlsx_rails/template_handler.rb +3 -3
- data/lib/axlsx_rails/version.rb +1 -1
- data/spec/axlsx_request_spec.rb +6 -5
- data/spec/ci.sh +2 -0
- data/spec/dummy/app/controllers/home_controller.rb +1 -1
- metadata +6 -4
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
axlsx_rails (0.1.
|
4
|
+
axlsx_rails (0.1.1)
|
5
5
|
axlsx
|
6
6
|
rails (~> 3.1)
|
7
7
|
|
@@ -41,7 +41,8 @@ GEM
|
|
41
41
|
i18n (>= 0.4.1)
|
42
42
|
addressable (2.2.8)
|
43
43
|
arel (3.0.2)
|
44
|
-
axlsx (1.1.
|
44
|
+
axlsx (1.1.8)
|
45
|
+
htmlentities (~> 4.3.1)
|
45
46
|
nokogiri (>= 1.4.1)
|
46
47
|
rake (>= 0.8.7)
|
47
48
|
rubyzip (>= 0.9.5)
|
@@ -73,6 +74,7 @@ GEM
|
|
73
74
|
guard-rspec (1.2.0)
|
74
75
|
guard (>= 1.1)
|
75
76
|
hike (1.2.1)
|
77
|
+
htmlentities (4.3.1)
|
76
78
|
httpauth (0.1)
|
77
79
|
i18n (0.6.0)
|
78
80
|
journey (1.0.4)
|
data/README.md
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
Axlsx-Rails — Axlsx templates for Rails views
|
2
2
|
===================================================
|
3
3
|
|
4
|
+
[![Build Status](https://secure.travis-ci.org/straydogstudio/axlsx_rails.png?branch=master)](http://travis-ci.org/straydogstudio/axlsx_rails)
|
5
|
+
|
4
6
|
##Installation
|
5
|
-
|
6
|
-
|
7
|
-
|
7
|
+
|
8
|
+
In your Gemfile:
|
9
|
+
|
10
|
+
gem 'axlsx_rails'
|
8
11
|
|
9
12
|
##Requirements
|
10
|
-
|
13
|
+
|
11
14
|
* Rails 3.1, but it has only been tested on 3.2.6
|
12
15
|
|
13
16
|
##Usage
|
14
|
-
-------
|
15
17
|
|
16
18
|
Axlsx-Rails provides a renderer and a template handler. It adds the :xlsx format and parses .xlsx.axslx templates.
|
17
19
|
|
@@ -25,7 +27,7 @@ You can either use the typical format:
|
|
25
27
|
|
26
28
|
or call render directly:
|
27
29
|
|
28
|
-
render "foobar", filename: "the_latest_foobar", disposition: 'inline'
|
30
|
+
render xlsx: "foobar", filename: "the_latest_foobar", disposition: 'inline'
|
29
31
|
|
30
32
|
###Template
|
31
33
|
|
@@ -54,15 +56,23 @@ To set the author attribute upon Axlsx::Package.new, insert the following in app
|
|
54
56
|
Partials are currently untested.
|
55
57
|
|
56
58
|
##Dependencies
|
57
|
-
|
59
|
+
|
58
60
|
- [Axlsx](https://github.com/randym/axlsx)
|
59
61
|
|
60
62
|
##Authors
|
61
|
-
|
63
|
+
|
62
64
|
* [Noel Peden](https://github.com/straydogstudio)
|
63
65
|
|
64
66
|
##Change log
|
65
|
-
|
67
|
+
|
68
|
+
- **July 19, 2012**: 0.1.1 release
|
69
|
+
- Travis-ci added (thanks randym)
|
70
|
+
- render statements and filename tests fixes (thanks engwan)
|
71
|
+
|
72
|
+
- **July 17, 2012**: 0.1.0 release
|
73
|
+
- Tests completed
|
74
|
+
- Acts_as_xlsx tested, example in docs
|
75
|
+
|
66
76
|
- **July 12, 2012**: 0.0.1 release
|
67
|
-
|
68
|
-
|
77
|
+
- Initial posting.
|
78
|
+
- It works, but there are no tests! Bad programmer!
|
@@ -2,15 +2,18 @@ require 'action_controller'
|
|
2
2
|
Mime::Type.register "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", :xlsx
|
3
3
|
|
4
4
|
ActionController::Renderers.add :xlsx do |filename, options|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
options[:template] = filename
|
6
|
+
|
7
|
+
disposition = options.delete(:disposition) || 'attachment'
|
8
|
+
download_name = options.delete(:filename) || "#{filename}.xlsx"
|
9
|
+
download_name += ".xlsx" unless download_name =~ /\.xlsx$/
|
10
|
+
|
11
|
+
send_data render_to_string(options), :filename => download_name, :type => Mime::XLSX, :disposition => disposition
|
9
12
|
end
|
10
13
|
|
11
14
|
# For respond_to default
|
12
15
|
class ActionController::Responder
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
16
|
+
def to_xlsx
|
17
|
+
controller.render :xlsx => controller.action_name
|
18
|
+
end
|
19
|
+
end
|
@@ -5,9 +5,9 @@ module ActionView
|
|
5
5
|
def default_format
|
6
6
|
Mime::XLSX
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def self.call(template)
|
10
|
-
"xlsx_package = Axlsx::Package.new(:author => #{axlsx_author.inspect});\n" +
|
10
|
+
"xlsx_package = Axlsx::Package.new(:author => #{axlsx_author.inspect});\n" +
|
11
11
|
template.source +
|
12
12
|
";\nxlsx_package.to_stream.string;"
|
13
13
|
end
|
@@ -21,4 +21,4 @@ module ActionView
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
ActionView::Template.register_template_handler :axlsx, ActionView::Template::Handlers::AxlsxBuilder
|
24
|
+
ActionView::Template.register_template_handler :axlsx, ActionView::Template::Handlers::AxlsxBuilder
|
data/lib/axlsx_rails/version.rb
CHANGED
data/spec/axlsx_request_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe 'Axlsx request', :type => :request do
|
|
8
8
|
|
9
9
|
it "downloads an excel file from default respond_to" do
|
10
10
|
visit '/home.xlsx'
|
11
|
-
page.response_headers['Content-Type'].should ==
|
11
|
+
page.response_headers['Content-Type'].should == Mime::XLSX
|
12
12
|
File.open('/tmp/axlsx_temp.xlsx', 'w') {|f| f.write(page.source) }
|
13
13
|
wb = nil
|
14
14
|
expect{ wb = Excelx.new('/tmp/axlsx_temp.xlsx') }.to_not raise_error
|
@@ -17,9 +17,10 @@ describe 'Axlsx request', :type => :request do
|
|
17
17
|
|
18
18
|
it "downloads an excel file from render statement with filename" do
|
19
19
|
visit '/another.xlsx'
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
|
21
|
+
page.response_headers['Content-Type'].should == Mime::XLSX
|
22
|
+
page.response_headers['Content-Disposition'].should include("filename=\"filename_test.xlsx\"")
|
23
|
+
|
23
24
|
File.open('/tmp/axlsx_temp.xlsx', 'w') {|f| f.write(page.source) }
|
24
25
|
wb = nil
|
25
26
|
expect{ wb = Excelx.new('/tmp/axlsx_temp.xlsx') }.to_not raise_error
|
@@ -37,4 +38,4 @@ describe 'Axlsx request', :type => :request do
|
|
37
38
|
wb.cell(3,2).should == 'Bugs'
|
38
39
|
end
|
39
40
|
|
40
|
-
end
|
41
|
+
end
|
data/spec/ci.sh
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: axlsx_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -193,6 +193,7 @@ files:
|
|
193
193
|
- spec/axlsx_builder_spec.rb
|
194
194
|
- spec/axlsx_renderer_spec.rb
|
195
195
|
- spec/axlsx_request_spec.rb
|
196
|
+
- spec/ci.sh
|
196
197
|
- spec/dummy/app/assets/javascripts/application.js
|
197
198
|
- spec/dummy/app/assets/stylesheets/application.css
|
198
199
|
- spec/dummy/app/controllers/application_controller.rb
|
@@ -262,7 +263,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
262
263
|
version: '0'
|
263
264
|
segments:
|
264
265
|
- 0
|
265
|
-
hash: -
|
266
|
+
hash: -1578624938055063002
|
266
267
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
267
268
|
none: false
|
268
269
|
requirements:
|
@@ -271,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
271
272
|
version: '0'
|
272
273
|
segments:
|
273
274
|
- 0
|
274
|
-
hash: -
|
275
|
+
hash: -1578624938055063002
|
275
276
|
requirements: []
|
276
277
|
rubyforge_project:
|
277
278
|
rubygems_version: 1.8.24
|
@@ -282,6 +283,7 @@ test_files:
|
|
282
283
|
- spec/axlsx_builder_spec.rb
|
283
284
|
- spec/axlsx_renderer_spec.rb
|
284
285
|
- spec/axlsx_request_spec.rb
|
286
|
+
- spec/ci.sh
|
285
287
|
- spec/dummy/app/assets/javascripts/application.js
|
286
288
|
- spec/dummy/app/assets/stylesheets/application.css
|
287
289
|
- spec/dummy/app/controllers/application_controller.rb
|