day_planner 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 945c2843fc7f28b960f82bd71392ab2ef725ce0d
4
- data.tar.gz: b716a7c571a211836e45bc0391612beee4ef6b2b
3
+ metadata.gz: dd170c0b68eb8d2b6f5500d091e48f54f84ed18b
4
+ data.tar.gz: 8d60689a518fb2eef34d02bd69cf428cc2f2ca98
5
5
  SHA512:
6
- metadata.gz: 803d6968fc5ae408ac6dfa209fd5a62b8494d72ea7c114da515ce70d6634816c79c4bc320c7ad428766331e5cd37eb9f2f4d3b08c6f26f7b619fb442cd3768d7
7
- data.tar.gz: 2d302295627b1d2a1dd90a90dac2c72a6152e6e89f1a47aa22ba04f1032b2d2e3e3f9c4b61fb4d94ccf60ae50cde3675cb3df84bb671df7dfa5b5a589d8d9a98
6
+ metadata.gz: 4c5afc19ceb951b1d4a110b7c2f4315a4b30e416bbf7ca0c984f6a3e5de0a184c4dec0acc5fe2d64697013fa74f144ebe1369140b3ca03f39c58108df3bff97c
7
+ data.tar.gz: 7806772039f3eaeacee8eb60b6e1d261fbca268fb8a482815b2de4016c548b40e45d52c4bfd104a23af432b38a195a96032155ee799a2759a1c35cf39aefdc8c
data/README.md CHANGED
@@ -24,13 +24,29 @@ If you're using Rails, it'll expect to find a file listing scheduled tasks in 'c
24
24
 
25
25
  ## Usage
26
26
 
27
- Here's an example of a scheduled task, living in (app)/config/scheduled_tasks.rb (this is the required/automatic location of the schedule file if you're using Rails):
27
+ ### Rails
28
+
29
+ Create a file called config/scheduled_tasks.rb. Put tasks in it like this:
28
30
 
29
31
  DayPlanner.schedule(every: 2.minutes) do
30
32
  MyClass.my_class_method
31
33
  end
32
34
 
33
- Obviously you only get those cute little time methods in Rails; otherwise, pass in an integer number of seconds. More sophisticated ways of scheduling tasks are intended in the future, but for now you'll just have to cope. If you don't specify an interval with 'every', it'll happen once and never again.
35
+ This file will be read in and its tasks will be added to the schedule automatically.
36
+
37
+ ### If you're not using Rails
38
+
39
+ I don't really know if it'll work. I haven't tried.
40
+
41
+ You will have to create a scheduled tasks file, somewhere. Use the same format, but obviously you won't have those cute little Rails-y time methods. You'll want to include this at the bottom:
42
+
43
+ DayPlanner.activate
44
+
45
+ It's only activated automatically in Rails.
46
+
47
+ I have not tested it outside of Rails and it may not work at all but ideally I'd prefer that it did. If you can give me feedback, I'd be much obliged.
48
+
49
+ ### Either way
34
50
 
35
51
  The tasks in the schedule will each be performed on startup and then thereafter according to their stated intervals.
36
52
 
@@ -44,7 +60,7 @@ Or, like
44
60
 
45
61
  DayPlanner.interval = 5
46
62
 
47
- 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 complain but not fail. It obviously will only run at scheduler thread's intervals. Use your best judgment.
63
+ 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 complain but not fail. The task obviously will only run at scheduler thread's intervals. Use your best judgment.
48
64
 
49
65
  Specify your preferred interval (and whatever other goodies may be waiting in the pipeline) 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. Don't pressure me.
50
66
 
@@ -74,10 +90,6 @@ To cancel a task, you can either call the task's "destroy" method, or call a cla
74
90
 
75
91
  You can either pass a name, if you named the task, or the task object.
76
92
 
77
- ### Non-Rails uses
78
-
79
- I sort of think it might work without Rails, keeping in mind the various aforementioned caveats? I'm not really sure. If it totally doesn't, I'd appreciate feedback.
80
-
81
93
  ## Contributing
82
94
 
83
95
  1. Fork it
@@ -1,6 +1,14 @@
1
1
  module DayPlanner
2
2
  @@tasks = []
3
3
  @@named_tasks = {}
4
+ @@status = "stopped"
5
+
6
+ class Railtie < Rails::Railtie
7
+ config.after_initialize do
8
+ require File.expand_path('config/scheduled_tasks')
9
+ DayPlanner.activate
10
+ end
11
+ end
4
12
 
5
13
  class << self
6
14
  def tasks
@@ -18,9 +26,19 @@ module DayPlanner
18
26
  raise ArgumentError, "DayPlanner couldn't find this task" if task.nil? || !task.is_a?(DayPlanner::Task)
19
27
  task.destroy
20
28
  end
29
+
30
+ def status
31
+ @@status
32
+ end
33
+
34
+ def deactivate
35
+ @@master.kill if defined?(@@master)
36
+ @@status = "stopped"
37
+ end
21
38
 
22
39
  def activate
23
40
  @@master.kill if defined?(@@master)
41
+ @@status = "running"
24
42
 
25
43
  if defined?(Rails) && Rails.logger
26
44
  Rails.logger.info("DayPlanner activated.")
@@ -153,7 +171,3 @@ module DayPlanner
153
171
  end
154
172
  end
155
173
  end
156
-
157
- require File.expand_path('config/scheduled_tasks') if defined?(Rails)
158
-
159
- DayPlanner.activate
@@ -1,7 +1,7 @@
1
1
  module DayPlanner
2
2
  MAJOR = 0
3
3
  MINOR = 0
4
- TINY = 11
4
+ TINY = 12
5
5
  BUILD = nil
6
6
 
7
7
  VERSION = [MAJOR, MINOR, TINY, BUILD].compact.join(".")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: day_planner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damon Siefert