Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better helper deprecation messages #184

Merged
merged 15 commits into from
Mar 27, 2024
71 changes: 47 additions & 24 deletions lib/phlex/rails/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ module Phlex::Rails::Helpers
autoload :CSRFMetaTags, "phlex/rails/helpers/csrf_meta_tags"
autoload :CheckBox, "phlex/rails/helpers/check_box"
autoload :CheckBoxTag, "phlex/rails/helpers/check_box_tag"
autoload :Checkbox, "phlex/rails/helpers/check_box" # DEPRECATED
autoload :CheckboxTag, "phlex/rails/helpers/check_box_tag" # DEPRECATED
autoload :ClassNames, "phlex/rails/helpers/class_names"
autoload :CollectionCheckBoxes, "phlex/rails/helpers/collection_check_boxes"
autoload :CollectionCheckboxes, "phlex/rails/helpers/collection_check_boxes" # DEPRECATED
autoload :CollectionRadioButtons, "phlex/rails/helpers/collection_radio_buttons"
autoload :CollectionSelect, "phlex/rails/helpers/collection_select"
autoload :ColorField, "phlex/rails/helpers/color_field"
Expand All @@ -40,11 +37,6 @@ module Phlex::Rails::Helpers
autoload :DateField, "phlex/rails/helpers/date_field"
autoload :DateFieldTag, "phlex/rails/helpers/date_field_tag"
autoload :DateSelect, "phlex/rails/helpers/date_select"
autoload :DateTimeField, "phlex/rails/helpers/datetime_field" # DEPRECATED
autoload :DateTimeFieldTag, "phlex/rails/helpers/datetime_field_tag" # DEPRECATED
autoload :DateTimeLocalField, "phlex/rails/helpers/datetime_local_field" # DEPRECATED
autoload :DateTimeLocalFieldTag, "phlex/rails/helpers/datetime_local_field_tag" # DEPRECATED
autoload :DateTimeSelect, "phlex/rails/helpers/datetime_select" # DEPRECATED
autoload :DatetimeField, "phlex/rails/helpers/datetime_field"
autoload :DatetimeFieldTag, "phlex/rails/helpers/datetime_field_tag"
autoload :DatetimeLocalField, "phlex/rails/helpers/datetime_local_field"
Expand Down Expand Up @@ -83,12 +75,6 @@ module Phlex::Rails::Helpers
autoload :ImageSubmitTag, "phlex/rails/helpers/image_submit_tag"
autoload :ImageTag, "phlex/rails/helpers/image_tag"
autoload :ImageURL, "phlex/rails/helpers/image_url"
autoload :JavaScriptImportMapTags, "phlex/rails/helpers/javascript_importmap_tags" # DEPRECATED
autoload :JavaScriptImportModuleTag, "phlex/rails/helpers/javascript_import_module_tag" # DEPRECATED
autoload :JavaScriptIncludeTag, "phlex/rails/helpers/javascript_include_tag" # DEPRECATED
autoload :JavaScriptPath, "phlex/rails/helpers/javascript_path" # DEPRECATED
autoload :JavaScriptTag, "phlex/rails/helpers/javascript_tag" # DEPRECATED
autoload :JavaScriptURL, "phlex/rails/helpers/javascript_url" # DEPRECATED
autoload :JavascriptImportModuleTag, "phlex/rails/helpers/javascript_import_module_tag"
autoload :JavascriptImportmapTags, "phlex/rails/helpers/javascript_importmap_tags"
autoload :JavascriptIncludeTag, "phlex/rails/helpers/javascript_include_tag"
Expand All @@ -98,7 +84,7 @@ module Phlex::Rails::Helpers
autoload :L, "phlex/rails/helpers/l"
autoload :Label, "phlex/rails/helpers/label"
autoload :LabelTag, "phlex/rails/helpers/label_tag"
autoload :LinkIf, "phlex/rails/helpers/link_to_if" # DEPRECATED
autoload :LinkIf, "phlex/rails/helpers/link_to_if"
autoload :LinkTo, "phlex/rails/helpers/link_to"
autoload :LinkToIf, "phlex/rails/helpers/link_to_if"
autoload :LinkToUnless, "phlex/rails/helpers/link_to_unless"
Expand Down Expand Up @@ -126,9 +112,7 @@ module Phlex::Rails::Helpers
autoload :PathToAudio, "phlex/rails/helpers/path_to_audio"
autoload :PathToFont, "phlex/rails/helpers/path_to_font"
autoload :PathToImage, "phlex/rails/helpers/path_to_image"
autoload :PathToJavaScript, "phlex/rails/helpers/path_to_javascript" # DEPRECATED
autoload :PathToJavascript, "phlex/rails/helpers/path_to_javascript"
autoload :PathToStyleSheet, "phlex/rails/helpers/path_to_stylesheet" # DEPRECATED
autoload :PathToStylesheet, "phlex/rails/helpers/path_to_stylesheet"
autoload :PathToVideo, "phlex/rails/helpers/path_to_video"
autoload :PhoneField, "phlex/rails/helpers/phone_field"
Expand All @@ -149,12 +133,10 @@ module Phlex::Rails::Helpers
autoload :SMSTo, "phlex/rails/helpers/sms_to"
autoload :Sanitize, "phlex/rails/helpers/sanitize"
autoload :SanitizeCSS, "phlex/rails/helpers/sanitize_css"
autoload :SanitizeCss, "phlex/rails/helpers/sanitize_css" # DEPRECATED
autoload :SearchField, "phlex/rails/helpers/search_field"
autoload :SearchFieldTag, "phlex/rails/helpers/search_field_tag"
autoload :Select, "phlex/rails/helpers/select"
autoload :SelectDate, "phlex/rails/helpers/select_date"
autoload :SelectDateTime, "phlex/rails/helpers/select_datetime" # DEPRECATED
autoload :SelectDatetime, "phlex/rails/helpers/select_datetime"
autoload :SelectDay, "phlex/rails/helpers/select_day"
autoload :SelectHour, "phlex/rails/helpers/select_hour"
Expand All @@ -167,9 +149,6 @@ module Phlex::Rails::Helpers
autoload :SimpleFormat, "phlex/rails/helpers/simple_format"
autoload :StripLinks, "phlex/rails/helpers/strip_links"
autoload :StripTags, "phlex/rails/helpers/strip_tags"
autoload :StyleSheetLinkTag, "phlex/rails/helpers/stylesheet_link_tag" # DEPRECATED
autoload :StyleSheetPath, "phlex/rails/helpers/stylesheet_path" # DEPRECATED
autoload :StyleSheetURL, "phlex/rails/helpers/stylesheet_url" # DEPRECATED
autoload :StylesheetLinkTag, "phlex/rails/helpers/stylesheet_link_tag"
autoload :StylesheetPath, "phlex/rails/helpers/stylesheet_path"
autoload :StylesheetURL, "phlex/rails/helpers/stylesheet_url"
Expand Down Expand Up @@ -204,9 +183,7 @@ module Phlex::Rails::Helpers
autoload :URLToAudio, "phlex/rails/helpers/url_to_audio"
autoload :URLToFont, "phlex/rails/helpers/url_to_font"
autoload :URLToImage, "phlex/rails/helpers/url_to_image"
autoload :URLToJavaScript, "phlex/rails/helpers/url_to_javascript" # DEPRECATED
autoload :URLToJavascript, "phlex/rails/helpers/url_to_javascript"
autoload :URLToStyleSheet, "phlex/rails/helpers/url_to_stylesheet" # DEPRECATED
autoload :URLToStylesheet, "phlex/rails/helpers/url_to_stylesheet"
autoload :URLToVideo, "phlex/rails/helpers/url_to_video"
autoload :UTF8EnforcerTag, "phlex/rails/helpers/utf8_enforcer_tag"
Expand All @@ -219,4 +196,50 @@ module Phlex::Rails::Helpers
autoload :WeekdaySelect, "phlex/rails/helpers/weekday_select"
autoload :WithOutputBuffer, "phlex/rails/helpers/with_output_buffer"
autoload :WordWrap, "phlex/rails/helpers/word_wrap"

