diff --git a/gems/activesupport/6.0/_test/test.rb b/gems/activesupport/6.0/_test/test.rb index 392495a4..4f8d2c69 100644 --- a/gems/activesupport/6.0/_test/test.rb +++ b/gems/activesupport/6.0/_test/test.rb @@ -42,6 +42,15 @@ class TestAttrInternal attr_internal_writer 'internal_variable_accessor_2' end +"yukihiro_matz".constantize +"yukihiro_matz".safe_constantize +"string_ending_with_id".titleize(keep_id_suffix: true).titleize +"::Net::HTTP".deconstantize.demodulize +"Donald E. Knuth".parameterize(separator: ":", preserve_case: true, locale: :en).parameterize +"ham_and_egg".tableize.classify +"author_id".humanize(capitalize: false, keep_id_suffix: true).humanize +"iD".upcase_first +"User".foreign_key(false).foreign_key "yukihiro_matz".camelize.underscore.dasherize "rabbit".pluralize.singularize "rabbit".pluralize(2).pluralize(:en).pluralize(2, :en) diff --git a/gems/activesupport/6.0/activesupport-generated.rbs b/gems/activesupport/6.0/activesupport-generated.rbs index 7624bfa2..dc615fab 100644 --- a/gems/activesupport/6.0/activesupport-generated.rbs +++ b/gems/activesupport/6.0/activesupport-generated.rbs @@ -5263,156 +5263,6 @@ class String def indent: (untyped amount, ?untyped? indent_string, ?bool indent_empty_lines) -> untyped end -# String inflections define new methods on the String class to transform names for different purposes. -# For instance, you can figure out the name of a table from the name of a class. -# -# 'ScaleScore'.tableize # => "scale_scores" -# -class String - # +constantize+ tries to find a declared constant with the name specified - # in the string. It raises a NameError when the name is not in CamelCase - # or is not initialized. See ActiveSupport::Inflector.constantize - # - # 'Module'.constantize # => Module - # 'Class'.constantize # => Class - # 'blargle'.constantize # => NameError: wrong constant name blargle - def constantize: () -> untyped - - # +safe_constantize+ tries to find a declared constant with the name specified - # in the string. It returns +nil+ when the name is not in CamelCase - # or is not initialized. See ActiveSupport::Inflector.safe_constantize - # - # 'Module'.safe_constantize # => Module - # 'Class'.safe_constantize # => Class - # 'blargle'.safe_constantize # => nil - def safe_constantize: () -> untyped - - alias camelcase camelize - - # Capitalizes all the words and replaces some characters in the string to create - # a nicer looking title. +titleize+ is meant for creating pretty output. It is not - # used in the Rails internals. - # - # The trailing '_id','Id'.. can be kept and capitalized by setting the - # optional parameter +keep_id_suffix+ to true. - # By default, this parameter is false. - # - # +titleize+ is also aliased as +titlecase+. - # - # 'man from the boondocks'.titleize # => "Man From The Boondocks" - # 'x-men: the last stand'.titleize # => "X Men: The Last Stand" - # 'string_ending_with_id'.titleize(keep_id_suffix: true) # => "String Ending With Id" - def titleize: (?keep_id_suffix: bool keep_id_suffix) -> untyped - - alias titlecase titleize - - # Removes the module part from the constant expression in the string. - # - # 'ActiveSupport::Inflector::Inflections'.demodulize # => "Inflections" - # 'Inflections'.demodulize # => "Inflections" - # '::Inflections'.demodulize # => "Inflections" - # ''.demodulize # => '' - # - # See also +deconstantize+. - def demodulize: () -> untyped - - # Removes the rightmost segment from the constant expression in the string. - # - # 'Net::HTTP'.deconstantize # => "Net" - # '::Net::HTTP'.deconstantize # => "::Net" - # 'String'.deconstantize # => "" - # '::String'.deconstantize # => "" - # ''.deconstantize # => "" - # - # See also +demodulize+. - def deconstantize: () -> untyped - - # Replaces special characters in a string so that it may be used as part of a 'pretty' URL. - # - # If the optional parameter +locale+ is specified, - # the word will be parameterized as a word of that language. - # By default, this parameter is set to nil and it will use - # the configured I18n.locale. - # - # class Person - # def to_param - # "#{id}-#{name.parameterize}" - # end - # end - # - # @person = Person.find(1) - # # => # - # - # <%= link_to(@person.name, person_path) %> - # # => Donald E. Knuth - # - # To preserve the case of the characters in a string, use the +preserve_case+ argument. - # - # class Person - # def to_param - # "#{id}-#{name.parameterize(preserve_case: true)}" - # end - # end - # - # @person = Person.find(1) - # # => # - # - # <%= link_to(@person.name, person_path) %> - # # => Donald E. Knuth - def parameterize: (?locale: untyped? locale, ?preserve_case: bool preserve_case, ?separator: ::String separator) -> untyped - - # Creates the name of a table like Rails does for models to table names. This method - # uses the +pluralize+ method on the last word in the string. - # - # 'RawScaledScorer'.tableize # => "raw_scaled_scorers" - # 'ham_and_egg'.tableize # => "ham_and_eggs" - # 'fancyCategory'.tableize # => "fancy_categories" - def tableize: () -> untyped - - # Creates a class name from a plural table name like Rails does for table names to models. - # Note that this returns a string and not a class. (To convert to an actual class - # follow +classify+ with +constantize+.) - # - # 'ham_and_eggs'.classify # => "HamAndEgg" - # 'posts'.classify # => "Post" - def classify: () -> untyped - - # Capitalizes the first word, turns underscores into spaces, and (by default)strips a - # trailing '_id' if present. - # Like +titleize+, this is meant for creating pretty output. - # - # The capitalization of the first word can be turned off by setting the - # optional parameter +capitalize+ to false. - # By default, this parameter is true. - # - # The trailing '_id' can be kept and capitalized by setting the - # optional parameter +keep_id_suffix+ to true. - # By default, this parameter is false. - # - # 'employee_salary'.humanize # => "Employee salary" - # 'author_id'.humanize # => "Author" - # 'author_id'.humanize(capitalize: false) # => "author" - # '_id'.humanize # => "Id" - # 'author_id'.humanize(keep_id_suffix: true) # => "Author Id" - def humanize: (?keep_id_suffix: bool keep_id_suffix, ?capitalize: bool capitalize) -> untyped - - # Converts just the first character to uppercase. - # - # 'what a Lovely Day'.upcase_first # => "What a Lovely Day" - # 'w'.upcase_first # => "W" - # ''.upcase_first # => "" - def upcase_first: () -> untyped - - # Creates a foreign key name from a class name. - # +separate_class_name_and_id_with_underscore+ sets whether - # the method should put '_' between the name and 'id'. - # - # 'Message'.foreign_key # => "message_id" - # 'Message'.foreign_key(false) # => "messageid" - # 'Admin::Post'.foreign_key # => "post_id" - def foreign_key: (?bool separate_class_name_and_id_with_underscore) -> untyped -end - class String # Wraps the current string in the ActiveSupport::StringInquirer class, # which gives you a prettier way to test for equality. diff --git a/gems/activesupport/6.0/activesupport.rbs b/gems/activesupport/6.0/activesupport.rbs index aa028bab..91b8fe95 100644 --- a/gems/activesupport/6.0/activesupport.rbs +++ b/gems/activesupport/6.0/activesupport.rbs @@ -392,10 +392,23 @@ end class String def camelize: (?Symbol first_letter) -> String + alias camelcase camelize def underscore: () -> String def dasherize: () -> String def pluralize: (?Integer | Symbol? count, ?Symbol locale) -> String def singularize: (?Symbol locale) -> String + def constantize: () -> untyped + def safe_constantize: () -> untyped + def titleize: (?keep_id_suffix: boolish) -> String + alias titlecase titleize + def demodulize: () -> String + def deconstantize: () -> String + def parameterize: (?separator: String, ?preserve_case: boolish, ?locale: Symbol) -> String + def tableize: () -> String + def classify: () -> String + def humanize: (?capitalize: boolish, ?keep_id_suffix: boolish) -> String + def upcase_first: () -> String + def foreign_key: (?boolish separate_class_name_and_id_with_underscore) -> String end module ActiveSupport diff --git a/gems/activesupport/7.0/_test/test.rb b/gems/activesupport/7.0/_test/test.rb index 1c5354b0..d77e2c4f 100644 --- a/gems/activesupport/7.0/_test/test.rb +++ b/gems/activesupport/7.0/_test/test.rb @@ -17,3 +17,5 @@ nil.try(:tap) { |n| p n } nil.try { p 'hello' } nil.try { |n| p n } + +"Id".downcase_first diff --git a/gems/activesupport/7.0/activesupport-7.0.rbs b/gems/activesupport/7.0/activesupport-7.0.rbs index b3ce4444..702386a0 100644 --- a/gems/activesupport/7.0/activesupport-7.0.rbs +++ b/gems/activesupport/7.0/activesupport-7.0.rbs @@ -89,3 +89,8 @@ class Array[unchecked out Elem] # # => [1, 2, true] def compact_blank!: () -> Array[Elem] end + +# active_support/core_ext/string/inflections.rb +class String + def downcase_first: () -> String +end