dayrb 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c7ac0153612ed3373be609657a8bf1f728a02e3
4
- data.tar.gz: b784f73c240adb63a1f1a09f4f029aa62f6c969e
3
+ metadata.gz: 9bd54d621f2ea27a6da4f10359e31ff7a365c9d1
4
+ data.tar.gz: 15e902f847d739d4d13fac1a05ec6e5ebe473e74
5
5
  SHA512:
6
- metadata.gz: d1ab3833bda41a260a3f0981b147ccf08656cdc1db02f72e75107c4496af79f782c24257d902b53a33d7188a8ab0e2c0cd96603c050e11c48ed82dd4a1816ab8
7
- data.tar.gz: 28a9b4dab170b478d43014df35b058df3e549c21ae02405a18513228d19cc9705812388d8099ac22e0cbc5eae6421672ab4f04d8dfb3992b15db5c69029b1828
6
+ metadata.gz: 89b92e1d09a1501b9a12816f5661c299eebce95948cc1b838d6a212f54e1b60409c81a5bdc676b1c43116e0bcd996c9b758756223aa0d4c9952632cbe9c00b59
7
+ data.tar.gz: 4097d69eeb3ea33c1806db806c61dc92e3d271b1bf179eea1fc33c56dc675d0cb1bd60134c7fb9d39e5868dc8ade11f3c69aadc44f7b17e6dd4d5a68c80c880a
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.3
1
+ 2.0.4
data/bin/day.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  # Created in July 2013
6
6
  # See 'day.rb help' for usage.
7
7
  #
8
- # MIT License; See LICENSE file; Cameron Carroll 2014
8
+ # MIT License; See LICENSE file; Cameron Carroll 2015
9
9
 
10
10
  require_relative '../lib/day/configuration'
11
11
  require_relative '../lib/day/tasklist'
@@ -14,7 +14,7 @@ require_relative '../lib/day/presenter'
14
14
 
15
15
  require 'fileutils'
16
16
 
17
- VERSION = '2.0.3'
17
+ VERSION = '2.0.4'
18
18
 
19
19
  #-------------- User Configuration:
20
20
  #-------------- Please DO edit the following to your liking:
@@ -23,7 +23,7 @@ VERSION = '2.0.3'
23
23
  CONFIG_DIR = ENV['HOME'] + '/.config/dayrb/'
24
24
  CONFIG_FILE = CONFIG_DIR + 'daytodo'
25
25
 
26
- # Colorization:
26
+ # Colorization:
27
27
  # Use ANSI color codes...
28
28
  # (See http://bluesock.org/~willg/dev/ansi.html for codes.)
29
29
  # (Change values back to 0 for no colorization.)
@@ -94,6 +94,7 @@ db = YAML::DBM.new(CONFIG_FILE)
94
94
  config = Configuration.new(db)
95
95
  opts = Parser.parse_options(config)
96
96
 
97
+ # TODO: Simplify following logic, we don't need so many variables.
97
98
  # Build task objects and separate into two lists, valid today and all tasks.
98
99
  tasklist_object = Tasklist.new(config)
99
100
  all_tasks = tasklist_object.all_tasks
@@ -109,6 +110,8 @@ end
109
110
  # Easier (named) access to config and opts:
110
111
  new_context = opts[:task]
111
112
  current_context = config.data['context']
113
+ # If we were already tracking a task when program was called,
114
+ # this refers to the time spent in that task:
112
115
  old_time = Time.now - config.data['entry_time'] if config.data['entry_time']
113
116
 
114
117
  # Take action based on operation:
@@ -128,17 +131,19 @@ when :switch
128
131
  Presenter.announce_switch(new_context, current_context, old_time)
129
132
  config.switch_to(new_context)
130
133
  when :clear
131
- Presenter.announce_clear(new_context)
132
- config.clear_fulfillment(new_context)
134
+ confirmation = Presenter.confirm_clear(new_context)
135
+ config.clear_fulfillment(new_context) if confirmation
133
136
  when :leave
134
137
  Presenter.announce_leave_context(current_context, old_time)
135
138
  config.clear_context
136
139
  when :delete
137
- Presenter.announce_deletion(new_context, config.data['tasks'][new_context]['description'])
138
- config.delete(new_context)
140
+ confirmation = Presenter.confirm_deletion(new_context, config.data['tasks'][new_context]['description'])
141
+ if confirmation
142
+ config.delete(new_context)
143
+ end
139
144
  else
140
145
  Presenter.print_error_unknown
141
146
  end
142
147
 
143
148
  config.save
144
- db.close
149
+ db.close
data/changelog.md CHANGED
@@ -1,3 +1,10 @@
1
+ 2.0.4 -- 03/20/14
2
+ -------------------
3
+
4
+ * Updated help documentation to be more clear about abbreviated commands and descriptions, and also added some examples.
5
+ * Added confirmation for delete and clear commands.
6
+ * Fixed a problem where switching directly between two tasks didn't save fulfillment data for the first.
7
+
1
8
  2.0.3 -- 08/17/14
2
9
  ------------------
3
10
 
@@ -117,4 +124,3 @@
117
124
  -------------------
118
125
 
119
126
  * Task list printout will now give progress on current task.
120
-
data/dayrb.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'dayrb'
3
- s.version = '2.0.3'
3
+ s.version = '2.0.4'
4
4
  s.summary = "To-do & Time-Tracking CLI App"
5
5
  s.description = "Create and track time on tasks via command-line."
6
6
  s.authors = ["Cameron Carroll"]
@@ -11,4 +11,4 @@ Gem::Specification.new do |s|
11
11
  s.homepage =
12
12
  'http://github.com/sanarothe/day'
13
13
  s.license = 'MIT'
14
- end
14
+ end
@@ -1,7 +1,7 @@
1
1
  # DayRB Configuration (Data-Access Layer) Module
2
2
  #
3
3
  # Provides convenience methods for database access and holds db data.
4
- #
4
+ #
5
5
  # MIT License; See LICENSE file; Cameron Carroll 2014
6
6
 
7
7
  require 'yaml/dbm'
@@ -45,7 +45,7 @@ class Configuration
45
45
  #
46
46
  # @param next_key [String] the name of the task to switch to.
47
47
  def switch_to(next_key)
48
- cap_current_fulfillment if @context
48
+ cap_current_fulfillment if @data['context']
49
49
  @data['context'] = next_key if @data['tasks'].has_key?(next_key)
50
50
  @data['entry_time'] = Time.now.getutc
51
51
  end
@@ -137,4 +137,4 @@ class Configuration
137
137
  def clear_fulfillment_for(task)
138
138
  @data['tasks'][task]['fulfillment'] = nil
139
139
  end
140
- end
140
+ end
data/lib/day/presenter.rb CHANGED
@@ -54,12 +54,22 @@ Commands:
54
54
  (nonexisting task) Creates a new task
55
55
  (existing task) Start tracking time for named task.
56
56
  delete (task) Remove a task
57
+ rm (task) (Synonym for delete.)
57
58
  info Print all descriptions
58
59
  info (task) Print a specific description
60
+ i (task) (Synonym for info.)
59
61
  clear Clear fulfillment for all tasks.
60
62
  clear (task) Clear fulfillment for a specific task.
63
+ c (task) (Synonym for clear.)
64
+
65
+ Flags:
66
+ -a Print all tasks, including those not enabled today.
67
+
68
+ Tips:
69
+ Refer to a task either by its name or index.
70
+ Jump directly between tasks.
71
+ Include "vim" or your editor constant when creating new task to add a description.
61
72
 
62
- Refer to a task either by its name or index.
63
73
  See readme.md for a more detailed overview.
64
74
  eos
65
75
  end
@@ -69,24 +79,45 @@ See readme.md for a more detailed overview.
69
79
  puts "Day.rb v#{VERSION}"
70
80
  end
71
81
 
72
- # Announces task has been deleted and prints its description if applicable.
73
- #
74
- # @param task [String] Name of task to be deleted
75
- # @param description [String] Description of task (optional)
76
- def announce_deletion(task, description)
77
- puts "Deleted #{task}".color_text
78
- puts "Description was: #{description}".color_text if description
79
- end
82
+ # Asks whether the user is sure that they want to delete something.
83
+ #
84
+ # @param task [String] Name of task
85
+ # @param description [String] Description of task (optional)
86
+ def confirm_deletion(task, description)
87
+ puts "Are you sure you want to delete '#{task}'?: (Y/N)"
88
+ puts "It's description was #{description}: (Y/N)" if description
89
+ case confirmation = get_confirmation
90
+ when true
91
+ puts "Deleted #{task}".color_text
92
+ puts "Description was: #{description}".color_text if description
93
+ when false
94
+ puts "Didn't delete '#{task}.'".color_text
95
+ end
96
+ return confirmation
97
+ end
80
98
 
81
- # Announces that either a task or all tasks have had fulfillment cleared.
99
+ # Asks the user whether they're sure they want to clear fulfillment.
82
100
  #
83
101
  # @param task [String] Name of task to be cleared
84
- def announce_clear(task)
85
- if task
86
- puts "Cleared fulfillment for #{task}".color_text
87
- else
88
- puts "Cleared fulfillment for all tasks".color_text
89
- end
102
+ def confirm_clear(task)
103
+ if task
104
+ puts "Are you sure you want to clear fulfillment for #{task}?"
105
+ else
106
+ puts "Are you sure you want to clear all fulfillment data?"
107
+ end
108
+
109
+ case answer = get_confirmation
110
+ when true
111
+ if task
112
+ puts "Cleared fulfillment for #{task}".color_text
113
+ else
114
+ puts "Cleared fulfillment for all tasks".color_text
115
+ end
116
+ when false
117
+ puts "Didn't clear fulfillment."
118
+ end
119
+
120
+ return answer
90
121
  end
91
122
 
92
123
  # Announces a switch to a new task...
@@ -121,6 +152,20 @@ See readme.md for a more detailed overview.
121
152
 
122
153
  private
123
154
 
155
+ def get_confirmation
156
+ loop do
157
+ print " (Y/N) -->: "
158
+ case input = $stdin.gets
159
+ when /y/i, /yes/i
160
+ return true
161
+ when /n/i, /no/i
162
+ return false
163
+ else
164
+ p "Sorry, didn't catch that. Try 'yes' or 'no'."
165
+ end
166
+ end
167
+ end
168
+
124
169
  # Iterate through tasklist, printing index, name, description flag and fulfillment/estimate data.
125
170
  #
126
171
  # @param tasks [Hash] Collection of task_name => task_object pairs
@@ -220,4 +265,4 @@ See readme.md for a more detailed overview.
220
265
  puts "Sorry, that command is not known. Try 'help'."
221
266
  end
222
267
  end
223
- end
268
+ end
data/readme.md CHANGED
@@ -1,11 +1,11 @@
1
1
  day.rb
2
2
  ======
3
- (Version 2.0.3 -- August 2014)
3
+ (Version 2.0.4 -- March 2015)
4
4
 
5
5
  A command-line to-do & time-tracking application.
6
6
 
7
7
  * Define & describe tasks, and set time estimates for yourself.
8
- * Check in or out of tasks to track time spent.
8
+ * Check in and out of tasks to track time spent.
9
9
 
10
10
  Requirements:
11
11
  -------------
@@ -24,27 +24,48 @@ Installation:
24
24
  * Symlink day.rb into your favorite bin folder. (ln -s ~/apps/day/bin/day.rb ~/bin/day)
25
25
  * Chmod it to be executable (chmod +x ~/bin/day)
26
26
 
27
- Usage Overview:
27
+ Usage Overview:
28
28
  ---------------
29
-
30
29
  Usage: day.rb <command> [<args>]
31
30
 
32
31
  Commands:
33
- (no command) Prints out task list for the day
34
- (nonexisting task) Creates a new task
35
- (existing task) Start tracking time for named task
36
- delete (task) Remove a task
37
- info Print all descriptions
38
- info (task) Print a specific description
39
- clear Clear fulfillment for all tasks.
40
- clear (task) Clear fulfillment for a specific task.
41
-
42
- (From 'day.rb help')
43
-
44
- * Use the '-a' flag (with no command) to print out tasks that aren't enabled for the day
45
- * Jump directly from task to task
46
- * Stores data by default in ~/.config/day/ -- Edit the constant at top of script to change this.
47
-
48
- Copyright 2014 - Cameron Carroll
49
-
50
- License: MIT
32
+ (no command) Prints out task list for the day
33
+ (nonexisting task) Creates a new task
34
+ (existing task) Start tracking time for named task.
35
+ delete (task) Remove a task
36
+ rm (task) (Synonym for delete.)
37
+ info Print all descriptions
38
+ info (task) Print a specific description
39
+ i (task) (Synonym for info.)
40
+ clear Clear fulfillment for all tasks.
41
+ clear (task) Clear fulfillment for a specific task.
42
+ c (task) (Synonym for clear.)
43
+
44
+ Flags:
45
+ -a Also print tasks not enabled today.
46
+
47
+ Tips:
48
+ Refer to a task either by its name or index.
49
+ Jump directly between tasks.
50
+ Include "vim" or your editor constant when creating new task to add a description.
51
+ Configuration data is stored at the top of 'day.rb.'
52
+
53
+ Examples
54
+ --------
55
+ # Create a new task:
56
+ day.rb my_new_task
57
+
58
+ # Create task enabled on monday & wednesday, with a 45 minute estimate:
59
+ day.rb my_new_task m w 45
60
+
61
+ # Create a task with in-line description:
62
+ # Note parenthesis and quotations are mandatory.
63
+ day.rb my_new_task "(some description)"
64
+
65
+ # Create a task with editor description:
66
+ # Note 'vim' can be changed to any editor atop day.rb file.
67
+ day.rb my_new_task vim
68
+
69
+ Copyright 2015 - Cameron Carroll
70
+
71
+ License: MIT
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dayrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Carroll
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-17 00:00:00.000000000 Z
11
+ date: 2015-03-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Create and track time on tasks via command-line.
14
14
  email: ckcarroll4@gmail.com
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
52
  version: '0'
53
53
  requirements: []
54
54
  rubyforge_project:
55
- rubygems_version: 2.2.2
55
+ rubygems_version: 2.4.5
56
56
  signing_key:
57
57
  specification_version: 4
58
58
  summary: To-do & Time-Tracking CLI App
@@ -60,4 +60,3 @@ test_files:
60
60
  - spec/configuration_spec.rb
61
61
  - spec/parser_spec.rb
62
62
  - spec/spec_helper.rb
63
- has_rdoc: