mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Dogfooding "active_support/core_ext/symbol/starts_ends_with"
Any missing thing would be found such like #39159.
This commit is contained in:
parent
e47df59956
commit
98a1405f07
11 changed files with 25 additions and 15 deletions
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "active_support/core_ext/symbol/starts_ends_with"
|
||||
|
||||
module AbstractController
|
||||
module Translation
|
||||
# Delegates to <tt>I18n.translate</tt>. Also aliased as <tt>t</tt>.
|
||||
|
@ -11,7 +13,7 @@ module AbstractController
|
|||
# to translate many keys within the same controller / action and gives you a
|
||||
# simple framework for scoping them consistently.
|
||||
def translate(key, **options)
|
||||
if key.to_s.start_with?(".")
|
||||
if key.start_with?(".")
|
||||
path = controller_path.tr("/", ".")
|
||||
defaults = [:"#{path}#{key}"]
|
||||
defaults << options[:default] if options[:default]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "singleton"
|
||||
require "active_support/core_ext/symbol/starts_ends_with"
|
||||
|
||||
module Mime
|
||||
class Mimes
|
||||
|
@ -305,7 +306,7 @@ module Mime
|
|||
def to_a; end
|
||||
|
||||
def method_missing(method, *args)
|
||||
if method.to_s.end_with? "?"
|
||||
if method.end_with?("?")
|
||||
method[0..-2].downcase.to_sym == to_sym
|
||||
else
|
||||
super
|
||||
|
@ -313,7 +314,7 @@ module Mime
|
|||
end
|
||||
|
||||
def respond_to_missing?(method, include_private = false)
|
||||
(method.to_s.end_with? "?") || super
|
||||
method.end_with?("?") || super
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -348,11 +349,11 @@ module Mime
|
|||
|
||||
private
|
||||
def respond_to_missing?(method, _)
|
||||
method.to_s.end_with? "?"
|
||||
method.end_with?("?")
|
||||
end
|
||||
|
||||
def method_missing(method, *args)
|
||||
false if method.to_s.end_with? "?"
|
||||
false if method.end_with?("?")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,6 +4,7 @@ require "active_support/core_ext/hash/slice"
|
|||
require "active_support/core_ext/enumerable"
|
||||
require "active_support/core_ext/array/extract_options"
|
||||
require "active_support/core_ext/regexp"
|
||||
require "active_support/core_ext/symbol/starts_ends_with"
|
||||
require "action_dispatch/routing/redirection"
|
||||
require "action_dispatch/routing/endpoint"
|
||||
|
||||
|
@ -355,7 +356,7 @@ module ActionDispatch
|
|||
|
||||
def add_controller_module(controller, modyoule)
|
||||
if modyoule && !controller.is_a?(Regexp)
|
||||
if controller.to_s.start_with?("/")
|
||||
if controller&.start_with?("/")
|
||||
controller[1..-1]
|
||||
else
|
||||
[modyoule, controller].compact.join("/")
|
||||
|
|
|
@ -14,7 +14,7 @@ module ActionDispatch
|
|||
include Rails::Dom::Testing::Assertions
|
||||
|
||||
def html_document
|
||||
@html_document ||= if @response.media_type.to_s.end_with?("xml")
|
||||
@html_document ||= if @response.media_type&.end_with?("xml")
|
||||
Nokogiri::XML::Document.parse(@response.body)
|
||||
else
|
||||
Nokogiri::HTML::Document.parse(@response.body)
|
||||
|
|
|
@ -2162,6 +2162,7 @@ module ActionView
|
|||
|
||||
case record_name
|
||||
when String, Symbol
|
||||
record_name = record_name.to_s
|
||||
if nested_attributes_association?(record_name)
|
||||
return fields_for_with_nested_attributes(record_name, record_object, fields_options, block)
|
||||
end
|
||||
|
@ -2180,8 +2181,8 @@ module ActionView
|
|||
|
||||
record_name = if index
|
||||
"#{object_name}[#{index}][#{record_name}]"
|
||||
elsif record_name.to_s.end_with?("[]")
|
||||
record_name = record_name.to_s.sub(/(.*)\[\]$/, "[\\1][#{record_object.id}]")
|
||||
elsif record_name.end_with?("[]")
|
||||
record_name = record_name.sub(/(.*)\[\]$/, "[\\1][#{record_object.id}]")
|
||||
"#{object_name}#{record_name}"
|
||||
else
|
||||
"#{object_name}[#{record_name}]"
|
||||
|
|
|
@ -4,6 +4,7 @@ require "cgi"
|
|||
require "action_view/helpers/tag_helper"
|
||||
require "active_support/core_ext/string/output_safety"
|
||||
require "active_support/core_ext/module/attribute_accessors"
|
||||
require "active_support/core_ext/symbol/starts_ends_with"
|
||||
|
||||
module ActionView
|
||||
# = Action View Form Tag Helpers
|
||||
|
@ -134,7 +135,7 @@ module ActionView
|
|||
# # <option selected="selected">MasterCard</option></select>
|
||||
def select_tag(name, option_tags = nil, options = {})
|
||||
option_tags ||= ""
|
||||
html_name = (options[:multiple] == true && !name.to_s.end_with?("[]")) ? "#{name}[]" : name
|
||||
html_name = (options[:multiple] == true && !name.end_with?("[]")) ? "#{name}[]" : name
|
||||
|
||||
if options.include?(:include_blank)
|
||||
include_blank = options[:include_blank]
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
require "cases/helper"
|
||||
require "models/developer"
|
||||
require "models/computer"
|
||||
require "active_support/core_ext/symbol/starts_ends_with"
|
||||
|
||||
class CallbackDeveloper < ActiveRecord::Base
|
||||
self.table_name = "developers"
|
||||
|
@ -29,7 +30,7 @@ class CallbackDeveloper < ActiveRecord::Base
|
|||
end
|
||||
|
||||
ActiveRecord::Callbacks::CALLBACKS.each do |callback_method|
|
||||
next if callback_method.to_s.start_with?("around_")
|
||||
next if callback_method.start_with?("around_")
|
||||
define_callback_method(callback_method)
|
||||
send(callback_method, callback_proc(callback_method))
|
||||
send(callback_method, callback_object(callback_method))
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
require "cases/helper"
|
||||
require "models/post"
|
||||
require "models/comment"
|
||||
require "active_support/core_ext/symbol/starts_ends_with"
|
||||
|
||||
module ActiveRecord
|
||||
module DelegationTests
|
||||
|
@ -50,7 +51,7 @@ module ActiveRecord
|
|||
ActiveRecord::FinderMethods.public_instance_methods(false) - [:raise_record_not_found_exception!] +
|
||||
ActiveRecord::SpawnMethods.public_instance_methods(false) - [:spawn, :merge!] +
|
||||
ActiveRecord::QueryMethods.public_instance_methods(false).reject { |method|
|
||||
method.to_s.end_with?("=", "!", "value", "values", "clause")
|
||||
method.end_with?("=", "!", "value", "values", "clause")
|
||||
} - [:reverse_order, :arel, :extensions, :construct_join_dependency] + [
|
||||
:any?, :many?, :none?, :one?,
|
||||
:first_or_create, :first_or_create!, :first_or_initialize,
|
||||
|
|
|
@ -148,7 +148,7 @@ module ActiveSupport
|
|||
|
||||
normalized_gem_paths = Gem.path.map { |path| File.join path, "" }
|
||||
dtw = dtw.reject do |path|
|
||||
normalized_gem_paths.any? { |gem_path| path.to_s.start_with?(gem_path) }
|
||||
normalized_gem_paths.any? { |gem_path| path.to_path.start_with?(gem_path) }
|
||||
end
|
||||
|
||||
@ph.filter_out_descendants(dtw)
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "active_support/core_ext/hash/deep_merge"
|
||||
require "active_support/core_ext/symbol/starts_ends_with"
|
||||
|
||||
module ActiveSupport
|
||||
class OptionMerger #:nodoc:
|
||||
instance_methods.each do |method|
|
||||
undef_method(method) unless method.to_s.start_with?("__", "instance_eval", "class", "object_id")
|
||||
undef_method(method) unless method.start_with?("__", "instance_eval", "class", "object_id")
|
||||
end
|
||||
|
||||
def initialize(context, options)
|
||||
|
|
|
@ -5,6 +5,7 @@ require "action_dispatch"
|
|||
require "rails"
|
||||
require "active_support/deprecation"
|
||||
require "active_support/core_ext/string/filters"
|
||||
require "active_support/core_ext/symbol/starts_ends_with"
|
||||
require "rails/dev_caching"
|
||||
require "rails/command/environment_argument"
|
||||
|
||||
|
@ -178,7 +179,7 @@ module Rails
|
|||
# ["-p3001", "-C", "--binding", "127.0.0.1"] # => {"-p"=>true, "-C"=>true, "--binding"=>true}
|
||||
user_flag = {}
|
||||
@original_options.each do |command|
|
||||
if command.to_s.start_with?("--")
|
||||
if command.start_with?("--")
|
||||
option = command.split("=")[0]
|
||||
user_flag[option] = true
|
||||
elsif command =~ /\A(-.)/
|
||||
|
|
Loading…
Reference in a new issue