From f39a4d7d9f4e31d46bb352e01d7c2a2fc400a897 Mon Sep 17 00:00:00 2001 From: Jared White Date: Sat, 2 Nov 2024 23:14:42 -0700 Subject: [PATCH] Clean up some TODOs, weed out some Error classes --- bridgetown-core/lib/bridgetown-core.rb | 3 +-- .../lib/bridgetown-core/commands/build.rb | 7 +------ .../lib/bridgetown-core/concerns/site/ssr.rb | 1 - bridgetown-core/lib/bridgetown-core/drops/drop.rb | 15 ++++++--------- bridgetown-core/lib/bridgetown-core/errors.rb | 10 ++-------- bridgetown-core/lib/bridgetown-core/filters.rb | 2 +- bridgetown-core/lib/bridgetown-core/hooks.rb | 1 - .../lib/bridgetown-core/resource/base.rb | 6 +----- .../lib/bridgetown-core/ruby_template_view.rb | 1 - .../lib/bridgetown-core/tags/post_url.rb | 2 +- .../bridgetown/foundation/refine_ext/object.rb | 2 +- .../bridgetown/foundation/refine_ext/string.rb | 2 +- bridgetown-website/README.md | 3 --- 13 files changed, 15 insertions(+), 40 deletions(-) delete mode 100644 bridgetown-website/README.md diff --git a/bridgetown-core/lib/bridgetown-core.rb b/bridgetown-core/lib/bridgetown-core.rb index ee12adcd0..3a9dba1de 100644 --- a/bridgetown-core/lib/bridgetown-core.rb +++ b/bridgetown-core/lib/bridgetown-core.rb @@ -35,7 +35,7 @@ def require_all(path) require "bridgetown-foundation" # 3rd party -require "active_support" # TODO: remove by the end of 2024 +require "active_support" # TODO: remove by the end of 2025 require "active_support/core_ext/object/blank" require "active_support/core_ext/string/inflections" require "active_support/core_ext/string/output_safety" @@ -76,7 +76,6 @@ module Bridgetown autoload :DefaultsReader, "bridgetown-core/readers/defaults_reader" autoload :Deprecator, "bridgetown-core/deprecator" autoload :EntryFilter, "bridgetown-core/entry_filter" - # TODO: we have too many errors! This is silly autoload :Errors, "bridgetown-core/errors" autoload :FrontMatter, "bridgetown-core/front_matter" autoload :GeneratedPage, "bridgetown-core/generated_page" diff --git a/bridgetown-core/lib/bridgetown-core/commands/build.rb b/bridgetown-core/lib/bridgetown-core/commands/build.rb index bf1ca2b27..d6d80243a 100644 --- a/bridgetown-core/lib/bridgetown-core/commands/build.rb +++ b/bridgetown-core/lib/bridgetown-core/commands/build.rb @@ -66,11 +66,7 @@ def build build_site(config_options) end - # TODO: remove this logic…I can't find "detach" anywhere - if config_options.fetch("detach", false) - Bridgetown.logger.info "Auto-regeneration:", - "disabled when running server detached." - elsif config_options.fetch("watch", false) + if config_options.fetch("watch", false) watch_site(config_options) else Bridgetown.logger.info "Auto-regeneration:", "disabled. Use --watch to enable." @@ -111,7 +107,6 @@ def display_folder_paths(config_options) Bridgetown.logger.info "Environment:", Bridgetown.environment.cyan Bridgetown.logger.info "Source:", source Bridgetown.logger.info "Destination:", destination - # TODO: work with arrays return unless config_options["plugins_dir"].is_a?(String) plugins_dir = File.expand_path(config_options["plugins_dir"]) diff --git a/bridgetown-core/lib/bridgetown-core/concerns/site/ssr.rb b/bridgetown-core/lib/bridgetown-core/concerns/site/ssr.rb index d853b4d97..305ace24e 100644 --- a/bridgetown-core/lib/bridgetown-core/concerns/site/ssr.rb +++ b/bridgetown-core/lib/bridgetown-core/concerns/site/ssr.rb @@ -45,7 +45,6 @@ def ssr_setup(&block) end def ssr_first_read - # TODO: this shouldn't be running twice, right?! Bridgetown::Hooks.trigger :site, :pre_read, self defaults_reader.tap do |d| d.path_defaults.clear diff --git a/bridgetown-core/lib/bridgetown-core/drops/drop.rb b/bridgetown-core/lib/bridgetown-core/drops/drop.rb index 0993a4e73..4b49a573d 100644 --- a/bridgetown-core/lib/bridgetown-core/drops/drop.rb +++ b/bridgetown-core/lib/bridgetown-core/drops/drop.rb @@ -49,25 +49,22 @@ def [](key) end alias_method :invoke_drop, :[] - # Set a field in the Drop. If mutable, sets in the mutations and - # returns. If not mutable, checks first if it's trying to override a - # Drop method and raises a DropMutationException if so. If not - # mutable and the key is not a method on the Drop, then it sets the - # key to the value in the underlying hash (e.g. document front - # matter) + # Set a field in the Drop. If mutable, sets in the mutations and returns. If not mutable, + # checks first if it's trying to override a Drop method and raises an exception if so. + # If not mutable and the key is not a method on the Drop, then it sets the key to the value + # in the underlying hash (e.g. document front matter) # # @param key [String] key whose value to set # @param val [Object] what to set the key's value to # @return [Object] the value the key was set to unless the Drop is not mutable - # and the key matches a method in which case it raises a - # DropMutationException. + # and the key matches a method in which case it raises an exception def []=(key, val) setter = "#{key}=" if respond_to?(setter) public_send(setter, val) elsif respond_to?(key.to_s) unless self.class.mutable? - raise Errors::DropMutationException, "Key #{key} cannot be set in the drop." + raise Errors::FatalException, "Key #{key} cannot be set in the drop." end mutations[key] = val diff --git a/bridgetown-core/lib/bridgetown-core/errors.rb b/bridgetown-core/lib/bridgetown-core/errors.rb index 2823e4c40..0ad078e6a 100644 --- a/bridgetown-core/lib/bridgetown-core/errors.rb +++ b/bridgetown-core/lib/bridgetown-core/errors.rb @@ -4,16 +4,10 @@ module Bridgetown module Errors FatalException = Class.new(::RuntimeError) - DropMutationException = Class.new(FatalException) - InvalidPermalinkError = Class.new(FatalException) - InvalidYAMLFrontMatterError = Class.new(FatalException) - MissingDependencyException = Class.new(FatalException) - + InvalidConfigurationError = Class.new(FatalException) InvalidDateError = Class.new(FatalException) - InvalidPostNameError = Class.new(FatalException) + InvalidYAMLFrontMatterError = Class.new(FatalException) PostURLError = Class.new(FatalException) - InvalidURLError = Class.new(FatalException) - InvalidConfigurationError = Class.new(FatalException) def self.print_build_error(exc, trace: false, logger: Bridgetown.logger, server: false) # rubocop:todo Metrics logger.error "Exception raised:", exc.class.to_s.bold diff --git a/bridgetown-core/lib/bridgetown-core/filters.rb b/bridgetown-core/lib/bridgetown-core/filters.rb index 1c03388be..83b4d86fc 100644 --- a/bridgetown-core/lib/bridgetown-core/filters.rb +++ b/bridgetown-core/lib/bridgetown-core/filters.rb @@ -192,7 +192,7 @@ def where(input, property, value) # rubocop:disable Metrics/CyclomaticComplexity def where_exp(input, variable, expression) return input unless input.respond_to?(:select) - input = input.values if input.is_a?(Hash) # FIXME + input = input.values if input.is_a?(Hash) condition = parse_condition(expression) @context.stack do diff --git a/bridgetown-core/lib/bridgetown-core/hooks.rb b/bridgetown-core/lib/bridgetown-core/hooks.rb index e198f9226..4d0a2da98 100644 --- a/bridgetown-core/lib/bridgetown-core/hooks.rb +++ b/bridgetown-core/lib/bridgetown-core/hooks.rb @@ -25,7 +25,6 @@ def to_s @registry = {} - NotAvailable = Class.new(RuntimeError) Uncallable = Class.new(RuntimeError) def self.priority_value(priority) diff --git a/bridgetown-core/lib/bridgetown-core/resource/base.rb b/bridgetown-core/lib/bridgetown-core/resource/base.rb index e9457b7a9..6502dc34f 100644 --- a/bridgetown-core/lib/bridgetown-core/resource/base.rb +++ b/bridgetown-core/lib/bridgetown-core/resource/base.rb @@ -106,11 +106,7 @@ def data # # @param new_data [HashWithDotAccess::Hash] def data=(new_data) - if site.config.fast_refresh && write? - # TODO: investigate if this would be better: - # @data.value = front_matter_defaults - mark_for_fast_refresh! - end + mark_for_fast_refresh! if site.config.fast_refresh && write? Signalize.batch do @content_signal.value += 1 diff --git a/bridgetown-core/lib/bridgetown-core/ruby_template_view.rb b/bridgetown-core/lib/bridgetown-core/ruby_template_view.rb index 747b1a1a5..76e0cf463 100644 --- a/bridgetown-core/lib/bridgetown-core/ruby_template_view.rb +++ b/bridgetown-core/lib/bridgetown-core/ruby_template_view.rb @@ -131,7 +131,6 @@ def _liquid_context def _partial_path(partial_name, ext) partial_name = partial_name.split("/").tap { _1.last.prepend("_") }.join("/") - # TODO: see if there's a workaround for this to speed up performance site.in_source_dir(site.config[:partials_dir], "#{partial_name}.#{ext}") end end diff --git a/bridgetown-core/lib/bridgetown-core/tags/post_url.rb b/bridgetown-core/lib/bridgetown-core/tags/post_url.rb index e6ab658a9..95012d64e 100644 --- a/bridgetown-core/lib/bridgetown-core/tags/post_url.rb +++ b/bridgetown-core/lib/bridgetown-core/tags/post_url.rb @@ -12,7 +12,7 @@ def initialize(name) all, @path, @date, @slug = *name.sub(%r!^/!, "").match(MATCHER) unless all - raise Bridgetown::Errors::InvalidPostNameError, + raise Bridgetown::Errors::FatalException, "'#{name}' does not contain valid date and/or title." end diff --git a/bridgetown-foundation/lib/bridgetown/foundation/refine_ext/object.rb b/bridgetown-foundation/lib/bridgetown/foundation/refine_ext/object.rb index ac54c889f..a4ed8a2b5 100644 --- a/bridgetown-foundation/lib/bridgetown/foundation/refine_ext/object.rb +++ b/bridgetown-foundation/lib/bridgetown/foundation/refine_ext/object.rb @@ -54,7 +54,7 @@ def within?(other) # rubocop:disable Metrics # NOTE: if you _really_ need to preserve Active Support's `in?` functionality, you can just # require "active_support/core_ext/object/inclusion" def in?(...) = Bridgetown::Foundation.deprecation_warning( - self, :in?, :within?, 2024, 12 + self, :in?, :within?, 2025, 12 ).then { within?(...) } end end diff --git a/bridgetown-foundation/lib/bridgetown/foundation/refine_ext/string.rb b/bridgetown-foundation/lib/bridgetown/foundation/refine_ext/string.rb index bf9450b4d..c7135fe94 100644 --- a/bridgetown-foundation/lib/bridgetown/foundation/refine_ext/string.rb +++ b/bridgetown-foundation/lib/bridgetown/foundation/refine_ext/string.rb @@ -23,7 +23,7 @@ def indent(indent_by, *args) def questionable = Bridgetown::Foundation::QuestionableString.new(self) def inquiry = Bridgetown::Foundation.deprecation_warning( - self, :inquiry, :questionable, 2024, 12 + self, :inquiry, :questionable, 2025, 12 ).then { questionable } end end diff --git a/bridgetown-website/README.md b/bridgetown-website/README.md deleted file mode 100644 index 59525c4ab..000000000 --- a/bridgetown-website/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# New 2021 Website for Bridgetown - -TODO: build and launch a new website for Bridgetown! =)