toodledo 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,36 +1,42 @@
1
- == 1.1.1 / 2008-02-29
2
-
3
- * Rake release was bad. Re-releasing.
4
-
5
- == 1.1.0 / 2008-02-24
6
-
7
- * Add functionality to add, delete goals, contexts, and folders from client.
8
- * Add functionality to archive folders.
9
- * Add stdin command to read from pipe or redirected files
10
- * Add formatters for the client so it's easier to tweak line output.
11
- * Add proper priority support to the client (in the format !top, !high, etc.)
12
- * Make filter able to take symbols.
13
- * Change symbol for goals from $ to ^ (was confusing when entering 'I owe $5')
14
- * Add unit tests for client.
15
- * Better error messages and explanation of toodledo setup.
16
- * Fix the debug command so it doesn't crash the interactive client.
17
- * Fixed some bugs in date processing.
18
- * Fixed bugs in priority handling.
19
- * Fixed session invalid bug on reconnect.
20
-
21
- == 1.0.2 / 2008-02-14
22
-
23
- * Fix a silly bug where whitespace wasn't stripped from edit, complete and delete.
24
- * Enable interactive debug, and refactor the logging to be in client, not commands.
25
- * Enable toodledo symbols to be anywhere in the string, not just before the task.
26
- * Cleaner error messages if the task id is not found.
27
- * Make sure failed commands exit with non-zero status.
28
-
29
- == 1.0.1 / 2008-02-11
30
-
31
- * Fix bug in client where priority filter was not being applied.
32
-
33
- == 1.0.0 / 2008-02-10
34
-
35
- * First version released!
36
-
1
+ == 1.1.2 / 2008-03-22
2
+
3
+ * Added get_session_info()
4
+ * Added get_account_info()
5
+ * Added get_task_by_id() and make task a little smarter about parents / subtasks.
6
+
7
+ == 1.1.1 / 2008-02-29
8
+
9
+ * Rake release was bad. Rereleasing.
10
+
11
+ == 1.1.0 / 2008-02-24
12
+
13
+ * Add functionality to add, delete goals, contexts, and folders from client.
14
+ * Add functionality to archive folders.
15
+ * Add stdin command to read from pipe or redirected files
16
+ * Add formatters for the client so it's easier to tweak line output.
17
+ * Add proper priority support to the client (in the format !top, !high, etc.)
18
+ * Make filter able to take symbols.
19
+ * Change symbol for goals from $ to ^ (was confusing when entering 'I owe $5')
20
+ * Add unit tests for client.
21
+ * Better error messages and explanation of toodledo setup.
22
+ * Fix the debug command so it doesn't crash the interactive client.
23
+ * Fixed some bugs in date processing.
24
+ * Fixed bugs in priority handling.
25
+ * Fixed session invalid bug on reconnect.
26
+
27
+ == 1.0.2 / 2008-02-14
28
+
29
+ * Fix a silly bug where whitespace wasn't stripped from edit, complete and delete.
30
+ * Enable interactive debug, and refactor the logging to be in client, not commands.
31
+ * Enable toodledo symbols to be anywhere in the string, not just before the task.
32
+ * Cleaner error messages if the task id is not found.
33
+ * Make sure failed commands exit with non-zero status.
34
+
35
+ == 1.0.1 / 2008-02-11
36
+
37
+ * Fix bug in client where priority filter was not being applied.
38
+
39
+ == 1.0.0 / 2008-02-10
40
+
41
+ * First version released!
42
+
@@ -1,39 +1,39 @@
1
- History.txt
2
- Manifest.txt
3
- README.txt
4
- Rakefile
5
- bin/toodledo
6
- lib/toodledo.rb
7
- lib/toodledo/command_line/add_command.rb
8
- lib/toodledo/command_line/base_command.rb
9
- lib/toodledo/command_line/client.rb
10
- lib/toodledo/command_line/complete_command.rb
11
- lib/toodledo/command_line/context_formatter.rb
12
- lib/toodledo/command_line/delete_command.rb
13
- lib/toodledo/command_line/edit_command.rb
14
- lib/toodledo/command_line/folder_formatter.rb
15
- lib/toodledo/command_line/goal_formatter.rb
16
- lib/toodledo/command_line/hotlist_command.rb
17
- lib/toodledo/command_line/interactive_command.rb
18
- lib/toodledo/command_line/list_contexts_command.rb
19
- lib/toodledo/command_line/list_folders_command.rb
20
- lib/toodledo/command_line/list_goals_command.rb
21
- lib/toodledo/command_line/list_tasks_command.rb
22
- lib/toodledo/command_line/parser_helper.rb
23
- lib/toodledo/command_line/setup_command.rb
24
- lib/toodledo/command_line/stdin_command.rb
25
- lib/toodledo/command_line/task_formatter.rb
26
- lib/toodledo/context.rb
27
- lib/toodledo/folder.rb
28
- lib/toodledo/goal.rb
29
- lib/toodledo/invalid_configuration_error.rb
30
- lib/toodledo/item_not_found_error.rb
31
- lib/toodledo/priority.rb
32
- lib/toodledo/repeat.rb
33
- lib/toodledo/server_error.rb
34
- lib/toodledo/session.rb
35
- lib/toodledo/task.rb
36
- test/client_test.rb
37
- test/parser_helper_test.rb
38
- test/session_test.rb
39
- test/toodledo_functional_test.rb
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ bin/toodledo
6
+ lib/toodledo.rb
7
+ lib/toodledo/command_line/add_command.rb
8
+ lib/toodledo/command_line/base_command.rb
9
+ lib/toodledo/command_line/client.rb
10
+ lib/toodledo/command_line/complete_command.rb
11
+ lib/toodledo/command_line/context_formatter.rb
12
+ lib/toodledo/command_line/delete_command.rb
13
+ lib/toodledo/command_line/edit_command.rb
14
+ lib/toodledo/command_line/folder_formatter.rb
15
+ lib/toodledo/command_line/goal_formatter.rb
16
+ lib/toodledo/command_line/hotlist_command.rb
17
+ lib/toodledo/command_line/interactive_command.rb
18
+ lib/toodledo/command_line/list_tasks_command.rb
19
+ lib/toodledo/command_line/list_contexts_command.rb
20
+ lib/toodledo/command_line/list_folders_command.rb
21
+ lib/toodledo/command_line/list_goals_command.rb
22
+ lib/toodledo/command_line/parser_helper.rb
23
+ lib/toodledo/command_line/setup_command.rb
24
+ lib/toodledo/command_line/stdin_command.rb
25
+ lib/toodledo/command_line/task_formatter.rb
26
+ lib/toodledo/context.rb
27
+ lib/toodledo/folder.rb
28
+ lib/toodledo/goal.rb
29
+ lib/toodledo/invalid_configuration_error.rb
30
+ lib/toodledo/item_not_found_error.rb
31
+ lib/toodledo/priority.rb
32
+ lib/toodledo/repeat.rb
33
+ lib/toodledo/server_error.rb
34
+ lib/toodledo/session.rb
35
+ lib/toodledo/task.rb
36
+ test/client_test.rb
37
+ test/parser_helper_test.rb
38
+ test/session_test.rb
39
+ test/toodledo_functional_test.rb
@@ -1,65 +1,65 @@
1
- #
2
- # The top level Toodledo module. This does very little that is
3
- # interesting. You probably want to look at Toodledo::Session
4
- #
5
- module Toodledo
6
-
7
- # Required for gem
8
- VERSION = '1.1.1'
9
-
10
- # Returns the configuration object.
11
- def self.get_config()
12
- return @@config
13
- end
14
-
15
- # Sets the configuration explicitly. Useful when you
16
- # want to specifically set the configuration without
17
- # using the file system.
18
- def self.set_config(override_config)
19
- @@config = override_config
20
- end
21
-
22
- #
23
- # Provides a convenient way of connecting and running a session.
24
- #
25
- # The following will do most everything you want, assuming you've set
26
- # the config correctly:
27
- #
28
- # require 'toodledo'
29
- # Toodledo.begin do |session|
30
- # session.add_task('foo')
31
- # end
32
- #
33
- def self.begin(logger = nil)
34
- config = Toodledo.get_config()
35
-
36
- proxy = config['proxy']
37
-
38
- connection = config['connection']
39
- base_url = connection['url']
40
- user_id = connection['user_id']
41
- password = connection['password']
42
-
43
- session = Session.new(user_id, password, logger)
44
-
45
- base_url = Session::DEFAULT_API_URL if (base_url == nil)
46
- session.connect(base_url, proxy)
47
-
48
- if (block_given?)
49
- yield(session)
50
- end
51
-
52
- session.disconnect()
53
- end
54
- end
55
-
56
- require 'toodledo/server_error'
57
- require 'toodledo/item_not_found_error'
58
- require 'toodledo/invalid_configuration_error'
59
- require 'toodledo/task'
60
- require 'toodledo/context'
61
- require 'toodledo/goal'
62
- require 'toodledo/folder'
63
- require 'toodledo/repeat'
64
- require 'toodledo/priority'
65
- require 'toodledo/session'
1
+ #
2
+ # The top level Toodledo module. This does very little that is
3
+ # interesting. You probably want to look at Toodledo::Session
4
+ #
5
+ module Toodledo
6
+
7
+ # Required for gem
8
+ VERSION = '1.1.2'
9
+
10
+ # Returns the configuration object.
11
+ def self.get_config()
12
+ return @@config
13
+ end
14
+
15
+ # Sets the configuration explicitly. Useful when you
16
+ # want to specifically set the configuration without
17
+ # using the file system.
18
+ def self.set_config(override_config)
19
+ @@config = override_config
20
+ end
21
+
22
+ #
23
+ # Provides a convenient way of connecting and running a session.
24
+ #
25
+ # The following will do most everything you want, assuming you've set
26
+ # the config correctly:
27
+ #
28
+ # require 'toodledo'
29
+ # Toodledo.begin do |session|
30
+ # session.add_task('foo')
31
+ # end
32
+ #
33
+ def self.begin(logger = nil)
34
+ config = Toodledo.get_config()
35
+
36
+ proxy = config['proxy']
37
+
38
+ connection = config['connection']
39
+ base_url = connection['url']
40
+ user_id = connection['user_id']
41
+ password = connection['password']
42
+
43
+ session = Session.new(user_id, password, logger)
44
+
45
+ base_url = Session::DEFAULT_API_URL if (base_url == nil)
46
+ session.connect(base_url, proxy)
47
+
48
+ if (block_given?)
49
+ yield(session)
50
+ end
51
+
52
+ session.disconnect()
53
+ end
54
+ end
55
+
56
+ require 'toodledo/server_error'
57
+ require 'toodledo/item_not_found_error'
58
+ require 'toodledo/invalid_configuration_error'
59
+ require 'toodledo/task'
60
+ require 'toodledo/context'
61
+ require 'toodledo/goal'
62
+ require 'toodledo/folder'
63
+ require 'toodledo/repeat'
64
+ require 'toodledo/priority'
65
+ require 'toodledo/session'
@@ -35,7 +35,7 @@ module Toodledo
35
35
  end
