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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8dd0935f041ad0970890bde1e14a491e38393070
4
- data.tar.gz: 860494c709c6e3c5a1ea6603ea2225c64adff057
3
+ metadata.gz: 96f91d7434b86e3af1742db62b7e63a83e8f779a
4
+ data.tar.gz: 4ac1f4f2a2b58864219d43ca63aa0d0b05ababe4
5
5
  SHA512:
6
- metadata.gz: d4f84cae0f0b1b53443209508c5752f3e6d703a976644993297cd5c4484ab5886a2c4c124982f0764bbd632e7f07f53f88d151f3aafe753974a9e38780f5882b
7
- data.tar.gz: 972de31762c139e78a1249dc6cfd3d24ff87cd584fc8b11007aae3884e81a2f371567bb866e5dd99bdb7618f56cba667ee1bcb8811fa15591a9e927d95aaea39
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', :every_minutes_job)
29
- def every_minutes_job
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 comes from [jmettraux/rufus-scheduler](https://github.com/jmettraux/rufus-scheduler)
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
- @scheduler.cron job.cron_field do
57
- schedule.new(self).send job.job_name
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', :cron_field, :job_name)
10
+ Job = Struct.new('Job', :type, :field, :job_name)
11
11
 
12
12
  class << self
13
- def cron(cron_field, job_name)
14
- jobs << Job.new(cron_field, job_name)
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 "Handlers that are anonymous classes must define self.name."
29
+ raise "Schedules that are anonymous classes must define self.name."
26
30
  end
27
31
  end
28
32
  end
@@ -1,5 +1,5 @@
1
1
  module Lita
2
2
  class Schedule
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  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.2
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-08-04 00:00:00.000000000 Z
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.2
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