toodledo 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,16 +1,21 @@
1
+ $: << File.expand_path(File.dirname(__FILE__) + "/../lib")
2
+
1
3
  require 'test/unit'
4
+ require 'toodledo'
2
5
  require 'toodledo/command_line/parser_helper'
3
6
 
7
+
4
8
  #
5
9
  # Tests the parser helper
6
10
  #
7
11
  class ParserHelperTest < Test::Unit::TestCase
8
12
 
13
+ include Toodledo
9
14
  include Toodledo::CommandLine::ParserHelper
10
15
 
11
16
  def test_find_context
12
17
 
13
- input = "*Folder @Context $Goal"
18
+ input = "blah blah blah *Folder @Context ^Goal"
14
19
 
15
20
  context = parse_context(input)
16
21
 
@@ -19,7 +24,7 @@ class ParserHelperTest < Test::Unit::TestCase
19
24
 
20
25
  def test_find_harder_context
21
26
 
22
- input = "@[Harder Context] *[Harder Folder] $[Harder Goal]"
27
+ input = "@[Harder Context] *[Harder Folder] ^[Harder Goal] blah blah blah"
23
28
 
24
29
  context = parse_context(input)
25
30
 
@@ -27,7 +32,7 @@ class ParserHelperTest < Test::Unit::TestCase
27
32
  end
28
33
 
29
34
  def test_find_folder
30
- input = "*Folder @Context $Goal"
35
+ input = "*Folder @Context ^Goal blah blah blah"
31
36
 
32
37
  folder = parse_folder(input)
33
38
 
@@ -36,7 +41,7 @@ class ParserHelperTest < Test::Unit::TestCase
36
41
 
37
42
  def test_find_harder_folder
38
43
 
39
- input = "@[Harder Context] *[Harder Folder] $[Harder Goal]"
44
+ input = "Some Text @[Harder Context] *[Harder Folder] ^[Harder Goal]"
40
45
 
41
46
  folder = parse_folder(input)
42
47
 
@@ -44,7 +49,7 @@ class ParserHelperTest < Test::Unit::TestCase
44
49
  end
45
50
 
46
51
  def test_find_goal
47
- input = "*Folder @Context $Goal"
52
+ input = "*Folder @Context ^Goal wefawef wefawefawfe"
48
53
 
49
54
  goal = parse_goal(input)
50
55
 
@@ -52,12 +57,75 @@ class ParserHelperTest < Test::Unit::TestCase
52
57
  end
53
58
 
54
59
  def test_find_harder_goal
55
- input = "@[Harder Context] *[Harder Folder] $[Harder Goal]"
60
+ input = "@[Harder Context] *[Harder Folder] ^[Harder Goal] Some text"
56
61
 
57
62
  goal = parse_goal(input)
58
63
 
59
64
  assert(goal == 'Harder Goal', "Value not found")
60
65
  end
61
66
 
67
+ def test_find_priority_with_top
68
+ input = "!top I AM VERY IMPORTANT!"
69
+
70
+ priority = parse_priority(input)
71
+
72
+ assert(priority == Priority::TOP, "Value not found")
73
+ end
74
+
75
+ def test_find_priority_with_high
76
+ input = "!high I am high priority."
77
+
78
+ priority = parse_priority(input)
79
+
80
+ assert_equal(Priority::HIGH, priority, "Value not found")
81
+ end
82
+
83
+ def test_find_priority_with_medium
84
+ input = "!medium I am medium priority."
85
+
86
+ priority = parse_priority(input)
87
+
88
+ assert_equal(Priority::MEDIUM, priority, "Value not found")
89
+ end
90
+
91
+ def test_find_priority_with_low
92
+ input = "!low I am low priority."
93
+
94
+ priority = parse_priority(input)
95
+
96
+ assert_equal(Priority::LOW, priority, "Value not found")
97
+ end
98
+
99
+ def test_find_priority_with_negative
100
+ input = "!negative I am negative priority."
101
+
102
+ priority = parse_priority(input)
103
+
104
+ assert_equal(Priority::NEGATIVE, priority, "Value not found")
105
+ end
106
+
107
+ def test_find_level_with_life()
108
+
109
+ input = 'life This is my goal'
110
+ level = parse_level(input)
111
+
112
+ assert_equal(Goal::LIFE_LEVEL, level, 'level not found')
113
+ end
114
+
115
+ def test_find_level_with_medium()
116
+
117
+ input = 'medium This is my goal'
118
+ level = parse_level(input)
119
+
120
+ assert_equal(Goal::MEDIUM_LEVEL, level, 'level not found')
121
+ end
122
+
123
+ def test_find_level_with_short()
124
+
125
+ input = 'short This is my goal'
126
+ level = parse_level(input)
127
+
128
+ assert_equal(Goal::SHORT_LEVEL, level, 'level not found')
129
+ end
62
130
 
63
131
  end
data/test/session_test.rb CHANGED
@@ -90,7 +90,7 @@ class SessionTest < Test::Unit::TestCase
90
90
  assert myhash[:context] == context_id
91
91
  end
92
92
 
93
- def test_handle_boolean_with_string()
93
+ def test_handle_boolean_with_string_true()
94
94
  myhash = {}
95
95
  params = { :bool => 'true' }
96
96
  @session.handle_boolean(myhash, params, :bool)
@@ -98,7 +98,7 @@ class SessionTest < Test::Unit::TestCase
98
98
  assert myhash[:bool] == "1"
99
99
  end
100
100
 
101
- def test_handle_boolean_with_string()
101
+ def test_handle_boolean_with_string_false()
102
102
  myhash = {}
103
103
  params = { :bool => 'false' }
104
104
  @session.handle_boolean(myhash, params, :bool)
@@ -32,9 +32,9 @@ class ToodledoFunctionalTest < Test::Unit::TestCase
32
32
 
33
33
  # Always fails.
34
34
  # def test_get_user_id()
35
- # user_id = @session.get_user_id(@email, @password)
35
+ # user_id = @session.get_user_id(@email, @password)
36
36
  #
37
- # assert user_id == @user_id
37
+ # # assert user_id == @user_id
38
38
  # end
39
39
 
40
40
  def test_add_edit_and_remove_task
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.0.2
4
+ version: 1.1.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-02-14 00:00:00 -08:00
12
+ date: 2008-02-24 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.5.0
41
41
  version:
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. Want an RSS feed? Want to have the Mac read out your top priority? It can all happen."
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
44
44
  executables:
45
45
  - toodledo
@@ -50,7 +50,6 @@ extra_rdoc_files:
50
50
  - Manifest.txt
51
51
  - README.txt
52
52
  files:
53
- - CHANGELOG
54
53
  - History.txt
55
54
  - Manifest.txt
56
55
  - README.txt
@@ -61,22 +60,31 @@ files:
61
60
  - lib/toodledo/command_line/base_command.rb
62
61
  - lib/toodledo/command_line/client.rb
63
62
  - lib/toodledo/command_line/complete_command.rb
63
+ - lib/toodledo/command_line/context_formatter.rb
64
64
  - lib/toodledo/command_line/delete_command.rb
65
65
  - lib/toodledo/command_line/edit_command.rb
66
+ - lib/toodledo/command_line/folder_formatter.rb
67
+ - lib/toodledo/command_line/goal_formatter.rb
66
68
  - lib/toodledo/command_line/hotlist_command.rb
67
- - lib/toodledo/command_line/list_command.rb
68
- - lib/toodledo/command_line/main_command.rb
69
+ - lib/toodledo/command_line/interactive_command.rb
70
+ - lib/toodledo/command_line/list_tasks_command.rb
71
+ - lib/toodledo/command_line/list_folders_command.rb
72
+ - lib/toodledo/command_line/list_goals_command.rb
69
73
  - lib/toodledo/command_line/parser_helper.rb
70
74
  - lib/toodledo/command_line/setup_command.rb
75
+ - lib/toodledo/command_line/sTdin_command.rb
76
+ - lib/toodledo/command_line/task_formatter.rb
71
77
  - lib/toodledo/context.rb
72
78
  - lib/toodledo/folder.rb
73
79
  - lib/toodledo/goal.rb
80
+ - lib/toodledo/invalid_configuration_error.rb
74
81
  - lib/toodledo/item_not_found_error.rb
75
82
  - lib/toodledo/priority.rb
76
83
  - lib/toodledo/repeat.rb
77
84
  - lib/toodledo/server_error.rb
78
85
  - lib/toodledo/session.rb
79
86
  - lib/toodledo/task.rb
87
+ - test/client_test.rb
80
88
  - test/parser_helper_test.rb
81
89
  - test/session_test.rb
82
90
  - test/toodledo_functional_test.rb
@@ -107,5 +115,8 @@ rubygems_version: 1.0.1
107
115
  signing_key:
108
116
  specification_version: 2
109
117
  summary: A command line client and API to Toodledo
