diff --git a/config/application.rb b/config/application.rb index f2f8512d4..36c3652c6 100644 --- a/config/application.rb +++ b/config/application.rb @@ -26,7 +26,7 @@ class Application < Rails::Application # Please, add to the `ignore` list any other `lib` subdirectories that do # not contain `.rb` files, or that should not be reloaded or eager loaded. # Common ones are `templates`, `generators`, or `middleware`, for example. - config.autoload_lib(ignore: %w(assets tasks)) + config.autoload_lib(ignore: %w(assets tasks generators)) # Configuration for the application, engines, and railties goes here. # @@ -35,5 +35,8 @@ class Application < Rails::Application # # config.time_zone = "Central Time (US & Canada)" # config.eager_load_paths << Rails.root.join("extras") + + # FIXME: fix loading issues and remove line below + config.add_autoload_paths_to_load_path = true end end diff --git a/config/environments/development.rb b/config/environments/development.rb index f37ff0d3a..3e2a24bd2 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -19,6 +19,6 @@ if Iqvoc.const_defined?(:Application) Iqvoc::Application.configure do # Settings specified here will take precedence over those in config/environment.rb - Iqvoc::Environments.setup_development(config) + Iqvoc::Environments::Development.setup_development(config) end end diff --git a/config/environments/production.rb b/config/environments/production.rb index 97f981761..c83532d0a 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -19,6 +19,6 @@ if Iqvoc.const_defined?(:Application) Iqvoc::Application.configure do # Settings specified here will take precedence over those in config/environment.rb - Iqvoc::Environments.setup_production(config) + Iqvoc::Environments::Production.setup_production(config) end end diff --git a/config/environments/test.rb b/config/environments/test.rb index 008143a36..4815592fc 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -19,6 +19,6 @@ if Iqvoc.const_defined?(:Application) Iqvoc::Application.configure do # Settings specified here will take precedence over those in config/environment.rb - Iqvoc::Environments.setup_test(config) + Iqvoc::Environments::Test.setup_test(config) end end diff --git a/config/initializers/zeitwerk.rb b/config/initializers/zeitwerk.rb index 9cce22730..b30c0366f 100644 --- a/config/initializers/zeitwerk.rb +++ b/config/initializers/zeitwerk.rb @@ -2,5 +2,6 @@ Rails.autoloaders.main.inflector.inflect( 'skos' => 'SKOS', 'rdfs' => 'RDFS', - 'rdfapi' => 'RDFAPI' + 'rdfapi' => 'RDFAPI', + 'version' => 'VERSION' ) diff --git a/lib/iqvoc/environments/development.rb b/lib/iqvoc/environments/development.rb index 1eb34dd2f..93f920b30 100644 --- a/lib/iqvoc/environments/development.rb +++ b/lib/iqvoc/environments/development.rb @@ -1,77 +1,81 @@ require "active_support/core_ext/integer/time" require 'iqvoc' -module Iqvoc::Environments - def self.setup_development(config) - # Settings specified here will take precedence over those in config/application.rb. - - # In the development environment your application's code is reloaded any time - # it changes. This slows down response time but is perfect for development - # since you don't have to restart the web server when you make code changes. - config.enable_reloading = true - - # Do not eager load code on boot. - config.eager_load = false - - # Show full error reports. - config.consider_all_requests_local = true - - # Enable server timing - config.server_timing = true - - # Enable/disable caching. By default caching is disabled. - # Run rails dev:cache to toggle caching. - if Rails.root.join("tmp/caching-dev.txt").exist? - config.action_controller.perform_caching = true - config.action_controller.enable_fragment_cache_logging = true - - config.cache_store = :memory_store - config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{2.days.to_i}" - } - else - config.action_controller.perform_caching = false - - config.cache_store = :null_store - end +module Iqvoc + module Environments + module Development + def self.setup_development(config) + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded any time + # it changes. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.enable_reloading = true + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable server timing + config.server_timing = true - # Store uploaded files on the local file system (see config/storage.yml for options). - config.active_storage.service = :local + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join("tmp/caching-dev.txt").exist? + config.action_controller.perform_caching = true + config.action_controller.enable_fragment_cache_logging = true - # Don't care if the mailer can't send. - config.action_mailer.raise_delivery_errors = false + config.cache_store = :memory_store + config.public_file_server.headers = { + "Cache-Control" => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false - config.action_mailer.perform_caching = false + config.cache_store = :null_store + end - # Print deprecation notices to the Rails logger. - config.active_support.deprecation = :log + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local - # Raise exceptions for disallowed deprecations. - config.active_support.disallowed_deprecation = :raise + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] + config.action_mailer.perform_caching = false - # Raise an error on page load if there are pending migrations. - config.active_record.migration_error = :page_load + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log - # Highlight code that triggered database queries in logs. - config.active_record.verbose_query_logs = true + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise - # Highlight code that enqueued background job in logs. - config.active_job.verbose_enqueue_logs = true + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load - # Raises error for missing translations. - config.i18n.raise_on_missing_translations = true + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true - # Annotate rendered view with file names. - config.action_view.annotate_rendered_view_with_filenames = true + # Highlight code that enqueued background job in logs. + config.active_job.verbose_enqueue_logs = true - # Uncomment if you wish to allow Action Cable access from any origin. - # config.action_cable.disable_request_forgery_protection = true - # Raise error when a before_action's only/except options reference missing actions - config.action_controller.raise_on_missing_callback_actions = true + # Raises error for missing translations. + config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + config.action_view.annotate_rendered_view_with_filenames = true + + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true + + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true + end + end end end diff --git a/lib/iqvoc/environments/production.rb b/lib/iqvoc/environments/production.rb index e91212ab4..f3735ea5b 100644 --- a/lib/iqvoc/environments/production.rb +++ b/lib/iqvoc/environments/production.rb @@ -1,98 +1,102 @@ require "active_support/core_ext/integer/time" require 'iqvoc' -module Iqvoc::Environments - def self.setup_production(config) - # Settings specified here will take precedence over those in config/application.rb. - - # Code is not reloaded between requests. - config.enable_reloading = false - - # Eager load code on boot. This eager loads most of Rails and - # your application in memory, allowing both threaded web servers - # and those relying on copy on write to perform better. - # Rake tasks automatically ignore this option for performance. - config.eager_load = true - - # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false - config.action_controller.perform_caching = true - - # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment - # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files). - # config.require_master_key = true - - # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead. - config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? - config.public_file_server.headers = { - 'Cache-Control' => "public, s-maxage=#{365.days.to_i}, max-age=#{365.days.to_i}, immutable", - 'Expires' => 1.year.from_now.to_formatted_s(:rfc822) - } - - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.asset_host = "http://assets.example.com" - - # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache - # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX - - # Store uploaded files on the local file system (see config/storage.yml for options). - config.active_storage.service = :local - - # Mount Action Cable outside main process or domain. - # config.action_cable.mount_path = nil - # config.action_cable.url = "wss://example.com/cable" - # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] - - # Assume all access to the app is happening through a SSL-terminating reverse proxy. - # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. - # config.assume_ssl = true - - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true - - # Log to STDOUT by default - config.logger = ActiveSupport::Logger.new(STDOUT) - .tap { |logger| logger.formatter = ::Logger::Formatter.new } - .then { |logger| ActiveSupport::TaggedLogging.new(logger) } - - # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] - - # "info" includes generic and useful information about system operation, but avoids logging too much - # information to avoid inadvertent exposure of personally identifiable information (PII). If you - # want to log everything, set the level to "debug". - config.log_level = ENV.fetch("LOG_LEVEL", "info") - - # Use a different cache store in production. - # config.cache_store = :mem_cache_store - - # Use a real queuing backend for Active Job (and separate queues per environment). - # config.active_job.queue_adapter = :resque - # config.active_job.queue_name_prefix = "iqvoc_production" - - config.action_mailer.perform_caching = false - - # Ignore bad email addresses and do not raise email delivery errors. - # Set this to true and configure the email server for immediate delivery to raise delivery errors. - # config.action_mailer.raise_delivery_errors = false - - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation cannot be found). - config.i18n.fallbacks = true - - # Don't log any deprecations. - config.active_support.report_deprecations = false - - # Do not dump schema after migrations. - config.active_record.dump_schema_after_migration = false - - # Enable DNS rebinding protection and other `Host` header attacks. - # config.hosts = [ - # "example.com", # Allow requests from example.com - # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` - # ] - # Skip DNS rebinding protection for the default health check endpoint. - # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } +module Iqvoc + module Environments + module Production + def self.setup_production(config) + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.enable_reloading = false + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment + # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead. + config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? + config.public_file_server.headers = { + 'Cache-Control' => "public, s-maxage=#{365.days.to_i}, max-age=#{365.days.to_i}, immutable", + 'Expires' => 1.year.from_now.to_formatted_s(:rfc822) + } + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.asset_host = "http://assets.example.com" + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache + # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain. + # config.action_cable.mount_path = nil + # config.action_cable.url = "wss://example.com/cable" + # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] + + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. + # config.assume_ssl = true + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Log to STDOUT by default + config.logger = ActiveSupport::Logger.new(STDOUT) + .tap { |logger| logger.formatter = ::Logger::Formatter.new } + .then { |logger| ActiveSupport::TaggedLogging.new(logger) } + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # "info" includes generic and useful information about system operation, but avoids logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). If you + # want to log everything, set the level to "debug". + config.log_level = ENV.fetch("LOG_LEVEL", "info") + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment). + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "iqvoc_production" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Don't log any deprecations. + config.active_support.report_deprecations = false + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false + + # Enable DNS rebinding protection and other `Host` header attacks. + # config.hosts = [ + # "example.com", # Allow requests from example.com + # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` + # ] + # Skip DNS rebinding protection for the default health check endpoint. + # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } + end + end end end diff --git a/lib/iqvoc/environments/test.rb b/lib/iqvoc/environments/test.rb index c00536324..ccbec53db 100644 --- a/lib/iqvoc/environments/test.rb +++ b/lib/iqvoc/environments/test.rb @@ -5,62 +5,66 @@ # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! -module Iqvoc::Environments - def self.setup_test(config) - # Settings specified here will take precedence over those in config/application.rb. +module Iqvoc + module Environments + module Test + def self.setup_test(config) + # Settings specified here will take precedence over those in config/application.rb. - # While tests run files are not watched, reloading is not necessary. - config.enable_reloading = false + # While tests run files are not watched, reloading is not necessary. + config.enable_reloading = false - # Eager loading loads your entire application. When running a single test locally, - # this is usually not necessary, and can slow down your test suite. However, it's - # recommended that you enable it in continuous integration systems to ensure eager - # loading is working properly before deploying your code. - config.eager_load = ENV["CI"].present? + # Eager loading loads your entire application. When running a single test locally, + # this is usually not necessary, and can slow down your test suite. However, it's + # recommended that you enable it in continuous integration systems to ensure eager + # loading is working properly before deploying your code. + config.eager_load = ENV["CI"].present? - # Configure public file server for tests with Cache-Control for performance. - config.public_file_server.enabled = true - config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{1.hour.to_i}" - } + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + "Cache-Control" => "public, max-age=#{1.hour.to_i}" + } - # Show full error reports and disable caching. - config.consider_all_requests_local = true - config.action_controller.perform_caching = false - config.cache_store = :null_store + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + config.cache_store = :null_store - # Render exception templates for rescuable exceptions and raise for other exceptions. - config.action_dispatch.show_exceptions = :rescuable + # Render exception templates for rescuable exceptions and raise for other exceptions. + config.action_dispatch.show_exceptions = :rescuable - # Disable request forgery protection in test environment. - config.action_controller.allow_forgery_protection = false + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false - # Store uploaded files on the local file system in a temporary directory. - config.active_storage.service = :test + # Store uploaded files on the local file system in a temporary directory. + config.active_storage.service = :test - config.action_mailer.perform_caching = false + config.action_mailer.perform_caching = false - # Tell Action Mailer not to deliver emails to the real world. - # The :test delivery method accumulates sent emails in the - # ActionMailer::Base.deliveries array. - config.action_mailer.delivery_method = :test + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test - # Print deprecation notices to the stderr. - config.active_support.deprecation = :stderr + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr - # Raise exceptions for disallowed deprecations. - config.active_support.disallowed_deprecation = :raise + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] - # Raises error for missing translations. - config.i18n.raise_on_missing_translations = true + # Raises error for missing translations. + config.i18n.raise_on_missing_translations = true - # Annotate rendered view with file names. - # config.action_view.annotate_rendered_view_with_filenames = true + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true - # Raise error when a before_action's only/except options reference missing actions - config.action_controller.raise_on_missing_callback_actions = true + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true + end + end end end