36
36
 
37
37
  if (task.parent_id != nil)
38
- msg += " parent[#{task.parent_id}]"
38
+ msg += " parent[#{task.parent.title}]"
39
39
  end
40
40
 
41
41
  if (task.length != nil)
@@ -46,7 +46,10 @@ module Toodledo
46
46
  msg += " timer[#{task.timer}]"
47
47
  end
48
48
 
49
- # Use the highline color library
49
+ if (task.num_children != nil)
50
+ msg += " children[#{task.num_children}]"
51
+ end
52
+
50
53
  msg += " #{task.title}"
51
54
 
52
55
  if (task.note != nil)
@@ -244,7 +244,63 @@ module Toodledo
244
244
  result = call('getUserid', params)
245
245
  return result.text
246
246
  end
247
-
247
+
248
+ #
249
+ # Returns the information associated with this account.
250
+ #
251
+ # pro : Whether or not the user is a Pro member. You need to know this if you want to use subtasks.
252
+ # dateformat : The user's prefered format for representing dates. (0=M D, Y, 1=M/D/Y, 2=D/M/Y, 3=Y-M-D)
253
+ # timezone : The number of half hours that the user's timezone is offset from the server's timezone. A value of -4 means that the user's timezone is 2 hours earlier than the server's timezone.
254
+ # hidemonths : If the task is due this many months into the future, the user wants them to be hidden.
255
+ # hotlistpriority : The priority value above which tasks should appear on the hotlist.
256
+ # hotlistduedate : The due date lead-time by which tasks should will appear on the hotlist.
257
+ def get_account_info()
258
+ result = call('getAccountInfo', {}, @key)
259
+
260
+ pro = (result.elements['pro'].text.to_i == 1) ? true : false
261
+
262
+ hash = {
263
+ :userid => result.elements['userid'].text,
264
+ :alias => result.elements['alias'].text,
265
+ :pro => pro,
266
+ :dateformat => result.elements['dateformat'].text.to_i,
267
+ :timezone => result.elements['timezone'].text.to_i,
268
+ :hidemonths => result.elements['hidemonths'].text.to_i,
269
+ :hotlistpriority => result.elements['hotlistpriority'].text.to_i,
270
+ :hotlistduedate => result.elements['hotlistduedate'].text.to_i
271
+ }
272
+
273
+ return hash
274
+ end
275
+
276
+ #
277
+ # The "getServerInfo" API call will return some information about the server and your current API session.
278
+ #
279
+ # unixtime: the time since epoch of the server.
280
+ # date: the date of the server.
281
+ # tokenexpires: how long in minutes before the current token expires.
282
+ #
283
+ def get_server_info()
284
+ result = call('getServerInfo', {}, @key)
285
+
286
+ # <server>
287
+ #<unixtime>1204569838</unixtime>
288
+ #<date>Mon, 3 Mar 2008 12:43:58 -0600</date>
289
+ #<tokenexpires>45.4</tokenexpires>
290
+ #</server>
291
+
292
+ unixtime = result.elements['unixtime'].text.to_i
293
+ server_date = Time.at(unixtime)
294
+ token_expires = result.elements['tokenexpires'].text.to_i
295
+ hash = {
296
+ :unixtime => unixtime,
297
+ :date => server_date,
298
+ :tokenexpires => token_expires
299
+ }
300
+
301
+ return hash
302
+ end
303
+
248
304
  ############################################################################
