listings 0.1.13 → 0.1.14

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
- SHA256:
3
- metadata.gz: a9b35711b73e6f70de549f6508b4d2626a3dc5c899d809bb08f1b6e6ff0adf49
4
- data.tar.gz: 942eadc3eb9a0adfce42a544c61f263aeab9f3bf4a8825656a3a28bac3b36301
2
+ SHA1:
3
+ metadata.gz: 4591a7706b0590ae7a1958eb970989b111ddd602
4
+ data.tar.gz: 9d77ce4ae69577c507ebce9ad93eaf1383dbb794
5
5
  SHA512:
6
- metadata.gz: 9668f06ac36fcf570e47c0c325719c51f2c34118943acd673a82f910ccef7f7dbf9850c8d443a519c39ebf36fe4ad0ce9d087a2161fc8e400bd082953c8b5ff2
7
- data.tar.gz: 53b6c6433a53d146d9ac62eaae1e68d7e7299c4f4a2945f10c1d276d7c98a43ca68e49197abfc0b5f4660c22dd7d3b2ef5b55a6b3217dc6b40a17f6829078046
6
+ metadata.gz: d0da43eddc770ae15ad49502830922bc4f5592be2135fe888c4a24549ca66a592deef3c8982bfb1ff0db6c7f4bbec4d9c601d70d3218e610717e3806f6bfb812
7
+ data.tar.gz: a2f408023fbe5f2a6fca0615ebeeeedd75be2e129c40bb2ecaa02318af7465a50c025bfc09f2c6d3caf6afcf6e6d532401197f8603bf2073babd59d8fecb186c
@@ -20,7 +20,7 @@ module Listings
20
20
  @listing = prepare_listing params, view_context, false
21
21
 
22
22
  respond_to do |format|
23
- format.csv { send_data @listing.to_csv, filename: @listing.export_filename(:csv) }
23
+ format.csv { @listing.send_csv(self) }
24
24
  format.xls do
25
25
  headers["Content-Disposition"] = "attachment; filename=\"#{@listing.export_filename(:xls)}\""
26
26
  render 'listings/export'
@@ -177,26 +177,25 @@ module Listings
177
177
  (params[:format] || :html).to_sym
178
178
  end
179
179
 
180
- def to_array
181
- data = []
182
-
183
- data << self.columns.map { |c| c.human_name }
184
-
185
- self.items.each do |item|
186
- row = []
187
- self.columns.each do |col|
188
- row << col.value_for(item)
189
- end
190
- data << row
191
- end
192
-
193
- data
194
- end
195
-
196
- def to_csv
197
- CSV.generate do |csv|
198
- self.to_array.each do |row|
199
- csv << row
180
+ def send_csv(controller)
181
+ csv_filename = self.export_filename(:csv)
182
+
183
+ controller.headers["X-Accel-Buffering"] = "no"
184
+ controller.headers["Cache-Control"] = "no-cache"
185
+ controller.headers["Content-Type"] = "text/csv; charset=utf-8"
186
+ controller.headers["Content-Disposition"] = %(attachment; filename="#{csv_filename}")
187
+ controller.headers["Transfer-Encoding"] = "chunked"
188
+ controller.headers.delete("Content-Length")
189
+
190
+ controller.response_body = Enumerator.new do |lines|
191
+ lines << self.columns.map { |c| c.human_name }.to_csv
192
+
193
+ self.items.find_each do |item|
194
+ row = []
195
+ self.columns.each do |col|
196
+ row << col.value_for(item)
197
+ end
198
+ lines << row.to_csv
200
199
  end
201
200
  end
202
201
  end
@@ -1,3 +1,3 @@
1
1
  module Listings
2
- VERSION = "0.1.13"
2
+ VERSION = "0.1.14"
3
3
  end
@@ -1 +1 @@
1
- ../../spec
1
+ spec/dummy/../../spec
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.13
4
+ version: 0.1.14
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: 2020-04-17 00:00:00.000000000 Z
11
+ date: 2021-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -285,88 +285,89 @@ required_rubygems_version: !ruby/object:Gem::Requirement
285
285
  - !ruby/object:Gem::Version
286
286
  version: '0'
287
287
  requirements: []
288
- rubygems_version: 3.0.3
288
+ rubyforge_project:
289
+ rubygems_version: 2.6.12
289
290
  signing_key:
290
291
  specification_version: 4
291
292
  summary: Simple creation of listings in rails applications.
292
293
  test_files:
293
- - spec/spec_helper.rb
294
- - spec/dummy/app/listings/filtered_posts_listing.rb
295
- - spec/dummy/app/listings/posts_listing.rb
294
+ - spec/dummy/README.rdoc
295
+ - spec/dummy/Rakefile
296
+ - spec/dummy/app/assets/config/manifest.js
297
+ - spec/dummy/app/assets/javascripts/application.js
298
+ - spec/dummy/app/assets/stylesheets/application.css
299
+ - spec/dummy/app/controllers/application_controller.rb
300
+ - spec/dummy/app/controllers/posts_controller.rb
301
+ - spec/dummy/app/controllers/welcome_controller.rb
302
+ - spec/dummy/app/helpers/application_helper.rb
303
+ - spec/dummy/app/helpers/posts_helper.rb
296
304
  - spec/dummy/app/listings/array_listing.rb
297
305
  - spec/dummy/app/listings/authors_listing.rb
306
+ - spec/dummy/app/listings/filtered_posts_listing.rb
298
307
  - spec/dummy/app/listings/hash_listing.rb
299
- - spec/dummy/app/listings/tracks_listing.rb
308
+ - spec/dummy/app/listings/posts_listing.rb
300
309
  - spec/dummy/app/listings/tracks_fixed_order_listing.rb
301
- - spec/dummy/app/models/object_track.rb
310
+ - spec/dummy/app/listings/tracks_listing.rb
302
311
  - spec/dummy/app/models/album.rb
303
312
  - spec/dummy/app/models/author.rb
304
313
  - spec/dummy/app/models/object_album.rb
305
- - spec/dummy/app/models/track.rb
314
+ - spec/dummy/app/models/object_track.rb
306
315
  - spec/dummy/app/models/post.rb
307
- - spec/dummy/app/controllers/application_controller.rb
308
- - spec/dummy/app/controllers/welcome_controller.rb
309
- - spec/dummy/app/controllers/posts_controller.rb
310
- - spec/dummy/app/views/posts/filtered.html.haml
311
- - spec/dummy/app/views/posts/index.html.haml
316
+ - spec/dummy/app/models/track.rb
317
+ - spec/dummy/app/views/layouts/application.html.erb
312
318
  - spec/dummy/app/views/listings/_date.html.haml
313
319
  - spec/dummy/app/views/listings/_posts_count.html.haml
320
+ - spec/dummy/app/views/posts/filtered.html.haml
321
+ - spec/dummy/app/views/posts/index.html.haml
314
322
  - spec/dummy/app/views/shared/_post_partial.html.haml
315
323
  - spec/dummy/app/views/welcome/array.html.haml
316
- - spec/dummy/app/views/welcome/index.html.haml
324
+ - spec/dummy/app/views/welcome/authors.html.haml
317
325
  - spec/dummy/app/views/welcome/hash.html.haml
326
+ - spec/dummy/app/views/welcome/index.html.haml
318
327
  - spec/dummy/app/views/welcome/tracks.html.haml
319
- - spec/dummy/app/views/welcome/authors.html.haml
320
- - spec/dummy/app/views/layouts/application.html.erb
321
- - spec/dummy/app/assets/config/manifest.js
322
- - spec/dummy/app/assets/javascripts/application.js
323
- - spec/dummy/app/assets/stylesheets/application.css
324
- - spec/dummy/app/helpers/posts_helper.rb
325
- - spec/dummy/app/helpers/application_helper.rb
326
- - spec/dummy/config/routes.rb
327
- - spec/dummy/config/locales/en.yml
328
- - spec/dummy/config/environments/production.rb
329
- - spec/dummy/config/environments/development.rb
330
- - spec/dummy/config/environments/test.rb
331
- - spec/dummy/config/environment.rb
332
328
  - spec/dummy/config/application.rb
