From 4b1327306d547fbefdac1716cf0d4ba5a3f44ac8 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Fri, 11 Mar 2011 11:01:39 +0000 Subject: [PATCH] fixed some weird loading/require issues which seemed to be happening on rare occasions when used in a rails project --- lib/time_ext.rb | 4 ---- lib/time_ext/core_ext/numeric.rb | 2 ++ lib/time_ext/core_ext/time.rb | 4 ++++ time_ext.gemspec | 4 +++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/time_ext.rb b/lib/time_ext.rb index 3544f1e..73b975e 100644 --- a/lib/time_ext.rb +++ b/lib/time_ext.rb @@ -1,8 +1,4 @@ require 'rubygems' -require 'active_support' - -# support both Active Support 2.x and 3.x -require 'active_support/time' if !Time.respond_to?(:days_in_month) require 'time_ext/calculations' require 'time_ext/iterations' diff --git a/lib/time_ext/core_ext/numeric.rb b/lib/time_ext/core_ext/numeric.rb index e7c112c..5f31973 100644 --- a/lib/time_ext/core_ext/numeric.rb +++ b/lib/time_ext/core_ext/numeric.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/numeric/time' unless Numeric.new.respond_to?(:seconds) # fixes rare loading issue + class Numeric alias :sec :seconds alias :min :minutes diff --git a/lib/time_ext/core_ext/time.rb b/lib/time_ext/core_ext/time.rb index aa5c599..c3ca9ed 100644 --- a/lib/time_ext/core_ext/time.rb +++ b/lib/time_ext/core_ext/time.rb @@ -1,3 +1,7 @@ +require 'active_support' +require 'active_support/time' unless Time.respond_to?(:days_in_month) # support both Active Support 2.x and 3.x +require 'active_support/core_ext/time/calculations' unless Time.new.respond_to?(:ago) # fixes rare loading issue + class Time include TimeExt::Support include TimeExt::Calculations diff --git a/time_ext.gemspec b/time_ext.gemspec index 50b5317..fc32bd8 100644 --- a/time_ext.gemspec +++ b/time_ext.gemspec @@ -19,9 +19,11 @@ Gem::Specification.new do |s| s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] - s.add_runtime_dependency 'activesupport', '>= 2.3.0' + s.add_runtime_dependency 'activesupport', '>= 2.3.2' s.add_runtime_dependency 'i18n', '>= 0.4.2' + s.add_development_dependency 'rake', '>= 0.8.7' s.add_development_dependency 'rspec', '>= 2.1.0' s.add_development_dependency 'yard', '>= 0.6.3' + s.add_development_dependency 'ruby-debug' end