249
305
  # Tasks
250
306
  ############################################################################
@@ -354,6 +410,17 @@ module Toodledo
354
410
  end
355
411
  return tasks
356
412
  end
413
+
414
+ #
415
+ # Gets a single task by its id, and returns the task.
416
+ #
417
+ def get_task_by_id(id)
418
+ result = call('getTasks', {:id => id}, @key)
419
+ result.elements.each do |el|
420
+ task = Task.parse(self, el)
421
+ return task
422
+ end
423
+ end
357
424
 
358
425
  # Adds a task to Toodledo.
359
426
  #
@@ -22,8 +22,8 @@ module Toodledo
22
22
  # Indicates that the task's duedate is optional. See
23
23
  # http://www.toodledo.com/info/help.php?sel=42
24
24
  OPTIONAL = '?'
25
-
26
- attr_reader :parent_id, :children, :title, :tag
25
+
26
+ attr_reader :parent_id, :parent, :title, :tag
27
27
  attr_reader :added, :modified, :completed
28
28
  attr_reader :duedate, :duedatemodifier
29
29
  attr_reader :repeat, :priority, :length, :timer, :note
@@ -43,6 +43,10 @@ module Toodledo
43
43
  def goal
44
44
  return @goal
45
45
  end
46
+
47
+ def num_children
48
+ return @num_children
49
+ end
46
50
 
47
51
  def initialize(id, params = {})
48
52
  @id = id
@@ -50,8 +54,9 @@ module Toodledo
50
54
  @title = params[:title]
51
55
  @tag = params[:tag]
52
56
 
53
- @parent_id = params[:parent]
54
- @children = params[:children]
57
+ @parent_id = params[:parent_id]
58
+ @parent = params[:parent]
59
+ @num_children = params[:num_children]
55
60
 
56
61
  # The folder, context and goals are parsed out from get_tasks() call into
57
62
  # the appropriate object.
@@ -81,7 +86,7 @@ module Toodledo
81
86
  end
82
87
 
83
88
  def is_parent?
84
- return ! (@children == nil || @children == 0)
89
+ return ! (@num_children == nil || @num_children == 0)
85
90
  end
86
91
 
87
92
  # Parses a task element and returns a new Task.
@@ -164,15 +169,21 @@ module Toodledo
164
169
  priority = el.elements['priority'].text.to_i
165
170
 
166
171
  # Only set a parent if it's not the 'empty parent'.
167
- parent_id = el.elements['parent'].text
168
- if parent_id == '0'
172
+ parent_id_el = el.elements['parent']
173
+ if (parent_id_el != nil)
174
+ parent_id = parent_id_el.text
175
+ if parent_id == '0'
176
+ parent_id = nil
177
+ else
178
+ parent_id = parent_id.to_i
179
+ parent = session.get_task_by_id(parent_id)
180
+ end
181
+ else
169
182
  parent_id = nil
170
- else
171
- parent_id = parent_id.to_i
172
183
  end
173
-
184
+
174
185
  # This is actually the NUMBER of children. Two children returns 2.
175
- children = el.elements['children'].text.to_i
186
+ num_children = el.elements['children'].text.to_i
176
187
 
