schedular 0.1.11 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.11
1
+ 0.1.13
@@ -19,4 +19,4 @@ es:
19
19
  formats:
20
20
  month: "%B de %Y"
21
21
  short_month: "%b %Y"
22
- long: "%d de %B de %Y"
22
+ long: "%d de %B de %Y"
@@ -15,6 +15,10 @@ module Schedular
15
15
  time = Range === time || DateTime === time ? time : (time..time+1)
16
16
  { :conditions => {:value => time} }
17
17
  }
18
+
19
+ named_scope :order_by_closest_to, lambda { |date|
20
+ {:limit => count, :order => "ABS(strftime('%s', value) - strftime('%s', #{date.to_formatted_s :db})) desc"}
21
+ }
18
22
 
19
23
  named_scope :all_day, lambda{ |bool| {:conditions => {'all_day' => (bool.nil? ? true : bool)} }}
20
24
 
data/test/test_event.rb CHANGED
@@ -97,9 +97,13 @@ class Schedular::EventTest < Test::Unit::TestCase
97
97
  assert_equal [@event3], Schedular::Event.by_params(:year => '2010', :month => '3', :day => '2')
98
98
  end
99
99
 
100
- # should 'find by params with no year' do
101
- # assert_equal Schedular::Event.find(:all), Schedular::Event.by_params(:year => nil)
102
- # end
100
+ should 'find by params with no year' do
101
+ assert_equal Schedular::Event.find(:all), Schedular::Event.by_params(:year => nil)
102
+ end
103
+
104
+ should 'find closest prior date' do
105
+ assert_equal Schedular::Time.by_time_or_period(Date.civil(2010, 1, -1)), Schedular::Event.closest_dates(Date.civil(2010, 3), 1)
106
+ end
103
107
  end
104
108
 
105
109
  should 'allways order times by value' do
data/test/test_time.rb CHANGED
@@ -71,6 +71,10 @@ class Schedular::TimeTest < Test::Unit::TestCase
71
71
  day = Date.civil(2010, 3, 2)
72
72
  assert_equal Schedular::Time.by_time_or_period(day..day + 1), Schedular::Time.by_params(:year => '2010', :month => '3', :day => '2')
73
73
  end
74
+
75
+ should 'find closest' do
76
+ assert_equal Schedular::Time.by_time_or_period(Date.civil(2010, 2, -1)), Schedular::Time.closest_to(Date.civil(2010, 3), 1)
77
+ end
74
78
  end
75
79
 
76
80
  should 'allways order by value' do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schedular
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 11
10
- version: 0.1.11
9
+ - 13
10
+ version: 0.1.13
11
11
  platform: ruby
12
12
  authors:
13
13
  - Macario Ortega
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-11 00:00:00 -05:00
18
+ date: 2010-10-26 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency