lita-schedule 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 +9 -3
- data/lib/lita/lita.rb +9 -2
- data/lib/lita/schedule.rb +8 -4
- data/lib/lita/schedule/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96f91d7434b86e3af1742db62b7e63a83e8f779a
|
4
|
+
data.tar.gz: 4ac1f4f2a2b58864219d43ca63aa0d0b05ababe4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f42a7d3babcca6e2808cd0c8985d69549196df0841577d7ccac1e5e03b4133336913c500473a20e94c9d0698c9191e34211daeef5f746c474c95bd200661d3d
|
7
|
+
data.tar.gz: 48b9cd0783eb411e0c2df7e2acec038d828cb2f99fbbf9798ea2f9bdf7bdfc053692d4a5f94a52c5ef8fae3643d6388c81789ab895ed1a0a6e330afe436894ff
|
data/README.md
CHANGED
@@ -25,8 +25,14 @@ module Lita
|
|
25
25
|
module Schedules
|
26
26
|
class TimeTone < Schedule
|
27
27
|
|
28
|
-
cron('* * * * * Asia/Tokyo', :
|
29
|
-
def
|
28
|
+
cron('* * * * * Asia/Tokyo', :every_minutes_job1)
|
29
|
+
def every_minutes_job1
|
30
|
+
target = Struct.new(:room).new('your_room@conf.hipchat.com')
|
31
|
+
robot.send_message(target, Time.now.to_s)
|
32
|
+
end
|
33
|
+
|
34
|
+
every('1m', :every_minutes_job2)
|
35
|
+
def every_minutes_job2
|
30
36
|
target = Struct.new(:room).new('your_room@conf.hipchat.com')
|
31
37
|
robot.send_message(target, Time.now.to_s)
|
32
38
|
end
|
@@ -36,7 +42,7 @@ module Lita
|
|
36
42
|
end
|
37
43
|
```
|
38
44
|
|
39
|
-
cron-fields
|
45
|
+
cron-fields and every-fields come from [jmettraux/rufus-scheduler](https://github.com/jmettraux/rufus-scheduler)
|
40
46
|
|
41
47
|
|
42
48
|
## Contributing
|
data/lib/lita/lita.rb
CHANGED
@@ -53,8 +53,15 @@ module Lita
|
|
53
53
|
|
54
54
|
Lita.schedules.each { |schedule|
|
55
55
|
schedule.jobs.each { |job|
|
56
|
-
|
57
|
-
|
56
|
+
case job.type
|
57
|
+
when :cron
|
58
|
+
@scheduler.cron job.field do
|
59
|
+
schedule.new(self).send job.job_name
|
60
|
+
end
|
61
|
+
when :cycle
|
62
|
+
@scheduler.every job.field do
|
63
|
+
schedule.new(self).send job.job_name
|
64
|
+
end
|
58
65
|
end
|
59
66
|
}
|
60
67
|
}
|
data/lib/lita/schedule.rb
CHANGED
@@ -7,11 +7,15 @@ module Lita
|
|
7
7
|
attr_reader :redis
|
8
8
|
attr_reader :robot
|
9
9
|
|
10
|
-
Job = Struct.new('Job', :
|
10
|
+
Job = Struct.new('Job', :type, :field, :job_name)
|
11
11
|
|
12
12
|
class << self
|
13
|
-
def cron(
|
14
|
-
jobs << Job.new(
|
13
|
+
def cron(field, job_name)
|
14
|
+
jobs << Job.new(:cron, field, job_name)
|
15
|
+
end
|
16
|
+
|
17
|
+
def every(field, job_name)
|
18
|
+
jobs << Job.new(:cycle, field, job_name)
|
15
19
|
end
|
16
20
|
|
17
21
|
def jobs
|
@@ -22,7 +26,7 @@ module Lita
|
|
22
26
|
if name
|
23
27
|
Util.underscore(name.split("::").last)
|
24
28
|
else
|
25
|
-
raise "
|
29
|
+
raise "Schedules that are anonymous classes must define self.name."
|
26
30
|
end
|
27
31
|
end
|
28
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-schedule
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fukayatsu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
145
|
version: '0'
|
146
146
|
requirements: []
|
147
147
|
rubyforge_project:
|
148
|
-
rubygems_version: 2.0.
|
148
|
+
rubygems_version: 2.0.3
|
149
149
|
signing_key:
|
150
150
|
specification_version: 4
|
151
151
|
summary: Add base class for scheduled job(cron) to Lita
|