buoys 1.1.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +1 -1
  3. data/Rakefile +2 -0
  4. data/lib/buoys/buoy.rb +3 -2
  5. data/lib/buoys/config.rb +1 -3
  6. data/lib/buoys/loader.rb +1 -1
  7. data/lib/buoys/railtie.rb +1 -1
  8. data/lib/buoys/version.rb +1 -1
  9. data/lib/generators/buoys/templates/_buoys.html.erb +1 -1
  10. data/lib/generators/buoys/templates/breadcrumbs.rb +1 -1
  11. data/test/buoys_buoy_test.rb +17 -1
  12. data/test/buoys_generator_test.rb +2 -2
  13. data/test/dummy/Rakefile +1 -1
  14. data/test/dummy/app/assets/config/manifest.js +3 -0
  15. data/test/dummy/app/assets/javascripts/application.js +3 -1
  16. data/test/dummy/app/assets/javascripts/cable.js +13 -0
  17. data/test/dummy/app/assets/stylesheets/application.css +3 -3
  18. data/test/dummy/app/channels/application_cable/channel.rb +4 -0
  19. data/test/dummy/app/channels/application_cable/connection.rb +4 -0
  20. data/test/dummy/app/controllers/application_controller.rb +0 -5
  21. data/test/dummy/app/helpers/application_helper.rb +0 -2
  22. data/test/dummy/app/jobs/application_job.rb +2 -0
  23. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  24. data/test/dummy/app/models/application_record.rb +3 -0
  25. data/test/dummy/app/models/item.rb +1 -1
  26. data/test/dummy/app/models/user.rb +1 -1
  27. data/test/dummy/app/views/layouts/application.html.erb +10 -9
  28. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  29. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  30. data/test/dummy/bin/bundle +1 -1
  31. data/test/dummy/bin/rails +1 -1
  32. data/test/dummy/bin/setup +20 -13
  33. data/test/dummy/bin/update +31 -0
  34. data/test/dummy/bin/yarn +11 -0
  35. data/test/dummy/config/application.rb +9 -21
  36. data/test/dummy/config/boot.rb +2 -4
  37. data/test/dummy/config/cable.yml +10 -0
  38. data/test/dummy/config/database.yml +1 -1
  39. data/test/dummy/config/environment.rb +1 -3
  40. data/test/dummy/config/environments/development.rb +31 -13
  41. data/test/dummy/config/environments/production.rb +31 -18
  42. data/test/dummy/config/environments/test.rb +10 -13
  43. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  44. data/test/dummy/config/initializers/assets.rb +6 -5
  45. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -2
  46. data/test/dummy/config/initializers/content_security_policy.rb +25 -0
  47. data/test/dummy/config/initializers/cookies_serializer.rb +2 -2
  48. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -2
  49. data/test/dummy/config/initializers/inflections.rb +0 -2
  50. data/test/dummy/config/initializers/mime_types.rb +0 -2
  51. data/test/dummy/config/initializers/wrap_parameters.rb +2 -4
  52. data/test/dummy/config/locales/en.yml +10 -0
  53. data/test/dummy/config/puma.rb +37 -0
  54. data/test/dummy/config/routes.rb +2 -2
  55. data/test/dummy/config/spring.rb +6 -0
  56. data/test/dummy/config/storage.yml +34 -0
  57. data/test/dummy/config.ru +2 -1
  58. data/test/dummy/db/development.sqlite3 +0 -0
  59. data/test/dummy/db/test.sqlite3 +0 -0
  60. data/test/dummy/log/development.log +129 -0
  61. data/test/dummy/log/test.log +486 -263
  62. data/test/dummy/package.json +5 -0
  63. data/test/dummy/public/404.html +6 -6
  64. data/test/dummy/public/422.html +6 -6
  65. data/test/dummy/public/500.html +6 -6
  66. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  67. data/test/dummy/public/apple-touch-icon.png +0 -0
  68. data/test/dummy/tmp/development_secret.txt +1 -0
  69. data/test/test_helper.rb +4 -5
  70. metadata +101 -47
  71. data/test/dummy/README.rdoc +0 -28
  72. data/test/dummy/config/initializers/session_store.rb +0 -5
  73. data/test/dummy/config/secrets.yml +0 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 36271005ba0ba04593d62e6d6f0d2c0cc0156c91
