toodledo 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,42 +1,47 @@
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
+ == 1.2.0 / 2008-04-19
2
+
3
+ * Added get_deleted() method
4
+ * Added lastaddedit and lastdeleted to get_account_info()
5
+
6
+ == 1.1.2 / 2008-03-22
7
+
8
+ * Added get_session_info()
9
+ * Added get_account_info()
10
+ * Added get_task_by_id() and make task a little smarter about parents / subtasks.
11
+
12
+ == 1.1.1 / 2008-03-01 (ish)
13
+
14
+ * Rake manifest was bad. Rereleasing.
15
+
16
+ == 1.1.0 / 2008-02-24
17
+
18
+ * Add functionality to add, delete goals, contexts, and folders from client.
19
+ * Add functionality to archive folders.
20
+ * Add stdin command to read from pipe or redirected files
21
+ * Add formatters for the client so it's easier to tweak line output.
22
+ * Add proper priority support to the client (in the format !top, !high, etc.)
23
+ * Make filter able to take symbols.
24
+ * Change symbol for goals from $ to ^ (was confusing when entering 'I owe $5')
25
+ * Add unit tests for client.
26
+ * Better error messages and explanation of toodledo setup.
27
+ * Fix the debug command so it doesn't crash the interactive client.
28
+ * Fixed some bugs in date processing.
29
+ * Fixed bugs in priority handling.
30
+ * Fixed session invalid bug on reconnect.
31
+
32
+ == 1.0.2 / 2008-02-14
33
+
34
+ * Fix a silly bug where whitespace wasn't stripped from edit, complete and delete.
35
+ * Enable interactive debug, and refactor the logging to be in client, not commands.
36
+ * Enable toodledo symbols to be anywhere in the string, not just before the task.
37
+ * Cleaner error messages if the task id is not found.
38
+ * Make sure failed commands exit with non-zero status.
39
+
40
+ == 1.0.1 / 2008-02-11
41
+
42
+ * Fix bug in client where priority filter was not being applied.
43
+
44
+ == 1.0.0 / 2008-02-10
45
+
46
+ * First version released!
47
+
data/lib/toodledo.rb CHANGED
@@ -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.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'
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.2.0'
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'
@@ -254,11 +254,32 @@ module Toodledo
254
254
  # hidemonths : If the task is due this many months into the future, the user wants them to be hidden.
255
255
  # hotlistpriority : The priority value above which tasks should appear on the hotlist.
256
256
  # hotlistduedate : The due date lead-time by which tasks should will appear on the hotlist.
257
+ # lastaddedit: last time this was edited
258
+ # lastdelete:
257
259
  def get_account_info()
258
260
  result = call('getAccountInfo', {}, @key)
259
261
 
260
262
  pro = (result.elements['pro'].text.to_i == 1) ? true : false
261
263
 
264
+ #<lastaddedit>2008-01-24 12:26:45</lastaddedit>
265
+ #<lastdelete>2008-01-23 15:45:55</lastdelete>
266
+ fmt = DATETIME_FORMAT
267
+
268
+ lastaddedit = result.elements['lastaddedit'].text
269
+ if (lastaddedit != nil)
270
+ last_modified_date = DateTime.strptime(lastaddedit, fmt)
271
+ else
272
+ last_modified_date = nil
273
+ end
274
+
275
+ lastdelete = result.elements['lastdelete'].text
276
+ if (lastdelete != nil)
277
+ logger.debug("lastdelete = #{lastdelete}")
278
+ last_deleted_date = DateTime.strptime(lastdelete, fmt)
279
+ else
280
+ last_deleted_date = nil
281
+ end
282
+
262
283
  hash = {
263
284
  :userid => result.elements['userid'].text,
264
285
  :alias => result.elements['alias'].text,
@@ -267,7 +288,9 @@ module Toodledo
267
288
  :timezone => result.elements['timezone'].text.to_i,
268
289
  :hidemonths => result.elements['hidemonths'].text.to_i,
269
290
  :hotlistpriority => result.elements['hotlistpriority'].text.to_i,
270
- :hotlistduedate => result.elements['hotlistduedate'].text.to_i
291
+ :hotlistduedate => result.elements['hotlistduedate'].text.to_i,
292
+ :lastaddedit => last_modified_date,
293
+ :lastdelete => last_deleted_date
271
294
  }
272
295
 
273
296
  return hash
@@ -550,6 +573,24 @@ module Toodledo
550
573
 
551
574
  return (result.text == '1')
552
575
  end
576
+
577
+ #
578
+ # Returns deleted tasks.
579
+ #
580
+ # after: a datetime object that indicates the start date after which deletes should be shown.
581
+ #
582
+ def get_deleted(after )
583
+ logger.debug("get_deleted(#{after})") if logger
584
+
585
+ formatted_after = after.strftime(Session::DATETIME_FORMAT)
586
+ result = call('getDeleted', { :after => formatted_after }, @key)
587
+ deleted_tasks = []
588
+ result.elements.each do |el|
589
+ deleted_task = Task.parse_deleted(self, el)
590
+ deleted_tasks << deleted_task
591
+ end
592
+ return deleted_tasks
593
+ end
553
594
 
554
595
  ############################################################################
555
596
  # Contexts
data/lib/toodledo/task.rb CHANGED
@@ -89,6 +89,27 @@ module Toodledo
89
89
  return ! (@num_children == nil || @num_children == 0)
90
90
  end
91
91
 
92
+ # Returns a hash containing :id and :stamp, a timestamp showing when the task was deleted.
93
+ #
94
+ # <task>
95
+ # <id>12345</id>
96
+ # <stamp>2008-02-25 07:46:42</stamp>
97
+ # </task>
98
+ # <task>
99
+ # <id>67890</id>
100
+ # <stamp>2008-03-12 14:11:12</stamp>
101
+ # </task>
102
+ #
103
+ def self.parse_deleted(session, el)
104
+ id = el.elements['id'].text
105
+ stamp = el.elements['stamp'].text
106
+
107
+ fmt = Session::DATETIME_FORMAT
108
+ deleted_stamp = DateTime.strptime(stamp, fmt)
109
+
110
+ return { :id => id, :stamp => deleted_stamp }
111
+ end
112
+
92
113
  # Parses a task element and returns a new Task.
93
114
  def self.parse(session, el)
94
115
 
@@ -23,7 +23,7 @@ class ToodledoFunctionalTest < Test::Unit::TestCase
23
23
  proxy = nil
24
24
 
25
25
  logger = Logger.new(STDOUT)
26
- logger.level = Logger::ERROR
26
+ logger.level = Logger::DEBUG
27
27
 
28
28
  @session = Session.new(@user_id, @password, logger)
29
29
  @session.connect(base_url, proxy)
@@ -153,6 +153,19 @@ class ToodledoFunctionalTest < Test::Unit::TestCase
153
153
  assert info_hash[:hidemonths] == 6
154
154
  assert info_hash[:hotlistpriority] == 3
155
155
  assert info_hash[:hotlistduedate] == 14
156
+
157
+ # Doesn't seem to work.
158
+ # assert info_hash[:lastaddedit] != nil
159
+ assert info_hash[:lastdelete] != nil
160
+ end
161
+
162
+ def test_get_deleted()
163
+ deleted_tasks = @session.get_deleted(Time.at(0))
164
+
165
+ deleted_tasks.each { |deleted_hash|
166
+ assert deleted_hash[:id] != nil
167
+ assert deleted_hash[:stamp] != nil
168
+ }
156
169
  end
157
170
 
158
171
  #
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.2
4
+ version: 1.2.0
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-03-22 00:00:00 -07:00
12
+ date: 2008-04-19 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency