1. 18 12月, 2019 1 次提交
  2. 04 12月, 2019 1 次提交
  3. 02 12月, 2019 1 次提交
    • R
      Fix `since` and `ago` with a duration which has empty parts · aa93e3cb
      Ryuta Kamizono 提交于
      Related #37839.
      
      Sometimes divisions of `ActiveSupport::Duration` makes the instance's
      parts attribute empty, but it has a value actually (e.g. `(1.minute /
      60) # => @value=1 (second), but empty parts`).
      
      In that case we should respect `value` as the source of seconds.
      aa93e3cb
  4. 30 11月, 2019 1 次提交
  5. 01 10月, 2019 3 次提交
  6. 16 9月, 2019 1 次提交
  7. 09 9月, 2019 1 次提交
  8. 27 8月, 2019 1 次提交
    • A
      Disallow all non-numerics as Duration.build input, Fixes #37012 · 1a48d503
      Alexei Emam 提交于
          Prevent `ActiveSupport::Duration.build(value)` from creating instances of
          `ActiveSupport::Duration` unless `value` is of type `Numeric`.
      
          Addresses the errant set of behaviours described in #37012 where
          `ActiveSupport::Duration` comparisons would fail confusingly
          or return unexpected results when comparing durations built from instances of `String`.
      
          Before:
      
              small_duration_from_string = ActiveSupport::Duration.build('9')
              large_duration_from_string = ActiveSupport::Duration.build('100000000000000')
              small_duration_from_int = ActiveSupport::Duration.build(9)
      
              large_duration_from_string > small_duration_from_string
                  => false
      
              small_duration_from_string == small_duration_from_int
                  => false
      
              small_duration_from_int < large_duration_from_string
                  => ArgumentError (comparison of ActiveSupport::Duration::Scalar
                          with ActiveSupport::Duration failed)
      
              large_duration_from_string > small_duration_from_int
                  => ArgumentError (comparison of String with ActiveSupport::Duration failed)
      
          After:
      
              small_duration_from_string = ActiveSupport::Duration.build('9')
                  => TypeError (can't build an `ActiveSupport::Duration` from a `String`)
      1a48d503
  9. 05 8月, 2019 2 次提交
  10. 02 8月, 2019 3 次提交
  11. 27 7月, 2019 1 次提交
    • K
      Remove tough to grasp -1 + 1 = 0 from String#to · efa2299a
      Kasper Timm Hansen 提交于
      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 "".
      efa2299a
  12. 18 7月, 2019 1 次提交
    • A
      Omit marshal_dump & _dump from delegate_missing_to · 722c45f6
      Aaron Lipman 提交于
      Exclude missing marshal_dump and _dump methods from being delegated to
      an object's delegation target via the delegate_missing_to extension.
      This avoids unintentionally adding instance variables to an object
      during marshallization, should the delegation target be a method which
      would otherwise add them.
      
      In current versions of Ruby, a bug exists in the way objects are
      marshalled, allowing for instance variables to be added or removed
      during marshallization (see https://bugs.ruby-lang.org/issues/15968).
      This results in a corrupted serialized byte stream, causing an object's
      instance variables to "leak" into subsequent serialized objects during
      demarshallization.
      
      In Rails, this behavior may be triggered when marshalling an object that
      uses the delegate_missing_to extension, if the delegation target is a
      method which adds or removes instance variables to an object being
      marshalled - when calling Marshal.dump(object), Ruby's built in behavior
      will check whether the object responds to :marshal_dump or :_dump, which
      in turn triggers the delegation target method in the
      responds_to_missing? function defined in
      activesupport/lib/active_support/core_ext/module/delegation.rb
      
      While future versions of Ruby will resolve this bug by raising a
      RuntimeError, the underlying cause of this error may not be readily
      apparent when encountered by Rails developers. By excluding marshal_dump
      and _dump from being delegated to an object's target, this commit
      eliminates a potential cause of unexpected behavior and/or
      RuntimeErrors.
      
      Fixes #36522
      722c45f6
  13. 12 7月, 2019 1 次提交
  14. 16 6月, 2019 1 次提交
  15. 13 6月, 2019 1 次提交
  16. 05 6月, 2019 1 次提交
    • D
      Add compact_blank shortcut for reject(&:blank?) · c8847c17
      Dana Sherson 提交于
      I frequently find myself having to .compact but for blank. which means
      on an array reject(&:blank?) (this is fine), or,
      on a hash `.reject { |_k, v| v.blank? }` which is slightly more
      frustrating and i usually write it as .reject(&:blank?) first and am
      confused when it's trying to check if the keys are blank.
      
      I've added the analagous .compact_blank! where there's a reject! to
      build on (there's also a reject! in Set, but there's no other core_ext
      touching Set so i've left that alone)
      c8847c17
  17. 28 5月, 2019 1 次提交
  18. 24 5月, 2019 1 次提交
  19. 06 5月, 2019 1 次提交
    • J
      Improve String#first and #last performance · 0e2de0e3
      Jonathan Hefner 提交于
      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.)
      0e2de0e3
  20. 27 4月, 2019 1 次提交
    • J
      Frozen truncate (#36109) · 4dfdc7eb
      Jordan Thomas 提交于
      * 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]
      4dfdc7eb
  21. 28 3月, 2019 1 次提交
  22. 19 3月, 2019 1 次提交
    • A
      Fix Time#advance to work with dates before 1001-03-07 · 58ac3f21
      Andrew White 提交于
      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.
      58ac3f21
  23. 12 3月, 2019 1 次提交
  24. 07 3月, 2019 1 次提交
  25. 06 3月, 2019 1 次提交
  26. 09 2月, 2019 3 次提交
  27. 18 1月, 2019 1 次提交
  28. 31 12月, 2018 2 次提交
  29. 23 12月, 2018 1 次提交
  30. 21 12月, 2018 3 次提交