listings 0.1.14 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4591a7706b0590ae7a1958eb970989b111ddd602
4
- data.tar.gz: 9d77ce4ae69577c507ebce9ad93eaf1383dbb794
3
+ metadata.gz: 22306e285b8f18877c6d47cc742bfa3cb284c4ac
4
+ data.tar.gz: f402374e22a72800dfef55e6a8d65fabc2c17a69
5
5
  SHA512:
6
- metadata.gz: d0da43eddc770ae15ad49502830922bc4f5592be2135fe888c4a24549ca66a592deef3c8982bfb1ff0db6c7f4bbec4d9c601d70d3218e610717e3806f6bfb812
7
- data.tar.gz: a2f408023fbe5f2a6fca0615ebeeeedd75be2e129c40bb2ecaa02318af7465a50c025bfc09f2c6d3caf6afcf6e6d532401197f8603bf2073babd59d8fecb186c
6
+ metadata.gz: e0dac07fedd6ef74330151646a991720ded9b0ff2cdb8f7059cfcf0d0d3e62a8a44176a95a9abee7a37e2665662a071670aedf1e7358066fdcdc90858d9248a6
7
+ data.tar.gz: bf3482c5505d5bce1c903e65cb29dace7917f8fbf60f4629ded558e24cab4d2a2b14a352b8d29f9d9f2d624324254e9be50caf8c34424acf03f3107bdf2fbc80
@@ -21,10 +21,7 @@ module Listings
21
21
 
22
22
  respond_to do |format|
23
23
  format.csv { @listing.send_csv(self) }
24
- format.xls do
25
- headers["Content-Disposition"] = "attachment; filename=\"#{@listing.export_filename(:xls)}\""
26
- render 'listings/export'
27
- end
24
+ format.xls { @listing.send_xls(self) }
28
25
  end
29
26
  ensure
30
27
  Kaminari::Helpers::Tag.paginate_with_listings(nil)
@@ -11,7 +11,7 @@
11
11
  <Cell><Data ss:Type="String"><%= col.human_name %></Data></Cell>
12
12
  <% end %>
13
13
  </Row>
14
- <% @listing.items.each do |item| %>
14
+ <% @listing.export_each do |item| %>
15
15
  <Row>
16
16
  <% @listing.columns.each do |col| %>
17
17
  <% col.value_for(item).tap do |value| %>
data/lib/listings/base.rb CHANGED
@@ -177,6 +177,12 @@ module Listings
177
177
  (params[:format] || :html).to_sym
178
178
  end
179
179
 
180
+ def export_each
181
+ self.items.each do |item|
182
+ yield item
183
+ end
184
+ end
185
+
180
186
  def send_csv(controller)
181
187
  csv_filename = self.export_filename(:csv)
182
188
 
@@ -190,7 +196,7 @@ module Listings
190
196
  controller.response_body = Enumerator.new do |lines|
191
197
  lines << self.columns.map { |c| c.human_name }.to_csv
192
198
 
193
- self.items.find_each do |item|
199
+ self.export_each do |item|
194
200
  row = []
195
201
  self.columns.each do |col|
196
202
  row << col.value_for(item)
@@ -200,6 +206,11 @@ module Listings
200
206
  end
201
207
  end
202
208
 
209
+ def send_xls(controller)
210
+ controller.headers["Content-Disposition"] = %(attachment; filename="#{self.export_filename(:xls)}")
211
+ controller.render 'listings/export'
212
+ end
213
+
203
214
  def method_missing(m, *args, &block)
204
215
  view_context.send(m, *args, &block)
205
216
  end
@@ -1,3 +1,3 @@
1
1
  module Listings
2
- VERSION = "0.1.14"
2
+ VERSION = "0.1.15"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: listings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian J. Cardiff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-25 00:00:00.000000000 Z
11
+ date: 2021-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails