ruboty-reminder 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: 220184f328d7e33769c728a75cc2f460c846fef9
4
- data.tar.gz: 637e3a1fd2542212a2fb33cc378c34aa6531c2b7
3
+ metadata.gz: c56465750cafb460b35d7e84402b23590ea03d6f
4
+ data.tar.gz: c3c163fe199748c4f45ae8caf74f941d3ba7abfc
5
5
  SHA512:
6
- metadata.gz: 2d40ec768186e09b46a627535182cbde67e6d970b09562c4439a95f8b458c3031223a7fd739c2879581b9e783da7e02c2e75564f30bfff102cb813a7406c4013
7
- data.tar.gz: 8c88ed81d33411e35853fb7054b183949375cc5f62b194cd103d3393b7b5b7e181e57bc8e48613d4c674bd6c9c7eb43d640fa6051f4a2f4efaed2eaf22ca4822
6
+ metadata.gz: 5cc958e1a1ae1774962297d3d5303302f9467605165e8831bafa9e50a29606439ad7dc1e6f1b439bb179b6b1adf5fe640192f71872415e367d7cbd5fa750d6d3
7
+ data.tar.gz: 0a18aa9fb81d7186fb5647f7f07d28ef8641341539f839f8a52da0e982c77249e15cc3c81f041aaac56683ebf41434d0323f07be7f8e1f6b3c4bd9d5db81a3d9
data/README.md CHANGED
@@ -22,5 +22,6 @@ gem 'ruboty-reminder'
22
22
 
23
23
  ```
24
24
  > @ruboty add task 07:00 Hi,kaihara!
25
- Task 270 created.
25
+ Task 270 is created.
26
+ Hi, kaihara!
26
27
  ```
@@ -5,7 +5,7 @@ module Ruboty
5
5
 
6
6
  on /add task (?<hh>\d{2}):(?<mm>\d{2}) (?<task>.+)/, name: 'add', description: 'Add a task'
7
7
  on /delete task (?<id>.+)/, name: 'delete', description: 'Delete a task'
8
- on /list tasks/, name: 'list', description: 'Show all reminders'
8
+ on /list tasks\z/, name: 'list', description: 'Show all reminders'
9
9
 
10
10
  def initialize(*args)
11
11
  super
@@ -31,7 +31,7 @@ module Ruboty
31
31
  )
32
32
  )
33
33
  task.start(robot)
34
- message.reply("Task #{task.hash[:id]} created.")
34
+ message.reply("Task #{task.hash[:id]} is created.")
35
35
 
36
36
  # Insert to the brain
37
37
  tasks[task.hash[:id]] = task.hash
@@ -39,23 +39,21 @@ module Ruboty
39
39
 
40
40
  def delete(message)
41
41
  if tasks.delete(message[:id].to_i)
42
- message.reply('Deleted.')
42
+ message.reply("Task #{message[:id]} is deleted.")
43
43
  else
44
- message.reply('Not found.')
44
+ message.reply("Task #{message[:id]} is not found.")
45
45
  end
46
46
  end
47
47
 
48
48
  def list(message)
49
- body =
50
- if tasks.empty?
51
- "The task doesn't exist."
52
- else
53
- tasks.map do |id, hash|
54
- "#{id}: #{'%02d' % hash[:hour]}:#{'%02d' % hash[:min]} -> #{hash[:body]}"
55
- end.join("\n")
56
- end
57
-
58
- message.reply(body)
49
+ if tasks.empty?
50
+ message.reply("The task doesn't exist.")
51
+ else
52
+ task_list = tasks.map do |id, hash|
53
+ "#{id}: #{'%02d' % hash[:hour]}:#{'%02d' % hash[:min]} -> #{hash[:body]}"
54
+ end.join("\n")
55
+ message.reply(task_list, code: true)
56
+ end
59
57
  end
60
58
 
61
59
  def restart
@@ -10,14 +10,21 @@ module Ruboty
10
10
  end
11
11
 
12
12
  def start(robot)
13
- current_time = Time.now
14
- target = Time.new(current_time.year, current_time.month, current_time.day, hash[:hour], hash[:min], 0)
13
+ current_time = Time.new.to_i
14
+ target_time = Time.new(
15
+ Time.now.year,
16
+ Time.now.month,
17
+ Time.now.day,
18
+ hash[:hour],
19
+ hash[:min],
20
+ 0
21
+ ).to_i
15
22
 
16
23
  wait_time =
17
- if target.to_i - current_time.to_i < 0
18
- (target + 24*60*60).to_i - current_time.to_i
24
+ if target_time - current_time < 0
25
+ (target_time + 24*60*60) - current_time
19
26
  else
20
- target.to_i - current_time.to_i
27
+ target_time - current_time
21
28
  end
22
29
 
23
30
  Thread.start do
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module Reminder
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: ruboty-reminder
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
  - kaihar4
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-16 00:00:00.000000000 Z
11
+ date: 2014-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruboty