workbook_rails 0.2.0 → 0.2.1

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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -7
  3. data/Gemfile.lock +206 -172
  4. data/README.md +3 -3
  5. data/Rakefile +7 -19
  6. data/lib/tasks/workbook_rails_tasks.rake +2 -0
  7. data/lib/workbook_rails/action_controller.rb +15 -10
  8. data/lib/workbook_rails/engine.rb +4 -4
  9. data/lib/workbook_rails/template_handler.rb +6 -5
  10. data/lib/workbook_rails/version.rb +3 -1
  11. data/lib/workbook_rails.rb +3 -2
  12. data/spec/ci.rb +5 -1
  13. data/spec/dummy/Rakefile +3 -1
  14. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  15. data/spec/dummy/app/controllers/home_controller.rb +14 -16
  16. data/spec/dummy/app/controllers/likes_controller.rb +3 -1
  17. data/spec/dummy/app/controllers/users_controller.rb +4 -2
  18. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  19. data/spec/dummy/app/mailers/notifier.rb +5 -4
  20. data/spec/dummy/app/models/like.rb +2 -0
  21. data/spec/dummy/app/models/user.rb +2 -0
  22. data/spec/dummy/bin/bundle +3 -1
  23. data/spec/dummy/bin/rails +3 -1
  24. data/spec/dummy/bin/rake +2 -0
  25. data/spec/dummy/config/application.rb +9 -8
  26. data/spec/dummy/config/boot.rb +4 -2
  27. data/spec/dummy/config/environment.rb +3 -1
  28. data/spec/dummy/config/environments/development.rb +2 -0
  29. data/spec/dummy/config/environments/production.rb +2 -0
  30. data/spec/dummy/config/environments/test.rb +6 -4
  31. data/spec/dummy/config/initializers/backtrace_silencers.rb +2 -0
  32. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -1
  33. data/spec/dummy/config/initializers/filter_parameter_logging.rb +2 -0
  34. data/spec/dummy/config/initializers/inflections.rb +2 -0
  35. data/spec/dummy/config/initializers/mime_types.rb +2 -0
  36. data/spec/dummy/config/initializers/secret_token.rb +3 -1
  37. data/spec/dummy/config/initializers/session_store.rb +2 -0
  38. data/spec/dummy/config/initializers/wrap_parameters.rb +2 -0
  39. data/spec/dummy/config/routes.rb +13 -11
  40. data/spec/dummy/config.ru +3 -1
  41. data/spec/dummy/db/migrate/20120717192452_create_users.rb +2 -0
  42. data/spec/dummy/db/migrate/20121206210955_create_likes.rb +2 -0
  43. data/spec/dummy/db/schema.rb +1 -2
  44. data/spec/dummy/db/test.sqlite3 +0 -0
  45. data/spec/dummy/log/test.log +6916 -16248
  46. data/spec/spec_helper.rb +14 -14
  47. data/spec/template_handler_spec.rb +12 -15
  48. data/spec/test_7.2.sh +6 -0
  49. data/spec/test_8.0.sh +6 -0
  50. data/spec/test_8.1.sh +6 -0
  51. data/spec/test_all_rails.sh +10 -4
  52. data/spec/workbook_mailer_spec.rb +9 -4
  53. data/spec/workbook_renderer_spec.rb +10 -10
  54. data/spec/workbook_request_spec.rb +60 -49
  55. metadata +13 -20
  56. data/spec/dummy/log/development.log +0 -24
  57. data/spec/test_6.0.sh +0 -4
  58. data/spec/test_6.1.sh +0 -4
  59. data/spec/test_7.0.sh +0 -4
  60. data/spec/test_7.1.sh +0 -4
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WorkbookRails
2
- VERSION = "0.2.0"
4
+ VERSION = '0.2.1'
3
5
  end
@@ -1,5 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'workbook_rails/engine'
2
4
  module WorkbookRails
3
- FORMATS = [:xlsx, :xls, :csv]
5
+ FORMATS = %i[xlsx xls csv].freeze
4
6
  end
5
-
data/spec/ci.rb CHANGED
@@ -1,3 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- exit system('cd spec/dummy && bundle install --without debug && bundle exec rake db:create && bundle exec rake db:migrate && cd ../../ && bundle exec rspec spec')
4
+ exit system(
5
+ 'cd spec/dummy && bundle install && bundle exec rake db:create && ' \
6
+ 'bundle exec rake db:migrate && cd ../../ && bundle exec rspec spec'
7
+ )
data/spec/dummy/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Add your own tasks in files placed in lib/tasks ending in .rake,
2
4
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
5
 
4
- require File.expand_path('../config/application', __FILE__)
6
+ require File.expand_path('config/application', __dir__)
5
7
 
6
8
  Rails.application.load_tasks
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ApplicationController < ActionController::Base
2
4
  # Prevent CSRF attacks by raising an exception.
3
5
  # For APIs, you may want to use :null_session instead.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #---
2
4
  # Excerpted from "Crafting Rails Applications",
3
5
  # published by The Pragmatic Bookshelf.
@@ -7,8 +9,7 @@
7
9
  # Visit http://www.pragmaticprogrammer.com/titles/jvrails for more book information.
8
10
  #---
9
11
  class HomeController < ApplicationController
10
- def index
11
- end
12
+ def index; end
12
13
 
13
14
  def generic
14
15
  respond_to do |format|
@@ -22,36 +23,33 @@ class HomeController < ApplicationController
22
23
  def only_html; end
23
24
 
24
25
  def another
25
- render :xlsx => "index", :filename => "filename_test.xlsx"
26
+ render xlsx: 'index', filename: 'filename_test.xlsx'
26
27
  end
27
28
 
28
29
  def render_elsewhere
29
30
  case params[:type]
30
- when '1'
31
- render :xlsx => "home/index", :template => 'users/respond_with'
32
- when '2'
33
- render :xlsx => "users/respond_with", :template => 'users/respond_with'
31
+ when '1', '2'
32
+ render xlsx: params[:type] == '1' ? 'home/index' : 'users/respond_with', template: 'users/respond_with'
34
33
  when '3'
35
- render template: "users/respond_with"
34
+ render template: 'users/respond_with'
36
35
  when '4'
37
- render "users/respond_with"
36
+ render 'users/respond_with'
38
37
  else
39
- render :xlsx => "index"
38
+ render xlsx: 'index'
40
39
  end
41
40
  end
42
41
 
43
- def withpartial
44
- end
42
+ def withpartial; end
45
43
 
46
44
  def useheader
47
45
  respond_to do |format|
48
- format.xlsx {
46
+ format.xlsx do
49
47
  if params[:set_direct]
50
- response.headers['Content-Disposition'] = "attachment; filename=\"filename_test.xlsx\""
48
+ response.headers['Content-Disposition'] = 'attachment; filename="filename_test.xlsx"'
51
49
  else
52
- render xlsx: "useheader", filename: "filename_test.xlsx"
50
+ render xlsx: 'useheader', filename: 'filename_test.xlsx'
53
51
  end
54
- }
52
+ end
55
53
  end
56
54
  end
57
55
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class LikesController < ApplicationController
2
4
  # GET /likes
3
5
  # GET /likes.json
@@ -13,6 +15,6 @@ class LikesController < ApplicationController
13
15
 
14
16
  def render_elsewhere
15
17
  @user = User.find(params[:user_id])
16
- render :xlsx => "index", :template => 'users/respond_with'
18
+ render xlsx: 'index', template: 'users/respond_with'
17
19
  end
18
20
  end
@@ -1,16 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class UsersController < ApplicationController
2
4
  respond_to :xlsx, :html
3
5
 
4
6
  def show
5
7
  @user = User.find(params[:id])
6
8
  respond_with(@user) do |format|
7
- format.xlsx { render "respond_with" }
9
+ format.xlsx { render 'respond_with' }
8
10
  end
9
11
  end
10
12
 
11
13
  def send_instructions
12
14
  @user = User.find(params[:user_id])
