fewald-worklog 0.2.35 → 0.2.37

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
  SHA256:
3
- metadata.gz: c6a7037fb7f1b5194e72152f812ef7e2defdcbe46e9845935a64b9e6fffbce32
4
- data.tar.gz: d2b005c1399811835d84fc9f53bc341a3cf4a861f898ede71c706defb895e63f
3
+ metadata.gz: c8a2feb90b202dad33157a6dfb35bc78d980efce61ec0a9cf369fb45b552308b
4
+ data.tar.gz: 9ff8b56050dca9ec76ea27d24da8ba21efde809da211d9db7429906eaf106799
5
5
  SHA512:
6
- metadata.gz: 7186e4bf2fd4978e5245cfbb7e798d70d37c9002eec9dc4a9c259798e4df87abb07ae3af12ea58e7febca6b5e33d8be5acabe61cffbf5e3db037ecd1bccc7e60
7
- data.tar.gz: 7699e19686d0e6a15d47ee9b2e12f2fe0da07f1e7ba70b1d90e8a967d295eba13ca0cd0c2892ad8f9f8bac0d2f0ba96180b44947616dd7b0c0c7998e39418175
6
+ metadata.gz: dcf962ca95d50c20cd715c29a562b259c93c0f292ecc7c3820d40321f02bf73b8c9a58f48bebdc8eefef3a83286676e999ca3a24e5cb690e9d34f1713a1bec90
7
+ data.tar.gz: b730874e4acf1840e1704924b062eeca2a2163394f481e2efc4fd5ef1c5dbd997fa8a1062e1c1f1dafb9f45af48148b6adc27c0e401186399a68de2c63cc0781
data/.version CHANGED
@@ -1 +1 @@
1
- 0.2.35
1
+ 0.2.37
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: DateTime.now.strftime('%Y-%m-%d'), desc: 'Set the date of the entry'
52
- option :time, type: :string, default: DateTime.now.strftime('%H:%M:%S'), desc: <<~DESC
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: DateTime.now.strftime('%Y-%m-%d')
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: DateTime.now.strftime('%Y-%m-%d')
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: DateTime.now.strftime('%Y-%m-%d'),
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: DateTime.now.strftime('%Y-%m-%d'),
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: DateTime.now.strftime('%Y-%m-%d')
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 [DateTime] the date and time of the log entry.
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
- @config = config || Configuration.new
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 = Digest::SHA256.hexdigest(message)[..6]
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], url: options[:url],
95
- epic: options[:epic], message:, project: options[:project])
96
- daily_log.entries << new_entry
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fewald-worklog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.35
4
+ version: 0.2.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - Friedrich Ewald