aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
Commit message (Collapse)AuthorAgeFilesLines
* Add missing file to require digest/uuid on active_support core extensionsLucas Arantes2019-06-121-0/+3
|
* Change commentsEdu Depetris2019-05-251-2/+2
|
* Address 639d7be. Readd changelog line; remove needless explicit return.Kasper Timm Hansen2019-05-241-1/+1
|
* Add :allow_nil option to delegate_missing_to; use in ActiveStorageMatt Tanous2019-05-231-3/+8
| | | | attachment
* Improve error message of ActiveSupport delegateokuramasafumi2019-04-291-1/+1
| | | | | | | | | ActiveSupport `delegate` has `to` option, but it's not a option hash anymore and now it's a keyword argument. When `to` argument is not given, it raises an ArgumentError but the message suggests supplying "options hash", which is now wrong. Now it's fixed to provide correct suggestion to supply a keyword argument.
* Frozen truncate (#36109)Jordan Thomas2019-04-261-1/+1
| | | | | | | | | | | | | | * Add test asserting truncate returns unfrozen string * Ensure strings returned from truncate are not frozen This fixes an issue where strings too short to be truncated were returned unfrozen, where as long-enough strings were returned frozen. Now retuned strings will not be frozen whether or not the string returned was shortened. * Update changelog w/ new truncate behavior description [Jordan Thomas + Rafael Mendonça França]
* Preserve html_safe? status on ActiveSupport::SafeBuffer#*r7kamura2019-04-191-0/+6
|
* Merge pull request #35771 from timoschilling/hash-speed-improvementsRafael França2019-04-021-1/+1
|\ | | | | Hash / HashWithIndifferentAccess speed improvements
| * Speed improvement for Hash#exceptTimo Schilling2019-03-291-1/+1
| |
* | Tweaks CHANGELOGs and docs [ci skip]Ryuta Kamizono2019-03-311-4/+4
|/ | | | | | | * add leading `#` before `=>` since hash rocket is valid Ruby code * add backticks * remove trailing spaces * and more
* Merge pull request #34405 from shugo/safe_buffer_backref_fixMatthew Draper2019-03-281-2/+37
|\ | | | | sub, sub!, gsub, and gsub! should set back references
| * Eliminate a thread local variable as suggested by nobuShugo Maeda2019-02-141-8/+1
| |
| * Remove trailing spaceShugo Maeda2018-11-081-1/+1
| |
| * Add a commented code example of what will be producedShugo Maeda2018-11-081-22/+22
| |
| * sub, sub!, gsub, and gsub! should set back referencesShugo Maeda2018-11-081-2/+44
| |
* | Fix bug in Range comparisons when comparing to excluded-end RangeOwen Stephens2019-03-281-12/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: ```ruby (1..10).cover?(1...11) => false ``` After: ```ruby (1..10).cover?(1...11) => true ``` See https://git.io/fjTtz for the commit against Ruby core that added support for Range arguments, with similar handling of this case.
* | Fix Time#advance to work with dates before 1001-03-07Andrew White2019-03-181-2/+1
| | | | | | | | | | | | | | | | | | In #10634 the behavior of Time#advance was changed to maintain a proleptic gregorian calendar for dates before calendar reform. However it didn't full address dates a long time before calendar reform and they gradually drift away from the proleptic calendar the further you go back in time. Fix this by always converting the date to gregorian before calling advance which sets the reform date to -infinity.
* | Update docs for 'parameterize()' [ci skip]Sharang Dashputre2019-03-161-1/+1
| |
* | support slice assignment on SafeBufferRichard Monette2019-03-131-2/+6
| |
* | Change wording of some instances of 'opt out' [ci skip]Sharang Dashputre2019-03-122-10/+10
| |
* | Add locale option to parameterizeKaan Ozkan2019-03-111-2/+7
| | | | | | | | | | | | Parameterize is triggering I18n#transliterate. This method already accepts a locale. It would be cleaner if similar to other string inflection methods #parameterize also accepted 'locale' as a parameter.
* | Fix including/excluding flatteningGabriel Sobrinho2019-03-062-7/+7
| |
* | Added Array#including, Array#excluding, Enumerable#including, ↵David Heinemeier Hansson2019-03-052-8/+40
| | | | | | | | Enumerable#excluding
* | activesupport: Simplify class_attribute implementation (#35454)Dylan Thacker-Smith2019-03-031-15/+10
| | | | | | | | | | | | | | | | * activesupport(class_attribute): Use redefine_singleton_method * activesupport(class_attribute): Use keyword arguments * activesupport(class_attribute): Avoid unnecessary redefinition for default
* | Remove redundant returning `object`Ryuta Kamizono2019-02-091-1/+0
| | | | | | | | `object.transform_values!` returns `object` itself.
* | Use Ruby 2.4+ native transform_values(!)Kasper Timm Hansen2019-02-081-7/+2
| |
* | Add 'Hash#deep_transform_values', and 'Hash#deep_transform_values!'Guillermo Iguaran2019-02-082-0/+53
| |
* | Remove the Kernel#` override that turns ENOENT into nilAkinori MUSHA2019-01-312-14/+0
| | | | | | | | | | | | | | | | | | | | | | | | ActiveSupport overrides `` Kernel#` `` so that it would not raise `Errno::ENOENT` but return `nil` instead (due to the last statement `STDERR.puts` returning nil) if a given command were not found. Because of this, you cannot safely say somthing like `` `command`.chomp `` when ActiveSupport is loaded. It turns out that this is an outdated monkey patch for Windows platforms to emulate Unix behavior on an ancient version of Ruby, and it should be removed by now.
* | No dup nor delete from optionsKrzysztof Rybka2019-01-181-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Memory comparison: Options: {:years=>1, :months=>1, :weeks=>1, :days=>1} Calculating ------------------------------------- master 576.000 memsize ( 0.000 retained) 5.000 objects ( 0.000 retained) 0.000 strings ( 0.000 retained) advance_no_dup 288.000 memsize ( 0.000 retained) 4.000 objects ( 0.000 retained) 0.000 strings ( 0.000 retained) Comparison: advance_no_dup: 288 allocated master: 576 allocated - 2.00x more Options: {:years=>1} Calculating ------------------------------------- master 264.000 memsize ( 0.000 retained) 2.000 objects ( 0.000 retained) 0.000 strings ( 0.000 retained) advance_no_dup 72.000 memsize ( 0.000 retained) 1.000 objects ( 0.000 retained) 0.000 strings ( 0.000 retained) Comparison: advance_no_dup: 72 allocated master: 264 allocated - 3.67x more Options: {:weeks=>1} Calculating ------------------------------------- master 264.000 memsize ( 0.000 retained) 2.000 objects ( 0.000 retained) 0.000 strings ( 0.000 retained) advance_no_dup 72.000 memsize ( 0.000 retained) 1.000 objects ( 0.000 retained) 0.000 strings ( 0.000 retained) Comparison: advance_no_dup: 72 allocated master: 264 allocated - 3.67x more Peformance comparison: Options: {:years=>1, :months=>1, :weeks=>1, :days=>1} Warming up -------------------------------------- master 27.740k i/100ms advance_no_dup 37.705k i/100ms Calculating ------------------------------------- master 338.511k (± 5.9%) i/s - 1.692M in 5.020333s advance_no_dup 572.980k (± 3.7%) i/s - 2.866M in 5.008680s Comparison: advance_no_dup: 572979.7 i/s master: 338510.9 i/s - 1.69x slower Options: {:years=>1} Warming up -------------------------------------- master 53.313k i/100ms advance_no_dup 115.016k i/100ms Calculating ------------------------------------- master 639.715k (± 1.7%) i/s - 3.199M in 5.001851s advance_no_dup 1.579M (± 6.4%) i/s - 7.936M in 5.053876s Comparison: advance_no_dup: 1579251.7 i/s master: 639714.8 i/s - 2.47x slower Options: {:weeks=>1} Warming up -------------------------------------- master 57.353k i/100ms advance_no_dup 129.141k i/100ms Calculating ------------------------------------- master 674.113k (± 3.4%) i/s - 3.384M in 5.025973s advance_no_dup 1.911M (± 2.5%) i/s - 9.556M in 5.004496s Comparison: advance_no_dup: 1910739.3 i/s master: 674112.6 i/s - 2.83x slower
* | Remove deprecated `Module#reachable?` methodRafael Mendonça França2019-01-172-7/+1
| |
* | Refactor calculating beginning_of_quarter and end_of_quarter (#34927)Krzysztof Rybka2019-01-141-2/+2
| | | | | | | | | | | | | | * Calculate first month of quarter instead of finding * Calculate last month of quarter instead of finding [Krzysztof Rybka + Rafael Mendonça França]
* | Clarify `delegate_missing_to` [ci skip]bogdanvlviv2019-01-041-1/+1
| | | | | | | | | | | | | | | | Since #34864 removed explicit receiver to clarify the purpose of `delegate_missing_to`, I think it will be better to do the same a few lines above to easier figure out that `delegate_missing_to` defines `method_missing`, `respond_to_missing?` when comparing these examples.
* | Clarify benefit of `delegate_missing_to`Michael Gee2019-01-041-1/+1
| | | | | | Removing the explicit receiver clarifies the purpose of `delegate_missing_to`.
* | Make Active Storage blob keys lowercaseJulik Tarkhanov2018-12-301-3/+23
| | | | | | Accommodate case-insensitive filesystems and database collations.
* | Clarify the :to parameter of delegateEddie Lebow2018-12-201-1/+1
| |
* | Follow up #34754bogdanvlviv2018-12-203-3/+3
| | | | | | | | | | | | | | - Fix a few deprecation warnings - Remove testing of `Hash#slice` - Imporve test of `Hash#slice!` - Remove mention about `Hash#slice` from the guide
* | Use native `Array#append`, `Array#prepend`, `Hash#transform_keys`, and ↵Ryuta Kamizono2018-12-203-36/+2
| | | | | | | | | | | | | | | | | | | | `Hash#transform_keys!` Since Rails 6 requires Ruby 2.5. https://github.com/ruby/ruby/blob/ruby_2_5/NEWS Follow up #34754.
* | Require Ruby 2.5 for Rails 6.Kasper Timm Hansen2018-12-191-23/+0
| | | | | | | | | | | | | | | | | | | | Generally followed the pattern for https://github.com/rails/rails/pull/32034 * Removes needless CI configs for 2.4 * Targets 2.5 in rubocop * Updates existing CHANGELOG entries for fewer merge conflicts * Removes Hash#slice extension as that's inlined on Ruby 2.5. * Removes the need for send on define_method in MethodCallAssertions.
* | Merge pull request #34037 from reitermarkus/atomic_write-permissionsRafael França2018-11-221-1/+1
|\ \ | | | | | | `atomic_write`: Ensure correct permission when `tmpdir` is the same as `dirname`.
| * | Ensure correct permission when `tmpdir` is the same as `dirname`.Markus Reiter2018-10-021-1/+1
| | |
* | | Remove odd spaces [ci skip]Ryuta Kamizono2018-11-211-2/+2
| | |
* | | Improve documentation for Hash#slice!Daniel Lopez 👾2018-11-211-2/+3
| |/ |/|
* | Consistently use kwargs for `instance_{reader,writer,accessor}` optionsRyuta Kamizono2018-10-201-12/+7
| | | | | | | | | | | | | | | | Since #29294, `mattr_acessor` uses kwargs for `instance_reader`, `instance_writer`, and `instance_accessor` options. `thread_mattr_accessor` and `config_accessor` also take the same options, so let's maintain these options handles the same.
* | ActiveSupport module may not always already defined hereAkira Matsuda2018-10-202-150/+154
| | | | | | | | `ruby -ractive_support/core_ext/range/conversions.rb -ep` dies with uninitialized constant ActiveSupport
* | attribute_accessors no longer uses extract_options since ↵Akira Matsuda2018-10-201-2/+0
| | | | | | | | a5b0c60714e1e8d8c182af830a26e1c7c884271d
* | Fix issue where duration where always rounded up to a second:Edouard CHIN2018-10-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Adding a Float as a duration to a datetime would result in the Float being rounded. Doing something like would have no effect because the 0.45 seconds would be rounded to 0 second. ```ruby time = DateTime.parse("2018-1-1") time += 0.45.seconds ``` This behavior was intentionally added a very long time ago, the reason was because Ruby 1.8 was using `Integer#gcd` in the constructor of Rational which didn't accept a float value. That's no longer the case and doing `Rational(0.45, 86400)` would now perfectly work fine. - Fixes #34008
* | Merge pull request #34068 from schneems/schneems/micro-optimize-try-nilRichard Schneeman2018-10-051-2/+2
|\ \ | | | | | | 23% faster Nil#try
| * | This PR speeds up Nil#try by avoiding an allocation when only one argument ↵schneems2018-10-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | is passed: ```ruby class FooNew def try(method_name = nil, *args) nil end end class FooOld def try(*args) nil end end require 'benchmark/ips' foo_new = FooNew.new foo_old = FooOld.new Benchmark.ips do |x| x.report("new") { foo_new.try(:anything) } x.report("old") { foo_old.try(:anything) } x.compare! end # Warming up -------------------------------------- # new 250.633k i/100ms # old 232.322k i/100ms # Calculating ------------------------------------- # new 6.476M (± 4.8%) i/s - 32.332M in 5.005777s # old 5.258M (± 3.2%) i/s - 26.485M in 5.042589s # Comparison: # new: 6476002.5 i/s # old: 5257912.5 i/s - 1.23x slower ``` It's worth noting that checking for nil separately as in https://github.com/rails/rails/pull/34067 seems to be MUCH faster. It might be worth it to apply a blanket `&.` to every internal `try` call.
* | | Prefix Module#parent, Module#parents, and Module#parent_name with moduleGannon McGibbon2018-10-021-13/+37
| | |
* | | Merge pull request #33058 from gmcgibbon/string_first_last_negative_deprecationRafael França2018-10-021-0/+8
|\ \ \ | |_|/ |/| | Add deprecation warning when String#first and String#last receive neg…