fewald-worklog 0.2.16 → 0.2.18

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 +1 -0
  4. data/lib/printer.rb +11 -1
  5. data/lib/worklog.rb +17 -3
  6. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d406551a4b3ab8ab4845636c440e4d1cc82e5ac6fc0c188328ed8a5b8608c893
4
- data.tar.gz: 0170211e2a62fecfd26b58d8d6d8eeff9e0b55412ac9715a79fe67066887430f
3
+ metadata.gz: 226d608638c12cd6ed618d5669d1e675baf2826ec9f7092887cf08b2612bf845
4
+ data.tar.gz: 897ee2bbd7ee446a2397815632c0738115c7b2ce4e37251ef3197db7cbf1c7fc
5
5
  SHA512:
6
- metadata.gz: 222b26f794ceae4b3dfd33be51cd300b07fa0dc594811f30aa6bb66b4d71f79cf985e62663f33fb6305fd0a88d098c9dd91f62e250ef2cbdc416e9673673dc6d
7
- data.tar.gz: ec0c33c3041dfe1e3f1d73f2b2b3a3175c7a414beda395f6590af8350a66cdd3d79aaf03143daea1684b0571fff0787bcd5ebd32c7a543f34aadeb78b29ecd75
6
+ metadata.gz: c313a4c546a9aa10ca55c718fda09a9ec3bedd3e16bea9beaea95cfb0153ac1b2ac3be1f8d06f5a5baa60e33d451bfbb270c2f6ddbc31a381462da6e549dd8db
7
+ data.tar.gz: bede43615c16b5c457e953c0f30a902cfaeaa4d55dc7ddcc9d00bdfe6f27e9b40676ee94a88d7c2d89d34b6321bd8e0284fd8233c4144c4ee1864a91505e7091
data/.version CHANGED
@@ -1 +1 @@
1
- 0.2.16
1
+ 0.2.18
data/lib/cli.rb CHANGED
@@ -92,6 +92,7 @@ class WorklogCLI < Thor
92
92
  EOF
93
93
  option :epics_only, type: :boolean, default: false, desc: 'Show only entries that are marked as epic'
94
94
  option :tags, type: :array, default: [], desc: 'Filter entries by tags. Tags are treated as an OR condition.'
95
+ option :project, type: :string, desc: 'Filter entries by project key.'
95
96
  def show
96
97
  worklog = Worklog::Worklog.new
97
98
  worklog.show(options)
data/lib/printer.rb CHANGED
@@ -15,7 +15,15 @@ class Printer
15
15
  # Prints a whole day of work log entries.
16
16
  # If date_inline is true, the date is printed inline with the time.
17
17
  # If epics_only is true, only epic entries are printed.
18
- def print_day(daily_log, date_inline = false, epics_only = false)
18
+ # @param daily_log [DailyLog] The daily log containing entries.
19
+ # @param date_inline [Boolean] If true, the date is printed inline with the time.
20
+ # @param epics_only [Boolean] If true, only epic entries are printed.
21
+ # @param filter [Hash] A hash of filters to apply to the entries.
22
+ # @return [void]
23
+ # @example
24
+ # printer.print_day(daily_log, date_inline: true, epics_only: false, project: 'xyz')
25
+ # printer.print_day(daily_log, date_inline: false, epics_only: true)
26
+ def print_day(daily_log, date_inline = false, epics_only = false, filter = {})
19
27
  daily_log.date = Date.strptime(daily_log.date, '%Y-%m-%d') unless daily_log.date.respond_to?(:strftime)
20
28
 
21
29
  date_string = daily_log.date.strftime('%a, %B %-d, %Y')
@@ -24,6 +32,8 @@ class Printer
24
32
  daily_log.entries.each do |entry|
25
33
  next if epics_only && !entry.epic?
26
34
 
35
+ next unless filter.compact.all? { |k, v| entry.send(k) == v }
36
+
27
37
  print_entry(daily_log, entry, date_inline)
28
38
  end
29
39
  end
data/lib/worklog.rb CHANGED
@@ -115,6 +115,20 @@ module Worklog
115
115
  WorkLogger.info Rainbow("Updated work log for #{options[:date]}").green
116
116
  end
117
117
 
118
+ # Show the work log for a specific date range or a single date.
119
+ #
120
+ # @param options [Hash] the options hash containing date range or single date.
121
+ # @option options [Integer] :days the number of days to show from today (default: 1).
122
+ # @option options [String] :from the start date in 'YYYY-MM-DD' format.
123
+ # @option options [String] :to the end date in 'YYYY-MM-DD' format.
124
+ # @option options [String] :date a specific date in 'YYYY-MM-DD' format.
125
+ # @option options [Boolean] :epics_only whether to show only entries with epics (default: false).
126
+ # @option options [String] :project the project key to filter entries by project.
127
+ #
128
+ # @example
129
+ # worklog.show(days: 7)
130
+ # worklog.show(from: '2023-10-01', to: '2023-10-31')
131
+ # worklog.show(date: '2023-10-01')
118
132
  def show(options = {})
119
133
  people = @storage.load_people!
120
134
  printer = Printer.new(people)
@@ -126,7 +140,7 @@ module Worklog
126
140
  printer.no_entries(start_date, end_date)
127
141
  else
128
142
  entries.each do |entry|
129
- printer.print_day(entry, entries.size > 1, options[:epics_only])
143
+ printer.print_day(entry, entries.size > 1, options[:epics_only], project: options[:project])
130
144
  end
131
145
  end
132
146
  end
@@ -193,8 +207,8 @@ module Worklog
193
207
  projects.each_value do |project|
194
208
  puts "#{Rainbow(project.name).gold} (#{project.key})"
195
209
  puts " Description: #{project.description}" if project.description
196
- puts " Start date: #{project.start_date}" if project.start_date
197
- puts " End date: #{project.end_date}" if project.end_date
210
+ puts " Start date: #{project.start_date.strftime('%b %d, %Y')}" if project.start_date
211
+ puts " End date: #{project.end_date.strftime('%b %d, %Y')}" if project.end_date
198
212
  puts " Status: #{project.status}" if project.status
199
213
  end
200
214
  puts 'No projects found.' if projects.empty?
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.16
4
+ version: 0.2.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Friedrich Ewald