fewald-worklog 0.2.35 → 0.2.36
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 +4 -4
- data/.version +1 -1
- data/lib/cli.rb +9 -7
- data/lib/daily_log.rb +11 -0
- data/lib/log_entry.rb +1 -1
- data/lib/worklog.rb +14 -10
- 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: f4a1e8dcbe0888052cbdd6911d745d5e2230fe8b54044aba1182be9aba7c72c3
|
|
4
|
+
data.tar.gz: 364028684dbb314f458e8d5b0ee4f70da677b13c504453c983a9a91ed5984285
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0dd4c38a53df350dbaf26781edfdb6557aaa67dcce74517daa5ee05750a8d0f31b1fa5ee4861e875df2da7208f8bc692c86d3d6e6100e93e51772d8825d67db7
|
|
7
|
+
data.tar.gz: 95bc98822100b421b6256c7a1f2f0820e459e8590a93ba11cc16a24a48ab1f26142a59cd4818a9ee57e091b3645727366b8c9ef9c0fe5bdb3e518378586b79d8
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.36
|
data/lib/cli.rb
CHANGED
|
@@ -36,6 +36,7 @@ class WorklogCLI < Thor
|
|
|
36
36
|
super
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
# Set the exit on failure behavior from Thor to true
|
|
39
40
|
def self.exit_on_failure?
|
|
40
41
|
true
|
|
41
42
|
end
|
|
@@ -48,9 +49,10 @@ class WorklogCLI < Thor
|
|
|
48
49
|
People can be referenced either by using the tilde "~" or the at symbol "@", followed by
|
|
49
50
|
an alphanumeric string.
|
|
50
51
|
LONGDESC
|
|
51
|
-
option :date, type: :string, default:
|
|
52
|
-
option :time, type: :string, default:
|
|
52
|
+
option :date, type: :string, default: Time.now.strftime('%Y-%m-%d'), desc: 'Set the date of the entry'
|
|
53
|
+
option :time, type: :string, default: Time.now.strftime('%H:%M:%S'), desc: <<~DESC
|
|
53
54
|
Set the time of the entry. Can be provided in HHMM, HH:MM, or HH:MM:SS format.
|
|
55
|
+
By default, the system time zone is used and converted to UTC for storage.
|
|
54
56
|
DESC
|
|
55
57
|
option :tags, type: :array, default: [], desc: 'Add tags to the entry'
|
|
56
58
|
option :ticket, type: :string, desc: 'Ticket number associated with the entry. Can be any alphanumeric string.'
|
|
@@ -63,14 +65,14 @@ class WorklogCLI < Thor
|
|
|
63
65
|
end
|
|
64
66
|
|
|
65
67
|
desc 'edit', 'Edit a day in the work log. By default, the current date is used.'
|
|
66
|
-
option :date, type: :string, default:
|
|
68
|
+
option :date, type: :string, default: Time.now.strftime('%Y-%m-%d')
|
|
67
69
|
def edit
|
|
68
70
|
worklog = Worklog::Worklog.new
|
|
69
71
|
worklog.edit(options)
|
|
70
72
|
end
|
|
71
73
|
|
|
72
74
|
desc 'remove', 'Remove last entry from the log'
|
|
73
|
-
option :date, type: :string, default:
|
|
75
|
+
option :date, type: :string, default: Time.now.strftime('%Y-%m-%d')
|
|
74
76
|
def remove
|
|
75
77
|
worklog = Worklog::Worklog.new
|
|
76
78
|
worklog.remove(options)
|
|
@@ -80,7 +82,7 @@ class WorklogCLI < Thor
|
|
|
80
82
|
long_desc <<~LONGDESC
|
|
81
83
|
Show the work log for a specific date or a range of dates. As a default, all items from the current day will be shown.
|
|
82
84
|
LONGDESC
|
|
83
|
-
option :date, type: :string, default:
|
|
85
|
+
option :date, type: :string, default: Time.now.strftime('%Y-%m-%d'),
|
|
84
86
|
desc: <<~DESC
|
|
85
87
|
Show the work log for a specific date. If this option is provided, --from and --to and --days should not be used.
|
|
86
88
|
DESC
|
|
@@ -120,7 +122,7 @@ class WorklogCLI < Thor
|
|
|
120
122
|
end
|
|
121
123
|
|
|
122
124
|
desc 'tags', 'Show all tags used in the work log'
|
|
123
|
-
option :date, type: :string, default:
|
|
125
|
+
option :date, type: :string, default: Time.now.strftime('%Y-%m-%d'),
|
|
124
126
|
desc: <<~DESC
|
|
125
127
|
Show the work log for a specific date. If this option is provided, --from and --to and --days should not be used.
|
|
126
128
|
DESC
|
|
@@ -160,7 +162,7 @@ class WorklogCLI < Thor
|
|
|
160
162
|
end
|
|
161
163
|
|
|
162
164
|
desc 'summary', 'Generate a summary of the work log entries'
|
|
163
|
-
option :date, type: :string, default:
|
|
165
|
+
option :date, type: :string, default: Time.now.strftime('%Y-%m-%d')
|
|
164
166
|
option :from, type: :string, desc: <<-EOF
|
|
165
167
|
'Inclusive start date of the range. Takes precedence over --date if defined.'
|
|
166
168
|
EOF
|
data/lib/daily_log.rb
CHANGED
|
@@ -73,5 +73,16 @@ module Worklog
|
|
|
73
73
|
|
|
74
74
|
@entries.find { |entry| entry.key == key }
|
|
75
75
|
end
|
|
76
|
+
|
|
77
|
+
# Add a log entry to the daily log in the entries array at the end.
|
|
78
|
+
# At this point, the log is not checked for duplicates and not sorted.
|
|
79
|
+
# @param entry [LogEntry] the log entry to add
|
|
80
|
+
def <<(entry) = @entries << entry
|
|
81
|
+
|
|
82
|
+
def size = @entries.size
|
|
83
|
+
def length = @entries.length
|
|
84
|
+
def empty? = @entries.empty?
|
|
85
|
+
def clear = @entries.clear
|
|
86
|
+
def key?(key) = @entries.any? { |entry| entry.key == key }
|
|
76
87
|
end
|
|
77
88
|
end
|
data/lib/log_entry.rb
CHANGED
|
@@ -11,7 +11,7 @@ module Worklog
|
|
|
11
11
|
# @!attribute [rw] key
|
|
12
12
|
# @return [String] the unique key of the log entry. The key is generated based on the time and message.
|
|
13
13
|
# @!attribute [rw] time
|
|
14
|
-
# @return [
|
|
14
|
+
# @return [Time] the date and time of the log entry.
|
|
15
15
|
# @!attribute [rw] tags
|
|
16
16
|
# @return [Array<String>] the tags associated with the log entry.
|
|
17
17
|
# @!attribute [rw] ticket
|
data/lib/worklog.rb
CHANGED
|
@@ -6,17 +6,17 @@ require 'rainbow'
|
|
|
6
6
|
require 'yaml'
|
|
7
7
|
|
|
8
8
|
require 'configuration'
|
|
9
|
-
require 'digest'
|
|
10
|
-
require 'hash'
|
|
11
9
|
require 'daily_log'
|
|
12
10
|
require 'date_parser'
|
|
11
|
+
require 'hash'
|
|
12
|
+
require 'hasher'
|
|
13
13
|
require 'log_entry'
|
|
14
|
-
require 'storage'
|
|
15
14
|
require 'worklogger'
|
|
16
15
|
require 'string_helper'
|
|
17
16
|
require 'printer'
|
|
18
17
|
require 'project_storage'
|
|
19
18
|
require 'statistics'
|
|
19
|
+
require 'storage'
|
|
20
20
|
require 'summary'
|
|
21
21
|
require 'takeout'
|
|
22
22
|
|
|
@@ -46,7 +46,10 @@ module Worklog
|
|
|
46
46
|
attr_reader :config, :storage
|
|
47
47
|
|
|
48
48
|
def initialize(config = nil)
|
|
49
|
-
|
|
49
|
+
# Load or use provided configuration
|
|
50
|
+
@config = config || Configuration.load
|
|
51
|
+
|
|
52
|
+
# Initialize storage
|
|
50
53
|
@storage = Storage.new(@config)
|
|
51
54
|
|
|
52
55
|
WorkLogger.level = @config.log_level == :debug ? Logger::Severity::DEBUG : Logger::Severity::INFO
|
|
@@ -88,12 +91,12 @@ module Worklog
|
|
|
88
91
|
validate_projects!(options[:project]) if options[:project] && !options[:project].empty?
|
|
89
92
|
|
|
90
93
|
# Use the first 7 characters of the SHA256 hash of message as the key
|
|
91
|
-
key =
|
|
94
|
+
key = Hasher.sha256(message)
|
|
92
95
|
|
|
93
96
|
daily_log = @storage.load_log!(@storage.filepath(date))
|
|
94
|
-
new_entry = LogEntry.new(key:, time:, tags: options[:tags], ticket: options[:ticket],
|
|
95
|
-
epic: options[:epic], message:, project: options[:project])
|
|
96
|
-
daily_log
|
|
97
|
+
new_entry = LogEntry.new(key:, source: 'manual', time:, tags: options[:tags], ticket: options[:ticket],
|
|
98
|
+
url: options[:url], epic: options[:epic], message:, project: options[:project])
|
|
99
|
+
daily_log << new_entry
|
|
97
100
|
|
|
98
101
|
# Sort by time in case an entry was added later out of order.
|
|
99
102
|
daily_log.entries.sort_by!(&:time)
|
|
@@ -107,6 +110,7 @@ module Worklog
|
|
|
107
110
|
WorkLogger.info Rainbow("Added entry on #{options[:date]}: #{message}").green
|
|
108
111
|
end
|
|
109
112
|
|
|
113
|
+
# Edit an existing work log entry for a specific date.
|
|
110
114
|
def edit(options = {})
|
|
111
115
|
date = Date.strptime(options[:date], '%Y-%m-%d')
|
|
112
116
|
|
|
@@ -470,7 +474,7 @@ module Worklog
|
|
|
470
474
|
|
|
471
475
|
# Parse a time string in HHMM, HH:MM, or HH:MM:SS format.
|
|
472
476
|
# @param time_string [String] the time string to parse
|
|
473
|
-
# @return [Time] the parsed Time object
|
|
477
|
+
# @return [Time] the parsed Time object in UTC
|
|
474
478
|
def parse_time_string!(time_string)
|
|
475
479
|
# Validate the time string format
|
|
476
480
|
unless time_string.match?(/^\d{1,2}:?\d{2}:?\d{2}?$/)
|
|
@@ -487,7 +491,7 @@ module Worklog
|
|
|
487
491
|
|
|
488
492
|
# Append seconds to time if not provided
|
|
489
493
|
time_string += ':00' if time_string.split(':').size == 2
|
|
490
|
-
Time.strptime(time_string, '%H:%M:%S')
|
|
494
|
+
Time.strptime(time_string, '%H:%M:%S').utc
|
|
491
495
|
end
|
|
492
496
|
end
|
|
493
497
|
end
|