13
15
  @user.send_instructions
14
- render plain: "Email sent"
16
+ render plain: 'Email sent'
15
17
  end
16
18
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ApplicationHelper
2
4
  end
@@ -1,14 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Notifier < ActionMailer::Base
2
- default :from => 'noreply@company.com'
4
+ default from: 'noreply@company.com'
3
5
 
4
6
  def instructions(user)
5
7
  @user = user
6
8
 
7
9
  # normal syntax
8
10
  xlsx = render_to_string handlers: [:wb], template: 'users/mailers/instructions', layout: false, formats: [:xlsx]
9
- attachments["user_#{user.id}.xlsx"] = {mime_type: Mime[:xlsx], content: xlsx}
11
+ attachments["user_#{user.id}.xlsx"] = { mime_type: Mime[:xlsx], content: xlsx }
10
12
 
11
- mail :to => user.email, :subject => 'Instructions'
13
+ mail to: user.email, subject: 'Instructions'
12
14
  end
13
-
14
15
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Like < ActiveRecord::Base
2
4
  belongs_to :user
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class User < ActiveRecord::Base
2
4
  has_many :likes
3
5
 
@@ -1,3 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2
+ # frozen_string_literal: true
3
+
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
3
5
  load Gem.bin_path('bundler', 'bundle')
data/spec/dummy/bin/rails CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
2
+ # frozen_string_literal: true
3
+
4
+ APP_PATH = File.expand_path('../config/application', __dir__)
3
5
  require_relative '../config/boot'
4
6
  require 'rails/commands'
data/spec/dummy/bin/rake CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  require_relative '../config/boot'
3
5
  require 'rake'
4
6
  Rake.application.run
