From 9bbd974a75e50ef514b04f4b900076275713bbbc Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Tue, 28 Sep 2010 19:15:39 +0300 Subject: [PATCH 1/4] fixed compatibility with Active Support 3.x --- lib/time_ext.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/time_ext.rb b/lib/time_ext.rb index 0b59b37..3544f1e 100644 --- a/lib/time_ext.rb +++ b/lib/time_ext.rb @@ -1,6 +1,9 @@ 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' require 'time_ext/support' From 5afb6bc2b9428251dc6438be01f8705f8aea260d Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Tue, 28 Sep 2010 19:16:11 +0300 Subject: [PATCH 2/4] removed last traces of Time#map method which was causing issues with Active Record --- lib/time_ext/iterations.rb | 2 +- spec/time_iterations_spec.rb | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/time_ext/iterations.rb b/lib/time_ext/iterations.rb index 6eb4aa2..01e13e7 100644 --- a/lib/time_ext/iterations.rb +++ b/lib/time_ext/iterations.rb @@ -83,7 +83,7 @@ module TimeExt # Dynamically define convenience methods, like #each_hour instead of #each(:hour). [:year, :month, :day, :hour, :min, :sec].each do |unit| - [:each, :beginning_of_each, :map_each, :map_beginning_of_each, :map].each do |method| + [:each, :beginning_of_each, :map_each, :map_beginning_of_each].each do |method| define_method "#{method}_#{unit}" do |*args, &block| send(method, unit, *args, &block) end diff --git a/spec/time_iterations_spec.rb b/spec/time_iterations_spec.rb index 4eaa326..00c3785 100644 --- a/spec/time_iterations_spec.rb +++ b/spec/time_iterations_spec.rb @@ -52,8 +52,6 @@ describe "Time Iterations" do match = (1..6).map { |i| @now + i.hours } @now.map_each_hour.until(@now + 6.hours) { |time| time }.should == match @now.until(@now + 6.hours).map_each(:hour) { |time| time }.should == match - # check so the #map alias for #map_each works - @now.map_hour.until(@now + 6.hours) { |time| time }.should == match end it "should iterate over time objects backwards with #until set in the past" do From 5ece10846a2040c59eba28a668fbb7d33e0b18b5 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Tue, 28 Sep 2010 19:16:36 +0300 Subject: [PATCH 3/4] added spec to check for core extention method aliases --- spec/core_ext_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 spec/core_ext_spec.rb diff --git a/spec/core_ext_spec.rb b/spec/core_ext_spec.rb new file mode 100644 index 0000000..df001ae --- /dev/null +++ b/spec/core_ext_spec.rb @@ -0,0 +1,19 @@ +require File.expand_path(File.dirname(__FILE__) + '/spec_helper') + +describe "Core Extensions" do + + it "should alias Numeric class methods" do + number = 1 + number.sec.should == number.second + number.min.should == number.minute + end + + it "should alias Time instance methods" do + time = Time.now + time.secs_ago(10).should == time.ago(10) + time.seconds_ago(10).should == time.ago(10) + time.secs_since(10).should == time.since(10) + time.seconds_since(10).should == time.since(10) + end + +end \ No newline at end of file From f49c6bd455a09f84f98d732a4aa9fca69cb18f81 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Tue, 28 Sep 2010 19:17:19 +0300 Subject: [PATCH 4/4] Version bump to 0.2.6 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 3a4036f..53a75d6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.5 +0.2.6