ruboty-reminder 0.2.0 → 0.2.1

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: da80f209dcff681fda0091e2be6025fdd58ea5b2
4
- data.tar.gz: 0c5b965d4791226ca2ce14a99b941fe17811e7bc
3
+ metadata.gz: 93fb18c3e643c38f4af4441b0823494061952f11
4
+ data.tar.gz: 82c4b5602bf80e1290b84e4ecad0bf1230737d20
5
5
  SHA512:
6
- metadata.gz: a01a00f58699c9ea3b6a561d8564f845f284c059c8c2e789a548ed7c4dc85a1f47968d548f4b93d8807ee1633cb307542d81aa5ed2088715ba6f82fd12bb0ae1
7
- data.tar.gz: 223f2cbf7cd3eaade988047e2d2ecf25dcc10afe6164f897cbf2a9e863ec833b0d2860d94344946ed7e736e61c9e36523839e8df72eb39178e14303f24b92ac0
6
+ metadata.gz: db32f2201a7b285a3d5e2d8c0a968a8809ad3d601a92a38ea2e4c6974f20263cf896b954370e28cbe509071bac6278360a19c8b8e9992f77fae18e6045108e60
7
+ data.tar.gz: c45044e3319bd2d338ed800f82c2eb8af40d2861f549864cbeeb1d8e381e430859516267b9c0daba497b82ac15adfd3575061d1d793f0ffb81fabbfea35256d6
@@ -55,13 +55,11 @@ module Ruboty
55
55
  task.start(robot)
56
56
  message.reply("Reminder #{task.hash[:id]} is created.")
57
57
 
58
- reminders[task.hash[:id]] = task
58
+ reminders[task.hash[:id]] = task.hash
59
59
  end
60
60
 
61
61
  def delete(message)
62
- if task = reminders[message[:id].to_i]
63
- task.thread.kill
64
- reminders.delete(message[:id].to_i)
62
+ if reminders.delete(message[:id].to_i)
65
63
  message.reply("Reminder #{message[:id]} is deleted.")
66
64
  else
67
65
  message.reply("Reminder #{message[:id]} is not found.")
@@ -72,21 +70,21 @@ module Ruboty
72
70
  if reminders.empty?
73
71
  message.reply("The reminder doesn't exist.")
74
72
  else
75
- sorted_reminders = reminders.sort_by {|_id, task| task.hash[:unixtime]}
73
+ sorted_reminders = reminders.sort_by {|_id, hash| hash[:unixtime]}
76
74
 
77
- reminder_list = sorted_reminders.map do |id, task|
78
- date = "#{task.hash[:year]}/#{'%02d' % task.hash[:month]}/#{'%02d' % task.hash[:day]}"
79
- time = "#{'%02d' % task.hash[:hour]}:#{'%02d' % task.hash[:min]}"
80
- "#{id}: #{date} #{time} -> #{task.hash[:body]}"
75
+ reminder_list = sorted_reminders.map do |id, hash|
76
+ date = "#{hash[:year]}/#{'%02d' % hash[:month]}/#{'%02d' % hash[:day]}"
77
+ time = "#{'%02d' % hash[:hour]}:#{'%02d' % hash[:min]}"
78
+ "#{id}: #{date} #{time} -> #{hash[:body]}"
81
79
  end
82
80
  message.reply(reminder_list.join("\n"), code: true)
83
81
  end
84
82
  end
85
83
 
86
84
  def restart
87
- reminders.each do |id, task|
88
- new_task = Ruboty::Reminder::Task.new(task.hash)
89
- new_task.start(robot)
85
+ reminders.each do |id, hash|
86
+ task = Ruboty::Reminder::Task.new(hash)
87
+ task.start(robot)
90
88
  end
91
89
  end
92
90
 
@@ -1,17 +1,16 @@
1
1
  module Ruboty
2
2
  module Reminder
3
3
  class Task
4
- attr_reader :hash, :thread
4
+ attr_reader :hash
5
5
 
6
6
  def initialize(hash)
7
7
  @hash = hash
8
- @thread = nil
9
8
  end
10
9
 
11
10
  def start(robot)
12
11
  wait_time = hash[:unixtime] - Time.now.to_i
13
12
 
14
- @thread = Thread.start do
13
+ Thread.start do
15
14
  sleep(wait_time)
16
15
  Message.new(
17
16
  hash.except(:id, :body, :year, :month, :day, :hour, :min, :unixtime).merge(robot: robot)
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module Reminder
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaihar4
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-11 00:00:00.000000000 Z
11
+ date: 2015-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruboty
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  requirements: []
91
91
  rubyforge_project:
92
- rubygems_version: 2.2.2
92
+ rubygems_version: 2.4.5
93
93
  signing_key:
94
94
  specification_version: 4
95
95
  summary: Ruboty handler to remind a task.