aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2014-01-01 20:29:56 +0000
committerAndrew White <andyw@pixeltrix.co.uk>2014-01-01 20:29:56 +0000
commit75ad0e642c69cd037ce02172ce68e664634389ed (patch)
tree385c9e2df073cab79ce05b42451f954eff7f6e68 /activesupport
parente97d48f17e2ac5a0530c096543253886e057f624 (diff)
downloadrails-75ad0e642c69cd037ce02172ce68e664634389ed.tar.gz
rails-75ad0e642c69cd037ce02172ce68e664634389ed.tar.bz2
rails-75ad0e642c69cd037ce02172ce68e664634389ed.zip
Don't lazy load the tzinfo library
Lazy loading the tzinfo library doesn't really buy us anything because the gem is installed as a dependency via the gemspec and if a developer is using Active Support outside of Rails then they can cherry pick which files to load anyway. Fixes #13553
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/CHANGELOG.md6
-rw-r--r--activesupport/lib/active_support/values/time_zone.rb21
2 files changed, 8 insertions, 19 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index b1a6ac30d3..19db8ac873 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -1,3 +1,9 @@
+* Don't lazy load the `tzinfo` library as it causes problems on Windows.
+
+ Fixes #13553
+
+ *Andrew White*
+
* Use `remove_possible_method` instead of `remove_method` to avoid
a `NameError` to be thrown on FreeBSD with the `Date` object.
diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb
index 3862ab5c42..8ca4973162 100644
--- a/activesupport/lib/active_support/values/time_zone.rb
+++ b/activesupport/lib/active_support/values/time_zone.rb
@@ -1,3 +1,4 @@
+require 'tzinfo'
require 'thread_safe'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/object/try'
@@ -208,8 +209,6 @@ module ActiveSupport
# (GMT). Seconds were chosen as the offset unit because that is the unit
# that Ruby uses to represent time zone offsets (see Time#utc_offset).
def initialize(name, utc_offset = nil, tzinfo = nil)
- self.class.send(:require_tzinfo)
-
@name = name
@utc_offset = utc_offset
@tzinfo = tzinfo || TimeZone.find_tzinfo(name)
@@ -389,7 +388,7 @@ module ActiveSupport
case arg
when String
begin
- lazy_zones_map[arg] ||= create(arg).tap { |tz| tz.utc_offset }
+ @lazy_zones_map[arg] ||= create(arg).tap { |tz| tz.utc_offset }
rescue TZInfo::InvalidTimezoneIdentifier
nil
end
@@ -406,22 +405,6 @@ module ActiveSupport
def us_zones
@us_zones ||= all.find_all { |z| z.name =~ /US|Arizona|Indiana|Hawaii|Alaska/ }
end
-
- protected
-
- def require_tzinfo
- require 'tzinfo' unless defined?(::TZInfo)
- rescue LoadError
- $stderr.puts "You don't have tzinfo installed in your application. Please add it to your Gemfile and run bundle install"
- raise
- end
-
- private
-
- def lazy_zones_map
- require_tzinfo
- @lazy_zones_map
- end
end
private