fewald-worklog 0.2.30 → 0.2.32

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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/.version +1 -1
  3. data/lib/cli.rb +3 -1
  4. data/lib/takeout.rb +0 -7
  5. data/lib/worklog.rb +23 -3
  6. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e916debca7f984d8594502f3b859bde2a737ffa6b150eab5727c0fb421f355fa
4
- data.tar.gz: 03d737038fdb12ff54161114b1ede537ff2f371a3499aee287cda71b3425ecff
3
+ metadata.gz: 14033d83050a174467b6159bc1fdbfb7fd3bc7ffc8883f3b04bc241dec77184b
4
+ data.tar.gz: 7499e124a43649989ffb3010fcb4965f4110ea7efe7d41a8e49515a0d165e022
5
5
  SHA512:
6
- metadata.gz: 145e2873f416d9a6da8210f863697f8b757b7afbafead62619ba76156cf21e8b2fb87ff1f171a75d98dd853d68205b34aa4913bb1c07eb2a9b49bf32d4fa0500
7
- data.tar.gz: 91e513051b1fc158fe152703f43671b3a2f13b6428d74a29611fe2d24beeb63924182f0e1f0472b653e894c093fcb1907dc605dfa2f930bab46c4019f03f79cb
6
+ metadata.gz: 54887531704ca1ef6cc7ef0303d899b991036add0f914f81d55189a67a5b7d2254fc89dff9114cbb7237a394d69fe020dc0175cd0978a56766def700f8bb226d
7
+ data.tar.gz: 1a1207af445e9074d0d66b2802943e71a1a63f7aaaa7ec06f95c10805b3529207acc06ade759a0275bdc675da26ccce6ecdf1200c292bf0817a2a98e6e278975
data/.version CHANGED
@@ -1 +1 @@
1
- 0.2.30
1
+ 0.2.32
data/lib/cli.rb CHANGED
@@ -49,7 +49,9 @@ class WorklogCLI < Thor
49
49
  an alphanumeric string.
50
50
  LONGDESC
51
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: 'Set the time of the entry'
52
+ option :time, type: :string, default: DateTime.now.strftime('%H:%M:%S'), desc: <<~DESC
53
+ Set the time of the entry. Can be provided in HHMM, HH:MM, or HH:MM:SS format.
54
+ DESC
53
55
  option :tags, type: :array, default: [], desc: 'Add tags to the entry'
54
56
  option :ticket, type: :string, desc: 'Ticket number associated with the entry. Can be any alphanumeric string.'
55
57
  option :url, type: :string, desc: 'URL to associate with the entry'
data/lib/takeout.rb CHANGED
@@ -24,13 +24,6 @@ module Worklog
24
24
  def to_tar_gz
25
25
  tar_io = StringIO.new
26
26
 
27
- # Build a mapping of file names to their stats for timestamp preservation
28
- file_stats = {}
29
- all_files.each do |file_path|
30
- file_name = File.basename(file_path)
31
- file_stats[file_name] = File.stat(file_path)
32
- end
33
-
34
27
  Gem::Package::TarWriter.new(tar_io) do |tar|
35
28
  all_files.each do |file_path|
36
29
  file_name = File.basename(file_path)
data/lib/worklog.rb CHANGED
@@ -80,9 +80,7 @@ module Worklog
80
80
  date = Date.strptime(options[:date], '%Y-%m-%d')
81
81
 
82
82
  # Append seconds to time if not provided
83
- time = options[:time]
84
- time += ':00' if options[:time].split(':').size == 2
85
- time = Time.strptime(time, '%H:%M:%S')
83
+ time = parse_time_string!(options[:time])
86
84
  @storage.create_file_skeleton(date)
87
85
 
88
86
  # Validate that the project exists if provided
@@ -465,5 +463,27 @@ module Worklog
465
463
 
466
464
  raise ProjectNotFoundError, "Project with key '#{project_key}' does not exist."
467
465
  end
466
+
467
+ # Parse a time string in HHMM, HH:MM, or HH:MM:SS format.
468
+ # @param time_string [String] the time string to parse
469
+ # @return [Time] the parsed Time object
470
+ def parse_time_string!(time_string)
471
+ # Validate the time string format
472
+ unless time_string.match?(/^\d{1,2}:?\d{2}:?\d{2}?$/)
473
+ raise ArgumentError, 'Invalid time format. Expected HHMM, HH:MM, or HH:MM:SS.'
474
+ end
475
+
476
+ # Prefix with 0 if needed
477
+ time_string = "0#{time_string}" if time_string.length == 3
478
+
479
+ # Split hours and minutes if in HHMM format
480
+ if time_string.length == 4 && time_string.match?(/^\d{4}$/)
481
+ time_string = "#{time_string[0..1]}:#{time_string[2..3]}"
482
+ end
483
+
484
+ # Append seconds to time if not provided
485
+ time_string += ':00' if time_string.split(':').size == 2
486
+ Time.strptime(time_string, '%H:%M:%S')
487
+ end
468
488
  end
469
489
  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.30
4
+ version: 0.2.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Friedrich Ewald