hcl 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 852da2430771d5354f8fd2fca9bc55558e2248b7
4
- data.tar.gz: 0f21a80c83c9e105829f872c47860e34975120e0
3
+ metadata.gz: aacea7a83e911178697ab35835691bab2827299a
4
+ data.tar.gz: b85493c73665fa37297841027ceb12c2ffbe8b90
5
5
  SHA512:
6
- metadata.gz: 6a411682c2f8c9d049bfe3e13f436c9efd5c2cc3be9892d4ea9a3ed1b58008a60491d4f05530a9878af6a10ce6e9f7cd31b795caffce9727cbca0fddbb062e12
7
- data.tar.gz: 7c1e0be48bbe9043a86265cc35d05feb3fb4bcc64b13c56fd4bbdcff9bce1e04c9b564702cfaabcca132ea8e9cad49993edd0a44be5d6b05bd0b720d881ea59a
6
+ metadata.gz: 40d2a72969d751827efe2cdfeb11e49522787dcc9bc089042bba3470e367c9e1f600599c05da241312be4050b328a67ea862ba43ee4737159d31697bb3f1e729
7
+ data.tar.gz: 9c9b1c0af9ea5cce5f48032c93584472f288b8ca01402eb4fc0cfd7d1b5884c961c9523bd543a00dc5eeeca78322ae5107e82f75c5bece8f47dfae5ca53b14ca
data/CHANGELOG CHANGED
@@ -1,5 +1,16 @@
1
1
  = Recent Changes in HCl
2
2
 
3
+ == v0.4.3
4
+
5
+ * added cancel command to delete the last running timer, closes #13
6
+ * properly unescape string from Harvest API, closes #24
7
+ * stop command now checks for running timers from yesterday, closes #35
8
+ * added log command to log time/notes without leaving a timer running, closes #30
9
+
10
+ == v0.4.2
11
+
12
+ * resume command now accepts an optional task
13
+
3
14
  == v0.4.1
4
15
 
5
16
  * update dependencies
@@ -17,27 +17,18 @@ or you can install from source using jeweler:
17
17
  $ gem install jeweler
18
18
  $ rake install
19
19
 
20
- ### Prerequisites
21
-
22
- * Ruby (tested with 1.8.7)
23
- * Ruby OpenSSL support (in debian/ubuntu: apt-get install libopenssl-ruby)
24
- * Ruby extension building support (in debian/ubuntu: apt-get install ruby-dev)
25
- * RubyGems 1.3.3
26
- * Trollop option-parsing library (gem install trollop)
27
- * Chronic date-parsing library (gem install chronic)
28
- * HighLine console input library (gem install highline)
29
- * Jeweler packaging tool (needed to build the gem)
30
-
31
20
  ## Usage
32
21
 
33
- hcl (@<task_alias> | <project_id> <task_id>) [+time] [message]
22
+ hcl [start] (@<task_alias> | <project_id> <task_id>) [+<time>] [<message>]
34
23
  hcl note <message>
35
24
  hcl stop [message]
36
25
  hcl resume [@<task_alias>]
26
+ hcl log (@<task_alias> | <project_id> <task_id>) [+<time>] [<message>]
37
27
  hcl show [date]
38
28
  hcl tasks
39
29
  hcl alias <task_alias> <project_id> <task_id>
40
30
  hcl aliases
31
+ hcl (cancel | nvm | oops)
41
32
 
42
33
  ### Available Projects and Tasks
43
34
 
@@ -52,8 +43,8 @@ available tasks.
52
43
  Since it's not practical to enter two long numbers every time you want to
53
44
  identify a task, HCl supports task aliases:
54
45
 
55
- $ hcl alias xdev 1234 5678
56
- $ hcl @xdev Adding a new feature!
46
+ $ hcl alias tacodev 1234 5678
47
+ $ hcl @tacodev Adding a new feature
57
48
 
58
49
  ### Starting a Timer with Initial Time
59
50
 
@@ -61,14 +52,14 @@ You can also provide an initial time when starting a new timer.
61
52
  This can be expressed in floating-point or HH:MM. The following two
62
53
  commands are equivalent:
63
54
 
64
- $ hcl @xdev +0:15 Adding a new feature!
65
- $ hcl +.25 @xdev Adding a new feature!
55
+ $ hcl @tacodev +0:15 Doing some stuff
56
+ $ hcl +.25 @tacodev Doing some stuff
66
57
 
67
58
  ### Adding Notes to a Running Task
68
59
 
69
60
  While a task is running you can append lines to the task notes:
70
61
 
71
- $ hcl note Found a good time!
62
+ $ hcl note Then I did something else
72
63
 
73
64
  ### Stopping a Timer
74
65
 
@@ -76,7 +67,7 @@ The following command will stop a running timer (currently only one timer at
76
67
  a time is supported). You can provide a message when stopping a timer as
77
68
  well:
78
69
 
79
- $ hcl stop All done!
70
+ $ hcl stop All done doing things
80
71
 
81
72
  ### Resuming a Timer
82
73
 
@@ -86,6 +77,25 @@ for that task:
86
77
  $ hcl resume
87
78
  $ hcl resume @xdev
88
79
 
80
+ ### Canceling a Timer
81
+
82
+ If you accidentally started a timer that you didn't mean to, you can cancel
83
+ it:
84
+
85
+ $ hcl cancel
86
+
87
+ This will delete the running timer, or the last-updated timer if one isn't
88
+ running. You can also use `nvm` or `oops` instead of `cancel`.
89
+
90
+ ### Logging without Starting a Timer
91
+
92
+ You can log time and notes without leaving a timer running. It takes
93
+ the same arguments as start:
94
+
95
+ $ hcl log @xdev +1 Worked for an hour.
96
+
97
+ The above starts and immediately stops a one-hour timer with the given note.
98
+
89
99
  ### Date Formats
