hcl 0.4.14 → 0.4.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +4 -0
- data/Gemfile +8 -9
- data/README.markdown +5 -5
- data/lib/hcl/app.rb +1 -1
- data/lib/hcl/commands.rb +7 -4
- data/lib/hcl/net.rb +5 -1
- data/lib/hcl/version.rb +1 -1
- data/man/hcl.1 +0 -255
- data/test/app_test.rb +1 -1
- data/test/command_test.rb +21 -4
- data/test/net_test.rb +20 -0
- data/test/task_test.rb +22 -12
- data/test/test_helper.rb +12 -8
- data/test/utility_test.rb +21 -0
- metadata +52 -66
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b075deba585be93e48ef66396c6c847d6b7bf0e0
|
4
|
+
data.tar.gz: 646e8e506006258deaee88748a40820f40d69bbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8694e4acad5a4af641c724d7851ef559b032b097567790bd3d5fcb53cff394969dbcbb3886342036866aa2f310fcf66b0374ce3a6f3deb803956a43175137e7a
|
7
|
+
data.tar.gz: b0d1da651a3bb4e4688dfc664371a74aacab0a5d3b17a75e5e51d4c779032dd9fdbde652d0dc01cc3f80f4539496651e44f15eed962dbc1f7c4b0e8e1bae1dcc
|
data/CHANGELOG.markdown
CHANGED
data/Gemfile
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
gemspec
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
gem '
|
10
|
-
|
11
|
-
gem 'yajl-ruby', platform:'rbx', group:'test'
|
3
|
+
|
4
|
+
group :development do
|
5
|
+
gem 'ronn'
|
6
|
+
end
|
7
|
+
|
8
|
+
group :test, :development do
|
9
|
+
gem 'byebug'
|
10
|
+
end
|
data/README.markdown
CHANGED
@@ -9,7 +9,7 @@ HCl is a command-line tool for interacting with Harvest time sheets using the
|
|
9
9
|
[![Gem Version](https://badge.fury.io/rb/hcl.png)](http://badge.fury.io/rb/hcl)
|
10
10
|
|
11
11
|
[htt]: http://www.getharvest.com/api/time_tracking
|
12
|
-
[rdoc]: http://
|
12
|
+
[rdoc]: http://www.rubydoc.info/github/zenhob/hcl/master
|
13
13
|
|
14
14
|
## GETTING STARTED
|
15
15
|
|
@@ -19,7 +19,7 @@ You can install hcl directly from rubygems.org:
|
|
19
19
|
|
20
20
|
or you can install from source:
|
21
21
|
|
22
|
-
rake install
|
22
|
+
rake doc && rake install
|
23
23
|
|
24
24
|
Once installed, you can view this README as a man page:
|
25
25
|
|
@@ -189,10 +189,10 @@ commands show the time sheet for the specified day:
|
|
189
189
|
### Harvest service status
|
190
190
|
|
191
191
|
Harvest provides a [status API], which you can query using the
|
192
|
-
`hcl status` command. This will tell you whether Harvest itself is up
|
193
|
-
|
192
|
+
`hcl status` command. This will tell you whether Harvest itself is up,
|
193
|
+
along with a timestamp of when it was last tested.
|
194
194
|
|
195
|
-
[status API]: http://harveststatus.com
|
195
|
+
[status API]: http://harveststatus.com
|
196
196
|
|
197
197
|
## AUTHOR
|
198
198
|
|
data/lib/hcl/app.rb
CHANGED
data/lib/hcl/commands.rb
CHANGED
@@ -12,12 +12,15 @@ module HCl
|
|
12
12
|
|
13
13
|
# Show the network status of the Harvest service.
|
14
14
|
def status
|
15
|
-
result = Faraday.new("http://
|
16
|
-
f.use :harvest, '', ''
|
15
|
+
result = Faraday.new("http://kccljmymlslr.statuspage.io/api/v2") do |f|
|
17
16
|
f.adapter Faraday.default_adapter
|
18
17
|
end.get('status.json').body
|
19
|
-
|
20
|
-
|
18
|
+
|
19
|
+
json = Yajl::Parser.parse result, symbolize_keys: true
|
20
|
+
status = json[:status][:description]
|
21
|
+
updated_at = DateTime.parse(json[:page][:updated_at]).strftime "%F %T %:z"
|
22
|
+
|
23
|
+
"#{status} [#{updated_at}]"
|
21
24
|
end
|
22
25
|
|
23
26
|
def console
|
data/lib/hcl/net.rb
CHANGED
@@ -19,7 +19,11 @@ module HCl
|
|
19
19
|
"https://#{subdomain}.harvestapp.com"
|
20
20
|
) do |f|
|
21
21
|
f.use :harvest, login, password
|
22
|
-
|
22
|
+
if opts['test_adapter']
|
23
|
+
f.adapter :test, opts['test_adapter']
|
24
|
+
else
|
25
|
+
f.adapter Faraday.default_adapter
|
26
|
+
end
|
23
27
|
end
|
24
28
|
end
|
25
29
|
|
data/lib/hcl/version.rb
CHANGED
data/man/hcl.1
CHANGED
@@ -1,255 +0,0 @@
|
|
1
|
-
.\" generated with Ronn/v0.7.3
|
2
|
-
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
|
-
.
|
4
|
-
.TH "HCL" "1" "April 2014" "" ""
|
5
|
-
.
|
6
|
-
.SH "NAME"
|
7
|
-
\fBhcl\fR \- Track time with Harvest time sheets
|
8
|
-
.
|
9
|
-
.SH "SYNOPSIS"
|
10
|
-
.
|
11
|
-
.nf
|
12
|
-
|
13
|
-
hcl [start] @<task_alias> [+<time>] [<message>]
|
14
|
-
hcl note <message>
|
15
|
-
hcl stop [<message>]
|
16
|
-
hcl resume [@<task_alias>]
|
17
|
-
hcl log @<task_alias> [+<time>] [<message>]
|
18
|
-
hcl show [<date>]
|
19
|
-
hcl tasks [<project_code>]
|
20
|
-
hcl alias <task_alias> <project_id> <task_id>
|
21
|
-
hcl unalias <task_alias>
|
22
|
-
hcl aliases
|
23
|
-
hcl (cancel | nvm | oops)
|
24
|
-
hcl config
|
25
|
-
hcl status
|
26
|
-
.
|
27
|
-
.fi
|
28
|
-
.
|
29
|
-
.SH "DESCRIPTION"
|
30
|
-
.
|
31
|
-
.SS "Available Projects and Tasks"
|
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\.
|
33
|
-
.
|
34
|
-
.IP "" 4
|
35
|
-
.
|
36
|
-
.nf
|
37
|
-
|
38
|
-
hcl tasks
|
39
|
-
.
|
40
|
-
.fi
|
41
|
-
.
|
42
|
-
.IP "" 0
|
43
|
-
.
|
44
|
-
.P
|
45
|
-
You can also pass a project code (this is the short optional code associated with each project) to list only the tasks for that project\.
|
46
|
-
.
|
47
|
-
.SS "Starting a Timer"
|
48
|
-
Since it\'s not practical to enter two long numbers every time you want to identify a task, HCl supports task aliases:
|
49
|
-
.
|
50
|
-
.IP "" 4
|
51
|
-
.
|
52
|
-
.nf
|
53
|
-
|
54
|
-
hcl alias tacodev 1234 5678
|
55
|
-
hcl @tacodev Adding a new feature
|
56
|
-
.
|
57
|
-
.fi
|
58
|
-
.
|
59
|
-
.IP "" 0
|
60
|
-
.
|
61
|
-
.SS "Starting a Timer with Initial Time"
|
62
|
-
You can also provide an initial time when starting a new timer\. This can be expressed in floating\-point or HH:MM\. The following two commands are equivalent:
|
63
|
-
.
|
64
|
-
.IP "" 4
|
65
|
-
.
|
66
|
-
.nf
|
67
|
-
|
68
|
-
hcl @tacodev +0:15 Doing some stuff
|
69
|
-
hcl +\.25 @tacodev Doing some stuff
|
70
|
-
.
|
71
|
-
.fi
|
72
|
-
.
|
73
|
-
.IP "" 0
|
74
|
-
.
|
75
|
-
.SS "Adding Notes to a Running Task"
|
76
|
-
While a task is running you can append lines to the task notes:
|
77
|
-
.
|
78
|
-
.IP "" 4
|
79
|
-
.
|
80
|
-
.nf
|
81
|
-
|
82
|
-
hcl note Then I did something else
|
83
|
-
.
|
84
|
-
.fi
|
85
|
-
.
|
86
|
-
.IP "" 0
|
87
|
-
.
|
88
|
-
.P
|
89
|
-
\fBNote\fR that \fBshow\fR only displays the last line of the timer notes\. You can list all the notes for a running timer by issuing the note command without any arguments:
|
90
|
-
.
|
91
|
-
.IP "" 4
|
92
|
-
.
|
93
|
-
.nf
|
94
|
-
|
95
|
-
hcl note
|
96
|
-
.
|
97
|
-
.fi
|
98
|
-
.
|
99
|
-
.IP "" 0
|
100
|
-
.
|
101
|
-
.SS "Stopping a Timer"
|
102
|
-
The following command will stop a running timer (currently only one timer at a time is supported)\. You can provide a message when stopping a timer as well:
|
103
|
-
.
|
104
|
-
.IP "" 4
|
105
|
-
.
|
106
|
-
.nf
|
107
|
-
|
108
|
-
hcl stop All done doing things
|
109
|
-
.
|
110
|
-
.fi
|
111
|
-
.
|
112
|
-
.IP "" 0
|
113
|
-
.
|
114
|
-
.SS "Resuming a Timer"
|
115
|
-
You can resume a stopped timer\. Specify a task to resume the last timer for that task:
|
116
|
-
.
|
117
|
-
.IP "" 4
|
118
|
-
.
|
119
|
-
.nf
|
120
|
-
|
121
|
-
hcl resume
|
122
|
-
hcl resume @xdev
|
123
|
-
.
|
124
|
-
.fi
|
125
|
-
.
|
126
|
-
.IP "" 0
|
127
|
-
.
|
128
|
-
.SS "Canceling a Timer"
|
129
|
-
If you accidentally started a timer that you didn\'t mean to, you can cancel it:
|
130
|
-
.
|
131
|
-
.IP "" 4
|
132
|
-
.
|
133
|
-
.nf
|
134
|
-
|
135
|
-
hcl cancel
|
136
|
-
.
|
137
|
-
.fi
|
138
|
-
.
|
139
|
-
.IP "" 0
|
140
|
-
.
|
141
|
-
.P
|
142
|
-
This will delete the running timer, or the last\-updated timer if one isn\'t running\. You can also use \fBnvm\fR or \fBoops\fR instead of \fBcancel\fR\.
|
143
|
-
.
|
144
|
-
.SS "Logging without Starting a Timer"
|
145
|
-
You can log time and notes without leaving a timer running\. It takes the same arguments as start:
|
146
|
-
.
|
147
|
-
.IP "" 4
|
148
|
-
.
|
149
|
-
.nf
|
150
|
-
|
151
|
-
hcl log @xdev +1 Worked for an hour\.
|
152
|
-
.
|
153
|
-
.fi
|
154
|
-
.
|
155
|
-
.IP "" 0
|
156
|
-
.
|
157
|
-
.P
|
158
|
-
The above starts and immediately stops a one\-hour timer with the given note\.
|
159
|
-
.
|
160
|
-
.SH "ADVANCED USAGE"
|
161
|
-
.
|
162
|
-
.SS "Bash Auto\-completion of Task Aliases"
|
163
|
-
You can enable auto\-completion of task aliases by adding this to your shell configuration (note the backticks inside the double quotes):
|
164
|
-
.
|
165
|
-
.IP "" 4
|
166
|
-
.
|
167
|
-
.nf
|
168
|
-
|
169
|
-
complete \-W "`cat ~/\.hcl/aliases`" hcl
|
170
|
-
.
|
171
|
-
.fi
|
172
|
-
.
|
173
|
-
.IP "" 0
|
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
|
-
.
|
178
|
-
.SS "Configuration Profiles"
|
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\.
|
180
|
-
.
|
181
|
-
.P
|
182
|
-
Here is a shell alias \fBmyhcl\fR with a separate configuration from the main \fBhcl\fR command, and another command to configure alias completion:
|
183
|
-
.
|
184
|
-
.IP "" 4
|
185
|
-
.
|
186
|
-
.nf
|
187
|
-
|
188
|
-
alias myhcl="env HCL_DIR=~/\.myhcl hcl"
|
189
|
-
complete \-W "`cat ~/\.myhcl/aliases`" myhcl
|
190
|
-
.
|
191
|
-
.fi
|
192
|
-
.
|
193
|
-
.IP "" 0
|
194
|
-
.
|
195
|
-
.P
|
196
|
-
Adding something like the above to your bashrc will enable a new command, \fBmyhcl\fR\. When using \fBmyhcl\fR you can use different credentials and aliases, while \fBhcl\fR will continue to function with your original configuration\.
|
197
|
-
.
|
198
|
-
.SS "Interactive Console"
|
199
|
-
An interactive Ruby console is provided to allow you to use the fairly powerful Harvest API client built into HCl, since not all of its features are exposed via the command line\. The current {HCl::App} instance is available as \fBhcl\fR\.
|
200
|
-
.
|
201
|
-
.P
|
202
|
-
It\'s also possible to issue HCl commands directly (except \fBalias\fR, see below), or to query specific JSON end points and have the results pretty\-printed:
|
203
|
-
.
|
204
|
-
.IP "" 4
|
205
|
-
.
|
206
|
-
.nf
|
207
|
-
|
208
|
-
hcl console
|
209
|
-
hcl> show "yesterday"
|
210
|
-
# => prints yesterday\'s timesheet, note the quotes!
|
211
|
-
hcl> hcl\.http\.get(\'daily\')
|
212
|
-
# => displays a pretty\-printed version of the JSON output
|
213
|
-
.
|
214
|
-
.fi
|
215
|
-
.
|
216
|
-
.IP "" 0
|
217
|
-
.
|
218
|
-
.P
|
219
|
-
Note that the HCl internals may change without notice\. Also, commands (like \fBalias\fR) that are also reserved words in Ruby can\'t be issued directly (use \fBsend :alias\fR instead)\.
|
220
|
-
.
|
221
|
-
.SS "Date Formats"
|
222
|
-
Dates can be expressed in a variety of ways\. See the Chronic documentation \fIhttp://chronic\.rubyforge\.org/\fR for more information about available date input formats\. The following commands show the time sheet for the specified day:
|
223
|
-
.
|
224
|
-
.IP "" 4
|
225
|
-
.
|
226
|
-
.nf
|
227
|
-
|
228
|
-
hcl show yesterday
|
229
|
-
hcl show last friday
|
230
|
-
hcl show 2 days ago
|
231
|
-
hcl show 1 week ago
|
232
|
-
.
|
233
|
-
.fi
|
234
|
-
.
|
235
|
-
.IP "" 0
|
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
|
-
.
|
240
|
-
.SH "AUTHOR"
|
241
|
-
HCl was designed and implemented by Zack Hobson \fIhttp://github\.com/zenhob\fR\.
|
242
|
-
.
|
243
|
-
.IP "\(bu" 4
|
244
|
-
Non\-SSL support by Michael Bleigh \fIhttp://github\.com/mbleigh\fR\.
|
245
|
-
.
|
246
|
-
.IP "\(bu" 4
|
247
|
-
Resume command by Brian Cooke \fIhttp://github\.com/bricooke\fR\.
|
248
|
-
.
|
249
|
-
.IP "\(bu" 4
|
250
|
-
UI improvements by Chris Scharf \fIhttp://github\.com/scharfie\fR\.
|
251
|
-
.
|
252
|
-
.IP "" 0
|
253
|
-
.
|
254
|
-
.P
|
255
|
-
See LICENSE for copyright details\.
|
data/test/app_test.rb
CHANGED
@@ -40,7 +40,7 @@ class AppTest < HCl::TestCase
|
|
40
40
|
|
41
41
|
def test_socket_error
|
42
42
|
app = HCl::App.new
|
43
|
-
app.expects(:show).raises(
|
43
|
+
app.expects(:show).raises(Faraday::Error)
|
44
44
|
app.expects(:exit).with(1)
|
45
45
|
app.process_args('show').run
|
46
46
|
assert_match /connection failed/i, error_output
|
data/test/command_test.rb
CHANGED
@@ -19,6 +19,18 @@ class CommandTest < HCl::TestCase
|
|
19
19
|
@settings
|
20
20
|
end
|
21
21
|
|
22
|
+
def test_config
|
23
|
+
config.each_line do |config_line|
|
24
|
+
assert_match(/^(login: bob|password: \*\*\*|subdomain: bobclock)$/, config_line)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_set_without_args
|
29
|
+
@settings = {'taco.time'=>'now'}
|
30
|
+
set
|
31
|
+
assert_equal "taco.time: now\n", standard_output
|
32
|
+
end
|
33
|
+
|
22
34
|
def test_log_failure
|
23
35
|
HCl::DayEntry.expects(:with_timer).returns(stub)
|
24
36
|
assert_raises(HCl::CommandError) { log "stuff" }
|
@@ -29,9 +41,15 @@ class CommandTest < HCl::TestCase
|
|
29
41
|
register_uri(:get, '/daily', {:day_entries=>[], :projects=> [{
|
30
42
|
:name=>"Harvest Command Line", :code=>"hcl", :id=>"123", :client=>"zenhob",
|
31
43
|
:tasks=> [{:name=>"Development", :id=>"456"} ]
|
44
|
+
},{
|
45
|
+
:name=>"Detached", :code=>'', :id=>"456", :client=>"zenhob",
|
46
|
+
:tasks=> [{:name=>"Development", :id=>"678"} ]
|
32
47
|
}]})
|
33
48
|
result = tasks
|
34
|
-
assert_equal
|
49
|
+
assert_equal \
|
50
|
+
"456 678\tzenhob - Detached - Development\n"+
|
51
|
+
"123 456\tzenhob - [hcl] Harvest Command Line - Development",
|
52
|
+
result
|
35
53
|
end
|
36
54
|
|
37
55
|
def test_show
|
@@ -74,7 +92,6 @@ class CommandTest < HCl::TestCase
|
|
74
92
|
end
|
75
93
|
|
76
94
|
def test_stop
|
77
|
-
entry = stub
|
78
95
|
register_uri(:get, '/daily', {day_entries:[{id:123,notes:'',hours:1,client:nil,project:nil,timer_started_at:DateTime.now}]})
|
79
96
|
register_uri(:post, '/daily/update/123', {day_entry:{notes:'all done'}})
|
80
97
|
register_uri(:get, '/daily/timer/123')
|
@@ -82,10 +99,10 @@ class CommandTest < HCl::TestCase
|
|
82
99
|
end
|
83
100
|
|
84
101
|
def test_stop_yesterday
|
85
|
-
entry = stub
|
86
102
|
yesterday = (DateTime.now - 1).strftime("%3j")
|
103
|
+
yesteryear = (DateTime.now - 1).strftime("%Y")
|
87
104
|
register_uri(:get, '/daily', {day_entries:[]})
|
88
|
-
register_uri(:get, "/daily/#{yesterday}
|
105
|
+
register_uri(:get, "/daily/#{yesterday}/#{yesteryear}", {day_entries:[{id:321,notes:'',hours:1,client:nil,project:nil,timer_started_at:DateTime.now}]})
|
89
106
|
register_uri(:post, '/daily/update/321', {day_entry:{notes:'all done next day'}})
|
90
107
|
register_uri(:get, '/daily/timer/321')
|
91
108
|
stop 'all done next day'
|
data/test/net_test.rb
CHANGED
@@ -8,6 +8,26 @@ class NetTest < HCl::TestCase
|
|
8
8
|
assert_equal 'bobclock', http.subdomain
|
9
9
|
end
|
10
10
|
|
11
|
+
def test_redirect_failure
|
12
|
+
register_status(:get, "/taco", 302)
|
13
|
+
assert_raises(HCl::HarvestMiddleware::Failure) { http.get('/taco') }
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_auth_failure
|
17
|
+
register_status(:get, "/burrito", 403)
|
18
|
+
assert_raises(HCl::HarvestMiddleware::AuthFailure) { http.get('/burrito') }
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_throttle_failure
|
22
|
+
register_status(:get, "/sushi", 503)
|
23
|
+
assert_raises(HCl::HarvestMiddleware::ThrottleFailure) { http.get('/sushi') }
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_generic_failure
|
27
|
+
register_status(:get, "/kimchee", 500)
|
28
|
+
assert_raises(HCl::HarvestMiddleware::Failure) { http.get('/kimchee') }
|
29
|
+
end
|
30
|
+
|
11
31
|
def test_http_deep_unescape
|
12
32
|
register_uri(:get, "/foo", {
|
13
33
|
status:'gotten & got!',
|
data/test/task_test.rb
CHANGED
@@ -5,18 +5,28 @@ class TaskTest < HCl::TestCase
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def test_cache_tasks_hash
|
8
|
-
HCl::Task.cache_tasks_hash({ projects: [{
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
8
|
+
HCl::Task.cache_tasks_hash({ projects: [ {
|
9
|
+
name: "taco tasks",
|
10
|
+
id: 3,
|
11
|
+
client: "Taco Town",
|
12
|
+
tasks: [{
|
13
|
+
name: "frying tortilla",
|
14
|
+
id: 12,
|
15
|
+
billable: true
|
16
|
+
}]
|
17
|
+
}, {
|
18
|
+
name: "burrito tasks",
|
19
|
+
id: 5,
|
20
|
+
client: "Burritoville",
|
21
|
+
tasks: [{
|
22
|
+
name: "wrapping",
|
23
|
+
id: 16,
|
24
|
+
billable: true
|
25
|
+
}]
|
26
|
+
} ]})
|
27
|
+
assert_equal 2, HCl::Task.all.size
|
28
|
+
assert_equal 'wrapping', HCl::Task.all.first.name
|
29
|
+
assert_equal 'frying tortilla', HCl::Task.all.last.name
|
20
30
|
end
|
21
31
|
|
22
32
|
def test_add
|
data/test/test_helper.rb
CHANGED
@@ -11,7 +11,7 @@ begin
|
|
11
11
|
# source: https://travis-ci.org/zenhob/hcl
|
12
12
|
minimum_coverage 80
|
13
13
|
end
|
14
|
-
rescue LoadError
|
14
|
+
rescue LoadError
|
15
15
|
$stderr.puts 'No test coverage tools found, skipping coverage check.'
|
16
16
|
end
|
17
17
|
|
@@ -22,8 +22,8 @@ require 'hcl'
|
|
22
22
|
require 'minitest/autorun'
|
23
23
|
require 'mocha/setup'
|
24
24
|
require 'fileutils'
|
25
|
-
require '
|
26
|
-
require '
|
25
|
+
require 'faraday'
|
26
|
+
require 'byebug' if ENV['DEBUG']
|
27
27
|
|
28
28
|
# require test extensions/helpers
|
29
29
|
Dir[File.dirname(__FILE__) + '/ext/*.rb'].each { |ext| require ext }
|
@@ -31,20 +31,24 @@ Dir[File.dirname(__FILE__) + '/ext/*.rb'].each { |ext| require ext }
|
|
31
31
|
class HCl::TestCase < MiniTest::Test
|
32
32
|
attr_reader :http
|
33
33
|
def setup
|
34
|
-
|
34
|
+
@stubs = Faraday::Adapter::Test::Stubs.new
|
35
35
|
@http = HCl::Net.new \
|
36
36
|
'login' => 'bob',
|
37
37
|
'password' => 'secret',
|
38
|
-
'subdomain' => 'bobclock'
|
38
|
+
'subdomain' => 'bobclock',
|
39
|
+
'test_adapter' => @stubs
|
39
40
|
end
|
40
41
|
|
41
42
|
def register_uri method, path, data={}
|
42
|
-
|
43
|
-
|
43
|
+
@stubs.send(method, path) { [200, {}, Yajl::Encoder.encode(data)] }
|
44
|
+
end
|
45
|
+
|
46
|
+
def register_status method, path, status_code
|
47
|
+
@stubs.send(method, path) { [status_code.to_i, {}, ''] }
|
44
48
|
end
|
45
49
|
|
46
50
|
def teardown
|
47
|
-
|
51
|
+
@stubs.verify_stubbed_calls
|
48
52
|
end
|
49
53
|
end
|
50
54
|
|
data/test/utility_test.rb
CHANGED
@@ -3,6 +3,27 @@ require 'test_helper'
|
|
3
3
|
class UtilityTest < HCl::TestCase
|
4
4
|
include HCl::Utility
|
5
5
|
|
6
|
+
def test_get_task_ids
|
7
|
+
@settings = {'task.taco'=>'123 456'}
|
8
|
+
assert_equal ['123', '456'], get_task_ids('taco', [])
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_get_ident_with_symbol
|
12
|
+
assert_equal 'taco', get_ident(%w[ +:25 @taco makin tacos ])
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_get_ident_without_symbol
|
16
|
+
assert_equal 'burrito', get_ident(%w[ burrito +:32 makin burritos ])
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_get_starting_time_minutes
|
20
|
+
assert_equal 0.25, get_starting_time(%w[ @taco +:15 makin tacos ])
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_get_starting_time_decimal
|
24
|
+
assert_equal 0.25, get_starting_time(%w[ @taco +.25 makin tacos ])
|
25
|
+
end
|
26
|
+
|
6
27
|
def test_time2float_decimal
|
7
28
|
assert_equal 2.5, time2float("2.5")
|
8
29
|
end
|
metadata
CHANGED
@@ -1,223 +1,209 @@
|
|
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.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zack Hobson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem-man
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.3.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.3.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: trollop
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 2.1.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 2.1.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: chronic
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 0.10.2
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.10.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: highline
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.7.2
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
68
|
+
version: 1.7.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: faraday
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.9.
|
75
|
+
version: 0.9.1
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.9.
|
82
|
+
version: 0.9.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: yajl-ruby
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.1
|
89
|
+
version: 1.2.1
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.1
|
96
|
+
version: 1.2.1
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: escape_utils
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.0
|
103
|
+
version: 1.1.0
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 1.0
|
110
|
+
version: 1.1.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: pry
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - '='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
117
|
+
version: 0.10.1
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - '='
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
124
|
+
version: 0.10.1
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rake
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: rubygems-tasks
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- -
|
150
|
+
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: mocha
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- -
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '0'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- -
|
164
|
+
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: yard
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- -
|
171
|
+
- - ">="
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '0'
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- -
|
178
|
+
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: simplecov
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- -
|
185
|
+
- - ">="
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: '0'
|
188
188
|
type: :development
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
|
-
- -
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: '0'
|
195
|
-
- !ruby/object:Gem::Dependency
|
196
|
-
name: fakeweb
|
197
|
-
requirement: !ruby/object:Gem::Requirement
|
198
|
-
requirements:
|
199
|
-
- - '>='
|
200
|
-
- !ruby/object:Gem::Version
|
201
|
-
version: '0'
|
202
|
-
type: :development
|
203
|
-
prerelease: false
|
204
|
-
version_requirements: !ruby/object:Gem::Requirement
|
205
|
-
requirements:
|
206
|
-
- - '>='
|
192
|
+
- - ">="
|
207
193
|
- !ruby/object:Gem::Version
|
208
194
|
version: '0'
|
209
195
|
- !ruby/object:Gem::Dependency
|
210
196
|
name: minitest
|
211
197
|
requirement: !ruby/object:Gem::Requirement
|
212
198
|
requirements:
|
213
|
-
- -
|
199
|
+
- - ">="
|
214
200
|
- !ruby/object:Gem::Version
|
215
201
|
version: '0'
|
216
202
|
type: :development
|
217
203
|
prerelease: false
|
218
204
|
version_requirements: !ruby/object:Gem::Requirement
|
219
205
|
requirements:
|
220
|
-
- -
|
206
|
+
- - ">="
|
221
207
|
- !ruby/object:Gem::Version
|
222
208
|
version: '0'
|
223
209
|
description: HCl is a command-line client for manipulating Harvest time sheets.
|
@@ -227,14 +213,14 @@ executables:
|
|
227
213
|
extensions: []
|
228
214
|
extra_rdoc_files: []
|
229
215
|
files:
|
230
|
-
- LICENSE
|
231
|
-
- Rakefile
|
232
|
-
- Gemfile
|
233
|
-
- bin/hcl
|
234
|
-
- man/hcl.1
|
235
216
|
- CHANGELOG.markdown
|
217
|
+
- Gemfile
|
236
218
|
- HACKING.markdown
|
219
|
+
- LICENSE
|
237
220
|
- README.markdown
|
221
|
+
- Rakefile
|
222
|
+
- bin/hcl
|
223
|
+
- lib/hcl.rb
|
238
224
|
- lib/hcl/app.rb
|
239
225
|
- lib/hcl/commands.rb
|
240
226
|
- lib/hcl/console.rb
|
@@ -246,7 +232,7 @@ files:
|
|
246
232
|
- lib/hcl/timesheet_resource.rb
|
247
233
|
- lib/hcl/utility.rb
|
248
234
|
- lib/hcl/version.rb
|
249
|
-
-
|
235
|
+
- man/hcl.1
|
250
236
|
- test/app_test.rb
|
251
237
|
- test/command_test.rb
|
252
238
|
- test/day_entry_test.rb
|
@@ -255,7 +241,7 @@ files:
|
|
255
241
|
- test/task_test.rb
|
256
242
|
- test/test_helper.rb
|
257
243
|
- test/utility_test.rb
|
258
|
-
homepage:
|
244
|
+
homepage: https://zenhob.github.io/hcl/
|
259
245
|
licenses:
|
260
246
|
- MIT
|
261
247
|
metadata: {}
|
@@ -265,17 +251,17 @@ require_paths:
|
|
265
251
|
- lib
|
266
252
|
required_ruby_version: !ruby/object:Gem::Requirement
|
267
253
|
requirements:
|
268
|
-
- -
|
254
|
+
- - ">="
|
269
255
|
- !ruby/object:Gem::Version
|
270
256
|
version: '0'
|
271
257
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
272
258
|
requirements:
|
273
|
-
- -
|
259
|
+
- - ">="
|
274
260
|
- !ruby/object:Gem::Version
|
275
261
|
version: '0'
|
276
262
|
requirements: []
|
277
263
|
rubyforge_project:
|
278
|
-
rubygems_version: 2.
|
264
|
+
rubygems_version: 2.4.5
|
279
265
|
signing_key:
|
280
266
|
specification_version: 4
|
281
267
|
summary: Harvest timesheets from the command-line
|