axlsx_rails 0.1.2 → 0.1.3

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.
@@ -1,5 +1,8 @@
1
1
  # Change log
2
2
 
3
+ - **December 6, 2012**: 0.1.3 release
4
+ - Fix for absolute template paths
5
+
3
6
  - **July 25, 2012**: 0.1.2 release
4
7
  - Partials tested
5
8
 
@@ -1,106 +1,109 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- axlsx_rails (0.1.2)
4
+ axlsx_rails (0.1.3)
5
5
  axlsx
6
6
  rails (~> 3.1)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- actionmailer (3.2.6)
12
- actionpack (= 3.2.6)
11
+ actionmailer (3.2.9)
12
+ actionpack (= 3.2.9)
13
13
  mail (~> 2.4.4)
14
- actionpack (3.2.6)
15
- activemodel (= 3.2.6)
16
- activesupport (= 3.2.6)
14
+ actionpack (3.2.9)
15
+ activemodel (= 3.2.9)
16
+ activesupport (= 3.2.9)
17
17
  builder (~> 3.0.0)
18
18
  erubis (~> 2.7.0)
19
- journey (~> 1.0.1)
19
+ journey (~> 1.0.4)
20
20
  rack (~> 1.4.0)
21
21
  rack-cache (~> 1.2)
22
22
  rack-test (~> 0.6.1)
23
- sprockets (~> 2.1.3)
24
- activemodel (3.2.6)
25
- activesupport (= 3.2.6)
23
+ sprockets (~> 2.2.1)
24
+ activemodel (3.2.9)
25
+ activesupport (= 3.2.9)
26
26
  builder (~> 3.0.0)
27
- activerecord (3.2.6)
28
- activemodel (= 3.2.6)
29
- activesupport (= 3.2.6)
27
+ activerecord (3.2.9)
28
+ activemodel (= 3.2.9)
29
+ activesupport (= 3.2.9)
30
30
  arel (~> 3.0.2)
31
31
  tzinfo (~> 0.3.29)
32
- activeresource (3.2.6)
33
- activemodel (= 3.2.6)
34
- activesupport (= 3.2.6)
35
- activesupport (3.2.6)
32
+ activeresource (3.2.9)
33
+ activemodel (= 3.2.9)
34
+ activesupport (= 3.2.9)
35
+ activesupport (3.2.9)
36
36
  i18n (~> 0.6)
37
37
  multi_json (~> 1.0)
38
- acts_as_xlsx (1.0.5)
38
+ acts_as_xlsx (1.0.6)
39
39
  activerecord (>= 2.3.9)
40
40
  axlsx (>= 1.0.13)
41
41
  i18n (>= 0.4.1)
42
- addressable (2.2.8)
42
+ addressable (2.3.2)
43
43
  arel (3.0.2)
44
- axlsx (1.1.8)
44
+ axlsx (1.3.4)
45
45
  htmlentities (~> 4.3.1)
46
46
  nokogiri (>= 1.4.1)
47
- rake (>= 0.8.7)
48
47
  rubyzip (>= 0.9.5)
49
- builder (3.0.0)
50
- capybara (1.1.2)
48
+ builder (3.0.4)
49
+ capybara (2.0.1)
51
50
  mime-types (>= 1.16)
52
51
  nokogiri (>= 1.3.3)
53
52
  rack (>= 1.0.0)
54
53
  rack-test (>= 0.5.4)
55
54
  selenium-webdriver (~> 2.0)
56
- xpath (~> 0.1.4)
57
- childprocess (0.3.3)
58
- ffi (~> 1.0.6)
55
+ xpath (~> 1.0.0)
56
+ childprocess (0.3.6)
57
+ ffi (~> 1.0, >= 1.0.6)
59
58
  choice (0.1.6)
59
+ coderay (1.0.8)
60
60
  diff-lcs (1.1.3)
61
61
  erubis (2.7.0)
62
- faraday (0.8.1)
62
+ faraday (0.8.4)
63
63
  multipart-post (~> 1.1)
64
- ffi (1.0.11)
64
+ ffi (1.2.0)
65
65
  google-spreadsheet-ruby (0.3.0)
66
66
  google_drive (>= 0.3.0)
67
- google_drive (0.3.1)
67
+ google_drive (0.3.2)
68
68
  nokogiri (>= 1.4.4, != 1.5.2, != 1.5.1)
69
69
  oauth (>= 0.3.6)
70
70
  oauth2 (>= 0.5.0)
71
71
  growl (1.0.3)
72
- guard (1.2.3)
72
+ guard (1.5.4)
73
73
  listen (>= 0.4.2)
74
+ lumberjack (>= 1.0.2)
75
+ pry (>= 0.9.10)
74
76
  thor (>= 0.14.6)
75
- guard-rspec (1.2.0)
77
+ guard-rspec (2.3.0)
76
78
  guard (>= 1.1)
79
+ rspec (~> 2.11)
77
80
  hike (1.2.1)
78
81
  htmlentities (4.3.1)
79
- httpauth (0.1)
80
- i18n (0.6.0)
82
+ httpauth (0.2.0)
83
+ i18n (0.6.1)
81
84
  journey (1.0.4)
82
- jquery-rails (2.0.2)
83
- railties (>= 3.2.0, < 5.0)
84
- thor (~> 0.14)
85
- json (1.7.3)
86
- jwt (0.1.4)
87
- json (>= 1.2.4)
88
- libwebsocket (0.1.3)
85
+ jquery-rails (2.1.4)
86
+ railties (>= 3.0, < 5.0)
87
+ thor (>= 0.14, < 2.0)
88
+ json (1.7.5)
89
+ jwt (0.1.5)
90
+ multi_json (>= 1.0)
91
+ libwebsocket (0.1.7.1)
89
92
  addressable
90
- listen (0.4.7)
91
- rb-fchange (~> 0.0.5)
92
- rb-fsevent (~> 0.9.1)
93
- rb-inotify (~> 0.8.8)
93
+ websocket
94
+ listen (0.6.0)
94
95
  log4r (1.1.10)
96
+ lumberjack (1.0.2)
95
97
  mail (2.4.4)
96
98
  i18n (>= 0.4.0)
97
99
  mime-types (~> 1.16)
98
100
  treetop (~> 1.4.8)
101
+ method_source (0.8.1)
99
102
  mime-types (1.19)
100
- multi_json (1.3.6)
103
+ multi_json (1.4.0)
101
104
  multipart-post (1.1.5)
102
105
  nokogiri (1.5.5)
103
- oauth (0.4.6)
106
+ oauth (0.4.7)
104
107
  oauth2 (0.8.0)
105
108
  faraday (~> 0.8)
106
109
  httpauth (~> 0.1)
@@ -108,34 +111,34 @@ GEM
108
111
  multi_json (~> 1.0)
109
112
  rack (~> 1.2)
110
113
  polyglot (0.3.3)
114
+ pry (0.9.10)
115
+ coderay (~> 1.0.5)
116
+ method_source (~> 0.8)
117
+ slop (~> 3.3.1)
111
118
  rack (1.4.1)
112
119
  rack-cache (1.2)
113
120
  rack (>= 0.4)
114
121
  rack-ssl (1.3.2)
115
122
  rack
116
- rack-test (0.6.1)
123
+ rack-test (0.6.2)
117
124
  rack (>= 1.0)
118
- rails (3.2.6)
119
- actionmailer (= 3.2.6)
120
- actionpack (= 3.2.6)
121
- activerecord (= 3.2.6)
122
- activeresource (= 3.2.6)
123
- activesupport (= 3.2.6)
125
+ rails (3.2.9)
126
+ actionmailer (= 3.2.9)
127
+ actionpack (= 3.2.9)
128
+ activerecord (= 3.2.9)
129
+ activeresource (= 3.2.9)
130
+ activesupport (= 3.2.9)
124
131
  bundler (~> 1.0)
