diff options
Diffstat (limited to 'activesupport')
5 files changed, 18 insertions, 10 deletions
diff --git a/activesupport/lib/active_support/buffered_logger.rb b/activesupport/lib/active_support/buffered_logger.rb index a14f008be5..b937d4c50d 100644 --- a/activesupport/lib/active_support/buffered_logger.rb +++ b/activesupport/lib/active_support/buffered_logger.rb @@ -48,14 +48,17 @@ module ActiveSupport if log.respond_to?(:write) @log = log elsif File.exist?(log) - @log = open(log, (File::WRONLY | File::APPEND)) - @log.binmode - @log.sync = true + @log = open_log(log, (File::WRONLY | File::APPEND)) else FileUtils.mkdir_p(File.dirname(log)) - @log = open(log, (File::WRONLY | File::APPEND | File::CREAT)) - @log.binmode - @log.sync = true + @log = open_log(log, (File::WRONLY | File::APPEND | File::CREAT)) + end + end + + def open_log(log, mode) + open(log, mode).tap do |log| + log.set_encoding(Encoding::BINARY) if log.respond_to?(:set_encoding) + log.sync = true end end diff --git a/activesupport/lib/active_support/core_ext/numeric/time.rb b/activesupport/lib/active_support/core_ext/numeric/time.rb index e73915ffcf..58a03d508e 100644 --- a/activesupport/lib/active_support/core_ext/numeric/time.rb +++ b/activesupport/lib/active_support/core_ext/numeric/time.rb @@ -1,4 +1,6 @@ require 'active_support/duration' +require 'active_support/core_ext/time/calculations' +require 'active_support/core_ext/time/acts_like' class Numeric # Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years. diff --git a/activesupport/lib/active_support/core_ext/object/duplicable.rb b/activesupport/lib/active_support/core_ext/object/duplicable.rb index 02cb5dfee7..9d044eba71 100644 --- a/activesupport/lib/active_support/core_ext/object/duplicable.rb +++ b/activesupport/lib/active_support/core_ext/object/duplicable.rb @@ -1,3 +1,4 @@ +#-- # Most objects are cloneable, but not all. For example you can't dup +nil+: # # nil.dup # => TypeError: can't dup NilClass @@ -14,6 +15,7 @@ # # That's why we hardcode the following cases and check duplicable? instead of # using that rescue idiom. +#++ class Object # Can you safely dup this object? # diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb index dcac17536a..00fda2b370 100644 --- a/activesupport/lib/active_support/core_ext/time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/time/calculations.rb @@ -1,4 +1,5 @@ require 'active_support/duration' +require 'active_support/core_ext/time/zones' class Time COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] diff --git a/activesupport/test/option_merger_test.rb b/activesupport/test/option_merger_test.rb index 5b2e16a212..2bdd3034e5 100644 --- a/activesupport/test/option_merger_test.rb +++ b/activesupport/test/option_merger_test.rb @@ -66,11 +66,11 @@ class OptionMergerTest < Test::Unit::TestCase end end - def test_nested_method_with_options_using_lamdba - local_lamdba = lambda { { :lambda => true } } + def test_nested_method_with_options_using_lambda + local_lambda = lambda { { :lambda => true } } with_options(@options) do |o| - assert_equal @options.merge(local_lamdba.call), - o.method_with_options(local_lamdba).call + assert_equal @options.merge(local_lambda.call), + o.method_with_options(local_lambda).call end end |