aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/buffered_logger.rb15
-rw-r--r--activesupport/lib/active_support/core_ext/numeric/time.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/object/duplicable.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/time/calculations.rb1
4 files changed, 14 insertions, 6 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]