hcl 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +5 -0
- data/HACKING.markdown +6 -0
- data/README.markdown +3 -3
- data/Rakefile +2 -3
- data/lib/hcl/app.rb +23 -13
- data/lib/hcl/timesheet_resource.rb +8 -4
- data/lib/hcl/version.rb +1 -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: 1e1be76a382c48d42a98e4bad37a360bab90b728
|
4
|
+
data.tar.gz: 73afc8798c5cf88030394d3429db7c50e37c9ffa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10ecb6e3ac58681da880d0dffffff802efe12073f885bd6f66cdb3e42a4be44c32f51d15490db6b52ef708ce26686c0c196e15896e96721bb6985795b2710503
|
7
|
+
data.tar.gz: 831bcaac4c81408f66545380b3de4e76387f30a43592b0ab1210f0f14a1a758bd815ad6a4675b9a770698d9043e67ef56cdff232bc47211355cbc87f9cb87e46
|
data/CHANGELOG
CHANGED
data/HACKING.markdown
CHANGED
data/README.markdown
CHANGED
@@ -30,9 +30,9 @@ or you can install from source:
|
|
30
30
|
|
31
31
|
### Available Projects and Tasks
|
32
32
|
|
33
|
-
To start a new timer you need to identify the project and task.
|
34
|
-
|
35
|
-
|
33
|
+
To start a new timer you need to identify the project and task.
|
34
|
+
The tasks command displays a list of available tasks with their
|
35
|
+
project and task IDs.
|
36
36
|
|
37
37
|
$ hcl tasks
|
38
38
|
|
data/Rakefile
CHANGED
data/lib/hcl/app.rb
CHANGED
@@ -2,14 +2,13 @@ require 'yaml'
|
|
2
2
|
require 'fileutils'
|
3
3
|
|
4
4
|
require 'trollop'
|
5
|
-
require 'highline'
|
5
|
+
require 'highline/import'
|
6
6
|
|
7
7
|
module HCl
|
8
8
|
class App
|
9
9
|
include HCl::Utility
|
10
10
|
include HCl::Commands
|
11
11
|
|
12
|
-
|
13
12
|
HCL_DIR = ENV['HCL_DIR'] || "#{ENV['HOME']}/.hcl"
|
14
13
|
SETTINGS_FILE = "#{HCL_DIR}/settings.yml"
|
15
14
|
CONFIG_FILE = "#{HCL_DIR}/config.yml"
|
@@ -61,6 +60,10 @@ module HCl
|
|
61
60
|
rescue SocketError => e
|
62
61
|
STDERR.puts "Connection failed. (#{e.message})"
|
63
62
|
exit 1
|
63
|
+
rescue TimesheetResource::AuthFailure => e
|
64
|
+
STDERR.puts "Unable to authenticate: #{e}"
|
65
|
+
request_config
|
66
|
+
run
|
64
67
|
rescue TimesheetResource::Failure => e
|
65
68
|
STDERR.puts "API failure: #{e}"
|
66
69
|
exit 1
|
@@ -87,12 +90,15 @@ Commands:
|
|
87
90
|
# start a task using an alias
|
88
91
|
hcl [start] @<task_alias> [+<time>] [<message>]
|
89
92
|
|
90
|
-
# add a line to
|
93
|
+
# add a line to a running timer
|
91
94
|
hcl note <message>
|
92
95
|
|
93
96
|
# stop a running timer
|
94
97
|
hcl stop [<message>]
|
95
98
|
|
99
|
+
# log a task and time without leaving a timer running
|
100
|
+
hcl log @<task_alias> [+<time>] [<message>]
|
101
|
+
|
96
102
|
# resume the last stopped timer or a specific task
|
97
103
|
hcl resume [@<task_alias>]
|
98
104
|
|
@@ -119,9 +125,9 @@ EOM
|
|
119
125
|
self
|
120
126
|
end
|
121
127
|
|
122
|
-
|
128
|
+
private
|
123
129
|
|
124
|
-
def read_config
|
130
|
+
def read_config force=false
|
125
131
|
if File.exists? CONFIG_FILE
|
126
132
|
config = YAML::load File.read(CONFIG_FILE)
|
127
133
|
TimesheetResource.configure config
|
@@ -130,17 +136,21 @@ EOM
|
|
130
136
|
TimesheetResource.configure config
|
131
137
|
write_config config
|
132
138
|
else
|
133
|
-
|
134
|
-
puts "Please specify your Harvest credentials.\n"
|
135
|
-
config['login'] = ask("Email Address: ").to_s
|
136
|
-
config['password'] = ask("Password: ") { |q| q.echo = false }.to_s
|
137
|
-
config['subdomain'] = ask("Subdomain: ").to_s
|
138
|
-
config['ssl'] = %w(y yes).include?(ask("Use SSL? (y/n): ").downcase)
|
139
|
-
TimesheetResource.configure config
|
140
|
-
write_config config
|
139
|
+
request_config
|
141
140
|
end
|
142
141
|
end
|
143
142
|
|
143
|
+
def request_config
|
144
|
+
config = {}
|
145
|
+
puts "Please specify your Harvest credentials.\n"
|
146
|
+
config['login'] = ask("Email Address: ").to_s
|
147
|
+
config['password'] = ask("Password: ") { |q| q.echo = false }.to_s
|
148
|
+
config['subdomain'] = ask("Subdomain: ").to_s
|
149
|
+
config['ssl'] = %w(y yes).include?(ask("Use SSL? (y/n): ").downcase)
|
150
|
+
TimesheetResource.configure config
|
151
|
+
write_config config
|
152
|
+
end
|
153
|
+
|
144
154
|
def write_config config
|
145
155
|
puts "Writing configuration to #{CONFIG_FILE}."
|
146
156
|
File.open(CONFIG_FILE, 'w') do |f|
|
@@ -16,6 +16,7 @@ end
|
|
16
16
|
module HCl
|
17
17
|
class TimesheetResource
|
18
18
|
class Failure < StandardError; end
|
19
|
+
class AuthFailure < StandardError; end
|
19
20
|
|
20
21
|
def self.configure opts = nil
|
21
22
|
if opts
|
@@ -64,12 +65,15 @@ module HCl
|
|
64
65
|
request.content_type = 'application/xml'
|
65
66
|
request['Accept'] = 'application/xml'
|
66
67
|
response = https.request request, data
|
67
|
-
|
68
|
+
case response
|
69
|
+
when Net::HTTPSuccess
|
68
70
|
response.body
|
69
|
-
|
70
|
-
raise Failure, "Redirected
|
71
|
+
when Net::HTTPFound
|
72
|
+
raise Failure, "Redirected! Perhaps your ssl configuration variable is set incorrectly?"
|
73
|
+
when Net::HTTPUnauthorized
|
74
|
+
raise AuthFailure, "Login failed."
|
71
75
|
else
|
72
|
-
raise Failure, "Unexpected response from the upstream API"
|
76
|
+
raise Failure, "Unexpected response from the upstream API."
|
73
77
|
end
|
74
78
|
end
|
75
79
|
|
data/lib/hcl/version.rb
CHANGED