4
- data.tar.gz: 62c723569c8a8ffb962b1204914209291efc0dca
2
+ SHA256:
3
+ metadata.gz: 7206430f425484e8e75b8cd16a49b6a737dafdc54486dfc7d803d1cd06a05b91
4
+ data.tar.gz: 170521a71be7ff33dd3d1a29a377f3e8dc2f2993debae6273e0ef3dc01249cd4
5
5
  SHA512:
6
- metadata.gz: df714e7c87349f56c64a60a99b7f5d8c94c34e9f572ce28bc60d3f5bbedf696b248eb4f7ded73d0c4cc4aeb7135df4f029cadd9774811c7ae1b23b88957d13af
7
- data.tar.gz: 4b1d8c37a805d8f23e4246caaebc788ff7e962cc71e74084023ef89c04467c607656ace7f5c29f9bf05ae90d13ce92a054e0b9b7227ba7e30d69e75ae5b3ba09
6
+ metadata.gz: 126f9ac46f9f98f28e24cdb3566c9ebc3d997c8e55f793ebc3e2545b1821e74944123748d02b6b36396b35d93f91b90bdb8afab2891f8d2502564aba60a09fbb
7
+ data.tar.gz: 153b7a25618e75baa83a554cacee3d97ef68adf320591c1bb1d20838655b0c067fb34a8a727b1def1f6b6958535d8c8e95a79046e9e7661af34755bde03276b3
data/README.md CHANGED
@@ -60,7 +60,7 @@ buoy :story do |story|
60
60
  # same as `link I18n.t('story', scope: 'buoys.breadcrumbs', default: 'story'), story_path(story)`
61
61
  end
62
62
 
63
- # You can alse override Buoys configuration
63
+ # You can also override Buoys configuration
64
64
  # ex)
65
65
  buoy :story_tasks do |story|
66
66
  link :story_tasks, story_tasks_path
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
4
  require 'bundler/setup'
3
5
  rescue LoadError
data/lib/buoys/buoy.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  module Buoys
4
4
  class Buoy
5
5
  attr_reader :previous, :context
6
+
6
7
  # buoy :account do
7
8
  # link 'Account', account_path
8
9
  # end
@@ -40,8 +41,8 @@ module Buoys
40
41
  end
41
42
  alias parent pre_buoy
42
43
 
43
- def method_missing(method, *args, &block)
44
- context.send(method, *args, &block)
44
+ def method_missing(method, *args, **kwargs, &block)
45
+ context.send(method, *args, **kwargs, &block)
45
46
  end
46
47
  end
47
48
  end
data/lib/buoys/config.rb CHANGED
@@ -3,9 +3,7 @@
3
3
  module Buoys
4
4
  class Config
5
5
  class << self
6
- attr_accessor :current_class
7
-
8
- attr_accessor :link_current
6
+ attr_accessor :current_class, :link_current
9
7
  end
10
8
  end
11
9
  end
data/lib/buoys/loader.rb CHANGED
@@ -32,7 +32,7 @@ module Buoys
32
32
  loaded_times.clear
33
33
 
34
34
  buoy_files.each do |file|
35
- instance_eval File.open(file).read, file
35
+ instance_eval File.read(file), file
36
36
  loaded_times << File.mtime(file)
37
37
  end
38
38
  end
data/lib/buoys/railtie.rb CHANGED
@@ -4,7 +4,7 @@ module Buoys
4
4
  class Railtie < ::Rails::Railtie
5
5
  initializer 'buoys' do
6
6
  ActiveSupport.on_load(:action_view) do
7
- ActionView::Base.send :include, Buoys::Helper
7
+ ActionView::Base.include Buoys::Helper
8
8
  end
9
9
  end
10
10
  end
data/lib/buoys/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Buoys
4
- VERSION = '1.1.0'.freeze
4
+ VERSION = '2.1.0'
5
5
  end
@@ -7,7 +7,7 @@
7
7
  <span itemprop='name'><%= link.text %></span>
8
8
  <meta itemprop='position' content='<%= i %>' />
9
9
  <% else %>
10
- <%= link_to link.text, link.url, link.options.merge(itemprop: :item) do %>
10
+ <%= link_to link.url, link.options.merge(itemprop: :item) do %>
11
11
  <span itemprop='name'><%= link.text %></span>
12
12
  <% end %>
13
13
  <meta itemprop='position' content='<%= i %>' />
@@ -23,7 +23,7 @@ end
23
23
  # # same as `link I18n.t(:story, scope: 'buoys.breadcrumbs', default: story), story_path(story)`
24
24
  # end
25
25
 
26
- # You can alse override Buoys configuration
26
+ # You can also override Buoys configuration
27
27
  #
28
28
  # ex)
29
29
  # buoy :story_tasks do |story|
@@ -4,7 +4,11 @@ require 'test_helper'
4
4
 
5
5
  class BuoysBuoyTest < ActiveSupport::TestCase
6
6
  setup do
7
- @view_context = ActionView::Base.new
7
+ @view_context = if ActionView::Base.respond_to?(:empty)
8
+ ActionView::Base.empty
9
+ else
10
+ ActionView::Base.new # Rails 5.2 or lower
11
+ end
8
12
  Buoys::Loader.load_buoys_files
9
13
  end
10
14
 
@@ -29,4 +33,16 @@ class BuoysBuoyTest < ActiveSupport::TestCase
29
33
  assert_equal links[0].text, 'Account'
30
34
  assert_equal links[0].url, 'http://example.com/account'
31
35
  end
36
+
37
+ test 'delegate unknown methods to view context' do
38
+ def @view_context.hello(arg, kwarg:, &block)
39
+ [arg, kwarg, block]
40
+ end
41
+
42
+ arg, kwarg, block = Buoys::Buoy.new(@view_context, :account).hello('hello', kwarg: ',') { 'world' }
43
+
44
+ assert_equal arg, 'hello'
45
+ assert_equal kwarg, ','
46
+ assert_equal block.call, 'world'
47
+ end
32
48
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # rubocop:disable Style/RegexpLiteral, Metrics/LineLength
3
+ # rubocop:disable Style/RegexpLiteral, Layout/LineLength
4
4
  require 'test_helper'
5
5
  require 'generators/buoys/install_generator'
6
6
 
@@ -51,4 +51,4 @@ class BuoysGeneratorTest < Rails::Generators::TestCase
51
51
  assert_file File.expand_path('./config/locales/buoys.en.yml', dest_root)
52
52
  end
53
53
  end
54
- # rubocop:enable Style/RegexpLiteral, Metrics/LineLength
54
+ # rubocop:enable Style/RegexpLiteral, Layout/LineLength
data/test/dummy/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # Add your own tasks in files placed in lib/tasks ending in .rake,
2
2
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
3
 
4
- require File.expand_path('../config/application', __FILE__)
4
+ require_relative 'config/application'
5
5
 
6
6
  Rails.application.load_tasks
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
@@ -5,9 +5,11 @@
5
5
  // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
6
  //
7
7
  // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file.
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
9
  //
10
10
  // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
11
  // about supported directives.
12
12
  //
13
+ //= require rails-ujs
14
+ //= require activestorage
13
15
  //= require_tree .
@@ -0,0 +1,13 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3
+ //
4
+ //= require action_cable
5
+ //= require_self
6
+ //= require_tree ./channels
7
+
8
+ (function() {
9
+ this.App || (this.App = {});
10
+
11
+ App.cable = ActionCable.createConsumer();
12
+
13
+ }).call(this);
@@ -6,9 +6,9 @@
6
6
  * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
7
  *
8
8
  * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any styles
10
- * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
- * file per style scope.
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
12
  *
13
13
  *= require_tree .
14
14
  *= require_self
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -1,7 +1,2 @@
1
- # frozen_string_literal: true
2
-
3
1
  class ApplicationController < ActionController::Base
4
- # Prevent CSRF attacks by raising an exception.
5
- # For APIs, you may want to use :null_session instead.
6
- protect_from_forgery with: :exception
7
2
  end
@@ -1,4 +1,2 @@
1
- # frozen_string_literal: true
2
-
3
1
  module ApplicationHelper
4
2
  end
@@ -0,0 +1,2 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ layout 'mailer'
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Item < ActiveRecord::Base
3
+ class Item < ApplicationRecord
4
4
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class User < ActiveRecord::Base
3
+ class User < ApplicationRecord
4
4
  end
@@ -1,14 +1,15 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
- <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
10
7
 
11
- <%= yield %>
8
+ <%= stylesheet_link_tag 'application', media: 'all' %>
9
+ <%= javascript_include_tag 'application' %>
10
+ </head>
12
11
 
13
- </body>
12
+ <body>
13
+ <%= yield %>
14
+ </body>
14
15
  </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
3
3
  load Gem.bin_path('bundler', 'bundle')
data/test/dummy/bin/rails CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
2
+ APP_PATH = File.expand_path('../config/application', __dir__)
3
3
  require_relative '../config/boot'
4
4
  require 'rails/commands'
data/test/dummy/bin/setup CHANGED
@@ -1,29 +1,36 @@
1
1
  #!/usr/bin/env ruby
2
- require 'pathname'
2
+ require 'fileutils'
3
+ include FileUtils
3
4
 
4
5
  # path to your application root.
5
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+ APP_ROOT = File.expand_path('..', __dir__)
6
7
 
7
- Dir.chdir APP_ROOT do
8
+ def system!(*args)
9
+ system(*args) || abort("\n== Command #{args} failed ==")
10
+ end
11
+
12
+ chdir APP_ROOT do
8
13
  # This script is a starting point to setup your application.
9
- # Add necessary setup steps to this file:
14
+ # Add necessary setup steps to this file.
15
+
16
+ puts '== Installing dependencies =='
17
+ system! 'gem install bundler --conservative'
18
+ system('bundle check') || system!('bundle install')
10
19
 
11
- puts "== Installing dependencies =="
12
- system "gem install bundler --conservative"
13
- system "bundle check || bundle install"
20
+ # Install JavaScript dependencies if using Yarn
21
+ # system('bin/yarn')
14
22
 
15
23
  # puts "\n== Copying sample files =="
16
- # unless File.exist?("config/database.yml")
17
- # system "cp config/database.yml.sample config/database.yml"
24
+ # unless File.exist?('config/database.yml')
25
+ # cp 'config/database.yml.sample', 'config/database.yml'
18
26
  # end
19
27
 
20
28
  puts "\n== Preparing database =="
21
- system "bin/rake db:setup"
29
+ system! 'bin/rails db:setup'
22
30
 
23
31
  puts "\n== Removing old logs and tempfiles =="
24
- system "rm -f log/*"
25
- system "rm -rf tmp/cache"
32
+ system! 'bin/rails log:clear tmp:clear'
26
33
 
27
34
  puts "\n== Restarting application server =="
28
- system "touch tmp/restart.txt"
35
+ system! 'bin/rails restart'
29
36
  end
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+ include FileUtils
4
+
5
+ # path to your application root.
6
+ APP_ROOT = File.expand_path('..', __dir__)
7
+
8
+ def system!(*args)
9
+ system(*args) || abort("\n== Command #{args} failed ==")
10
+ end
11
+
12
+ chdir APP_ROOT do
13
+ # This script is a way to update your development environment automatically.
14
+ # Add necessary update steps to this file.
15
+
16
+ puts '== Installing dependencies =='
17
+ system! 'gem install bundler --conservative'
18
+ system('bundle check') || system!('bundle install')
19
+
20
+ # Install JavaScript dependencies if using Yarn
21
+ # system('bin/yarn')
22
+
23
+ puts "\n== Updating database =="
24
+ system! 'bin/rails db:migrate'
25
+
26
+ puts "\n== Removing old logs and tempfiles =="
27
+ system! 'bin/rails log:clear tmp:clear'
28
+
29
+ puts "\n== Restarting application server =="
30
+ system! 'bin/rails restart'
31
+ end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path('..', __dir__)
3
+ Dir.chdir(APP_ROOT) do
4
+ begin
5
+ exec "yarnpkg", *ARGV
6
+ rescue Errno::ENOENT
7
+ $stderr.puts "Yarn executable was not detected in the system."
8
+ $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
9
+ exit 1
10
+ end
11
+ end
@@ -1,31 +1,19 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path('../boot', __FILE__)
1
+ require_relative 'boot'
4
2
 
5
3
  require 'rails/all'
6
4
 
7
5
  Bundler.require(*Rails.groups)
8
- require 'buoys'
6
+ require "buoys"
9
7
 
10
8
  module Dummy
11
9
  class Application < Rails::Application
12
- # Settings in config/environments/* take precedence over those specified here.
13
- # Application configuration should go into files in config/initializers
14
- # -- all .rb files in that directory are automatically loaded.
15
-
16
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
17
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
18
- # config.time_zone = 'Central Time (US & Canada)'
10
+ # Initialize configuration defaults for originally generated Rails version.
11
+ config.load_defaults 5.2
19
12
 
20
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
21
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
22
- # config.i18n.default_locale = :de
23
- config.i18n.default_locale = :en
24
-
25
- # Do not swallow errors in after_commit/after_rollback callbacks.
26
- if Gem::Version.new(Rails.version) >= Gem::Version.new('4.2.0') &&
27
- Gem::Version.new(Rails.version) <= Gem::Version.new('5.0.0')
28
- config.active_record.raise_in_transactional_callbacks = true
29
- end
13
+ # Settings in config/environments/* take precedence over those specified here.
14
+ # Application configuration can go into files in config/initializers
15
+ # -- all .rb files in that directory are automatically loaded after loading
16
+ # the framework and any gems in your application.
30
17
  end
31
18
  end
19
+
@@ -1,7 +1,5 @@
1
- # frozen_string_literal: true
2
-
3
1
  # Set up gems listed in the Gemfile.
4
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
5
3
 
6
4
  require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
7
- $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
5
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
@@ -0,0 +1,10 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: async
6
+
7
+ production:
8
+ adapter: redis
9
+ url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
10
+ channel_prefix: dummy_production
@@ -6,7 +6,7 @@
6
6
  #
7
7
  default: &default
8
8
  adapter: sqlite3
9
- pool: 5
9
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
10
10
  timeout: 5000
11
11
 
12
12
  development:
@@ -1,7 +1,5 @@
1
- # frozen_string_literal: true
2
-
3
1
  # Load the Rails application.
4
- require File.expand_path('../application', __FILE__)
2
+ require_relative 'application'
5
3
 
6
4
  # Initialize the Rails application.
7
5
  Rails.application.initialize!
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  Rails.application.configure do
4
2
  # Settings specified here will take precedence over those in config/application.rb.
5
3
 
@@ -11,33 +9,53 @@ Rails.application.configure do
11
9
  # Do not eager load code on boot.
12
10
  config.eager_load = false
13
11
 
14
- # Show full error reports and disable caching.
15
- config.consider_all_requests_local = true
16
- config.action_controller.perform_caching = false
12
+ # Show full error reports.
13
+ config.consider_all_requests_local = true
14
+
15
+ # Enable/disable caching. By default caching is disabled.
16
+ # Run rails dev:cache to toggle caching.
17
+ if Rails.root.join('tmp', 'caching-dev.txt').exist?
18
+ config.action_controller.perform_caching = true
19
+
20
+ config.cache_store = :memory_store
21
+ config.public_file_server.headers = {
22
+ 'Cache-Control' => "public, max-age=#{2.days.to_i}"
23
+ }
24
+ else
25
+ config.action_controller.perform_caching = false
26
+
27
+ config.cache_store = :null_store
28
+ end
29
+
30
+ # Store uploaded files on the local file system (see config/storage.yml for options)
31
+ config.active_storage.service = :local
17
32
 
18
33
  # Don't care if the mailer can't send.
19
34
  config.action_mailer.raise_delivery_errors = false
20
35
 
36
+ config.action_mailer.perform_caching = false
37
+
21
38
  # Print deprecation notices to the Rails logger.
22
39
  config.active_support.deprecation = :log
23
40
 
24
41
  # Raise an error on page load if there are pending migrations.
25
42
  config.active_record.migration_error = :page_load
26
43
 
44
+ # Highlight code that triggered database queries in logs.
45
+ config.active_record.verbose_query_logs = true
46
+
27
47
  # Debug mode disables concatenation and preprocessing of assets.
28
48
  # This option may cause significant delays in view rendering with a large
29
49
  # number of complex assets.
30
50
  config.assets.debug = true
31
51
 
32
- # Asset digests allow you to set far-future HTTP expiration dates on all assets,
33
- # yet still be able to expire them through the digest params.
34
- config.assets.digest = true
35
-
36
- # Adds additional error checking when serving assets at runtime.
37
- # Checks for improperly declared sprockets dependencies.
38
- # Raises helpful error messages.
39
- config.assets.raise_runtime_errors = true
52
+ # Suppress logger output for asset requests.
53
+ config.assets.quiet = true
40
54
 
41
55
  # Raises error for missing translations
42
56
  # config.action_view.raise_on_missing_translations = true
57
+
58
+ # Use an evented file watcher to asynchronously detect changes in source code,
59
+ # routes, locales, etc. This feature depends on the listen gem.
60
+ # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
43
61
  end