333
- - spec/dummy/config/database.yml
334
329
  - spec/dummy/config/boot.rb
330
+ - spec/dummy/config/database.yml
331
+ - spec/dummy/config/environment.rb
332
+ - spec/dummy/config/environments/development.rb
333
+ - spec/dummy/config/environments/production.rb
334
+ - spec/dummy/config/environments/test.rb
335
335
  - spec/dummy/config/initializers/backtrace_silencers.rb
336
+ - spec/dummy/config/initializers/inflections.rb
337
+ - spec/dummy/config/initializers/listings.rb
336
338
  - spec/dummy/config/initializers/mime_types.rb
339
+ - spec/dummy/config/initializers/secret_token.rb
337
340
  - spec/dummy/config/initializers/session_store.rb
338
341
  - spec/dummy/config/initializers/wrap_parameters.rb
339
- - spec/dummy/config/initializers/listings.rb
340
- - spec/dummy/config/initializers/secret_token.rb
341
- - spec/dummy/config/initializers/inflections.rb
342
+ - spec/dummy/config/locales/en.yml
343
+ - spec/dummy/config/routes.rb
342
344
  - spec/dummy/config.ru
343
- - spec/dummy/spec
344
- - spec/dummy/script/rails
345
- - spec/dummy/Rakefile
346
- - spec/dummy/public/favicon.ico
347
- - spec/dummy/public/422.html
348
- - spec/dummy/public/500.html
349
- - spec/dummy/public/404.html
350
- - spec/dummy/db/schema.rb
351
- - spec/dummy/db/seeds.rb
352
- - spec/dummy/db/migrate/20150611185922_create_tracks.rb
353
- - spec/dummy/db/migrate/20140728151246_add_category_to_post.rb
354
- - spec/dummy/db/migrate/20150611185824_create_albums.rb
355
345
  - spec/dummy/db/migrate/20130618143317_create_posts.rb
356
346
  - spec/dummy/db/migrate/20130618195559_add_author_to_posts.rb
357
- - spec/dummy/README.rdoc
358
- - spec/listings/tracks_listing_spec.rb
359
- - spec/listings/tracks_fixed_order_listing_spec.rb
360
- - spec/listings/posts_listing_spec.rb
361
- - spec/models/track_spec.rb
362
- - spec/models/post_spec.rb
363
- - spec/models/album_spec.rb
364
- - spec/support/query_counter.rb
347
+ - spec/dummy/db/migrate/20140728151246_add_category_to_post.rb
348
+ - spec/dummy/db/migrate/20150611185824_create_albums.rb
349
+ - spec/dummy/db/migrate/20150611185922_create_tracks.rb
350
+ - spec/dummy/db/schema.rb
351
+ - spec/dummy/db/seeds.rb
352
+ - spec/dummy/public/404.html
353
+ - spec/dummy/public/422.html
354
+ - spec/dummy/public/500.html
355
+ - spec/dummy/public/favicon.ico
356
+ - spec/dummy/script/rails
357
+ - spec/dummy/spec
365
358
  - spec/factories/albums.rb
366
- - spec/factories/traits.rb
367
359
  - spec/factories/authors.rb
368
360
  - spec/factories/posts.rb
369
361
  - spec/factories/tracks.rb
362
+ - spec/factories/traits.rb
370
363
  - spec/lib/filter_parser_spec.rb
371
364
  - spec/lib/sources/active_record_data_source_spec.rb
372
365
  - spec/lib/sources/object_data_source_spec.rb
366
+ - spec/listings/posts_listing_spec.rb
367
+ - spec/listings/tracks_fixed_order_listing_spec.rb
368
+ - spec/listings/tracks_listing_spec.rb
369
+ - spec/models/album_spec.rb
370
+ - spec/models/post_spec.rb
371
+ - spec/models/track_spec.rb
372
+ - spec/spec_helper.rb
373
+ - spec/support/query_counter.rb