taskbot 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ gem "mongo_mapper", "~> 0.8.6"
5
5
  gem "bson_ext", "~> 1.2.4"
6
6
  gem "daemons", "~> 1.1.0"
7
7
  gem "optiflag", "~> 0.7"
8
+ gem "mongomapper_id2", "~> 0.0.3"
8
9
 
9
10
  group :development do
10
11
  gem "bundler", "~> 1.0.0"
@@ -19,6 +19,11 @@ GEM
19
19
  activesupport (>= 2.3.4)
20
20
  jnunemaker-validatable (~> 1.8.4)
21
21
  plucky (~> 0.3.6)
22
+ mongomapper_id2 (0.0.3)
23
+ activesupport (>= 2.3.4)
24
+ jnunemaker-validatable (~> 1.8.4)
25
+ mongo_mapper
26
+ plucky (~> 0.3.6)
22
27
  optiflag (0.7)
23
28
  plucky (0.3.7)
24
29
  mongo (~> 1.1)
@@ -34,4 +39,5 @@ DEPENDENCIES
34
39
  daemons (~> 1.1.0)
35
40
  jeweler (~> 1.5.2)
36
41
  mongo_mapper (~> 0.8.6)
42
+ mongomapper_id2 (~> 0.0.3)
37
43
  optiflag (~> 0.7)
@@ -58,9 +58,11 @@ It is distributed as a Ruby gem and based on Cinch and MongoDB.
58
58
 
59
59
  Use --daemonize if you want to run it in the background.
60
60
 
61
- == Usage
61
+ == Changes
62
62
 
63
- Explore the options and features available with !task help
63
+ 0.1.2 - Fixes a bug preventing tasks from being removed correctly, and shortens visible task
64
+ identifiers to a simple integer. If you're updating an existing db you will need to
65
+ add a unique integer 'id2' to each task manually.
64
66
 
65
67
  == Getting Help
66
68
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -1,12 +1,17 @@
1
1
  module Cinch
2
2
  module Plugins
3
3
  module TaskBot
4
-
4
+
5
+ # content - String - Description of the item
6
+ # status - Symbol - Typically :open or :completed
7
+ # id2 - Integer - Auto-incrementing numeric key (id uses ObjectId).
8
+ # Numeric IDs are easier for users to deal with over IRC.
5
9
  class Task
6
10
  include MongoMapper::Document
7
11
  key :content, String
8
12
  key :status, Symbol, :default => :open
9
13
  belongs_to :user
14
+ auto_increment!
10
15
  end
11
16
 
12
17
  end
@@ -7,8 +7,8 @@ module Cinch
7
7
  match /add "(.+)"/, :method => :add_task
8
8
  match /add (.+) "(.+)"/, :method => :add_task_for
9
9
 
10
- match /complete|finish #(.+)/, :method => :complete_task
11
- match /rm|delete|remove #(.+)/, :method => :remove_task
10
+ match /(complete|finish) #(\d+)/, :method => :complete_task
11
+ match /(rm|delete|remove) #(\d+)/, :method => :remove_task
12
12
 
13
13
  match /list$/, :method => :get_list
14
14
  match /list (.+)/, :method => :get_list_for
@@ -49,18 +49,18 @@ module Cinch
49
49
  end
50
50
 
51
51
  # Mark a task completed
52
- def complete_task(m, task_id)
53
- set_task_status(m, task_id, :completed)
52
+ def complete_task(m, cmd_alias, task_id2)
53
+ set_task_status(m, task_id2.to_i, :completed)
54
54
  end
55
55
 
56
56
  # Remove a task
57
- def remove_task(m, task_id)
58
- task = Task.find(task_id)
57
+ def remove_task(m, cmd_alias, task_id2)
58
+ task = Task.find_by_id2(task_id2.to_i)
59
59
  if task
60
- Task.destroy(task_id)
61
- m.reply "Task ##{task_id} has been removed."
60
+ task.destroy
61
+ m.reply "Task ##{task_id2} has been removed."
62
62
  else
63
- m.reply "Task ##{task_id} not found."
63
+ m.reply "Task ##{task_id2} not found."
64
64
  end
65
65
  end
66
66
 
@@ -81,7 +81,7 @@ module Cinch
81
81
  user_status = (user.nil?) ? "New user '#{nick}' created" : "Existing user '#{nick}' found"
82
82
  user ||= User.create( :nick => nick )
83
83
  task = user.tasks.create( :content => content )
84
- m.reply "#{user_status}, task added as ##{task.id}"
84
+ m.reply "#{user_status}, task added as ##{task.id2}"
85
85
  return task
86
86
  end
87
87
 
@@ -90,24 +90,26 @@ module Cinch
90
90
  user = User.find_by_nick(nick)
91
91
  user_status = (user.nil?) ? "New user '#{nick}' created" : "Existing user '#{nick}' found"
92
92
  user ||= User.create( :nick => nick )
93
- open_tasks = user.tasks.map { |t| t if t.status == :open }
93
+ open_tasks = user.tasks.select { |t| t if t.status == :open }
94
94
  if open_tasks.empty?
95
95
  m.reply "#{user_status}, no open tasks."
96
96
  else
97
97
  m.reply "#{user_status}, open tasks:"
98
- open_tasks.each { |t| m.reply "##{t._id} #{t.content}" }
98
+ open_tasks.sort_by { |t| t.id2 }.each do |t|
99
+ m.reply "##{t.id2} #{t.content}"
100
+ end
99
101
  end
100
102
  end
101
103
 
102
- def set_task_status(m, task_id, new_status)
103
- task = Task.find(task_id)
104
+ def set_task_status(m, task_id2, new_status)
105
+ task = Task.find_by_id2(task_id2.to_i)
104
106
  if task
105
107
  old_status = task.status
106
108
  task.status = new_status
107
109
  task.save
108
- m.reply "Task ##{task.id} status changed from #{old_status} to #{task.status}"
110
+ m.reply "Task ##{task.id2} status changed from #{old_status} to #{task.status}"
109
111
  else
110
- m.reply "Task ##{task_id} not found."
112
+ m.reply "Task ##{task.id2} not found."
111
113
  end
112
114
  end
113
115
 
@@ -1,4 +1,4 @@
1
- %w{rubygems cinch mongo_mapper}.each { |d| require d }
1
+ %w{rubygems cinch mongo_mapper mongomapper_id2}.each { |d| require d }
2
2
 
3
3
  require "#{File.dirname(__FILE__)}/cinch/plugins/taskbot"
4
4
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{taskbot}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Logan Koester"]
12
- s.date = %q{2011-03-21}
12
+ s.date = %q{2011-03-30}
13
13
  s.default_executable = %q{taskbot}
14
14
  s.description = %q{Simple to-do lists implemented as an IRC robot}
15
15
  s.email = %q{logan@logankoester.com}
@@ -49,6 +49,7 @@ Gem::Specification.new do |s|
49
49
  s.add_runtime_dependency(%q<bson_ext>, ["~> 1.2.4"])
50
50
  s.add_runtime_dependency(%q<daemons>, ["~> 1.1.0"])
51
51
  s.add_runtime_dependency(%q<optiflag>, ["~> 0.7"])
52
+ s.add_runtime_dependency(%q<mongomapper_id2>, ["~> 0.0.3"])
52
53
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
53
54
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
54
55
  else
@@ -57,6 +58,7 @@ Gem::Specification.new do |s|
57
58
  s.add_dependency(%q<bson_ext>, ["~> 1.2.4"])
58
59
  s.add_dependency(%q<daemons>, ["~> 1.1.0"])
59
60
  s.add_dependency(%q<optiflag>, ["~> 0.7"])
61
+ s.add_dependency(%q<mongomapper_id2>, ["~> 0.0.3"])
60
62
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
61
63
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
62
64
  end
@@ -66,6 +68,7 @@ Gem::Specification.new do |s|
66
68
  s.add_dependency(%q<bson_ext>, ["~> 1.2.4"])
67
69
  s.add_dependency(%q<daemons>, ["~> 1.1.0"])
68
70
  s.add_dependency(%q<optiflag>, ["~> 0.7"])
71
+ s.add_dependency(%q<mongomapper_id2>, ["~> 0.0.3"])
69
72
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
70
73
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
71
74
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Logan Koester
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-03-21 00:00:00 -04:00
17
+ date: 2011-03-30 00:00:00 -04:00
18
18
  default_executable: taskbot
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -92,8 +92,23 @@ dependencies:
92
92
  prerelease: false
93
93
  version_requirements: *id005
94
94
  - !ruby/object:Gem::Dependency
95
- name: bundler
95
+ name: mongomapper_id2
96
96
  requirement: &id006 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ segments:
102
+ - 0
103
+ - 0
104
+ - 3
105
+ version: 0.0.3
106
+ type: :runtime
107
+ prerelease: false
108
+ version_requirements: *id006
109
+ - !ruby/object:Gem::Dependency
110
+ name: bundler
111
+ requirement: &id007 !ruby/object:Gem::Requirement
97
112
  none: false
98
113
  requirements:
99
114
  - - ~>
@@ -105,10 +120,10 @@ dependencies:
105
120
  version: 1.0.0
106
121
  type: :development
107
122
  prerelease: false
108
- version_requirements: *id006
123
+ version_requirements: *id007
109
124
  - !ruby/object:Gem::Dependency
110
125
  name: jeweler
111
- requirement: &id007 !ruby/object:Gem::Requirement
126
+ requirement: &id008 !ruby/object:Gem::Requirement
112
127
  none: false
113
128
  requirements:
114
129
  - - ~>
@@ -120,7 +135,7 @@ dependencies:
120
135
  version: 1.5.2
121
136
  type: :development
122
137
  prerelease: false
123
- version_requirements: *id007
138
+ version_requirements: *id008
124
139
  description: Simple to-do lists implemented as an IRC robot
125
140
  email: logan@logankoester.com
126
141
  executables:
@@ -158,7 +173,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
173
  requirements:
159
174
  - - ">="
160
175
  - !ruby/object:Gem::Version
161
- hash: -1125883457316166182
176
+ hash: -3386362502869741852
162
177
  segments:
163
178
  - 0
164
179
  version: "0"