day_planner 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/day_planner/base.rb +5 -21
- data/lib/day_planner/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e3db46fdb6f0e4d44bbb8cf35cc3a79e5a70591
|
4
|
+
data.tar.gz: 67ed162a83dc83baa7715518d81744a0102d7d73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6499ba96a636101542b4099a3fa5827516756cc1112e7cde358ef854e3579d59954171b125758515ac7e8c41459f0bffc23fc32334b03f817fc8fc31d3b1eae8
|
7
|
+
data.tar.gz: 072b2e04e07eb1e63a68fff4246899416a6a3af2c1a4c9067899c1b0d72e8f1f12a899b753d7e22b612817cbaade3e7209301579f4cce39b7db1e5e608fd2c80
|
data/README.md
CHANGED
@@ -44,6 +44,8 @@ Or, like
|
|
44
44
|
|
45
45
|
Note that if you try to schedule a task with an interval shorter than DayPlanner's interval, it'll complain and fail. If you shorten DayPlanner's interval to less than that of one of its tasks, it'll probably also complain and fail. Use your best judgment.
|
46
46
|
|
47
|
+
Specify these things in config/day_planner_tasks.rb. Note that you probably won't manage to precede that first minute-long wait. I may default to a shorter value in the future. I dunno.
|
48
|
+
|
47
49
|
## Contributing
|
48
50
|
|
49
51
|
1. Fork it
|
data/lib/day_planner/base.rb
CHANGED
@@ -28,24 +28,18 @@ module DayPlanner
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def interval=(value)
|
31
|
-
tasks.each do |t|
|
32
|
-
Rails.logger.warn("DayPlanner: Check interval exceeds the interval of one of its tasks. The task will perform at most every #{value.inspect}.") if t.interval > value
|
33
|
-
end
|
34
|
-
|
35
31
|
@@interval = value
|
36
32
|
end
|
37
33
|
|
38
34
|
private
|
39
35
|
def check_schedule
|
40
|
-
# Rails.logger.debug("DayPlanner is checking for tasks to perform")
|
41
|
-
|
42
36
|
tasks.each do |t|
|
43
37
|
if Time.now > t.last_executed + t.interval
|
44
38
|
begin
|
45
39
|
t.perform
|
46
40
|
rescue => e
|
47
|
-
|
48
|
-
|
41
|
+
puts "DayPlanner: Scheduled task threw an error! Behave yourselves!"
|
42
|
+
puts e.inspect
|
49
43
|
end
|
50
44
|
end
|
51
45
|
end
|
@@ -80,8 +74,8 @@ module DayPlanner
|
|
80
74
|
begin
|
81
75
|
perform
|
82
76
|
rescue => e
|
83
|
-
|
84
|
-
|
77
|
+
puts "DayPlanner: Task caused error on first performance. There's no second chance for a good first impression!"
|
78
|
+
puts e.inspect
|
85
79
|
end
|
86
80
|
end
|
87
81
|
end
|
@@ -89,14 +83,4 @@ end
|
|
89
83
|
|
90
84
|
DayPlanner.activate
|
91
85
|
|
92
|
-
if defined?(Rails)
|
93
|
-
module DayPlanner
|
94
|
-
class Railtie < Rails::Railtie
|
95
|
-
initializer "Include DayPlanner" do
|
96
|
-
ActiveSupport.on_load(:action_controller) do
|
97
|
-
include DayPlanner
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
86
|
+
require File.expand_path('config/day_planner_tasks') if defined?(Rails)
|
data/lib/day_planner/version.rb
CHANGED