110
- test_files: []
111
-
118
+ test_files:
119
+ - test/client_test.rb
120
+ - test/parser_helper_test.rb
121
+ - test/session_test.rb
122
+ - test/toodledo_functional_test.rb
data/CHANGELOG DELETED
@@ -1 +0,0 @@
1
- 1.0.0 - initial release
@@ -1,153 +0,0 @@
1
- require 'toodledo/command_line/parser_helper'
2
- require 'logger'
3
-
4
- module Toodledo
5
-
6
- module CommandLine
7
- # Runs the interactive client.
8
- class MainCommand < BaseCommand
9
-
10
- def initialize(client)
11
- super(client, 'interactive', false)
12
- self.short_desc = "Interactive client"
13
- self.description = "The interactive command line client."
14
- end
15
-
16
- def execute(args)
17
- Toodledo.begin(client.logger) do |session|
18
- command_loop(session)
19
- end
20
- end
21
-
22
- #
23
- # Displays the help message.
24
- #
25
- def help()
26
- puts "hotlist -- shows the hotlist\n"
27
- puts "tasks -- shows tasks ('tasks $[World Peace] *MyFolder' -- filters also apply)"
28
- puts "list -- does the same as tasks"
29
- puts
30
- puts "add -- adds a task ('add *Action @Home Eat breakfast')"
31
- puts "edit -- edits a task ('edit *Action 1134' will move 1134 to Action folder)"
32
- puts "complete -- completes a task ('complete 1234')\n"
33
- puts "delete -- deletes a task ('delete 1134')"
34
- puts
35
- puts "context -- defines a context filter on tasks"
36
- puts "goal -- defines a goal filter on tasks"
37
- puts "folder -- defines a folder filter on tasks\n"
38
- puts "priority -- defines a priority filter on tasks\n"
39
- puts "unfilter -- removes all filters on tasks\n"
40
- puts
41
- puts "folders -- shows all folders\n"
42
- puts "goals -- shows all goals"
43
- puts "contexts -- shows all contexts"
44
- puts
45
- puts "config -- displays the current configuration"
46
- puts
47
- puts "help or ? -- displays this help message\n"
48
- puts "quit or exit -- Leaves the application"
49
- end
50
-
51
- def clean(regexp, input)
52
- return input.sub(regexp, '')
53
- end
54
-
55
- def command_loop(session)
56
- loop do
57
- begin
58
- input = ask("> ") do |q|
59
- q.readline = true
60
- end
61
-
62
- input.strip!
63
-
64
- case input
65
- when /^help/, /^\s*\?/
66
- help()
67
-
68
- when /^add/
69
- line = clean(/^add/, input)
70
- client.add_task(session, line)
71
-
72
- when /^edit/
73
- line = clean(/^edit/, input)
74
- client.edit_task(session, line)
75
-
76
- when /^delete/
77
- line = clean(/^delete/, input)
78
- client.delete_task(session, line)
79
-
80
- when /^hotlist/
81
- line = clean(/^hotlist/, input)
82
- client.hotlist(session, line)
83
-
84
- when /^complete/
85
- line = clean(/^complete/, input)
86
- client.complete_task(session, line)
87
-
88
- when /^tasks/, /^list/
89
- line = clean(/^(tasks|list)/, input)
90
- client.list_tasks(session, line)
91
-
92
- when /^folders/
93
- line = clean(/^folders/, input)
94
- client.folders(session)
95
-
96
- when /^goals/
97
- client.goals(session)
98
-
99
- when /^contexts/
100
- client.contexts(session)
101
-
102
- when /^context/
103
- line = clean(/^context/, input)
104
- client.set_context_filter(session, line)
105
-
106
- when /^folder/
107
- line = clean(/^folder/, input)
108
- client.set_folder_filter(session, line)
109
-
110
- when /^goal/
111
- line = clean(/^goal/, input)
112
- client.set_goal_filter(session, line)
113
-
114
- when /^priority/
115
- line = clean(/^priority/, input)
116
- client.set_priority_filter(session, line)
117
-
118
- when /^config/
119
- client.show_config(session)
120
-
121
- when /^filters/
122
- client.list_filters()
123
-
124
- when /^unfilter/
125
- client.unfilter()
126
-
127
- when /debug/
128
- client.debug = ! client.debug?
129
- if (client.debug?)
130
- logger.level = Logger::DEBUG
131
- else
132
- logger.level = Logger::FATAL
133
- end
134
-
135
- when /^quit/, /^exit/
136
- break;
137
- else
138
- puts "'#{input}' is not a command: type help for a list"
139
- end
140
- rescue Toodledo::ItemNotFoundError => infe
141
- puts "Item not found: #{infe}"
142
- rescue Toodledo::ServerError => se
143
- puts "Server Error: #{se}"
144
- rescue RuntimeError => re
145
- puts "Error: #{re}"
146
- end
147
- end # loop
148
- end
149
-
150
- end
151
-
152
- end
153
- end