DEPRECATED = {
Checkbox: :CheckBox,
CheckboxTag: :CheckBoxTag,
CollectionCheckboxes: :CollectionCheckBoxes,
DateTimeField: :DatetimeField,
PathToJavaScript: :PathToJavascript,
DateTimeFieldTag: :DatetimeFieldTag,
DateTimeLocalField: :DatetimeLocalField,
DateTimeLocalFieldTag: :DatetimeLocalFieldTag,
DateTimeSelect: :DatetimeSelect,
JavaScriptImportModuleTag: :JavascriptImportModuleTag,
JavaScriptImportMapTags: :JavascriptImportmapTags,
JavaScriptIncludeTag: :JavascriptIncludeTag,
JavaScriptPath: :JavascriptPath,
JavaScriptTag: :JavascriptTag,
JavaScriptURL: :JavascriptURL,
LinkIf: :LinkToIf,
PathToStyleSheet: :PathToStylesheet,
SanitizeCss: :SanitizeCSS,
SelectDateTime: :SelectDatetime,
StyleSheetLinkTag: :StylesheetLinkTag,
StyleSheetPath: :StylesheetPath,
StyleSheetURL: :StylesheetURL,
URLToJavaScript: :URLToJavascript,
URLToStyleSheet: :URLToStylesheet
}

