aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
Commit message (Collapse)AuthorAgeFilesLines
* Use Thread.pass instead of Kernel.sleep to trigger race conditionGuilherme Mansur2019-08-052-21/+12
|
* Able to initalize default value for thread_mattr_*Guilherme Mansur2019-08-053-16/+46
| | | | | | | | | | | | | | | | | Added the ability to initialize `thread_mattr_*` methods with default values like so: ``` ruby class MyClass thread_attr_reader :foo, default: :foo thread_attr_writer :bar, default: :bar thread_attr_accessor: baz do "baz" end end ``` This is consistent with the api exposed by `mattr_accessor`.
* Revert "MethodCallAssertions is a regular player of the team ↵Rafael Mendonça França2019-08-022-3/+3
| | | | | | ActiveSupport::TestCase now" This reverts commit 98d0f7ebd34b858f12a12dcf37ae54fdbb5cab64.
* Revert "You give jruby_skip & rubinius_skip a good name"Rafael Mendonça França2019-08-023-20/+13
| | | | This reverts commit 8d2866bb80fbe81acb04f5b0c44f152f571fb29f.
* Missing require AS/core_ext/date/conversionsAkira Matsuda2019-08-022-0/+2
|
* hash_conversion itself does not at all depend on time extensionsAkira Matsuda2019-08-021-1/+0
|
* Lazily evaluate FileUpdateCheckerSharedTests when being includedAkira Matsuda2019-08-021-195/+199
| | | | To avoid "uninitialized constant ActiveSupport::Testing (NameError)"
* Missing require AS/core_ext/string/inflectionsAkira Matsuda2019-08-021-0/+2
|
* Let's try not to depend too much on other core extensions in a core ↵Akira Matsuda2019-08-021-1/+1
| | | | extension test
* Missing require AS/core_ext/object/blankAkira Matsuda2019-08-021-0/+1
|
* require only what each test concernsAkira Matsuda2019-08-024-4/+7
|
* You give jruby_skip & rubinius_skip a good nameAkira Matsuda2019-08-023-13/+20
| | | | | | | | This hack prevails everywhere in the codebase by being copy & pasted, and it's actually not a negative thing but a necessary thing for framework implementors, so it should better have a name and be a thing. And with this commit, activesupport/test/abstract_unit.rb now doesn't silently autoload AS::TestCase, so we're ready to establish clearner environment for running AS tests (probably in later commits)
* MethodCallAssertions is a regular player of the team ActiveSupport::TestCase nowAkira Matsuda2019-08-022-3/+3
| | | | It's used everywhere, clean and mature enough
* Missing require "AS/core_ext/date_time/conversions"Akira Matsuda2019-08-011-0/+1
| | | | | This causes "NameError: undefined local variable or method `nsec' for #<DateTime:0x0000559163cdd878>"
* Another missing require "AS/core_ext/object/try"Akira Matsuda2019-08-011-0/+1
|
* It may be better to explicitly require 'object/try' where we call `try`Akira Matsuda2019-08-012-0/+2
| | | | | | In most cases it works now without explicit require because it's accidentally required through active_support/core_ext/date_and_time/calculations.rb where we still call `try`, but that would stop working if we changed the Calculations implementation and remove the require call there.
* Use `try` only when we're unsure if the receiver would respond_to the methodAkira Matsuda2019-08-011-5/+5
|
* Prevent error on transliterate with frozen strings.Cliff Pruitt2019-07-312-7/+8
| | | | ActiveSupport::Inflector.transliterate mutates strings by changing encodings. Prior to this commit passing a frozen string would raise a `FrozenError`. This change duplicates the internal string, if frozen, before transliterating.
* Address to rubocop offencesRyuta Kamizono2019-07-311-1/+1
|
* Reduce Array allocationsAkira Matsuda2019-07-311-1/+1
|
* Accessing ivar with Symbols might be just a very little bit better than with ↵Akira Matsuda2019-07-312-2/+2
| | | | fstrings
* Cache tags_text to avoid computing tags each time when loggingAkira Matsuda2019-07-311-5/+10
|
* Speedup and reduce Array creation when constantizing a non-namespaced stringAkira Matsuda2019-07-311-25/+29
|
* [ci skip] Fix unclosed tags in `Inflector` docsvzvu3k6k2019-07-301-1/+1
|
* Call raise with parentheses like a normal method call with argumentsCarlos Antonio da Silva2019-07-291-2/+2
| | | | | | Using `(raise FooError, "error")` is like forcing a "new scope" around the `raise` call, it's simpler to just wrap the `raise` arguments with parentheses just like any other method call would.
* Use match? where we don't need MatchDataAkira Matsuda2019-07-296-8/+8
|
* Revert "Use assert_match / assert_no_match for asserting match"Akira Matsuda2019-07-291-3/+3
| | | | | | This reverts commit e9651deea4145f62224af56af027bfbb3e45e4cd. Now we're having both `=~` and `match?` for these objects, and it's nicer to have explicit tests for both of them
* Add AS::TimeZone#match?Akira Matsuda2019-07-292-0/+14
|
* Add AS::Multibyte::Chars#match?Akira Matsuda2019-07-292-1/+7
|
* Improves compatibility of require_dependency in zeitwerk mode [Closes #36774]Xavier Noria2019-07-281-1/+12
| | | | | | | | | | | | | | | Applications are not supposed to use require_dependency in their own code if running in zeitwerk mode, and require_dependency was initially aliased to require with that use case in mind. However, there are situations in which you cannot control the mode and need to be compatible with both. There, you might need require_dependency in case you are being executed in classic mode. Think about engines that want to support both modes in their parent applications, for example. Furthermore, Rails itself loads helpers using require_dependency. Therefore, we need better compatibility.
* Performance improvement for `String#to`Ryuta Kamizono2019-07-283-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ```ruby class String def to1(position) position = [position + length, -1].max if position < 0 self[0, position + 1] end def to2(position) position += size if position < 0 self[0, position + 1] || +"" end end Benchmark.ips do |x| x.report("'foo'.to(1)") { 'foo'.to(1) } x.report("'foo'.to1(1)") { 'foo'.to1(1) } x.report("'foo'.to2(1)") { 'foo'.to2(1) } x.report("'foo'.to(-1)") { 'foo'.to(-1) } x.report("'foo'.to1(-1)") { 'foo'.to1(-1) } x.report("'foo'.to2(-1)") { 'foo'.to2(-1) } x.report("'foo'.to(-10)") { 'foo'.to(-10) } x.report("'foo'.to1(-10)") { 'foo'.to1(-10) } x.report("'foo'.to2(-10)") { 'foo'.to2(-10) } end ``` Result: ``` Warming up -------------------------------------- 'foo'.to(1) 199.859k i/100ms 'foo'.to1(1) 220.293k i/100ms 'foo'.to2(1) 221.522k i/100ms 'foo'.to(-1) 205.032k i/100ms 'foo'.to1(-1) 195.837k i/100ms 'foo'.to2(-1) 214.975k i/100ms 'foo'.to(-10) 214.331k i/100ms 'foo'.to1(-10) 182.666k i/100ms 'foo'.to2(-10) 224.696k i/100ms Calculating ------------------------------------- 'foo'.to(1) 4.685M (± 4.2%) i/s - 23.583M in 5.042568s 'foo'.to1(1) 5.233M (± 5.8%) i/s - 26.215M in 5.026778s 'foo'.to2(1) 5.180M (± 5.7%) i/s - 25.918M in 5.020735s 'foo'.to(-1) 4.253M (± 7.0%) i/s - 21.323M in 5.043133s 'foo'.to1(-1) 4.438M (±11.2%) i/s - 21.934M in 5.025751s 'foo'.to2(-1) 4.716M (± 9.8%) i/s - 23.432M in 5.028088s 'foo'.to(-10) 4.678M (± 9.5%) i/s - 23.148M in 5.007379s 'foo'.to1(-10) 4.428M (± 5.1%) i/s - 22.103M in 5.005155s 'foo'.to2(-10) 5.243M (± 4.6%) i/s - 26.289M in 5.024695s ```
* Merge pull request #36185 from jonathanhefner/optimize-string-first-and-lastRafael França2019-07-282-34/+22
|\ | | | | Improve String#first and #last performance
| * Improve String#first and #last performanceJonathan Hefner2019-05-052-34/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Removes unnecessary conditional and method call for significant performance improvement. As a side effect, this fixes an unexpected behavior where passing a limit of 0 would return a frozen string. This also implements the Rails 6.1 intended behavior with regards to negative limits, and removes the previous deprecation warnings. String#first Comparison: new: 3056515.0 i/s old: 1943310.2 i/s - 1.57x slower String#last Comparison: new: 2691919.0 i/s old: 1924256.6 i/s - 1.40x slower (Note: "old" benchmarks have deprecation warnings commented out, for a more fair comparison.)
* | Use match? where we don't need MatchDataAkira Matsuda2019-07-273-4/+4
| | | | | | | | We're already running Performance/RegexpMatch cop, but it seems like the cop is not always =~ justice
* | Use assert_match / assert_no_match for asserting matchAkira Matsuda2019-07-271-3/+3
| |
* | Remove tough to grasp -1 + 1 = 0 from String#toKasper Timm Hansen2019-07-262-2/+4
| | | | | | | | | | | | | | | | | | | | | | In case a negative position is provided that exceeds the size of the string, we're relying on -1 returned from max to get 0 length by + 1 and let [] with a 0 length returning "" for us. E.g. "hello".to(-7), where -7 + 5 size = -2. That's lower than -1, so we use -1 instead and + 1 would turn it into 0. Instead allow outer bounds access and always return "".
* | Remove comments in test fileCliff Pruitt2019-07-261-7/+0
| |
* | Handle GB18030 strings with invalid characters in transliterateCliff Pruitt2019-07-262-13/+18
| | | | | | | | | | | | GB18030 is Unicode compatible and covers all Unicode code points so we can temporarily convert GB18030 strings to UTF-8 to perform the transliteration. After transliterating we want to convert back to GB18030. In all cases of transcoding, we replace invalid or undefined characters with the default replacement character ("?"). This is in line with the behavior of tidy_bytes which is used on the UTF-8 string before transliterating.
* | Handle US-ASCII strings with invalid characters in transliterateCliff Pruitt2019-07-262-19/+26
| | | | | | | | US-ASCII is a subset of UTF-8 so we can temporarily convert US-ASCII strings to UTF-8 to perform the transliteration. After we've converted characters to ASCII representations, we can set the encoding back to US-ASCII to return the same encoding we accepted.
* | Add encoding tests for ActiveSupport::Inflector.transliterateCliff Pruitt2019-07-261-0/+57
| |
* | Raise errors for ASCII-8BIT encoding in ActiveSupport::Inflector::transliterateCliff Pruitt2019-07-262-0/+12
| | | | | | | | Adds ArgumentErrors to `ActiveSupport::Inflector::transliterate` if a string is with ASCII-8BIT which will raise an error in `unicode_normalize`.
* | Merge pull request #36180 from jonathanhefner/optimize-string-fromRafael França2019-07-251-2/+3
|\ \ | | | | | | Avoid extra allocation in String#from and #to
| * | Avoid extra allocation in String#from and #toJonathan Hefner2019-05-051-2/+3
| |/ | | | | | | | | | | | | | | | | | | | | | | Removes unnecessary Range object allocations for a significant speed-up. String#from Comparison: new: 3378594.0 i/s old: 2380129.8 i/s - 1.42x slower String#to Comparison: new: 2866175.7 i/s old: 2304406.4 i/s - 1.24x slower
* | Use correct variable in `secure_compare!`yuuji.yaginuma2019-07-262-1/+14
| | | | | | | | | | `Messages::Rotator` has `@on_rotation` not `@rotation`. https://github.com/rails/rails/blob/72bc0806a7b378cd544e8fbf7ab22d74b7913ffb/activesupport/lib/active_support/messages/rotator.rb#L11
* | Fixup 64a430129fKasper Timm Hansen2019-07-251-3/+5
| |
* | Use binding.local_variable_get for `:for`Kasper Timm Hansen2019-07-251-5/+3
| | | | | | | | | | | | Simplifies the surrounding code outside `convert_value`. Ref: https://github.com/rails/rails/pull/36758
* | let autoloaded? support modules with overridden names [closes #36757]Xavier Noria2019-07-253-3/+21
| |
* | Merge pull request #36318 from itsWill/fix_event_object_payloadRafael França2019-07-253-1/+24
|\ \ | | | | | | Merge payload for EventObject subscribers
| * | Merge payload for EventObject subscribersGuilherme Mansur2019-05-223-1/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When instrumenting a block of code like: ```ruby ActiveSupport::Notifications.instrument("process_action.action_controller", raw_paylaod) do |payload| payload[:view_runtime] = render_view end ``` If we use an evented subscriber like so: ``` ruby ActiveSupport::Notifications.subscribe("process_action.action_controller", raw_payload) do |event| assert event.payload[:view_runtime] end ``` The code breaks because the underlying EventObject's payload does not have the `:view_runtime` key added during instrumentation. This is because the `EventedObject` subscriber calls the `finish` method with the `payload` of the event at the time it was pushed into the stack, before the block executes, but we want to call `finish` with the `payload` after the instrument block executes this way if the `payload` was modified during the block we have access to it. This is consistent with the other types of subscribers who don't have this bug.
* | | Merge pull request #36412 from robotdana/compact_blankRafael Mendonça França2019-07-253-0/+75
|\ \ \ | | | | | | | | | | | | Add compact_blank shortcut for reject(&:blank?)