aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/string
Commit message (Collapse)AuthorAgeFilesLines
* Add missing requireAkira Matsuda2013-07-111-0/+1
|
* Better not mutate the given options HashAkira Matsuda2013-07-101-3/+3
|
* Speed up String#truncateAkira Matsuda2013-07-101-1/+1
| | | | | | | Benchmark: user system total real old 1.550000 0.040000 1.590000 ( 1.585866) new 1.250000 0.040000 1.290000 ( 1.287693)
* Speedup String#toAkira Matsuda2013-07-101-1/+1
| | | | | | | | Benchmark: 1000000.times { str.to(30) } user system total real old 0.490000 0.110000 0.600000 ( 0.607374) new 0.390000 0.000000 0.390000 ( 0.387306)
* Remove deprecated `String#encoding_aware?` Arun Agrawal2013-07-031-8/+0
| | | core extensions (`core_ext/string/encoding`).
* Revert "Merge pull request #10600 from aditya-kapoor/code_refactor"Rafael Mendonça França2013-05-151-9/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 8ce3c1e5dde9fb180813e4d89324db03da110b13, reversing changes made to f93da579ce7f77dbd58b9a2165861aee265b8c93. Reason: It slow down the running time. require "diffbench" load 'output_safety.rb' N = 10000 b = ActiveSupport::SafeBuffer.new("hello world") DiffBench.bm do report "capitalize in safe buffer" do N.times do b.capitalize end end end > git checkout 069ea45; diffbench bench.rb; diffbench bench.rb;diffbench bench.rb;diffbench bench.rb;diffbench bench.rb;diffbench bench.rb;diffbench bench.rb; Running benchmark with current working tree Checkout HEAD^ Running benchmark with HEAD^ Checkout to previous HEAD again user system total real ----------------------------------capitalize in safe buffer After patch: 0.010000 0.000000 0.010000 ( 0.009733) Before patch: 0.010000 0.000000 0.010000 ( 0.007702) Improvement: -26% Running benchmark with current working tree Checkout HEAD^ Running benchmark with HEAD^ Checkout to previous HEAD again user system total real ----------------------------------capitalize in safe buffer After patch: 0.010000 0.000000 0.010000 ( 0.009768) Before patch: 0.010000 0.000000 0.010000 ( 0.007896) Improvement: -24% Running benchmark with current working tree Checkout HEAD^ Running benchmark with HEAD^ Checkout to previous HEAD again user system total real ----------------------------------capitalize in safe buffer After patch: 0.010000 0.000000 0.010000 ( 0.009938) Before patch: 0.010000 0.000000 0.010000 ( 0.007768) Improvement: -28% Running benchmark with current working tree Checkout HEAD^ Running benchmark with HEAD^ Checkout to previous HEAD again user system total real ----------------------------------capitalize in safe buffer After patch: 0.010000 0.000000 0.010000 ( 0.010001) Before patch: 0.010000 0.000000 0.010000 ( 0.007873) Improvement: -27% Running benchmark with current working tree Checkout HEAD^ Running benchmark with HEAD^ Checkout to previous HEAD again user system total real ----------------------------------capitalize in safe buffer After patch: 0.010000 0.000000 0.010000 ( 0.009670) Before patch: 0.010000 0.000000 0.010000 ( 0.007800) Improvement: -24% Running benchmark with current working tree Checkout HEAD^ Running benchmark with HEAD^ Checkout to previous HEAD again user system total real ----------------------------------capitalize in safe buffer After patch: 0.010000 0.000000 0.010000 ( 0.009949) Before patch: 0.010000 0.000000 0.010000 ( 0.007752) Improvement: -28%
* Added a blank space and removed to_symaditya-kapoor2013-05-141-4/+5
|
* Removed Class Eval and used define_method instead for the SafeBufferaditya-kapoor2013-05-141-12/+9
|
* Changed spelling of Busines to Businessaditya-kapoor2013-05-081-1/+1
|
* document String#to_time exceptionVipul A M2013-05-021-0/+1
|
* Adjust for daylight savings in String#to_timeAndrew White2013-04-231-8/+6
| | | | | | | | | | | | | | | The changes in b79adc4323 had a bug where if the time in the String was in standard time but the current time was in daylight savings then the calculated adjustment was off by an hour. This commit fixes this and adds extra tests for the following: * time in string is standard time, current time is standard time * time in string is standard time, current time is daylight savings * time in string is daylight savings, current time is standard time * time in string is daylight savings, current time is daylight savings Fixes #10306.
* interpolate instead of string concatVipul A M2013-04-151-1/+1
|
* Corrected paramter to parameterCarson McDonald2013-04-131-1/+1
|
* Revert "Merge pull request #10158 from steveklabnik/issue_10125"Rafael Mendonça França2013-04-101-2/+2
| | | | | | | | This reverts commit fa3ef8e82ab2f96cf15ef9bc885b2468fad77621, reversing changes made to e0af93dd3a5eeee2e2a67b05f34afb66cc80c00b. Reason: Routes, Active Record and the rendering stack should not depend on the default locale
* Fix inflector to respect default locale.Nick Cox2013-04-101-2/+2
| | | | | | | | The inflector was made aware of locales in 7db0b073fec6bc3e6f213b58c76e7f43fcc2ab97, but it defaulted to :en. That should actually be our default locale instead. Fixes #10125
* `fast_xs` support has been removed. Use 'String#encode(xml: :attr)`.Aaron Patterson2013-04-051-18/+0
|
* fix some typos in ASVipul A M2013-03-301-1/+1
|
* Call String#gsub with Hash directlyAman Gupta2013-03-041-2/+2
|
* no need for \Z, \z is more conciseXavier Noria2013-01-281-1/+1
|
* Improve String#squish whitespaces matchingAntoine Lyset2013-01-221-2/+5
|
* Use `DateTime.parse` inside `String#to_datetime`Andrew White2013-01-211-8/+1
| | | | | | | | | | Use the standard library's `DateTime.parse` because it's marginally faster and supports partial date/time strings. Benchmark: user system total real old 3.980000 0.000000 3.980000 ( 3.987606) new 3.640000 0.010000 3.650000 ( 3.641342)
* Standardise the return value of `to_time`Andrew White2013-01-211-17/+27
| | | | | | | | | | | | | | | | | | | | | | This commit standardises the return value of `to_time` to an instance of `Time` in the local system timezone, matching the Ruby core and standard library behavior. The default form for `String#to_time` has been changed from :utc to :local but research seems to suggest the latter is the more common form. Also fix an edge condition with `String#to_time` where the string has a timezone offset in it and the mode is :local. e.g: # Before: >> "2000-01-01 00:00:00 -0500".to_time(:local) => 2000-01-01 05:00:00 -0500 # After: >> "2000-01-01 00:00:00 -0500".to_time(:local) => 2000-01-01 00:00:00 -0500 Closes #2453
* Better error message for String#to_dateKelly Stannard2013-01-041-5/+1
| | | | | | | | | | I did this because to_date gives a very unhelpful error message if you do not pass in a correct date. In the process I think this cleans up the code nicely and even better it tends to be slightly faster than the current implementation. Benchmark https://gist.github.com/4440875
* Merge pull request #8560 from u16suzu/masterRafael Mendonça França2012-12-201-2/+2
|\ | | | | | | | | | | | | Fix document for String#humanize Conflicts: activesupport/lib/active_support/core_ext/string/inflections.rb
| * Fix: documentation for String#humanizeYuichiro Suzuki2012-12-201-2/+2
| |
* | Deprecate obsolete Time to DateTime fallback methodsAndrew White2012-12-111-1/+1
| | | | | | | | | | | | | | The Time.time_with_datetime_fallback, Time.utc_time and Time.local_time methods were added to handle the limitations of Ruby's native Time implementation. Those limitations no longer apply so we are deprecating them in 4.0 and they will be removed in 4.1.
* | Add String#in_time_zone methodAndrew White2012-12-111-0/+13
| | | | | | | | | | | | This commit adds a convenience method for converting a string to an ActiveSupport::TimeWithZone instance using the configured Time.zone or another passed as an argument.
* | Simplify String#mb_chars and stop proxying #classSteve Klabnik2012-11-281-5/+1
| | | | | | | | | | | | | | | | This behavior mattered under Ruby 1.8, but that doesn't matter now that we don't support it. In addition, we don't want to proxy the #class method. A test was added to prevent against regressions.
* | Fix documentation for String#mb_chars.Steve Klabnik2012-11-281-4/+1
| | | | | | | | This documentation has been out of date.
* | Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-11-031-2/+2
|\ \ | | | | | | | | | | | | | | | | | | Conflicts: actionpack/lib/action_controller/metal/mime_responds.rb activerecord/lib/active_record/attribute_methods.rb guides/source/working_with_javascript_in_rails.md
| * | Adding a missing parenthesis in the doc of String#parameterize.Geoffrey Roguelon2012-10-241-2/+2
| | |
* | | Make caller attribute in deprecation methods optionalAlexey Gaziev2012-10-301-1/+1
|/ /
* | String.to_time documentation along examples.Adam Stankiewicz2012-09-241-1/+11
| |
* | Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-09-212-4/+3
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: actionmailer/lib/action_mailer/base.rb activesupport/lib/active_support/configurable.rb activesupport/lib/active_support/core_ext/module/deprecation.rb guides/source/action_controller_overview.md guides/source/active_support_core_extensions.md guides/source/ajax_on_rails.textile guides/source/association_basics.textile guides/source/upgrading_ruby_on_rails.md While resolving conflicts, I have chosen to ignore changes done in docrails at some places - these will be most likely 1.9 hash syntax changes.
| * | update AS/core_ext docs [ci skip]Francesco Rodriguez2012-09-122-4/+3
| | |
* | | &#39 dates back to SGML when &#x27 was introduced in HTML 4.0Kalys Osmonov2012-09-091-1/+1
|/ /
* | Merge pull request #3578 from amatsuda/remove_j_alias_for_json_escapeRafael Mendonça França2012-08-211-7/+0
|\ \ | | | | | | Remove j alias for ERB::Util.json_escape
| * | Remove j alias for ERB::Util.json_escapeAkira Matsuda2011-11-091-7/+0
| | |
* | | defines String#indent [closes #7263] [Xavier Noria & Ace Suares]Xavier Noria2012-08-071-0/+43
| | |
* | | html_escape should escape single quotesSantiago Pastorino2012-07-311-3/+3
| | | | | | | | | | | | | | | https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content Closes #7215
* | | Make ActiveSupport::Inflector locale aware and multilingualDavid Celis2012-07-301-4/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Inflector is currently not very supportive of internationalized websites. If a user wants to singularize and/or pluralize words based on any locale other than English, they must define each case in locale files. Rather than create large locale files with mappings between singular and plural words, why not allow the Inflector to accept a locale? This patch makes ActiveSupport::Inflector locale aware and uses `:en`` unless otherwise specified. Users will still be provided a list of English (:en) inflections, but they may additionally define inflection rules for other locales. Each list is kept separately and permanently. There is no reason to limit users to one list of inflections: ActiveSupport::Inflector.inflections(:es) do |inflect| inflect.plural(/$/, 's') inflect.plural(/([^aeéiou])$/i, '\1es') inflect.plural(/([aeiou]s)$/i, '\1') inflect.plural(/z$/i, 'ces') inflect.plural(/á([sn])$/i, 'a\1es') inflect.plural(/é([sn])$/i, 'e\1es') inflect.plural(/í([sn])$/i, 'i\1es') inflect.plural(/ó([sn])$/i, 'o\1es') inflect.plural(/ú([sn])$/i, 'u\1es') inflect.singular(/s$/, '') inflect.singular(/es$/, '') inflect.irregular('el', 'los') end 'ley'.pluralize(:es) # => "leyes" 'ley'.pluralize(:en) # => "leys" 'avión'.pluralize(:es) # => "aviones" 'avión'.pluralize(:en) # => "avións" A multilingual Inflector should be of use to anybody that is tasked with internationalizing their Rails application. Signed-off-by: David Celis <david@davidcelis.com>
* | | Fix doc example for dasherizeMarc-Andre Lafortune2012-06-151-1/+1
| | |
* | | remove unnecessary requireSergey Nartimov2012-05-282-4/+0
| | | | | | | | | | | | | | | AS::Multibyte are no longer required by access and filters string core extensions.
* | | Update the documentation and add CHANGELOG entryRafael Mendonça França2012-05-261-1/+1
| | |
* | | doesn't modify params in SafeBuffer#%Vasiliy Ermolovich2012-05-181-3/+1
| | |
* | | Revert "Merge pull request #6354 from lest/patch-1"Carlos Galdino + Rafael Mendonça França2012-05-162-0/+4
| | | | | | | | | | | | | | | | | | | | | This reverts commit e8feaff60b9c04d34ad234f7d17b5d2ad9cc7a24, reversing changes made to 9adf28c026070afb78b80027521a4ddddd68d697. Reason: This broke the actionmailer tests
* | | remove unnecessary requireSergey Nartimov2012-05-162-4/+0
| | | | | | | | | | | | | | | - access & filters don't use multibyte ext - transliterate requires only AS::Multibyte but not multibyte ext
* | | fix safe string interpolation with SafeBuffer#%, closes #6352Vasiliy Ermolovich2012-05-161-0/+14
| | |
* | | remove backported string interpolationVasiliy Ermolovich2012-05-151-2/+0
| | |
* | | removing unnecessary 'examples' noise from activesupportFrancesco Rodriguez2012-05-131-1/+1
| | |