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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db61484751f4f46ad0e78d1221bd7c6291812ed8
4
- data.tar.gz: 835db00cb847562bb1bfdd32156ce14bae753d36
3
+ metadata.gz: 1e1be76a382c48d42a98e4bad37a360bab90b728
4
+ data.tar.gz: 73afc8798c5cf88030394d3429db7c50e37c9ffa
5
5
  SHA512:
6
- metadata.gz: 842e229a4dc43d0931f2fed478ec12e78576ad073095994ca71ff9fb9d79c24af4f592af479c0a8d01ae360e69a0a81c4e8084ee30c3d0ad694fe011345c14c8
7
- data.tar.gz: 298c413ac8be9f93bd0910ca7da08bb8a7d006ec86078ed1e30317e672d9f7cb13598a87e47caa10f61d1783feef16219bcec5300faa0733598df0e8a1cd84d8
6
+ metadata.gz: 10ecb6e3ac58681da880d0dffffff802efe12073f885bd6f66cdb3e42a4be44c32f51d15490db6b52ef708ce26686c0c196e15896e96721bb6985795b2710503
7
+ data.tar.gz: 831bcaac4c81408f66545380b3de4e76387f30a43592b0ab1210f0f14a1a758bd815ad6a4675b9a770698d9043e67ef56cdff232bc47211355cbc87f9cb87e46
data/CHANGELOG CHANGED
@@ -1,5 +1,10 @@
1
1
  = Recent Changes in HCl
2
2
 
3
+ == v0.4.6
4
+
5
+ * automatically request credentials on auth-failure
6
+ * fix user-entered credentials
7
+
3
8
  == v0.4.5
4
9
 
5
10
  * allow filtering of tasks by project code
data/HACKING.markdown CHANGED
@@ -14,3 +14,9 @@ To run HCl in place (e.g. for testing out local changes) you can use bundle exec
14
14
 
15
15
  bundle exec bin/hcl
16
16
 
17
+ ## Generating API documentation
18
+
19
+ To generate and view the API documentation:
20
+
21
+ rake doc
22
+ open doc/index.html
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. After you've
34
- used the show command you can use the tasks command to view a cached list of
35
- available tasks.
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
@@ -9,7 +9,6 @@ end
9
9
  task :default => :test
10
10
 
11
11
  require 'yard'
12
- YARD::Rake::YardocTask.new do |t|
13
- t.options = %w[--files CHANGELOG]
14
- end
12
+ YARD::Rake::YardocTask.new
13
+ task :doc => :yard
15
14
 
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 your running timer
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
- protected
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
- config = {}
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
- if response.kind_of? Net::HTTPSuccess
68
+ case response
69
+ when Net::HTTPSuccess
68
70
  response.body
69
- elsif response.kind_of? Net::HTTPFound
70
- raise Failure, "Redirected in the request. Perhaps your ssl configuration variable is set incorrectly?"
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
@@ -1,3 +1,3 @@
1
1
  module HCl
2
- VERSION = '0.4.5'
2
+ VERSION = '0.4.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hcl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zack Hobson