milkmaid 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,6 +30,7 @@ number appears at the beginning.
30
30
 
31
31
  $ milkmaid list
32
32
 
33
+
33
34
  Complete a task
34
35
 
35
36
  $ milkmaid complete <task number>
@@ -39,6 +40,11 @@ Postpone a task
39
40
 
40
41
  $ milkmaid postpone <task number>
41
42
 
43
+
44
+ Delete a task
45
+
46
+ $ milkmaid delete <task number>
47
+
42
48
  Add a task (Use single quotes to contain the task name)
43
49
 
44
50
  Adding a task supports Remember the Milk's Smart Add feature. With it you
@@ -46,6 +52,22 @@ can set properties such as the due date, priority, etc.
46
52
 
47
53
  $ milkmaid add '<task name>'
48
54
 
55
+ == Version history
56
+
57
+ === 0.2.0
58
+
59
+ * New delete command
60
+ * Friendlier usage information
61
+
62
+ === 0.1.1
63
+
64
+ * Fixed an issue when listing tasks with recurrences that were completed
65
+
66
+ === 0.1.0
67
+
68
+ * Initial version
69
+
70
+
49
71
  == Contributing to Milkmaid
50
72
 
51
73
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
@@ -11,18 +11,28 @@ def milkmaid
11
11
  end
12
12
 
13
13
  Main {
14
+ description "Milkmaid command-line client for Remember the Milk\n" +
15
+ "If this is your first time running this, use the auth command to connect to your account."
16
+
14
17
  def run
15
18
  help!
16
19
  end
17
20
 
18
21
  mode :list do
22
+ description "Lists all inactive tasks. Tasks that repeat are marked with a (R).\n" +
23
+ "If there is a due date, it appears to the right of the task. Tasks are color\n" +
24
+ "coded by priority the same when viewed on the web. Tasks due today are in bold\n" +
25
+ "while tasks that are overdue are underlined.\n" +
26
+ "Use this command to assign a number to tasks so you may perform other actions."
27
+
19
28
  def run
20
29
  begin
21
30
  milkmaid.incomplete_tasks.each_with_index do |taskseries, i|
31
+ task = Milkmaid::last_task taskseries
22
32
  text = "#{i+1}: #{taskseries['name']}"
23
33
  text << "(R)" unless taskseries['rrule'].nil?
24
- text << " #{Time.parse(taskseries['task'].as_array.last['due']).getlocal.strftime(
25
- "%A %b %d, %Y %I:%M %p")}" unless taskseries['task'].as_array.last['due'].empty?
34
+ text << " #{Time.parse(Milkmaid::last_task(taskseries)['due']).getlocal.strftime(
35
+ "%A %b %d, %Y %I:%M %p")}" unless task['due'].empty?
26
36
  color = {
27
37
  '1'=>[234, 82, 0],
28
38
  '2'=>[0, 96, 191],
@@ -30,14 +40,14 @@ Main {
30
40
  'N'=>:nothing
31
41
  }
32
42
  mode1 = mode2 = nil
33
- case Date.today <=> Date.parse(taskseries['task'].as_array.last['due'])
43
+ case Date.today <=> Date.parse(task['due'])
34
44
  when 0
35
45
  mode1 = :bold
36
46
  when 1
37
47
  mode1 = :bold
38
48
  mode2 = :underline
39
- end unless taskseries['task'].as_array.last['due'].empty?
40
- puts Paint[text, color[taskseries['task'].as_array.last['priority']], mode1, mode2]
49
+ end unless task['due'].empty?
50
+ puts Paint[text, color[task['priority']], mode1, mode2]
41
51
  end
42
52
  rescue RTM::NoTokenException
43
53
  puts "Authentication token not found. Run `#{__FILE__} auth start`"
@@ -46,8 +56,11 @@ Main {
46
56
  end
47
57
 
48
58
  mode :complete do
59
+ description "Marks a task as complete."
60
+
49
61
  argument(:tasknum) {
50
62
  cast :int
63
+ description "The number of the task as printed by the list command."
51
64
  }
52
65
 
53
66
  def run
@@ -63,8 +76,11 @@ Main {
63
76
  end
64
77
 
65
78
  mode :postpone do
79
+ description "Extends the due date of a task."
80
+
66
81
  argument(:tasknum) {
67
82
  cast :int
83
+ description "The number of the task as printed by the list command."
68
84
  }
69
85
 
70
86
  def run
@@ -79,6 +95,26 @@ Main {
79
95
  end
80
96
  end
81
97
 
98
+ mode :delete do
99
+ description "Gets rid of a task."
100
+
101
+ argument(:tasknum) {
102
+ cast :int
103
+ description "The number of the task as printed by the list command."
104
+ }
105
+
106
+ def run
107
+ begin
108
+ milkmaid.delete_task params['tasknum'].value
109
+ rescue Milkmaid::TaskNotFound
110
+ puts "Task ##{params['tasknum'].value} not found. Run `#{__FILE__} list` " +
111
+ "to load a list of tasks."
112
+ rescue RTM::NoTokenException
113
+ puts "Authentication token not found. Run `#{__FILE__} auth start`"
114
+ end
115
+ end
116
+ end
117
+
82
118
  mode :add do
83
119
  argument(:taskname)
84
120
 
@@ -92,7 +128,12 @@ Main {
92
128
  end
93
129
 
94
130
  mode :auth do
131
+ description "Auth commands are used to connect Milkmaid to your account."
132
+
95
133
  mode :start do
134
+ description "Use this command to generate an authentication link.\n" +
135
+ "Follow the link before issuing the auth finish command."
136
+
96
137
  def run
97
138
  puts '1. Visit the URL to authorize the application to access your account.'
98
139
  puts "2. Run `#{__FILE__} auth finish`"
@@ -102,6 +143,8 @@ Main {
102
143
  end
103
144
 
104
145
  mode :finish do
146
+ description "Use this command to complete authentication to your account."
147
+
105
148
  def run
106
149
  begin
107
150
  milkmaid.auth_finish
@@ -23,13 +23,13 @@ class Milkmaid
23
23
  if !items['taskseries'].nil?
24
24
  items['taskseries'].as_array.each do |taskseries|
25
25
  taskseries['list_id'] = list_id
26
- entries << taskseries if taskseries['task'].as_array.last['completed'].empty?
26
+ entries << taskseries if Milkmaid::last_task(taskseries)['completed'].empty?
27
27
  end
28
28
  end
29
29
  end
30
30
  entries.sort! do |a, b|
31
- taska = a['task'].as_array.last
32
- taskb = b['task'].as_array.last
31
+ taska = Milkmaid::last_task a
32
+ taskb = Milkmaid::last_task b
33
33
  result = taska['priority'] <=> taskb['priority']
34
34
  if result == 0
35
35
  if taska['due'].empty?
@@ -46,7 +46,7 @@ class Milkmaid
46
46
  entries.each_with_index do |taskseries, i|
47
47
  @config["#{i+1}list_id"] = taskseries['list_id']
48
48
  @config["#{i+1}taskseries_id"] = taskseries['id']
49
- @config["#{i+1}task_id"] = taskseries['task'].as_array.last['id']
49
+ @config["#{i+1}task_id"] = Milkmaid::last_task(taskseries)['id']
50
50
  end
51
51
  save_config
52
52
  entries
@@ -62,6 +62,11 @@ class Milkmaid
62
62
  call_rtm_api :postpone, tasknum
63
63
  end
64
64
 
65
+ def delete_task(tasknum)
66
+ check_task_ids tasknum
67
+ call_rtm_api :delete, tasknum
68
+ end
69
+
65
70
  def add_task(name)
66
71
  @rtm.tasks.add :name=>name, :parse=>'1', :timeline=>@timeline
67
72
  end
@@ -81,6 +86,10 @@ class Milkmaid
81
86
  class TaskNotFound < StandardError
82
87
  end
83
88
 
89
+ def self.last_task(taskseries)
90
+ taskseries['task'].as_array.last
91
+ end
92
+
84
93
  private
85
94
  def save_config
86
95
  File.open(@config_file, 'w') { |f| YAML.dump(@config, f) }
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "milkmaid"
8
- s.version = "0.1.1"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Marius Grigoriu"]
@@ -81,7 +81,8 @@ describe "Milkmaid" do
81
81
  describe "working with existing tasks" do
82
82
  it "raises an error when unable to find the desired task in config" do
83
83
  lambda { lib.complete_task 1 }.should raise_error(Milkmaid::TaskNotFound)
84
- lambda { lib.postpone_task 1 }.should raise_error(Milkmaid::TaskNotFound)
84
+ lambda { lib.postpone_task 2 }.should raise_error(Milkmaid::TaskNotFound)
85
+ lambda { lib.delete_task 3 }.should raise_error(Milkmaid::TaskNotFound)
85
86
  end
86
87
 
87
88
  it "marks the task as complete" do
@@ -93,6 +94,11 @@ describe "Milkmaid" do
93
94
  should_call_rtm_api(:postpone, 2)
94
95
  lib.postpone_task 2
95
96
  end
97
+
98
+ it "deletes a task" do
99
+ should_call_rtm_api(:delete, 3)
100
+ lib.delete_task 3
101
+ end
96
102
  end
97
103
 
98
104
  it "adds a task to the inbox using Smart Add" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: milkmaid
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Marius Grigoriu