def self.const_missing(name)
if (helper_module_name = DEPRECATED[name])
message = "[DEPRECATION] `Phlex::Rails::Helpers::#{name}` is deprecated. Please use `Phlex::Rails::Helpers::#{helper_module_name}` instead."

if name.to_s.downcase == helper_module_name.to_s.downcase
message << " Note that the casing of the module name has changed to match with the helper method name."
end

warn message

helper_module = const_get(helper_module_name)
const_set(name, helper_module)

helper_module
else
super
end
end
end
8 changes: 0 additions & 8 deletions lib/phlex/rails/helpers/check_box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,3 @@ module Phlex::Rails::Helpers::CheckBox
# @return [nil]
register_output_helper :check_box
end

module Phlex::Rails::Helpers::Checkbox
include Phlex::Rails::Helpers::CheckBox

def self.included(_)
warn "[DEPRECATION] Phlex::Rails::Helpers::Checkbox is deprecated. Please use Phlex::Rails::Helpers::CheckBox instead."
end
end
8 changes: 0 additions & 8 deletions lib/phlex/rails/helpers/check_box_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,3 @@ module Phlex::Rails::Helpers::CheckBoxTag
# @return [nil]
register_output_helper :check_box_tag
end

module Phlex::Rails::Helpers::CheckboxTag
include Phlex::Rails::Helpers::CheckBoxTag

def self.included(_)
warn "[DEPRECATION] Phlex::Rails::Helpers::CheckboxTag is deprecated. Please use Phlex::Rails::Helpers::CheckBoxTag instead."
end
end
8 changes: 0 additions & 8 deletions lib/phlex/rails/helpers/collection_check_boxes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,3 @@ module Phlex::Rails::Helpers::CollectionCheckBoxes
# @yieldparam builder [Phlex::Rails::BufferedCheckboxBuilder]
register_builder_yielding_helper :collection_check_boxes, Phlex::Rails::BufferedCheckboxBuilder
end

module Phlex::Rails::Helpers::CollectionCheckboxes
include Phlex::Rails::Helpers::CollectionCheckBoxes

def self.included(_)
warn "[DEPRECATION] Phlex::Rails::Helpers::CollectionCheckboxes is deprecated. Please use Phlex::Rails::Helpers::CollectionCheckBoxes instead."
end
end
8 changes: 0 additions & 8 deletions lib/phlex/rails/helpers/datetime_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,3 @@ module Phlex::Rails::Helpers::DatetimeField
# @return [nil]
register_output_helper :datetime_field
end

module Phlex::Rails::Helpers::DateTimeField
include Phlex::Rails::Helpers::DatetimeField

def self.included(_)
warn "[DEPRECATION] Phlex::Rails::Helpers::DateTimeField is deprecated. Please use Phlex::Rails::Helpers::DatetimeField instead."
end
end
8 changes: 0 additions & 8 deletions lib/phlex/rails/helpers/datetime_field_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,3 @@ module Phlex::Rails::Helpers::DatetimeFieldTag
# @return [nil]
register_output_helper :datetime_field_tag
end

module Phlex::Rails::Helpers::DateTimeFieldTag
include Phlex::Rails::Helpers::DatetimeFieldTag

def self.included(_)
warn "[DEPRECATION] Phlex::Rails::Helpers::DateTimeFieldTag is deprecated. Please use Phlex::Rails::Helpers::DatetimeFieldTag instead."
end
end
8 changes: 0 additions & 8 deletions lib/phlex/rails/helpers/datetime_local_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,3 @@ module Phlex::Rails::Helpers::DatetimeLocalField
# @return [nil]
register_output_helper :datetime_local_field
end

module Phlex::Rails::Helpers::DateTimeLocalField
include Phlex::Rails::Helpers::DatetimeLocalField

