1. 16 10月, 2018 1 次提交
  2. 13 10月, 2018 1 次提交
    • E
      Fix issue where duration where always rounded up to a second: · c85e3f65
      Edouard CHIN 提交于
      - 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
      c85e3f65
  3. 12 10月, 2018 4 次提交
  4. 08 10月, 2018 1 次提交
  5. 06 10月, 2018 2 次提交
  6. 05 10月, 2018 1 次提交
    • M
      Bugfix: ActiveSupport::EncryptedConfiguration reading of comment-only encrypted files (#34014) · bd107964
      Martin Spickermann 提交于
      * Fix reading comment only encrypted files
      
      When a encrypted file contains only comments then reading that files raises an error:
      
          NoMethodError: undefined method `deep_symbolize_keys' for false:FalseClass
              activesupport/lib/active_support/encrypted_configuration.rb:33:in `config'
              test/encrypted_configuration_test.rb:52:in `block in <class:EncryptedConfigurationTest>'
      
      This happens because the previous implementation returned a `{}` fallback for blank YAML strings. But it did not handle YAML strings that are present but still do not contain any _usefull_ YAML - like the file created by `Rails::Generators::EncryptedFileGenerator` which looks like this:
      
          # aws:
          #   access_key_id: 123
          #   secret_access_key: 345
      
      * Fix coding style violation
      
      * Add backwardscompatible with Psych versions that were shipped with Ruby <2.5
      
      * Do not rely on railties for Active Support test
      
      * Simplify error handling
      
      * Improve test naming
      
      * Simplify file creation in test
      bd107964
  7. 04 10月, 2018 2 次提交
    • S
      This PR speeds up Nil#try by avoiding an allocation when only one argument is passed: · 81d43f62
      schneems 提交于
      ```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.
      81d43f62
    • Y
      Don't use deprecated `LoggerSilence` · c55fc43b
      yuuji.yaginuma 提交于
      c55fc43b
  8. 03 10月, 2018 6 次提交
  9. 02 10月, 2018 1 次提交
  10. 01 10月, 2018 1 次提交
  11. 29 9月, 2018 2 次提交
    • Y
      Add `Style/RedundantFreeze` to remove redudant `.freeze` · aa3dcabd
      Yasuo Honda 提交于
      Since Rails 6.0 will support Ruby 2.4.1 or higher
      `# frozen_string_literal: true` magic comment is enough to make string object frozen.
      This magic comment is enabled by `Style/FrozenStringLiteralComment` cop.
      
      * Exclude these files not to auto correct false positive `Regexp#freeze`
       - 'actionpack/lib/action_dispatch/journey/router/utils.rb'
       - 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb'
      
      It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333
      Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed.
      
      * Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required
      
       - 'actionpack/test/controller/test_case_test.rb'
       - 'activemodel/test/cases/type/string_test.rb'
       - 'activesupport/lib/active_support/core_ext/string/strip.rb'
       - 'activesupport/test/core_ext/string_ext_test.rb'
       - 'railties/test/generators/actions_test.rb'
      aa3dcabd
    • G
      Add deprecation warning when String#first and String#last receive negative integers · ec9a89cb
      Gannon McGibbon 提交于
      [Gannon McGibbon + Eric Turner]
      ec9a89cb
  12. 28 9月, 2018 3 次提交
  13. 26 9月, 2018 1 次提交
  14. 23 9月, 2018 2 次提交
    • S
      Remove private def · 0fe2bb81
      Sakshi Jain 提交于
      0fe2bb81
    • Y
      Enable `Performance/UnfreezeString` cop · 1b86d901
      yuuji.yaginuma 提交于
      In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`.
      
      ```ruby
      # frozen_string_literal: true
      
      require "bundler/inline"
      
      gemfile(true) do
        source "https://rubygems.org"
      
        gem "benchmark-ips"
      end
      
      Benchmark.ips do |x|
        x.report('+@') { +"" }
        x.report('dup') { "".dup }
        x.compare!
      end
      ```
      
      ```
      $ ruby -v benchmark.rb
      ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
      Warming up --------------------------------------
                        +@   282.289k i/100ms
                       dup   187.638k i/100ms
      Calculating -------------------------------------
                        +@      6.775M (± 3.6%) i/s -     33.875M in   5.006253s
                       dup      3.320M (± 2.2%) i/s -     16.700M in   5.032125s
      
      Comparison:
                        +@:  6775299.3 i/s
                       dup:  3320400.7 i/s - 2.04x  slower
      
      ```
      1b86d901
  15. 22 9月, 2018 1 次提交
    • S
      Decrease memory allocations in cache.rb · 6da99b4e
      schneems 提交于
      The `merged_options` method is private and the output is never mutated.
      Using this info we can get rid of the `dup` behavior. We can also
      eliminate the `merge` call in the case where all the options being merged are the same.
      
      Returned results are frozen as an extra layer of protection against
      mutation.
      
      Before
      
      ```
      Total allocated: 741749 bytes (6642 objects)
      ```
      
      After
      
      ```
      Total allocated: 734039 bytes (6648 objects)
      ```
      
      Diff
      
      ```
      (741749 - 734039) / 741749.0 => ~ 1.0 %
      ```
      
      If you don't feel comfortable modifying this method, we could rename it
      and only use it internally.
      6da99b4e
  16. 21 9月, 2018 2 次提交
    • S
      Switch to supports_cache_versioning? check to a class method · 3424bd83
      schneems 提交于
      - Moving the `supports_cache_versioning?` check to a class method. 
      - Shorten the method doc. 
      - Expand on the error message.
      3424bd83
    • S
      [close #33907] Error when using "recyclable" cache keys with a store that does not support it · 135d3e15
      schneems 提交于
      If you are using the "in cache versioning" also known as "recyclable cache keys" the cache store must be aware of this scheme, otherwise you will generate cache entries that never invalidate.
      
      This PR adds a check to the initialization process to ensure that if recyclable cache keys are being used via 
      
      ```
      config.active_record.cache_versioning = true
      ```
      
      Then the cache store needs to show that it supports this versioning scheme. Cache stores can let Rails know that they support this scheme by adding a method `supports_in_cache_versioning?` and returning true.
      135d3e15
  17. 14 9月, 2018 1 次提交
  18. 12 9月, 2018 2 次提交
  19. 11 9月, 2018 2 次提交
  20. 08 9月, 2018 2 次提交
  21. 07 9月, 2018 2 次提交