time_ext 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.5
1
+ 0.2.6
data/lib/time_ext.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  require 'rubygems'
2
2
  require 'active_support'
3
3
 
4
+ # support both Active Support 2.x and 3.x
5
+ require 'active_support/time' if !Time.respond_to?(:days_in_month)
6
+
4
7
  require 'time_ext/calculations'
5
8
  require 'time_ext/iterations'
6
9
  require 'time_ext/support'
@@ -83,7 +83,7 @@ module TimeExt
83
83
 
84
84
  # Dynamically define convenience methods, like #each_hour instead of #each(:hour).
85
85
  [:year, :month, :day, :hour, :min, :sec].each do |unit|
86
- [:each, :beginning_of_each, :map_each, :map_beginning_of_each, :map].each do |method|
86
+ [:each, :beginning_of_each, :map_each, :map_beginning_of_each].each do |method|
87
87
  define_method "#{method}_#{unit}" do |*args, &block|
88
88
  send(method, unit, *args, &block)
89
89
  end
@@ -0,0 +1,19 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Core Extensions" do
4
+
5
+ it "should alias Numeric class methods" do
6
+ number = 1
7
+ number.sec.should == number.second
8
+ number.min.should == number.minute
9
+ end
10
+
11
+ it "should alias Time instance methods" do
12
+ time = Time.now
13
+ time.secs_ago(10).should == time.ago(10)
14
+ time.seconds_ago(10).should == time.ago(10)
15
+ time.secs_since(10).should == time.since(10)
16
+ time.seconds_since(10).should == time.since(10)
17
+ end
18
+
19
+ end
@@ -52,8 +52,6 @@ describe "Time Iterations" do
52
52
  match = (1..6).map { |i| @now + i.hours }
53
53
  @now.map_each_hour.until(@now + 6.hours) { |time| time }.should == match
54
54
  @now.until(@now + 6.hours).map_each(:hour) { |time| time }.should == match
55
- # check so the #map alias for #map_each works
56
- @now.map_hour.until(@now + 6.hours) { |time| time }.should == match
57
55
  end
58
56
 
59
57
  it "should iterate over time objects backwards with #until set in the past" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time_ext
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 5
10
- version: 0.2.5
9
+ - 6
10
+ version: 0.2.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jim Myhrberg
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-23 00:00:00 +03:00
18
+ date: 2010-09-28 00:00:00 +03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -87,6 +87,7 @@ files:
87
87
  - lib/time_ext/core_ext/time.rb
88
88
  - lib/time_ext/iterations.rb
89
89
  - lib/time_ext/support.rb
90
+ - spec/core_ext_spec.rb
90
91
  - spec/spec.opts
91
92
  - spec/spec_helper.rb
92
93
  - spec/time_calculations_spec.rb
@@ -126,6 +127,7 @@ signing_key:
126
127
  specification_version: 3
127
128
  summary: Extends the abilities of Ruby's built-in Time class by building on top of ActiveSupport.
128
129
  test_files:
130
+ - spec/core_ext_spec.rb
129
131
  - spec/spec_helper.rb
130
132
  - spec/time_calculations_spec.rb
131
133
  - spec/time_iterations_spec.rb