177
188
  title = el.elements['title'].text
178
189
 
@@ -189,8 +200,9 @@ module Toodledo
189
200
  note = nil if (note == '0')
190
201
 
191
202
  params = {
192
- :parent => parent_id,
193
- :children => children,
203
+ :parent_id => parent_id,
204
+ :parent => parent,
205
+ :num_children => num_children,
194
206
  :title => title,
195
207
  :tag => tag,
196
208
  :folder => folder,
@@ -180,6 +180,8 @@ class SessionTest < Test::Unit::TestCase
180
180
  assert myhash[:parent] == task_id
181
181
  end
182
182
 
183
+
184
+
183
185
  # handle_number
184
186
  # handle_string
185
187
  #
@@ -22,7 +22,10 @@ class ToodledoFunctionalTest < Test::Unit::TestCase
22
22
  # proxy = { 'host' => '127.0.0.1', 'port' => '8080'}
23
23
  proxy = nil
24
24
 
25
- @session = Session.new(@user_id, @password)
25
+ logger = Logger.new(STDOUT)
26
+ logger.level = Logger::ERROR
27
+
28
+ @session = Session.new(@user_id, @password, logger)
26
29
  @session.connect(base_url, proxy)
27
30
  end
28
31
 
@@ -31,11 +34,11 @@ class ToodledoFunctionalTest < Test::Unit::TestCase
31
34
  end
32
35
 
33
36
  # Always fails.
34
- # def test_get_user_id()
37
+ #def test_get_user_id()
35
38
  # user_id = @session.get_user_id(@email, @password)
36
39
  #
37
- # # assert user_id == @user_id
38
- # end
40
+ # assert user_id == @user_id
41
+ #end
39
42
 
40
43
  def test_add_edit_and_remove_task
41
44
  title = 'test_add_task'
@@ -131,6 +134,27 @@ class ToodledoFunctionalTest < Test::Unit::TestCase
131
134
  assert folders.length == 0
132
135
  end
133
136
 
137
+ def test_get_server_info()
138
+ info_hash = @session.get_server_info()
139
+
140
+ assert info_hash[:unixtime] != nil
141
+ assert info_hash[:date] != nil
142
+ assert info_hash[:tokenexpires] != nil
143
+ end
144
+
145
+ def test_get_account_info()
146
+ info_hash = @session.get_account_info()
147
+
148
+ assert info_hash[:userid] == @user_id
149
+ assert info_hash[:alias] == 'will.sargent+toodledo_rub'
150
+ assert info_hash[:pro] == false
151
+ assert info_hash[:dateformat] == 0
152
+ assert info_hash[:timezone] == 0
153
+ assert info_hash[:hidemonths] == 6
154
+ assert info_hash[:hotlistpriority] == 3
155
+ assert info_hash[:hotlistduedate] == 14
156
+ end
157
+
134
158
  #
135
159
  # Date functionality.
136
160
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toodledo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Sargent
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-02-29 00:00:00 -08:00
12
+ date: 2008-03-22 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -37,7 +37,7 @@ dependencies:
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 1.5.0
40
+ version: 1.5.1
41
41
  version:
42
42
  description: "== DESCRIPTION: This is a Ruby API and client for http://toodledo.com, a task management website. It implements all of the calls from Toodledo's developer API, and provides a nice wrapper around the functionality. The client allows you to work with Toodledo from the command line. It will work in either interactive or command line mode. You can also use the client in your shell scripts, or use the API directly as part of a web application. Custom private RSS feed? Want to have the Mac read out your top priority? Input tasks through Quicksilver? Print out tasks with a BetaBrite? It can all happen."
43
43
  email: will@tersesystems.com
@@ -67,10 +67,10 @@ files:
67
67
  - lib/toodledo/command_line/goal_formatter.rb
68
68
  - lib/toodledo/command_line/hotlist_command.rb
69
69
  - lib/toodledo/command_line/interactive_command.rb
70
+ - lib/toodledo/command_line/list_tasks_command.rb
70
71
  - lib/toodledo/command_line/list_contexts_command.rb
71
72
  - lib/toodledo/command_line/list_folders_command.rb
72
73
  - lib/toodledo/command_line/list_goals_command.rb
73
- - lib/toodledo/command_line/list_tasks_command.rb
74
74
  - lib/toodledo/command_line/parser_helper.rb
75
75
  - lib/toodledo/command_line/setup_command.rb
76
76
  - lib/toodledo/command_line/stdin_command.rb