def self.included(_)
warn "[DEPRECATION] Phlex::Rails::Helpers::DateTimeLocalField is deprecated. Please use Phlex::Rails::Helpers::DatetimeLocalField instead."
end
end
10 changes: 1 addition & 9 deletions lib/phlex/rails/helpers/datetime_local_field_tag.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
# frozen_string_literal: true

module Phlex::Rails::Helpers::DateTimeLocalFieldTag
module Phlex::Rails::Helpers::DatetimeLocalFieldTag
extend Phlex::Rails::HelperMacros

# @!method datetime_local_field_tag(...)
# @return [nil]
register_output_helper :datetime_local_field_tag
end

module Phlex::Rails::Helpers::DateTimeLocalFieldTag
include Phlex::Rails::Helpers::DatetimeLocalFieldTag

def self.included(_)
warn "[DEPRECATION] Phlex::Rails::Helpers::DateTimeLocalFieldTag is deprecated. Please use Phlex::Rails::Helpers::DatetimeLocalFieldTag instead."
end
end
8 changes: 0 additions & 8 deletions lib/phlex/rails/helpers/datetime_select.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,3 @@ module Phlex::Rails::Helpers::DatetimeSelect
# @return [nil]
register_output_helper :datetime_select
end

module Phlex::Rails::Helpers::DateTimeSelect
include Phlex::Rails::Helpers::DatetimeSelect

def self.included(_)
warn "[DEPRECATION] Phlex::Rails::Helpers::DateTimeSelect is deprecated. Please use Phlex::Rails::Helpers::DatetimeSelect instead."
end
end
8 changes: 0 additions & 8 deletions lib/phlex/rails/helpers/javascript_import_module_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,3 @@ module Phlex::Rails::Helpers::JavascriptImportModuleTag
# @return [nil]
register_output_helper :javascript_import_module_tag
end

module Phlex::Rails::Helpers::JavaScriptImportModuleTag
include Phlex::Rails::Helpers::JavascriptImportModuleTag

def self.included(_)
warn "[DEPRECATION] Phlex::Rails::Helpers::JavaScriptImportModuleTag is deprecated. Please use Phlex::Rails::Helpers::JavascriptImportModuleTag instead."
end
end
8 changes: 0 additions & 8 deletions lib/phlex/rails/helpers/javascript_importmap_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,3 @@ module Phlex::Rails::Helpers::JavascriptImportmapTags
# @return [nil]
register_output_helper :javascript_importmap_tags
end

module Phlex::Rails::Helpers::JavaScriptImportMapTags
include Phlex::Rails::Helpers::JavascriptImportmapTags

def self.included(_)
warn "[DEPRECATION] Phlex::Rails::Helpers::JavaScriptImportMapTags is deprecated. Please use Phlex::Rails::Helpers::JavascriptImportmapTags instead."
end
end
8 changes: 0 additions & 8 deletions lib/phlex/rails/helpers/javascript_include_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,3 @@ module Phlex::Rails::Helpers::JavascriptIncludeTag
# @return [nil]
register_output_helper :javascript_include_tag
end

module Phlex::Rails::Helpers::JavaScriptIncludeTag
include Phlex::Rails::Helpers::JavascriptIncludeTag

def self.included(_)
warn "[DEPRECATION] Phlex::Rails::Helpers::JavaScriptIncludeTag is deprecated. Please use Phlex::Rails::Helpers::JavascriptIncludeTag instead."
end
end
8 changes: 0 additions & 8 deletions lib/phlex/rails/helpers/javascript_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,3 @@ module Phlex::Rails::Helpers::JavascriptPath
# @!method javascript_path(...)
register_value_helper :javascript_path
end

module Phlex::Rails::Helpers::JavaScriptPath
include Phlex::Rails::Helpers::JavascriptPath

def self.included(_)
warn "[DEPRECATION] Phlex::Rails::Helpers::JavaScriptPath is deprecated. Please use Phlex::Rails::Helpers::JavascriptPath instead."
end
end
8 changes: 0 additions & 8 deletions lib/phlex/rails/helpers/javascript_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,3 @@ module Phlex::Rails::Helpers::JavascriptTag
# @return [nil]
register_output_helper :javascript_tag
end

module Phlex::Rails::Helpers::JavaScriptTag
include Phlex::Rails::Helpers::JavascriptTag

def self.included(_)
warn "[DEPRECATION] Phlex::Rails::Helpers::JavaScriptTag is deprecated. Please use Phlex::Rails::Helpers::JavascriptTag instead."
end
end
8 changes: 0 additions & 8 deletions lib/phlex/rails/helpers/javascript_url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,3 @@ module Phlex::Rails::Helpers::JavascriptURL
# @!method javascript_url(...)
register_value_helper :javascript_url
end

module Phlex::Rails::Helpers::JavaScriptURL
include Phlex::Rails::Helpers::JavascriptURL

def self.included(_)
warn "[DEPRECATION] Phlex::Rails::Helpers::JavaScriptURL is deprecated. Please use Phlex::Rails::Helpers::JavascriptURL instead."
end
end
8 changes: 0 additions & 8 deletions lib/phlex/rails/helpers/link_to_if.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,3 @@ module Phlex::Rails::Helpers::LinkToIf
# @return [nil]
register_output_helper :link_to_if
end

module Phlex::Rails::Helpers::LinkIf
include Phlex::Rails::Helpers::LinkToIf

def self.included(_)
warn "[DEPRECATION] Phlex::Rails::Helpers::LinkIf is deprecated. Please use Phlex::Rails::Helpers::LinkToIf instead."
end
end
8 changes: 0 additions & 8 deletions lib/phlex/rails/helpers/path_to_javascript.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,3 @@ module Phlex::Rails::Helpers::PathToJavascript
# @!method path_to_javascript(...)
register_value_helper :path_to_javascript
end

module Phlex::Rails::Helpers::PathToJavaScript
include Phlex::Rails::Helpers::PathToJavascript

def self.included(_)
warn "[DEPRECATION] Phlex::Rails::Helpers::PathToJavaScript is deprecated. Please use Phlex::Rails::Helpers::PathToJavascript instead."
end
end
8 changes: 0 additions & 8 deletions lib/phlex/rails/helpers/path_to_stylesheet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,3 @@ module Phlex::Rails::Helpers::PathToStylesheet
# @!method path_to_stylesheet(...)
register_value_helper :path_to_stylesheet
end

module Phlex::Rails::Helpers::PathToStyleSheet
include Phlex::Rails::Helpers::PathToStylesheet

def self.included(_)
warn "[DEPRECATION] Phlex::Rails::Helpers::PathToStyleSheet is deprecated. Please use Phlex::Rails::Helpers::PathToStylesheet instead."
end
end
8 changes: 0 additions & 8 deletions lib/phlex/rails/helpers/sanitize_css.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,3 @@ module Phlex::Rails::Helpers::SanitizeCSS
# @!method sanitize_css(...)
register_value_helper :sanitize_css
end

module Phlex::Rails::Helpers::SanitizeCss
include Phlex::Rails::Helpers::SanitizeCSS

def self.included
warn "Phlex::Rails::Helpers::SanitizeCss is deprecated. Use Phlex::Rails::Helpers::SanitizeCSS instead."
end
end
8 changes: 0 additions & 8 deletions lib/phlex/rails/helpers/select_datetime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,3 @@ module Phlex::Rails::Helpers::SelectDatetime
# @return [nil]
register_output_helper :select_datetime
end

module Phlex::Rails::Helpers::SelectDateTime
include Phlex::Rails::Helpers::SelectDatetime

def self.included(_)
warn "[DEPRECATION] Phlex::Rails::Helpers::SelectDateTime is deprecated. Please use Phlex::Rails::Helpers::SelectDatetime instead."
end
end
8 changes: 0 additions & 8 deletions lib/phlex/rails/helpers/stylesheet_link_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,3 @@ module Phlex::Rails::Helpers::StylesheetLinkTag
# @return [nil]
register_output_helper :stylesheet_link_tag
end

module Phlex::Rails::Helpers::StyleSheetLinkTag
include Phlex::Rails::Helpers::StylesheetLinkTag

def self.included(_)
warn "[DEPRECATION] Phlex::Rails::Helpers::StyleSheetLinkTag is deprecated. Please use Phlex::Rails::Helpers::StylesheetLinkTag instead."
end
end
8 changes: 0 additions & 8 deletions lib/phlex/rails/helpers/stylesheet_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,3 @@ module Phlex::Rails::Helpers::StylesheetPath
# @!method stylesheet_path(...)
register_value_helper :stylesheet_path
end

module Phlex::Rails::Helpers::StyleSheetPath
include Phlex::Rails::Helpers::StyleSheetPath

def self.included(_)
warn "[DEPRECATION] Phlex::Rails::Helpers::StyleSheetPath is deprecated. Please use Phlex::Rails::Helpers::StylesheetPath instead."
end
end
Loading