125
- railties (= 3.2.6)
126
- railties (3.2.6)
127
- actionpack (= 3.2.6)
128
- activesupport (= 3.2.6)
132
+ railties (= 3.2.9)
133
+ railties (3.2.9)
134
+ actionpack (= 3.2.9)
135
+ activesupport (= 3.2.9)
129
136
  rack-ssl (~> 1.3.2)
130
137
  rake (>= 0.8.7)
131
138
  rdoc (~> 3.4)
132
139
  thor (>= 0.14.6, < 2.0)
133
- rake (0.9.2.2)
134
- rb-fchange (0.0.5)
135
- ffi
136
- rb-fsevent (0.9.1)
137
- rb-inotify (0.8.8)
138
- ffi (>= 0.5.0)
140
+ rake (10.0.2)
141
+ rb-fsevent (0.9.2)
139
142
  rdoc (3.12)
140
143
  json (~> 1.4)
141
144
  roo (1.10.1)
@@ -145,42 +148,47 @@ GEM
145
148
  rubyzip (>= 0.9.4)
146
149
  spreadsheet (> 0.6.4)
147
150
  todonotes (>= 0.1.0)
148
- rspec (2.11.0)
149
- rspec-core (~> 2.11.0)
150
- rspec-expectations (~> 2.11.0)
151
- rspec-mocks (~> 2.11.0)
152
- rspec-core (2.11.0)
153
- rspec-expectations (2.11.1)
151
+ rspec (2.12.0)
152
+ rspec-core (~> 2.12.0)
153
+ rspec-expectations (~> 2.12.0)
154
+ rspec-mocks (~> 2.12.0)
155
+ rspec-core (2.12.1)
156
+ rspec-expectations (2.12.0)
154
157
  diff-lcs (~> 1.1.3)
155
- rspec-mocks (2.11.1)
156
- rspec-rails (2.11.0)
158
+ rspec-mocks (2.12.0)
159
+ rspec-rails (2.12.0)
157
160
  actionpack (>= 3.0)
158
161
  activesupport (>= 3.0)
159
162
  railties (>= 3.0)
160
- rspec (~> 2.11.0)
161
- ruby-ole (1.2.11.4)
163
+ rspec-core (~> 2.12.0)
164
+ rspec-expectations (~> 2.12.0)
165
+ rspec-mocks (~> 2.12.0)
166
+ ruby-ole (1.2.11.5)
162
167
  rubyzip (0.9.9)
163
- selenium-webdriver (2.24.0)
168
+ selenium-webdriver (2.27.0)
164
169
  childprocess (>= 0.2.5)
165
170
  libwebsocket (~> 0.1.3)
166
171
  multi_json (~> 1.0)
167
172
  rubyzip
168
- spreadsheet (0.7.3)
173
+ slop (3.3.3)
174
+ spreadsheet (0.7.5)
169
175
  ruby-ole (>= 1.0)
170
- sprockets (2.1.3)
176
+ sprockets (2.2.2)
171
177
  hike (~> 1.2)
178
+ multi_json (~> 1.0)
172
179
  rack (~> 1.0)
173
180
  tilt (~> 1.1, != 1.3.0)
174
181
  sqlite3 (1.3.6)
175
- thor (0.15.4)
182
+ thor (0.16.0)
176
183
  tilt (1.3.3)
177
- todonotes (0.1.0)
184
+ todonotes (0.1.1)
178
185
  log4r
179
- treetop (1.4.10)
186
+ treetop (1.4.12)
180
187
  polyglot
181
188
  polyglot (>= 0.3.1)
