hcl 0.4.11 → 0.4.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{CHANGELOG → CHANGELOG.markdown} +33 -24
- data/README.markdown +21 -6
- data/Rakefile +20 -5
- data/lib/hcl/app.rb +24 -1
- data/lib/hcl/commands.rb +18 -2
- data/lib/hcl/version.rb +1 -1
- data/man/hcl.1 +20 -11
- data/test/command_test.rb +24 -6
- data/test/ext/capture_output.rb +1 -1
- data/test/test_helper.rb +3 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45c0652b8ee6e90814a451dc2287a45422998828
|
4
|
+
data.tar.gz: 73b419a165dc6e8c2d1b75a8a7bd31eb639bec8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b505221e5543a832b272b175223cc5b22ca94aa60be13e0e44b60714efa3aed4ad326d7cbdb15a302de86899f296114d10e95793d347dff8e0362aa2908804b
|
7
|
+
data.tar.gz: d1f59e6eb45c915a2f2f9ed9d2d0fe666ad9472fe9c4f61c478bd990ad259e922a7c588314fb23191a651ce943c33c1c27cd332854ff0063b7e8f959d7356cb5
|
@@ -1,73 +1,82 @@
|
|
1
|
-
|
1
|
+
# Recent Changes in HCl
|
2
2
|
|
3
|
-
|
3
|
+
## v0.4.12 2014-02-04
|
4
|
+
|
5
|
+
* fixed crash when caching tasks for the first time, closes #56
|
6
|
+
* fixed crash when stopping a timer the next day
|
7
|
+
* added --changelog option
|
8
|
+
* remove completion command, cache aliases in a file instead, closes #51
|
9
|
+
* confirm timer deletion/cancellation, closes #47
|
10
|
+
* added `status` command to query Harvest service status
|
11
|
+
|
12
|
+
## v0.4.11 2014-01-25
|
4
13
|
|
5
14
|
* more detailed gem dependencies, prevents unexpected failures
|
6
15
|
* added a UNIX manual page for hcl(1)
|
7
16
|
|
8
|
-
|
17
|
+
## v0.4.10 2014-01-06
|
9
18
|
|
10
19
|
* added `config` command to display current credentials
|
11
20
|
* added `console` command for exploring the Harvest API
|
12
21
|
|
13
|
-
|
22
|
+
## v0.4.9 2013-12-21
|
14
23
|
|
15
24
|
* MacOS X: store password in default keychain
|
16
25
|
* abort log command when a timer is running
|
17
26
|
|
18
|
-
|
27
|
+
## v0.4.8 2013-11-30
|
19
28
|
|
20
29
|
* more fixes for 1.9.3
|
21
30
|
|
22
|
-
|
31
|
+
## v0.4.7 2013-11-30
|
23
32
|
|
24
33
|
* added --reauth option to refresh credentials
|
25
34
|
* added support for retrying on API throttle
|
26
35
|
* note command without args now displays all notes for a running timer
|
27
36
|
* fixed a crash on ruby 1.9.3
|
28
37
|
|
29
|
-
|
38
|
+
## v0.4.6 2013-11-21
|
30
39
|
|
31
40
|
* automatically request credentials on auth-failure
|
32
41
|
* fix user-entered credentials
|
33
42
|
|
34
|
-
|
43
|
+
## v0.4.5 2013-11-21
|
35
44
|
|
36
45
|
* allow filtering of tasks by project code
|
37
46
|
* eliminate shoulda from development dependencies
|
38
47
|
|
39
|
-
|
48
|
+
## v0.4.4 2013-11-20
|
40
49
|
|
41
50
|
* added completion command to output a Bash auto-complete script, closes #34
|
42
51
|
* removed jeweler dependency
|
43
52
|
|
44
|
-
|
53
|
+
## v0.4.3 2013-11-19
|
45
54
|
|
46
55
|
* added cancel command to delete the last running timer, closes #13
|
47
56
|
* properly unescape string from Harvest API, closes #24
|
48
57
|
* stop command now checks for running timers from yesterday, closes #35
|
49
58
|
* added log command to log time/notes without leaving a timer running, closes #30
|
50
59
|
|
51
|
-
|
60
|
+
## v0.4.2 2013-11-19
|
52
61
|
|
53
62
|
* resume command now accepts an optional task
|
54
63
|
|
55
|
-
|
64
|
+
## v0.4.1 2013-11-18
|
56
65
|
|
57
66
|
* update dependencies
|
58
67
|
|
59
|
-
|
68
|
+
## v0.4.0 2013-11-18
|
60
69
|
|
61
70
|
* start a timer or add a note without having to specify the sub-command
|
62
71
|
* aliases can be specified with "@" anywhere on the command line
|
63
72
|
* added alias and unalias to simplify setting task aliases
|
64
73
|
|
65
|
-
|
74
|
+
## v0.3.2 2011-12-30
|
66
75
|
|
67
76
|
* fixed support for modern Rubies
|
68
77
|
* it's now possible to provide a message with the stop command
|
69
78
|
|
70
|
-
|
79
|
+
## v0.3.1 2011-07-13
|
71
80
|
|
72
81
|
* use STDERR instead of STDOUT for error reporting
|
73
82
|
* sort tasks before viewing tasks (brian@madebyrocket.com)
|
@@ -75,46 +84,46 @@
|
|
75
84
|
* show current time when on 'start', 'stop', and 'show' commands (scharfie@gmail.com)
|
76
85
|
* include client name in tasks list (scharfie@gmail.com)
|
77
86
|
|
78
|
-
|
87
|
+
## v0.3.0 2010-04-02
|
79
88
|
|
80
89
|
* added support for free accounts
|
81
90
|
|
82
|
-
|
91
|
+
## v0.2.3 2009-08-23
|
83
92
|
|
84
93
|
* Allow decimal time offset without a dot, closes #29.
|
85
94
|
* Reverted and re-fixed: Adding note fails when task is started without notes, #26.
|
86
95
|
* Reinstate the --version option
|
87
96
|
|
88
|
-
|
97
|
+
## v0.2.2 2009-08-09
|
89
98
|
|
90
99
|
* Support installation via rip, closes #27.
|
91
100
|
* Fixed: Adding note fails when task is started without notes, closes #26.
|
92
101
|
* Avoid stack trace on missing XML root node, closes #25.
|
93
102
|
|
94
|
-
|
103
|
+
## v0.2.1 2009-07-30
|
95
104
|
|
96
105
|
* Fixed: Creating timers without starting them.
|
97
106
|
|
98
|
-
|
107
|
+
## v0.2.0 2009-07-30
|
99
108
|
|
100
109
|
* Allow an initial time to be specified when starting a timer, closes #9.
|
101
110
|
* Always display hours as HH:MM, closes #22.
|
102
111
|
* Do not write empty task cache, closes #23.
|
103
112
|
|
104
|
-
|
113
|
+
## v0.1.3 2009-07-28
|
105
114
|
|
106
115
|
* Add a note about ruby-dev for debian/ubuntu users, closes #20.
|
107
116
|
* Friendlier error message on unrecognized task, closes #18, #21.
|
108
117
|
|
109
|
-
|
118
|
+
## v0.1.2 2009-07-27
|
110
119
|
|
111
120
|
* Automatically include rubygems in bin/hcl.
|
112
121
|
|
113
|
-
|
122
|
+
## v0.1.1 2009-07-24
|
114
123
|
|
115
124
|
* Mention gem in README, read version from file.
|
116
125
|
|
117
|
-
|
126
|
+
## v0.1.0 2009-07-24
|
118
127
|
|
119
128
|
* Initial public release
|
120
129
|
|
data/README.markdown
CHANGED
@@ -11,7 +11,7 @@ HCl is a command-line tool for interacting with Harvest time sheets using the
|
|
11
11
|
[htt]: http://www.getharvest.com/api/time_tracking
|
12
12
|
[rdoc]: http://rdoc.info/github/zenhob/hcl/file/README.markdown
|
13
13
|
|
14
|
-
##
|
14
|
+
## GETTING STARTED
|
15
15
|
|
16
16
|
You can install hcl directly from rubygems.org:
|
17
17
|
|
@@ -21,7 +21,7 @@ or you can install from source:
|
|
21
21
|
|
22
22
|
rake install
|
23
23
|
|
24
|
-
##
|
24
|
+
## SYNOPSIS
|
25
25
|
|
26
26
|
hcl [start] @<task_alias> [+<time>] [<message>]
|
27
27
|
hcl note <message>
|
@@ -31,9 +31,13 @@ or you can install from source:
|
|
31
31
|
hcl show [<date>]
|
32
32
|
hcl tasks [<project_code>]
|
33
33
|
hcl alias <task_alias> <project_id> <task_id>
|
34
|
+
hcl unalias <task_alias>
|
34
35
|
hcl aliases
|
35
36
|
hcl (cancel | nvm | oops)
|
36
37
|
hcl config
|
38
|
+
hcl status
|
39
|
+
|
40
|
+
## DESCRIPTION
|
37
41
|
|
38
42
|
### Available Projects and Tasks
|
39
43
|
|
@@ -115,9 +119,12 @@ The above starts and immediately stops a one-hour timer with the given note.
|
|
115
119
|
### Bash Auto-completion of Task Aliases
|
116
120
|
|
117
121
|
You can enable auto-completion of task aliases by adding this to your shell
|
118
|
-
configuration:
|
122
|
+
configuration (note the backticks inside the double quotes):
|
123
|
+
|
124
|
+
complete -W "`cat ~/.hcl/aliases`" hcl
|
119
125
|
|
120
|
-
|
126
|
+
Warning: You will need to have run `hcl` at least once to create the aliases
|
127
|
+
file. Without it, this command will fail with an error.
|
121
128
|
|
122
129
|
### Configuration Profiles
|
123
130
|
|
@@ -131,7 +138,7 @@ Here is a shell alias `myhcl` with a separate configuration from the
|
|
131
138
|
main `hcl` command, and another command to configure alias completion:
|
132
139
|
|
133
140
|
alias myhcl="env HCL_DIR=~/.myhcl hcl"
|
134
|
-
|
141
|
+
complete -W "`cat ~/.myhcl/aliases`" myhcl
|
135
142
|
|
136
143
|
Adding something like the above to your bashrc will enable a new command,
|
137
144
|
`myhcl`. When using `myhcl` you can use different credentials and aliases,
|
@@ -171,7 +178,15 @@ commands show the time sheet for the specified day:
|
|
171
178
|
|
172
179
|
[cd]: http://chronic.rubyforge.org/
|
173
180
|
|
174
|
-
|
181
|
+
### Harvest service status
|
182
|
+
|
183
|
+
Harvest provides a [status API], which you can query using the
|
184
|
+
`hcl status` command. This will tell you whether Harvest itself is up and the
|
185
|
+
current response time, along with a timestamp of when it was last tested.
|
186
|
+
|
187
|
+
[status API]: http://harveststatus.com/status_api
|
188
|
+
|
189
|
+
## AUTHOR
|
175
190
|
|
176
191
|
HCl was designed and implemented by [Zack Hobson][zgh].
|
177
192
|
|
data/Rakefile
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'rubygems/tasks'
|
2
|
+
Gem::Tasks.new
|
3
|
+
|
1
4
|
require 'fileutils'
|
2
5
|
task :clean do
|
3
6
|
FileUtils.rm_rf %w[ pkg coverage doc man/hcl.1 ]
|
@@ -10,15 +13,27 @@ Rake::TestTask.new do |t|
|
|
10
13
|
end
|
11
14
|
task :default => :test
|
12
15
|
|
16
|
+
# process the README into a manual page using ronn
|
17
|
+
require 'ronn'
|
13
18
|
task :man do
|
14
|
-
|
19
|
+
print "Writing manual page..."
|
20
|
+
head, content = File.read('README.markdown').split("## SYNOPSIS\n")
|
21
|
+
content.prepend <<-END
|
22
|
+
hcl(1) -- Track time with Harvest time sheets
|
23
|
+
=============================================
|
24
|
+
|
25
|
+
## SYNOPSIS
|
26
|
+
END
|
27
|
+
FileUtils.mkdir_p('man')
|
28
|
+
File.write('man/hcl.1.ronn', content)
|
29
|
+
File.open('man/hcl.1','w').tap do |man|
|
30
|
+
man.write Ronn::Document.new('man/hcl.1.ronn').to_roff
|
31
|
+
end
|
32
|
+
puts "done."
|
15
33
|
end
|
16
|
-
task
|
34
|
+
task "pkg/hcl-#{HCl::VERSION}.gem" => :man
|
17
35
|
|
18
36
|
require 'yard'
|
19
37
|
YARD::Rake::YardocTask.new
|
20
38
|
task :doc => [:yard, :man]
|
21
39
|
|
22
|
-
require 'rubygems/tasks'
|
23
|
-
Gem::Tasks.new
|
24
|
-
|
data/lib/hcl/app.rb
CHANGED
@@ -11,6 +11,7 @@ module HCl
|
|
11
11
|
|
12
12
|
HCL_DIR = (ENV['HCL_DIR'] || "#{ENV['HOME']}/.hcl").freeze
|
13
13
|
SETTINGS_FILE = "#{HCL_DIR}/settings.yml".freeze
|
14
|
+
ALIAS_LIST = "#{HCL_DIR}/aliases".freeze
|
14
15
|
CONFIG_FILE = "#{HCL_DIR}/config.yml".freeze
|
15
16
|
|
16
17
|
attr_reader :http
|
@@ -38,6 +39,10 @@ module HCl
|
|
38
39
|
# Start the application.
|
39
40
|
def run
|
40
41
|
request_config if @options[:reauth]
|
42
|
+
if @options[:changelog]
|
43
|
+
system %[ more "#{File.join(File.dirname(__FILE__), '../../CHANGELOG.markdown')}" ]
|
44
|
+
exit
|
45
|
+
end
|
41
46
|
begin
|
42
47
|
if @command
|
43
48
|
if command? @command
|
@@ -92,6 +97,9 @@ Commands:
|
|
92
97
|
# create a task alias
|
93
98
|
hcl alias <task_alias> <project_id> <task_id>
|
94
99
|
|
100
|
+
# remove a task alias
|
101
|
+
hcl unalias <task_alias>
|
102
|
+
|
95
103
|
# list task aliases
|
96
104
|
hcl aliases
|
97
105
|
|
@@ -116,6 +124,12 @@ Commands:
|
|
116
124
|
# display the daily timesheet
|
117
125
|
hcl [show [<date>]]
|
118
126
|
|
127
|
+
# show your current credentials
|
128
|
+
hcl config
|
129
|
+
|
130
|
+
# display Harvest service status
|
131
|
+
hcl status
|
132
|
+
|
119
133
|
Examples:
|
120
134
|
hcl alias mytask 1234 4567
|
121
135
|
hcl @mytask +:15 Doing a thing that I started 15 minutes ago.
|
@@ -128,6 +142,7 @@ Examples:
|
|
128
142
|
Options:
|
129
143
|
EOM
|
130
144
|
opt :reauth, "Force refresh of auth details"
|
145
|
+
opt :changelog, "Review the HCl changelog"
|
131
146
|
end
|
132
147
|
@command = args.shift
|
133
148
|
@args = args
|
@@ -172,16 +187,24 @@ EOM
|
|
172
187
|
|
173
188
|
def read_settings
|
174
189
|
if File.exists? SETTINGS_FILE
|
175
|
-
@settings = YAML.load(File.read(SETTINGS_FILE))
|
190
|
+
@settings = YAML.load(File.read(SETTINGS_FILE)) || {}
|
176
191
|
else
|
177
192
|
@settings = {}
|
178
193
|
end
|
194
|
+
cache_aliases
|
195
|
+
end
|
196
|
+
|
197
|
+
def cache_aliases
|
198
|
+
File.open(ALIAS_LIST, 'w') do |f|
|
199
|
+
f.write aliases.join(' ')
|
200
|
+
end
|
179
201
|
end
|
180
202
|
|
181
203
|
def write_settings
|
182
204
|
File.open(SETTINGS_FILE, 'w') do |f|
|
183
205
|
f.write @settings.to_yaml
|
184
206
|
end
|
207
|
+
cache_aliases
|
185
208
|
nil
|
186
209
|
end
|
187
210
|
|
data/lib/hcl/commands.rb
CHANGED
@@ -10,6 +10,16 @@ module HCl
|
|
10
10
|
http.config_hash.merge(password:'***').map {|k,v| "#{k}: #{v}" }.join("\n")
|
11
11
|
end
|
12
12
|
|
13
|
+
# Show the network status of the Harvest service.
|
14
|
+
def status
|
15
|
+
result = Faraday.new("http://harveststatus.com/") do |f|
|
16
|
+
f.use :harvest, '', ''
|
17
|
+
f.adapter Faraday.default_adapter
|
18
|
+
end.get('status.json').body
|
19
|
+
date = Time.at(result[:last_check_time].to_i)
|
20
|
+
"Harvest is #{result[:status]}, response time: #{result[:last_response_time]}ms. [#{date}]"
|
21
|
+
end
|
22
|
+
|
13
23
|
def console
|
14
24
|
Console.new(self)
|
15
25
|
nil
|
@@ -18,7 +28,7 @@ module HCl
|
|
18
28
|
def tasks project_code=nil
|
19
29
|
tasks = Task.all
|
20
30
|
if tasks.empty? # cache tasks
|
21
|
-
DayEntry.today
|
31
|
+
DayEntry.today(http)
|
22
32
|
tasks = Task.all
|
23
33
|
end
|
24
34
|
tasks.select! {|t| t.project.code == project_code } if project_code
|
@@ -45,6 +55,9 @@ module HCl
|
|
45
55
|
def cancel
|
46
56
|
entry = DayEntry.with_timer(http) || DayEntry.last(http)
|
47
57
|
if entry
|
58
|
+
confirmed = /^y/.match(ask("#{entry}\nDelete this entry? (y/n): ").downcase)
|
59
|
+
return unless confirmed
|
60
|
+
|
48
61
|
if entry.cancel http
|
49
62
|
"Deleted entry #{entry}."
|
50
63
|
else
|
@@ -79,6 +92,9 @@ module HCl
|
|
79
92
|
|
80
93
|
def completion command=nil
|
81
94
|
command ||= $PROGRAM_NAME.split('/').last
|
95
|
+
$stderr.puts \
|
96
|
+
"The hcl completion command is deprecated (and slow!), instead use something like:",
|
97
|
+
"> complete -W "`cat #{HCl::App::ALIAS_LIST}`" #{command}"
|
82
98
|
%[complete -W "#{aliases.join ' '}" #{command}]
|
83
99
|
end
|
84
100
|
|
@@ -105,7 +121,7 @@ module HCl
|
|
105
121
|
end
|
106
122
|
|
107
123
|
def stop *args
|
108
|
-
entry = DayEntry.with_timer(http) || DayEntry.with_timer(http,
|
124
|
+
entry = DayEntry.with_timer(http) || DayEntry.with_timer(http, Date.today - 1)
|
109
125
|
if entry
|
110
126
|
entry.append_note(http, args.join(' ')) if args.any?
|
111
127
|
entry.toggle http
|
data/lib/hcl/version.rb
CHANGED
data/man/hcl.1
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
.\" generated with Ronn/v0.7.3
|
2
2
|
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
3
|
.
|
4
|
-
.TH "HCL" "1" "
|
4
|
+
.TH "HCL" "1" "February 2014" "" ""
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
7
|
\fBhcl\fR \- Track time with Harvest time sheets
|
@@ -18,14 +18,15 @@ hcl log @<task_alias> [+<time>] [<message>]
|
|
18
18
|
hcl show [<date>]
|
19
19
|
hcl tasks [<project_code>]
|
20
20
|
hcl alias <task_alias> <project_id> <task_id>
|
21
|
+
hcl unalias <task_alias>
|
21
22
|
hcl aliases
|
22
23
|
hcl (cancel | nvm | oops)
|
23
24
|
hcl config
|
25
|
+
hcl status
|
24
26
|
.
|
25
27
|
.fi
|
26
28
|
.
|
27
29
|
.SH "DESCRIPTION"
|
28
|
-
HCl is a command\-line tool for interacting with Harvest time sheets using the Harvest time tracking API\.
|
29
30
|
.
|
30
31
|
.SS "Available Projects and Tasks"
|
31
32
|
To start a new timer you need to identify the project and task\. The tasks command displays a list of available tasks with their project and task IDs\.
|
@@ -156,21 +157,24 @@ hcl log @xdev +1 Worked for an hour\.
|
|
156
157
|
.P
|
157
158
|
The above starts and immediately stops a one\-hour timer with the given note\.
|
158
159
|
.
|
159
|
-
.SH "
|
160
|
+
.SH "Advanced Usage"
|
160
161
|
.
|
161
162
|
.SS "Bash Auto\-completion of Task Aliases"
|
162
|
-
You can enable auto\-completion of task aliases by adding this to your shell configuration:
|
163
|
+
You can enable auto\-completion of task aliases by adding this to your shell configuration (note the backticks inside the double quotes):
|
163
164
|
.
|
164
165
|
.IP "" 4
|
165
166
|
.
|
166
167
|
.nf
|
167
168
|
|
168
|
-
|
169
|
+
complete \-W "`cat ~/\.hcl/aliases`" hcl
|
169
170
|
.
|
170
171
|
.fi
|
171
172
|
.
|
172
173
|
.IP "" 0
|
173
174
|
.
|
175
|
+
.P
|
176
|
+
Warning: You will need to have run \fBhcl\fR at least once to create the aliases file\. Without it, this command will fail with an error\.
|
177
|
+
.
|
174
178
|
.SS "Configuration Profiles"
|
175
179
|
You can modify your credentials with the \fB\-\-reauth\fR option, and review them with \fBhcl config\fR\. If you\'d rather store multiple configurations at once, specify an alternate configuration directory in the environment as \fBHCL_DIR\fR\. This can be used to interact with multiple harvest accounts at once\.
|
176
180
|
.
|
@@ -182,7 +186,7 @@ Here is a shell alias \fBmyhcl\fR with a separate configuration from the main \f
|
|
182
186
|
.nf
|
183
187
|
|
184
188
|
alias myhcl="env HCL_DIR=~/\.myhcl hcl"
|
185
|
-
|
189
|
+
complete \-W "`cat ~/\.myhcl/aliases`" myhcl
|
186
190
|
.
|
187
191
|
.fi
|
188
192
|
.
|
@@ -230,17 +234,22 @@ hcl show 1 week ago
|
|
230
234
|
.
|
231
235
|
.IP "" 0
|
232
236
|
.
|
237
|
+
.SS "Harvest service status"
|
238
|
+
Harvest provides a status API \fIhttp://harveststatus\.com/status_api\fR, which you can query using the \fBhcl status\fR command\. This will tell you whether Harvest itself is up and the current response time, along with a timestamp of when it was last tested\.
|
239
|
+
.
|
233
240
|
.SH "AUTHOR"
|
234
|
-
HCl was designed and implemented by Zack Hobson\.
|
241
|
+
HCl was designed and implemented by Zack Hobson \fIhttp://github\.com/zenhob\fR\.
|
235
242
|
.
|
236
243
|
.IP "\(bu" 4
|
237
|
-
Non\-SSL support by Michael Bleigh\.
|
244
|
+
Non\-SSL support by Michael Bleigh \fIhttp://github\.com/mbleigh\fR\.
|
238
245
|
.
|
239
246
|
.IP "\(bu" 4
|
240
|
-
Resume command by Brian Cooke\.
|
247
|
+
Resume command by Brian Cooke \fIhttp://github\.com/bricooke\fR\.
|
241
248
|
.
|
242
249
|
.IP "\(bu" 4
|
243
|
-
UI improvements by Chris Scharf\.
|
250
|
+
UI improvements by Chris Scharf \fIhttp://github\.com/scharfie\fR\.
|
244
251
|
.
|
245
252
|
.IP "" 0
|
246
|
-
|
253
|
+
.
|
254
|
+
.P
|
255
|
+
See LICENSE for copyright details\.
|
data/test/command_test.rb
CHANGED
@@ -25,13 +25,13 @@ class CommandTest < HCl::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_tasks
|
28
|
-
|
29
|
-
|
30
|
-
name:
|
31
|
-
|
32
|
-
|
28
|
+
FileUtils.rm_rf ENV['HCL_DIR']+"/cache"
|
29
|
+
register_uri(:get, '/daily', {:day_entries=>[], :projects=> [{
|
30
|
+
:name=>"Harvest Command Line", :code=>"hcl", :id=>"123", :client=>"zenhob",
|
31
|
+
:tasks=> [{:name=>"Development", :id=>"456"} ]
|
32
|
+
}]})
|
33
33
|
result = tasks
|
34
|
-
assert_equal "456
|
34
|
+
assert_equal "123 456\tzenhob - [hcl] Harvest Command Line - Development", result
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_show
|
@@ -81,6 +81,16 @@ class CommandTest < HCl::TestCase
|
|
81
81
|
stop 'all done'
|
82
82
|
end
|
83
83
|
|
84
|
+
def test_stop_yesterday
|
85
|
+
entry = stub
|
86
|
+
yesterday = (DateTime.now - 1).strftime("%3j")
|
87
|
+
register_uri(:get, '/daily', {day_entries:[]})
|
88
|
+
register_uri(:get, "/daily/#{yesterday}/2014", {day_entries:[{id:321,notes:'',hours:1,client:nil,project:nil,timer_started_at:DateTime.now}]})
|
89
|
+
register_uri(:post, '/daily/update/321', {day_entry:{notes:'all done next day'}})
|
90
|
+
register_uri(:get, '/daily/timer/321')
|
91
|
+
stop 'all done next day'
|
92
|
+
end
|
93
|
+
|
84
94
|
def test_resume
|
85
95
|
entry = stub
|
86
96
|
HCl::DayEntry.expects(:last).returns(entry)
|
@@ -100,6 +110,14 @@ class CommandTest < HCl::TestCase
|
|
100
110
|
entry = stub
|
101
111
|
HCl::DayEntry.expects(:with_timer).with(http).returns(entry)
|
102
112
|
entry.expects(:cancel).with(http).returns(true)
|
113
|
+
expects(:ask).returns('y')
|
114
|
+
cancel
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_cancel_no
|
118
|
+
entry = stub
|
119
|
+
HCl::DayEntry.expects(:with_timer).with(http).returns(entry)
|
120
|
+
expects(:ask).returns('n')
|
103
121
|
cancel
|
104
122
|
end
|
105
123
|
|
data/test/ext/capture_output.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -9,7 +9,7 @@ begin
|
|
9
9
|
source_file.lines.count < 15
|
10
10
|
end
|
11
11
|
# source: https://travis-ci.org/zenhob/hcl
|
12
|
-
minimum_coverage
|
12
|
+
minimum_coverage 80
|
13
13
|
end
|
14
14
|
rescue LoadError => e
|
15
15
|
$stderr.puts 'No test coverage tools found, skipping coverage check.'
|
@@ -23,11 +23,12 @@ require 'minitest/autorun'
|
|
23
23
|
require 'mocha/setup'
|
24
24
|
require 'fileutils'
|
25
25
|
require 'fakeweb'
|
26
|
+
require 'debugger' if ENV['DEBUG']
|
26
27
|
|
27
28
|
# require test extensions/helpers
|
28
29
|
Dir[File.dirname(__FILE__) + '/ext/*.rb'].each { |ext| require ext }
|
29
30
|
|
30
|
-
class HCl::TestCase < MiniTest::
|
31
|
+
class HCl::TestCase < MiniTest::Test
|
31
32
|
attr_reader :http
|
32
33
|
def setup
|
33
34
|
FakeWeb.allow_net_connect = false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hcl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zack Hobson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trollop
|
@@ -213,13 +213,14 @@ executables:
|
|
213
213
|
extensions: []
|
214
214
|
extra_rdoc_files: []
|
215
215
|
files:
|
216
|
-
- CHANGELOG
|
217
216
|
- LICENSE
|
218
217
|
- Rakefile
|
219
218
|
- Gemfile
|
219
|
+
- bin/hcl
|
220
|
+
- man/hcl.1
|
221
|
+
- CHANGELOG.markdown
|
220
222
|
- HACKING.markdown
|
221
223
|
- README.markdown
|
222
|
-
- bin/hcl
|
223
224
|
- lib/hcl/app.rb
|
224
225
|
- lib/hcl/commands.rb
|
225
226
|
- lib/hcl/console.rb
|
@@ -240,7 +241,6 @@ files:
|
|
240
241
|
- test/task_test.rb
|
241
242
|
- test/test_helper.rb
|
242
243
|
- test/utility_test.rb
|
243
|
-
- man/hcl.1
|
244
244
|
homepage: http://zackhobson.com/hcl/
|
245
245
|
licenses:
|
246
246
|
- MIT
|