piece_of_wax 1.0.0.rc3 → 1.0.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/piece_of_wax.rb +11 -8
- data/lib/piece_of_wax/logfile.rb +5 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b92e1cfe6301bf02d152496ddf9520477d8b51923acf0ef75cbfdf3d26e40e89
|
4
|
+
data.tar.gz: 8ce76810acf032cb480745549bf17723001fbf0e3ea0721b55644b2007f52ad6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5de817f46214d1fa70d63df75d46c0c2967765642be08098387cb145aa8cea8c9e15b20719db4e8042b4c77eadad3e533dde90784261cab6350421ba7fcef93d
|
7
|
+
data.tar.gz: 5af1c5b2f8bab1142db6c5a7a76f0764e1ac445e1f37f19ef069553c066f80e29bd9c71a8da2b1f50464d6563cc69451bfb0ccd4f0918d8c40e2789d1f3e879b
|
data/lib/piece_of_wax.rb
CHANGED
@@ -7,31 +7,34 @@ require "thor"
|
|
7
7
|
|
8
8
|
module PieceOfWax
|
9
9
|
class CLI < Thor
|
10
|
-
desc 'activity "_activity_"', "log activity
|
10
|
+
desc 'activity "_activity_"', "log activity"
|
11
11
|
option :time, aliases: :t, desc: 'time when activity was started'
|
12
|
-
def activity(str)
|
12
|
+
def activity(*str)
|
13
13
|
CLIOptions.instance.set(options)
|
14
14
|
time = DateTime.safe_parse(CLIOptions.instance[:time]) || DateTime.current_time
|
15
|
-
|
16
|
-
|
15
|
+
description = str.join(' ')
|
16
|
+
Logfile.new(DateTime.current_date).add_activity(time, description)
|
17
|
+
$stdout.puts "wrote #{description} to file"
|
17
18
|
end
|
18
19
|
|
19
20
|
desc 'edit "_activity_"', "edit activity"
|
20
21
|
option :n, default: '1', desc: 'the activity to edit, 1 being the most recently-logged'
|
21
|
-
def edit(str)
|
22
|
+
def edit(*str)
|
22
23
|
CLIOptions.instance.set(options)
|
24
|
+
description = str.join(' ')
|
23
25
|
index = (0 - CLIOptions.instance[:n].to_i)
|
24
26
|
logfile = Logfile.new(DateTime.current_date)
|
25
27
|
if logfile.contents[index]
|
26
|
-
logfile.edit_activity(index,
|
27
|
-
$stdout.puts "wrote #{
|
28
|
+
logfile.edit_activity(index, description)
|
29
|
+
$stdout.puts "wrote #{description} to file"
|
28
30
|
else
|
29
31
|
$stderr.puts 'activity referenced by "n" option does not exist'
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
33
|
-
desc "read [date]", "print activities on given [date] (
|
35
|
+
desc "read [date]", "print activities on given [date] (today by default)"
|
34
36
|
option :military, aliases: :m, desc: 'render time in military (24-hour) format'
|
37
|
+
option :'quitting-time', default: '17:45:00 -0500', aliases: :q, desc: 'last activity period is capped off at this time'
|
35
38
|
def read(date_str = '')
|
36
39
|
CLIOptions.instance.set(options)
|
37
40
|
date = DateTime.safe_parse(date_str) || DateTime.current_date
|
data/lib/piece_of_wax/logfile.rb
CHANGED
@@ -40,7 +40,7 @@ module PieceOfWax
|
|
40
40
|
<% contents.each_cons(2).map do |line1, line2| %>
|
41
41
|
<%= OutputLine::Activity.new(line1['datetime'], line2['datetime'], line1['description']) %>
|
42
42
|
<% end.join("\n") %>
|
43
|
-
<%= OutputLine::Activity.new(last_entry['datetime'],
|
43
|
+
<%= OutputLine::Activity.new(last_entry['datetime'], quitting_time, last_entry['description']) %>
|
44
44
|
ERB
|
45
45
|
# Unsure why ERB is inserting the double linebreaks after each
|
46
46
|
# iteration of `contents.each_cons(2)`. For now, subbing single linebreak
|
@@ -64,5 +64,9 @@ module PieceOfWax
|
|
64
64
|
def last_entry
|
65
65
|
contents.last
|
66
66
|
end
|
67
|
+
|
68
|
+
def quitting_time
|
69
|
+
CLIOptions.instance[:'quitting-time']
|
70
|
+
end
|
67
71
|
end
|
68
72
|
end
|