182
- tzinfo (0.3.33)
183
- xpath (0.1.4)
189
+ tzinfo (0.3.35)
190
+ websocket (1.0.4)
191
+ xpath (1.0.0)
184
192
  nokogiri (~> 1.3)
185
193
 
186
194
  PLATFORMS
@@ -195,6 +203,7 @@ DEPENDENCIES
195
203
  guard-rspec
196
204
  jquery-rails
197
205
  rake
206
+ rb-fsevent
198
207
  roo
199
208
  rspec-rails
200
209
  sqlite3
data/README.md CHANGED
@@ -2,12 +2,15 @@ Axlsx-Rails &mdash; Axlsx templates for Rails views
2
2
  ===================================================
3
3
 
4
4
  [![Build Status](https://secure.travis-ci.org/straydogstudio/axlsx_rails.png?branch=master)](http://travis-ci.org/straydogstudio/axlsx_rails)
5
+ [![Dependency Status](https://gemnasium.com/straydogstudio/axlsx_rails.png?branch=master)](https://gemnasium.com/straydogstudio/axlsx_rails)
5
6
 
6
7
  ##Installation
7
8
 
8
9
  In your Gemfile:
9
10
 
10
- gem 'axlsx_rails'
11
+ ```ruby
12
+ gem 'axlsx_rails'
13
+ ```
11
14
 
12
15
  ##Requirements
13
16
 
@@ -21,34 +24,62 @@ Axlsx-Rails provides a renderer and a template handler. It adds the :xlsx format
21
24
 
22
25
  You can either use the typical format:
23
26
 
24
- respond_to do |format|
25
- format.xlsx
26
- end
27
+ ```ruby
28
+ respond_to do |format|
29
+ format.xlsx
30
+ end
31
+ ```
27
32
 
28
33
  or call render directly:
29
34
 
30
- render xlsx: "foobar", filename: "the_latest_foobar", disposition: 'inline'
35
+ ```ruby
36
+ render xlsx: "foobar", filename: "the_latest_foobar", disposition: 'inline'
37
+ ```
38
+
39
+ If you merely want to specify a file name, you can do it one of two ways:
40
+
41
+ ```ruby
42
+ format.xlsx {
43
+ response.headers['Content-Disposition'] = 'attachment; filename="my_new_filename.xlsx"'
44
+ }
45
+ ```
46
+ Or:
47
+
48
+ ```ruby
49
+ format.xlsx {
50
+ render xlsx: "action_or_template", disposition: "attachment", filename: "my_new_filename.xlsx"
51
+ }
52
+ ```
53
+
54
+ > NOTE: Someday it would be nice to merely say something like:
55
+ render :filename 'blah.xlsx"
31
56
 
32
57
  ###Template
33
58
 
34
59
  Use the .xlsx.axlsx extension (sorry if your lysdexic!) In the template, use xlsx_package variable, which is set with Axlsx::Package.new:
35
60
 
36
- wb = xlsx_package.workbook
37
- style_shout = wb.styles.add_style sz: 16, b: true, alignment: { horizontal: :center }
38
- wb.add_worksheet(name: "Foobar") do |sheet|
39
- sheet.add_row ['Bad', 'spellers', 'of', 'the', 'world', '...']
40
- sheet.add_row ['Untie!']
41
- sheet.merge_cells("B1:B6")
42
- sheet["B1"].style = style_shout
43
- end
61
+ ```ruby
62
+ wb = xlsx_package.workbook
63
+ style_shout = wb.styles.add_style sz: 16, b: true, alignment: { horizontal: :center }
64
+ wb.add_worksheet(name: "Foobar") do |sheet|
65
+ sheet.add_row ['Bad', 'spellers', 'of', 'the', 'world', '...']
66
+ sheet.add_row ['Untie!']
67
+ sheet.merge_cells("B1:B6")
68
+ sheet["B1"].style = style_shout
69
+ end
70
+ ```
44
71
 
45
72
  If you use [acts_as_xlsx](https://github.com/randym/acts_as_xlsx), configure the active record normally, but specify the package in the template:
46
73
 
47
- User.to_xlsx package: xlsx_package, (other options)
74
+ ```ruby
75
+ User.to_xlsx package: xlsx_package, (other options)
76
+ ```
48
77
 
49
78
  To set the author attribute upon Axlsx::Package.new, insert the following in application.rb:
50
79
 
51
- config.axlsx_author = "Elmer Fudd"
80
+ ```ruby
81
+ config.axlsx_author = "Elmer Fudd"
82
+ ```
52
83
 
53
84
  > NOTE: We really ought to allow the author to be set in each call
54
85
 
@@ -56,17 +87,21 @@ To set the author attribute upon Axlsx::Package.new, insert the following in app
56
87
 
57
88
  Partials work as expected:
58
89
 
59
- wb = xlsx_package.workbook
60
- render :partial => 'cover_sheet', :locals => {:wb => wb}
61
- wb.add_worksheet(name: "Content") do |sheet|
62
- sheet.add_row ['Content']
63
- end
90
+ ```ruby
91
+ wb = xlsx_package.workbook
92
+ render :partial => 'cover_sheet', :locals => {:wb => wb}
93
+ wb.add_worksheet(name: "Content") do |sheet|
94
+ sheet.add_row ['Content']
95
+ end
96
+ ```
64
97
 
65
98
  With the partial simply using the passed variables:
66
99
 
67
- wb.add_worksheet(name: "Cover Sheet") do |sheet|
68
- sheet.add_row ['Cover', 'Sheet']
69
- end
100
+ ```ruby
101
+ wb.add_worksheet(name: "Cover Sheet") do |sheet|
102
+ sheet.add_row ['Cover', 'Sheet']
103
+ end
104
+ ```
70
105
 
71
106
  ##Dependencies
72
107
 
@@ -78,6 +113,9 @@ With the partial simply using the passed variables:
78
113
 
79
114
  ##Change log
80
115
 
116
+ - **December 6, 2012**: 0.1.3 release
117
+ - Fix for absolute template paths
118
+
81
119
  - **July 25, 2012**: 0.1.2 release
82
120
  - Partials tested
83
121
 
@@ -4,6 +4,10 @@ unless defined? Mime::XLSX
4
4
  end
5
5
 
6
6
  ActionController::Renderers.add :xlsx do |filename, options|
7
+ if filename =~ /^\/([^\/]+)\/(.+)$/
8
+ options[:prefixes][0] = $1
9
+ filename = $2
10
+ end
7
11
  options[:template] = filename
8
12
 
9
13
  disposition = options.delete(:disposition) || 'attachment'
@@ -1,3 +1,3 @@
1
1
  module AxlsxRails
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -8,7 +8,19 @@ 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 == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=utf-8"
11
+ page.response_headers['Content-Type'].should == Mime::XLSX.to_s + "; charset=utf-8"
12
+ File.open('/tmp/axlsx_temp.xlsx', 'w') {|f| f.write(page.source) }
13
+ wb = nil
14
+ expect{ wb = Excelx.new('/tmp/axlsx_temp.xlsx') }.to_not raise_error
15
+ wb.cell(2,1).should == 'Untie!'
16
+ end
17
+
18
+ it "downloads an excel file from respond_to while specifying filename" do
19
+ visit '/useheader.xlsx'
20
+
21
+ page.response_headers['Content-Type'].should == Mime::XLSX.to_s
22
+ page.response_headers['Content-Disposition'].should include("filename=\"filename_test.xlsx\"")
23
+
12
24
  File.open('/tmp/axlsx_temp.xlsx', 'w') {|f| f.write(page.source) }
13
25
  wb = nil
14
26
  expect{ wb = Excelx.new('/tmp/axlsx_temp.xlsx') }.to_not raise_error
@@ -28,10 +40,11 @@ describe 'Axlsx request', :type => :request do
28
40
  end
29
41
 
30
42
  it "downloads an excel file from acts_as_xlsx model" do
43
+ User.destroy_all
31
44
  @user1 = User.create name: 'Elmer', last_name: 'Fudd', address: '1234 Somewhere, Over NY 11111', email: 'elmer@fudd.com'
32
45
  @user2 = User.create name: 'Bugs', last_name: 'Bunny', address: '1234 Left Turn, Albuquerque NM 22222', email: 'bugs@bunny.com'
33
46
  visit '/users.xlsx'
34
- page.response_headers['Content-Type'].should == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=utf-8"
47
+ page.response_headers['Content-Type'].should == Mime::XLSX.to_s + "; charset=utf-8"
35
48
  File.open('/tmp/axlsx_temp.xlsx', 'w') {|f| f.write(page.source) }
36
49
  wb = nil
37
50
  expect{ wb = Excelx.new('/tmp/axlsx_temp.xlsx') }.to_not raise_error
@@ -40,7 +53,7 @@ describe 'Axlsx request', :type => :request do
40
53
 
41
54
  it "downloads an excel file with partial" do
42
55
  visit '/withpartial.xlsx'
43
- page.response_headers['Content-Type'].should == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=utf-8"
56
+ page.response_headers['Content-Type'].should == Mime::XLSX.to_s + "; charset=utf-8"
44
57
  File.open('/tmp/axlsx_temp.xlsx', 'w') {|f| f.write(page.source) }
45
58
  wb = nil
46
59
  expect{ wb = Excelx.new('/tmp/axlsx_temp.xlsx') }.to_not raise_error
@@ -48,4 +61,33 @@ describe 'Axlsx request', :type => :request do
48
61
  wb.cell(2,1,wb.sheets[1]).should == "Untie!"
49
62
  end
50
63
 
64
+ it "handles nested resources" do
65
+ User.destroy_all
66
+ @user = User.create name: 'Bugs', last_name: 'Bunny', address: '1234 Left Turn, Albuquerque NM 22222', email: 'bugs@bunny.com'
67
+ @user.likes.create(:name => 'Carrots')
68
+ @user.likes.create(:name => 'Celery')
69
+ visit "/users/#{@user.id}/likes.xlsx"
70
+ page.response_headers['Content-Type'].should == Mime::XLSX.to_s + "; charset=utf-8"
71
+ File.open('/tmp/axlsx_temp.xlsx', 'w') {|f| f.write(page.source) }
72
+ wb = nil
73
+ expect{ wb = Excelx.new('/tmp/axlsx_temp.xlsx') }.to_not raise_error
74
+ wb.cell(1,1).should == 'Bugs'
75
+ wb.cell(2,1).should == 'Carrots'
76
+ wb.cell(3,1).should == 'Celery'
77
+ end
78
+
79
+ it "handles reference to absolute paths" do
80
+ User.destroy_all
81
+ @user = User.create name: 'Bugs', last_name: 'Bunny', address: '1234 Left Turn, Albuquerque NM 22222', email: 'bugs@bunny.com'
82
+ visit "/users/#{@user.id}/render_elsewhere.xlsx"
83
+ page.response_headers['Content-Type'].should == Mime::XLSX.to_s
84
+ visit "/home/render_elsewhere.xlsx"
85
+ page.response_headers['Content-Type'].should == Mime::XLSX.to_s
86
+ visit "/render_elsewhere.xlsx"
87
+ page.response_headers['Content-Type'].should == Mime::XLSX.to_s
88
+ File.open('/tmp/axlsx_temp.xlsx', 'w') {|f| f.write(page.source) }
89
+ wb = nil
90
+ expect{ wb = Excelx.new('/tmp/axlsx_temp.xlsx') }.to_not raise_error
91
+ wb.cell(2,2).should == 'Bugs'
92
+ end
51
93
  end