hcl 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +11 -0
- data/README.markdown +30 -18
- data/VERSION +1 -1
- data/hcl.gemspec +1 -1
- data/lib/hcl/app.rb +15 -12
- data/lib/hcl/commands.rb +23 -1
- data/lib/hcl/day_entry.rb +11 -2
- data/lib/hcl/timesheet_resource.rb +5 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aacea7a83e911178697ab35835691bab2827299a
|
4
|
+
data.tar.gz: b85493c73665fa37297841027ceb12c2ffbe8b90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40d2a72969d751827efe2cdfeb11e49522787dcc9bc089042bba3470e367c9e1f600599c05da241312be4050b328a67ea862ba43ee4737159d31697bb3f1e729
|
7
|
+
data.tar.gz: 9c9b1c0af9ea5cce5f48032c93584472f288b8ca01402eb4fc0cfd7d1b5884c961c9523bd543a00dc5eeeca78322ae5107e82f75c5bece8f47dfae5ca53b14ca
|
data/CHANGELOG
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
= Recent Changes in HCl
|
2
2
|
|
3
|
+
== v0.4.3
|
4
|
+
|
5
|
+
* added cancel command to delete the last running timer, closes #13
|
6
|
+
* properly unescape string from Harvest API, closes #24
|
7
|
+
* stop command now checks for running timers from yesterday, closes #35
|
8
|
+
* added log command to log time/notes without leaving a timer running, closes #30
|
9
|
+
|
10
|
+
== v0.4.2
|
11
|
+
|
12
|
+
* resume command now accepts an optional task
|
13
|
+
|
3
14
|
== v0.4.1
|
4
15
|
|
5
16
|
* update dependencies
|
data/README.markdown
CHANGED
@@ -17,27 +17,18 @@ or you can install from source using jeweler:
|
|
17
17
|
$ gem install jeweler
|
18
18
|
$ rake install
|
19
19
|
|
20
|
-
### Prerequisites
|
21
|
-
|
22
|
-
* Ruby (tested with 1.8.7)
|
23
|
-
* Ruby OpenSSL support (in debian/ubuntu: apt-get install libopenssl-ruby)
|
24
|
-
* Ruby extension building support (in debian/ubuntu: apt-get install ruby-dev)
|
25
|
-
* RubyGems 1.3.3
|
26
|
-
* Trollop option-parsing library (gem install trollop)
|
27
|
-
* Chronic date-parsing library (gem install chronic)
|
28
|
-
* HighLine console input library (gem install highline)
|
29
|
-
* Jeweler packaging tool (needed to build the gem)
|
30
|
-
|
31
20
|
## Usage
|
32
21
|
|
33
|
-
hcl (@<task_alias> | <project_id> <task_id>) [
|
22
|
+
hcl [start] (@<task_alias> | <project_id> <task_id>) [+<time>] [<message>]
|
34
23
|
hcl note <message>
|
35
24
|
hcl stop [message]
|
36
25
|
hcl resume [@<task_alias>]
|
26
|
+
hcl log (@<task_alias> | <project_id> <task_id>) [+<time>] [<message>]
|
37
27
|
hcl show [date]
|
38
28
|
hcl tasks
|
39
29
|
hcl alias <task_alias> <project_id> <task_id>
|
40
30
|
hcl aliases
|
31
|
+
hcl (cancel | nvm | oops)
|
41
32
|
|
42
33
|
### Available Projects and Tasks
|
43
34
|
|
@@ -52,8 +43,8 @@ available tasks.
|
|
52
43
|
Since it's not practical to enter two long numbers every time you want to
|
53
44
|
identify a task, HCl supports task aliases:
|
54
45
|
|
55
|
-
$ hcl alias
|
56
|
-
$ hcl @
|
46
|
+
$ hcl alias tacodev 1234 5678
|
47
|
+
$ hcl @tacodev Adding a new feature
|
57
48
|
|
58
49
|
### Starting a Timer with Initial Time
|
59
50
|
|
@@ -61,14 +52,14 @@ You can also provide an initial time when starting a new timer.
|
|
61
52
|
This can be expressed in floating-point or HH:MM. The following two
|
62
53
|
commands are equivalent:
|
63
54
|
|
64
|
-
$ hcl @
|
65
|
-
$ hcl +.25 @
|
55
|
+
$ hcl @tacodev +0:15 Doing some stuff
|
56
|
+
$ hcl +.25 @tacodev Doing some stuff
|
66
57
|
|
67
58
|
### Adding Notes to a Running Task
|
68
59
|
|
69
60
|
While a task is running you can append lines to the task notes:
|
70
61
|
|
71
|
-
$ hcl note
|
62
|
+
$ hcl note Then I did something else
|
72
63
|
|
73
64
|
### Stopping a Timer
|
74
65
|
|
@@ -76,7 +67,7 @@ The following command will stop a running timer (currently only one timer at
|
|
76
67
|
a time is supported). You can provide a message when stopping a timer as
|
77
68
|
well:
|
78
69
|
|
79
|
-
$ hcl stop All done
|
70
|
+
$ hcl stop All done doing things
|
80
71
|
|
81
72
|
### Resuming a Timer
|
82
73
|
|
@@ -86,6 +77,25 @@ for that task:
|
|
86
77
|
$ hcl resume
|
87
78
|
$ hcl resume @xdev
|
88
79
|
|
80
|
+
### Canceling a Timer
|
81
|
+
|
82
|
+
If you accidentally started a timer that you didn't mean to, you can cancel
|
83
|
+
it:
|
84
|
+
|
85
|
+
$ hcl cancel
|
86
|
+
|
87
|
+
This will delete the running timer, or the last-updated timer if one isn't
|
88
|
+
running. You can also use `nvm` or `oops` instead of `cancel`.
|
89
|
+
|
90
|
+
### Logging without Starting a Timer
|
91
|
+
|
92
|
+
You can log time and notes without leaving a timer running. It takes
|
93
|
+
the same arguments as start:
|
94
|
+
|
95
|
+
$ hcl log @xdev +1 Worked for an hour.
|
96
|
+
|
97
|
+
The above starts and immediately stops a one-hour timer with the given note.
|
98
|
+
|
89
99
|
### Date Formats
|
90
100
|
|
91
101
|
Dates can be expressed in a variety of ways. See the [Chronic documentation][cd]
|
@@ -114,3 +124,5 @@ See LICENSE for copyright details.
|
|
114
124
|
[bricooke]: http://github.com/bricooke
|
115
125
|
[scharfie]: http://github.com/scharfie
|
116
126
|
|
127
|
+
|
128
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.3
|
data/hcl.gemspec
CHANGED
data/lib/hcl/app.rb
CHANGED
@@ -31,7 +31,7 @@ class Net::HTTP
|
|
31
31
|
end
|
32
32
|
|
33
33
|
module HCl
|
34
|
-
VERSION = "0.4.
|
34
|
+
VERSION = "0.4.3"
|
35
35
|
|
36
36
|
class App
|
37
37
|
include HCl::Utility
|
@@ -103,31 +103,34 @@ Commands:
|
|
103
103
|
# show all available tasks
|
104
104
|
hcl tasks
|
105
105
|
|
106
|
-
#
|
107
|
-
hcl alias <
|
106
|
+
# create a task alias
|
107
|
+
hcl alias <task_alias> <project_id> <task_id>
|
108
108
|
|
109
109
|
# list task aliases
|
110
110
|
hcl aliases
|
111
111
|
|
112
112
|
# start a task using an alias
|
113
|
-
hcl @<
|
113
|
+
hcl [start] @<task_alias> [+<time>] [<message>]
|
114
114
|
|
115
|
-
#
|
116
|
-
hcl
|
115
|
+
# add a line to your running timer
|
116
|
+
hcl note <message>
|
117
117
|
|
118
118
|
# stop a running timer
|
119
|
-
hcl stop [message]
|
119
|
+
hcl stop [<message>]
|
120
120
|
|
121
|
-
# resume the last stopped timer
|
122
|
-
hcl resume
|
121
|
+
# resume the last stopped timer or a specific task
|
122
|
+
hcl resume [@<task_alias>]
|
123
123
|
|
124
|
-
#
|
125
|
-
hcl
|
124
|
+
# delete the current or last running timer
|
125
|
+
hcl (cancel | oops | nvm)
|
126
|
+
|
127
|
+
# display the daily timesheet
|
128
|
+
hcl [show [<date>]]
|
126
129
|
|
127
130
|
Examples:
|
128
131
|
hcl alias mytask 1234 4567
|
129
132
|
hcl @mytask +:15 Doing a thing that I started 15 minutes ago.
|
130
|
-
hcl Adding a note to my running task.
|
133
|
+
hcl note Adding a note to my running task.
|
131
134
|
hcl stop That's enough for now.
|
132
135
|
hcl resume
|
133
136
|
hcl show yesterday
|
data/lib/hcl/commands.rb
CHANGED
@@ -24,6 +24,23 @@ module HCl
|
|
24
24
|
nil
|
25
25
|
end
|
26
26
|
|
27
|
+
def cancel
|
28
|
+
entry = DayEntry.with_timer || DayEntry.last
|
29
|
+
if entry
|
30
|
+
if entry.cancel
|
31
|
+
puts "Deleted entry #{entry}."
|
32
|
+
else
|
33
|
+
puts "Failed to delete #{entry}!"
|
34
|
+
exit 1
|
35
|
+
end
|
36
|
+
else
|
37
|
+
puts 'Nothing to cancel.'
|
38
|
+
exit 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
alias_method :oops, :cancel
|
42
|
+
alias_method :nvm, :cancel
|
43
|
+
|
27
44
|
def unset key
|
28
45
|
@settings.delete key
|
29
46
|
write_settings
|
@@ -62,8 +79,13 @@ module HCl
|
|
62
79
|
puts "Started timer for #{timer} (at #{current_time})"
|
63
80
|
end
|
64
81
|
|
82
|
+
def log *args
|
83
|
+
start *args
|
84
|
+
stop
|
85
|
+
end
|
86
|
+
|
65
87
|
def stop *args
|
66
|
-
entry = DayEntry.with_timer
|
88
|
+
entry = DayEntry.with_timer || DayEntry.with_timer(DateTime.yesterday)
|
67
89
|
if entry
|
68
90
|
entry.append_note(args.join(' ')) if args.any?
|
69
91
|
entry.toggle
|
data/lib/hcl/day_entry.rb
CHANGED
@@ -23,6 +23,15 @@ module HCl
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
def cancel
|
27
|
+
begin
|
28
|
+
DayEntry.delete("daily/delete/#{id}")
|
29
|
+
rescue TimesheetResource::Failure
|
30
|
+
return false
|
31
|
+
end
|
32
|
+
true
|
33
|
+
end
|
34
|
+
|
26
35
|
def notes
|
27
36
|
super || @data[:notes] = ''
|
28
37
|
end
|
@@ -36,8 +45,8 @@ module HCl
|
|
36
45
|
%{<request><notes>#{notes}</notes><hours>#{hours}</hours></request>}
|
37
46
|
end
|
38
47
|
|
39
|
-
def self.with_timer
|
40
|
-
all.detect {|t| t.running? }
|
48
|
+
def self.with_timer date=nil
|
49
|
+
all(date).detect {|t| t.running? }
|
41
50
|
end
|
42
51
|
|
43
52
|
def self.last_by_task project_id, task_id
|
@@ -37,6 +37,10 @@ module HCl
|
|
37
37
|
http_do Net::HTTP::Post, action, data
|
38
38
|
end
|
39
39
|
|
40
|
+
def self.delete action
|
41
|
+
http_do Net::HTTP::Delete, action
|
42
|
+
end
|
43
|
+
|
40
44
|
def self.http_do method_class, action, data = nil
|
41
45
|
https = Net::HTTP.new "#{subdomain}.harvestapp.com", (ssl ? 443 : 80)
|
42
46
|
request = method_class.new "/#{action}"
|
@@ -68,7 +72,7 @@ module HCl
|
|
68
72
|
|
69
73
|
def self.xml_to_hash elem
|
70
74
|
elem.elements.map { |e| e.name }.inject({}) do |a, f|
|
71
|
-
a[f.to_sym] = elem.elements[f].text if elem.elements[f]
|
75
|
+
a[f.to_sym] = CGI.unescape_html(elem.elements[f].text || '') if elem.elements[f]
|
72
76
|
a
|
73
77
|
end
|
74
78
|
end
|