zenhob-hcl 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -0
- data/bin/hcl +2 -3
- data/deps.rip +3 -0
- data/hcl.gemspec +5 -4
- data/lib/{hcl.rb → hcl/app.rb} +23 -21
- data/lib/hcl/day_entry.rb +9 -2
- data/lib/hcl/task.rb +1 -1
- data/lib/hcl/timesheet_resource.rb +3 -1
- data/lib/hcl/utility.rb +1 -1
- metadata +5 -4
- data/VERSION.yml +0 -4
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.2
|
data/bin/hcl
CHANGED
data/deps.rip
ADDED
data/hcl.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{hcl}
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Zack Hobson"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-08-09}
|
10
10
|
s.default_executable = %q{hcl}
|
11
11
|
s.description = %q{HCl is a command-line client for manipulating Harvest time sheets.}
|
12
12
|
s.email = %q{zack@opensourcery.com}
|
@@ -21,11 +21,12 @@ Gem::Specification.new do |s|
|
|
21
21
|
"LICENSE",
|
22
22
|
"README.markdown",
|
23
23
|
"Rakefile",
|
24
|
-
"VERSION
|
24
|
+
"VERSION",
|
25
25
|
"bin/hcl",
|
26
|
+
"deps.rip",
|
26
27
|
"hcl.gemspec",
|
27
28
|
"hcl_conf.yml.example",
|
28
|
-
"lib/hcl.rb",
|
29
|
+
"lib/hcl/app.rb",
|
29
30
|
"lib/hcl/day_entry.rb",
|
30
31
|
"lib/hcl/project.rb",
|
31
32
|
"lib/hcl/task.rb",
|
data/lib/{hcl.rb → hcl/app.rb}
RENAMED
@@ -1,12 +1,15 @@
|
|
1
|
+
## stdlib dependencies
|
1
2
|
require 'yaml'
|
2
3
|
require 'rexml/document'
|
3
4
|
require 'net/http'
|
4
5
|
require 'net/https'
|
5
6
|
|
7
|
+
## gem dependencies
|
6
8
|
require 'chronic'
|
7
9
|
require 'trollop'
|
8
10
|
require 'highline/import'
|
9
11
|
|
12
|
+
## app dependencies
|
10
13
|
require 'hcl/utility'
|
11
14
|
require 'hcl/timesheet_resource'
|
12
15
|
require 'hcl/project'
|
@@ -25,10 +28,10 @@ class Net::HTTP
|
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
28
|
-
|
29
|
-
|
31
|
+
module HCl
|
32
|
+
class App
|
33
|
+
include HCl::Utility
|
30
34
|
|
31
|
-
VERSION_FILE = File.dirname(__FILE__) + '/../VERSION.yml'
|
32
35
|
SETTINGS_FILE = "#{ENV['HOME']}/.hcl_settings"
|
33
36
|
CONFIG_FILE = "#{ENV['HOME']}/.hcl_config"
|
34
37
|
|
@@ -39,38 +42,36 @@ class HCl
|
|
39
42
|
end
|
40
43
|
|
41
44
|
def run
|
42
|
-
|
43
|
-
if
|
44
|
-
|
45
|
-
|
46
|
-
if result.
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
begin
|
46
|
+
if @command
|
47
|
+
if respond_to? @command
|
48
|
+
result = send @command, *@args
|
49
|
+
if not result.nil?
|
50
|
+
if result.respond_to? :to_a
|
51
|
+
puts result.to_a.join(', ')
|
52
|
+
elsif result.respond_to? :to_s
|
53
|
+
puts result
|
54
|
+
end
|
50
55
|
end
|
56
|
+
else
|
57
|
+
raise UnknownCommand, "unrecognized command `#{@command}'"
|
51
58
|
end
|
52
59
|
else
|
53
|
-
|
60
|
+
show
|
54
61
|
end
|
55
|
-
|
56
|
-
|
62
|
+
rescue TimesheetResource::Failure => e
|
63
|
+
puts "Internal failure. #{e}"
|
64
|
+
exit 1
|
57
65
|
end
|
58
66
|
end
|
59
67
|
|
60
68
|
def initialize
|
61
|
-
@version = YAML::load(File.read(VERSION_FILE))
|
62
69
|
read_config
|
63
70
|
read_settings
|
64
71
|
end
|
65
72
|
|
66
|
-
def version
|
67
|
-
[:major, :minor, :patch].map { |v| @version[v] }.join('.')
|
68
|
-
end
|
69
|
-
|
70
73
|
def process_args *args
|
71
|
-
version_string = version
|
72
74
|
Trollop::options(args) do
|
73
|
-
version "HCl #{version_string}"
|
74
75
|
stop_on %w[ show tasks set unset note add rm start stop ]
|
75
76
|
banner <<-EOM
|
76
77
|
HCl is a command-line client for manipulating Harvest time sheets.
|
@@ -228,5 +229,6 @@ EOM
|
|
228
229
|
puts "\t#{as_hours total_hours}\ttotal"
|
229
230
|
end
|
230
231
|
|
232
|
+
end
|
231
233
|
end
|
232
234
|
|
data/lib/hcl/day_entry.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
module HCl
|
3
3
|
class DayEntry < TimesheetResource
|
4
4
|
include Utility
|
5
|
+
|
5
6
|
# Get the time sheet entries for a given day. If no date is provided
|
6
7
|
# defaults to today.
|
7
8
|
def self.all date = nil
|
@@ -15,6 +16,7 @@ class HCl
|
|
15
16
|
|
16
17
|
def self.from_xml xml
|
17
18
|
doc = REXML::Document.new xml
|
19
|
+
raise Failure, "No root node in XML document: #{xml}" if doc.root.nil?
|
18
20
|
Task.cache_tasks doc
|
19
21
|
doc.root.elements.collect('//day_entry') do |day|
|
20
22
|
new xml_to_hash(day)
|
@@ -25,9 +27,14 @@ class HCl
|
|
25
27
|
def append_note new_notes
|
26
28
|
# If I don't include hours it gets reset.
|
27
29
|
# This doens't appear to be the case for task and project.
|
30
|
+
if notes.nil?
|
31
|
+
notes = new_notes
|
32
|
+
else
|
33
|
+
notes << " #{new_notes}"
|
34
|
+
end
|
28
35
|
DayEntry.post("daily/update/#{id}", <<-EOD)
|
29
36
|
<request>
|
30
|
-
<notes>#{notes
|
37
|
+
<notes>#{notes}</notes>
|
31
38
|
<hours>#{hours}</hours>
|
32
39
|
</request>
|
33
40
|
EOD
|
data/lib/hcl/task.rb
CHANGED
data/lib/hcl/utility.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zenhob-hcl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zack Hobson
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-08-09 00:00:00 -07:00
|
13
13
|
default_executable: hcl
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -67,11 +67,12 @@ files:
|
|
67
67
|
- LICENSE
|
68
68
|
- README.markdown
|
69
69
|
- Rakefile
|
70
|
-
- VERSION
|
70
|
+
- VERSION
|
71
71
|
- bin/hcl
|
72
|
+
- deps.rip
|
72
73
|
- hcl.gemspec
|
73
74
|
- hcl_conf.yml.example
|
74
|
-
- lib/hcl.rb
|
75
|
+
- lib/hcl/app.rb
|
75
76
|
- lib/hcl/day_entry.rb
|
76
77
|
- lib/hcl/project.rb
|
77
78
|
- lib/hcl/task.rb
|
data/VERSION.yml
DELETED