90
100
 
91
101
  Dates can be expressed in a variety of ways. See the [Chronic documentation][cd]
@@ -114,3 +124,5 @@ See LICENSE for copyright details.
114
124
  [bricooke]: http://github.com/bricooke
115
125
  [scharfie]: http://github.com/scharfie
116
126
 
127
+
128
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.2
1
+ 0.4.3
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "hcl"
8
- s.version = "0.4.2"
8
+ s.version = "0.4.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Zack Hobson"]
@@ -31,7 +31,7 @@ class Net::HTTP
31
31
  end
32
32
 
33
33
  module HCl
34
- VERSION = "0.4.2"
34
+ VERSION = "0.4.3"
35
35
 
36
36
  class App
37
37
  include HCl::Utility
@@ -103,31 +103,34 @@ Commands:
103
103
  # show all available tasks
104
104
  hcl tasks
105
105
 
106
- # set a task alias
107
- hcl alias <task> <project_id> <task_id>
106
+ # create a task alias
107
+ hcl alias <task_alias> <project_id> <task_id>
108
108
 
109
109
  # list task aliases
110
110
  hcl aliases
111
111
 
112
112
  # start a task using an alias
113
- hcl @<task> [+time] [message]
113
+ hcl [start] @<task_alias> [+<time>] [<message>]
114
114
 
115
- # display the daily timesheet
116
- hcl show [date]
115
+ # add a line to your running timer
116
+ hcl note <message>
117
117
 
118
118
  # stop a running timer
119
- hcl stop [message]
119
+ hcl stop [<message>]
120
120
 
121
- # resume the last stopped timer
122
- hcl resume
121
+ # resume the last stopped timer or a specific task
122
+ hcl resume [@<task_alias>]
123
123
 
124
- # add a line to your running timer
125
- hcl note <message>
124
+ # delete the current or last running timer
125
+ hcl (cancel | oops | nvm)
126
+
127
+ # display the daily timesheet
128
+ hcl [show [<date>]]
126
129
 
127
130
  Examples:
128
131
  hcl alias mytask 1234 4567
129
132
  hcl @mytask +:15 Doing a thing that I started 15 minutes ago.
130
- hcl Adding a note to my running task.
133
+ hcl note Adding a note to my running task.
131
134
  hcl stop That's enough for now.
132
135
  hcl resume
133
136
  hcl show yesterday
@@ -24,6 +24,23 @@ module HCl
24
24
  nil
25
25
  end
26
26
 
27
+ def cancel
28
+ entry = DayEntry.with_timer || DayEntry.last
29
+ if entry
30
+ if entry.cancel
31
+ puts "Deleted entry #{entry}."
32
+ else
33
+ puts "Failed to delete #{entry}!"
34
+ exit 1
35
+ end
36
+ else
37
+ puts 'Nothing to cancel.'
38
+ exit 1
39
+ end
40
+ end
41
+ alias_method :oops, :cancel
42
+ alias_method :nvm, :cancel
43
+
27
44
  def unset key
28
45
  @settings.delete key
29
46
  write_settings
@@ -62,8 +79,13 @@ module HCl
62
79
  puts "Started timer for #{timer} (at #{current_time})"
63
80
  end
64
81
 
82
+ def log *args
83
+ start *args
84
+ stop
85
+ end
86
+
65
87
  def stop *args
66
- entry = DayEntry.with_timer
88
+ entry = DayEntry.with_timer || DayEntry.with_timer(DateTime.yesterday)
67
89
  if entry
68
90
  entry.append_note(args.join(' ')) if args.any?
69
91
  entry.toggle
@@ -23,6 +23,15 @@ module HCl
23
23
  end
24
24
  end
25
25
 
26
+ def cancel
27
+ begin
28
+ DayEntry.delete("daily/delete/#{id}")
29
+ rescue TimesheetResource::Failure
30
+ return false
31
+ end
32
+ true
33
+ end
34
+
26
35
  def notes
27
36
  super || @data[:notes] = ''
28
37
  end
@@ -36,8 +45,8 @@ module HCl
36
45
  %{<request><notes>#{notes}</notes><hours>#{hours}</hours></request>}
37
46
  end
38
47
 
39
- def self.with_timer
40
- all.detect {|t| t.running? }
48
+ def self.with_timer date=nil
49
+ all(date).detect {|t| t.running? }
41
50
  end
42
51
 
43
52
  def self.last_by_task project_id, task_id
@@ -37,6 +37,10 @@ module HCl
37
37
  http_do Net::HTTP::Post, action, data
38
38
  end
39
39
 
40
+ def self.delete action
41
+ http_do Net::HTTP::Delete, action
42
+ end
43
+
40
44
  def self.http_do method_class, action, data = nil
41
45
  https = Net::HTTP.new "#{subdomain}.harvestapp.com", (ssl ? 443 : 80)
42
46
  request = method_class.new "/#{action}"
@@ -68,7 +72,7 @@ module HCl
68
72
 
69
73
  def self.xml_to_hash elem
70
74
  elem.elements.map { |e| e.name }.inject({}) do |a, f|
71
- a[f.to_sym] = elem.elements[f].text if elem.elements[f]
75
+ a[f.to_sym] = CGI.unescape_html(elem.elements[f].text || '') if elem.elements[f]
72
76
  a
73
77
  end
74
78
  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.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zack Hobson