@@ -1,20 +1,22 @@
1
- require File.expand_path('../boot', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('boot', __dir__)
2
4
 
3
5
  require 'rails/version'
4
6
  if Rails::VERSION::MAJOR < 4
5
7
  # Pick the frameworks you want:
6
- require "active_record/railtie"
7
- require "action_controller/railtie"
8
- require "action_mailer/railtie"
9
- require "active_resource/railtie"
10
- require "sprockets/railtie"
8
+ require 'active_record/railtie'
9
+ require 'action_controller/railtie'
10
+ require 'action_mailer/railtie'
11
+ require 'active_resource/railtie'
12
+ require 'sprockets/railtie'
11
13
  # require "rails/test_unit/railtie"
12
14
  else
13
15
  require 'rails/all'
14
16
  end
15
17
 
16
18
  Bundler.require(*Rails.groups)
17
- require "workbook_rails"
19
+ require 'workbook_rails'
18
20
 
19
21
  module Dummy
20
22
  class Application < Rails::Application
@@ -31,4 +33,3 @@ module Dummy
31
33
  # config.i18n.default_locale = :de
32
34
  end
33
35
  end
34
-
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Set up gems listed in the Gemfile.
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
3
5
 
4
6
  require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
- $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
7
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Load the Rails application.
2
- require File.expand_path('../application', __FILE__)
4
+ require File.expand_path('application', __dir__)
3
5
 
4
6
  # Initialize the Rails application.
5
7
  Rails.application.initialize!
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
@@ -1,4 +1,6 @@
1
- #Rails.application.configure do
1
+ # frozen_string_literal: true
2
+
3
+ # Rails.application.configure do
2
4
  Dummy::Application.configure do
3
5
  # Settings specified here will take precedence over those in config/application.rb.
4
6
 
@@ -15,9 +17,9 @@ Dummy::Application.configure do
15
17
 
16
18
  # Configure static asset server for tests with Cache-Control for performance.
17
19
  if config.respond_to? :serve_static_files
18
- config.serve_static_files = true
20
+ config.serve_static_files = true
19
21
  else
20
- config.serve_static_assets = true
22
+ config.serve_static_assets = true
21
23
  end
22
24
  config.static_cache_control = 'public, max-age=3600'
23
25
 
@@ -26,7 +28,7 @@ Dummy::Application.configure do
26
28
  config.action_controller.perform_caching = false
27
29
 
28
30
  # Raise exceptions instead of rendering exception templates.
29
- config.action_dispatch.show_exceptions = false
31
+ config.action_dispatch.show_exceptions = :none
30
32
 
31
33
  # Disable request forgery protection in test environment.
32
34
  config.action_controller.allow_forgery_protection = false
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
- Rails.application.config.action_dispatch.cookies_serializer = :json
5
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Configure sensitive parameters which will be filtered from the log file.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Add new inflection rules using the following format. Inflections
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Add new mime types for use in respond_to blocks:
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Dummy::Application.config.secret_token = 'afaaa2094c84c6a6082e6d8752d42984'
2
- Dummy::Application.config.secret_key_base = 'new secret key base'
4
+ Dummy::Application.config.secret_key_base = 'new secret key base'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  Rails.application.config.session_store :cookie_store, key: '_dummy_session'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # This file contains settings for ActionController::ParamsWrapper which
@@ -1,16 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.routes.draw do
2
- get "/users/:user_id/render_elsewhere(.:format)", :to => "likes#render_elsewhere"
3
- get "/users/:user_id/send_instructions", :to => "users#send_instructions"
4
+ get '/users/:user_id/render_elsewhere(.:format)', to: 'likes#render_elsewhere'
5
+ get '/users/:user_id/send_instructions', to: 'users#send_instructions'
4
6
  resources :users do
5
7
  resources :likes
6
8
  end
7
- get "/home(.:format)", :to => "home#index", :as => :home
8
- get "/home/generic(.:format)", :to => "home#generic", :as => :generic
9
- get "/home/only_html", :to => "home#only_html", :as => :only_html
10
- get "/another(.:format)", :to => "home#another", :as => :another
11
- get "/useheader(.:format)", :to => "home#useheader", :as => :useheader
12
- get "/withpartial(.:format)", :to => "home#withpartial", :as => :withpartial
13
- get "/home/render_elsewhere(.:format)", :to => "home#render_elsewhere"
14
- get "/render_elsewhere(.:format)", :to => "home#render_elsewhere"
15
- root to: "home#index"
9
+ get '/home(.:format)', to: 'home#index', as: :home
10
+ get '/home/generic(.:format)', to: 'home#generic', as: :generic
11
+ get '/home/only_html', to: 'home#only_html', as: :only_html
12
+ get '/another(.:format)', to: 'home#another', as: :another
13
+ get '/useheader(.:format)', to: 'home#useheader', as: :useheader
14
+ get '/withpartial(.:format)', to: 'home#withpartial', as: :withpartial
15
+ get '/home/render_elsewhere(.:format)', to: 'home#render_elsewhere'
16
+ get '/render_elsewhere(.:format)', to: 'home#render_elsewhere'
17
+ root to: 'home#index'
16
18
  end
data/spec/dummy/config.ru CHANGED
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is used by Rack-based servers to start the application.
2
4
 
3
- require ::File.expand_path('../config/environment', __FILE__)
5
+ require ::File.expand_path('config/environment', __dir__)
4
6
  run Rails.application
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreateUsers < (Rails.version < '5.1' ? ActiveRecord::Migration : ActiveRecord::Migration[5.0])
2
4
  def change
3
5
  create_table :users do |t|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreateLikes < (Rails.version < '5.1' ? ActiveRecord::Migration : ActiveRecord::Migration[5.0])
2
4
  def change
3
5
  create_table :likes do |t|
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema[7.0].define(version: 2012_12_06_210955) do
13
+ ActiveRecord::Schema[8.0].define(version: 2012_12_06_210955) do
14
14
  create_table "likes", force: :cascade do |t|
15
15
  t.string "name"
16
16
  t.integer "user_id"
@@ -26,5 +26,4 @@ ActiveRecord::Schema[7.0].define(version: 2012_12_06_210955) do
26
26
  t.datetime "created_at", precision: nil
27
27
  t.datetime "updated_at", precision: nil
28
28
  end
29
-
30
29
  end
Binary file