fewald-worklog 0.3.14 → 0.3.15

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 (5) hide show
  1. checksums.yaml +4 -4
  2. data/.version +1 -1
  3. data/lib/cli.rb +5 -5
  4. data/lib/worklog.rb +26 -5
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab7a9c5136dd285ee57cfe1331f6890c244bd99ec989e0c6a48ff19f57c8a0b0
4
- data.tar.gz: 7b5fb34ba1ef5dfe6292b0eccf85b3148f0e7de3d2d6406f3d19e5f5633fca50
3
+ metadata.gz: da159df72952acb0df4908e1e5ed04b5a43def0d9d8f351b19f407aa672d108b
4
+ data.tar.gz: 7afc0a6cd0da2f10456203c27b1c48ce0b1117f428932c1fb1157b32baaeeced
5
5
  SHA512:
6
- metadata.gz: 46d5f939c05647cc241c084528b9508fb4abac538484e65576d53558a81bcd4efb6229ea8efb86654d4f2ecb8eb472bb75eba73c045a9a38edd45892eae9adaf
7
- data.tar.gz: 1244216988115f3c18d8fffadb19b1908f5e95e2d4eebfc7bd942b1bb009ea79415e9e11e16900174d7b03bf764926687fb760eea4c67931138d6055cdc65fee
6
+ metadata.gz: 47553eb33fd2b3dc6c2c664431f36d99ab395832c29a26e4d4a06a6482d9244ad7035cf956bbb91d3bcbc2ae17cb2f79863ce7b04cfc0316848662f31862cb18
7
+ data.tar.gz: 5b1185d6bdd7fdef351ff7935a7d3b0512efa1027af2fc84972a682e06a8d03c0553127ebf8813a4067f2bdb9c4fc9f4bbce2aa66082da7ba29c17191f29a8f1
data/.version CHANGED
@@ -1 +1 @@
1
- 0.3.14
1
+ 0.3.15
data/lib/cli.rb CHANGED
@@ -65,7 +65,7 @@ class WorklogCLI < Thor
65
65
  end
66
66
 
67
67
  desc 'edit', 'Edit a day in the work log. By default, the current date is used.'
68
- option :date, type: :string, default: Time.now.strftime('%Y-%m-%d')
68
+ option :date, type: :string, default: Date.today.to_s
69
69
  def edit
70
70
  worklog = Worklog::Worklog.new
71
71
  worklog.edit(options)
@@ -84,7 +84,7 @@ class WorklogCLI < Thor
84
84
  end
85
85
 
86
86
  desc 'remove', 'Remove last entry from the log'
87
- option :date, type: :string, default: Time.now.strftime('%Y-%m-%d')
87
+ option :date, type: :string, default: Date.today.to_s
88
88
  def remove
89
89
  worklog = Worklog::Worklog.new
90
90
  worklog.remove(options)
@@ -94,7 +94,7 @@ class WorklogCLI < Thor
94
94
  long_desc <<~LONGDESC
95
95
  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.
96
96
  LONGDESC
97
- option :date, type: :string, default: Time.now.strftime('%Y-%m-%d'),
97
+ option :date, type: :string, default: Date.today.to_s,
98
98
  desc: <<~DESC
99
99
  Show the work log for a specific date. If this option is provided, --from and --to and --days should not be used.
100
100
  DESC
@@ -105,7 +105,7 @@ class WorklogCLI < Thor
105
105
  Inclusive end date of the range. Takes precedence over --date, if defined.
106
106
  EOF
107
107
  option :days, type: :numeric, desc: <<~EOF
108
- Number of days to show starting from --date. Takes precedence over --from and --to if defined.
108
+ Number of days to show starting from --date. Takes precedence over --from and --to, if defined.
109
109
  EOF
110
110
  option :epics_only, type: :boolean, default: false, desc: 'Show only entries that are marked as epic'
111
111
  option :tags, type: :array, default: [], desc: 'Filter entries by tags. Tags are treated as an OR condition.'
@@ -135,7 +135,7 @@ class WorklogCLI < Thor
135
135
  end
136
136
 
137
137
  desc 'tags', 'Show all tags used in the work log'
138
- option :date, type: :string, default: Time.now.strftime('%Y-%m-%d'),
138
+ option :date, type: :string, default: Date.today.to_s,
139
139
  desc: <<~DESC
140
140
  Show the work log for a specific date. If this option is provided, --from and --to and --days should not be used.
141
141
  DESC
data/lib/worklog.rb CHANGED
@@ -48,6 +48,11 @@ module Worklog
48
48
 
49
49
  attr_reader :config, :storage
50
50
 
51
+ # The earliest allowed start date for log entries.
52
+ # By default, filters that do not specify a start date will use this date.
53
+ # @return [Date] The earliest allowed start date.
54
+ EARLIEST_START_DATE = Date.new(1980, 1, 1).freeze
55
+
51
56
  def initialize(config = nil)
52
57
  # Load or use provided configuration
53
58
  @config = config || Configuration.load
@@ -329,7 +334,7 @@ module Worklog
329
334
  # worklog.tags(nil) # Show all tags for all time
330
335
  def tags(tag = nil, options = {})
331
336
  if tag.nil? || tag.empty?
332
- tag_overview
337
+ tag_overview(options)
333
338
  else
334
339
  tag_detail(tag, options)
335
340
  end
@@ -352,9 +357,16 @@ module Worklog
352
357
  end
353
358
 
354
359
  # Show overview of all tags used in the work log including their count.
355
- def tag_overview
356
- all_logs = @storage.all_days
357
- puts Rainbow('Tags used in the work log:').gold
360
+ def tag_overview(options)
361
+ start_date, end_date = start_end_date(options)
362
+
363
+ all_logs = @storage.days_between(start_date, end_date)
364
+ date_string = if start_date == end_date
365
+ "on #{start_date}"
366
+ else
367
+ "from #{start_date} to #{end_date}"
368
+ end
369
+ puts Rainbow("Tags used in the work log #{date_string}:").gold
358
370
 
359
371
  # Count all tags used in the work log
360
372
  tags = all_logs.map(&:entries).flatten.map(&:tags).flatten.compact.tally
@@ -482,9 +494,18 @@ module Worklog
482
494
 
483
495
  start_date = Date.today - options[:days]
484
496
  end_date = Date.today
497
+ elsif options[:from] && options[:to]
498
+ # If both from and to are provided
499
+ start_date = DateParser.parse_date_string!(options[:from], true)
500
+ end_date = DateParser.parse_date_string!(options[:to], false)
485
501
  elsif options[:from]
502
+ # If only from is provided
486
503
  start_date = DateParser.parse_date_string!(options[:from], true)
487
- end_date = DateParser.parse_date_string!(options[:to], false) if options[:to]
504
+ end_date = Date.today
505
+ elsif options[:to]
506
+ # If only to is provided
507
+ start_date = EARLIEST_START_DATE
508
+ end_date = DateParser.parse_date_string!(options[:to], false)
488
509
  elsif options[:date]
489
510
  start_date = Date.strptime(options[:date], '%Y-%m-%d')
490
511
  end_date = start_date
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.3.14
4
+ version: 0.3.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Friedrich Ewald