fewald-worklog 0.2.25 → 0.2.27

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: 7412052ae6f6e4ff3fab0cc85cc061a3370aa144a5ae0d720e8b4c18771f71b5
4
- data.tar.gz: 347ca8cf68c1170c1ccbf2a0d939bc2507257a33c9ae3bdd4cdf8cd46acb1d74
3
+ metadata.gz: 1f5d2936c205d022b512f27dba2b197c789a718be8e16e2f16a8e16a1ca9b845
4
+ data.tar.gz: ff15975240c49b93d59796e8f20ac9e1eb1afde3d6b1c48468a592e184cf4d02
5
5
  SHA512:
6
- metadata.gz: 8e31310232c8c15e9215adefefcd160cf42dac279c3a5e72cea7b7b1193abf9ed1ce15540237ba90c3f16c719b7c170dd27dd628b1082eef857354b1611e5f9a
7
- data.tar.gz: b581a94567bbc30cce66f634d9d8c6879c8f0cc82b27867972a0c9c81927516ee2065803347d9e071ddd2e112bf3a2d633c712aec2df188cbeb1c717738fbb37
6
+ metadata.gz: 5a23fd91469659a76fd9bd6d0bb7d4479f60527bb2dd9a32e5c46d37d39615b44232dcab5b223dbb072e3a26d203b13efdfb8af8584fd4feca8e943dab8c98fe
7
+ data.tar.gz: 4648476ae4f62e5a0dce5ac5cd3eecf2f1e1519783962d999e6891fe197733f45e8aa3cd410159ed2b1265fee5a348d9369bcc7e91e653521075676c530bb974
data/.version CHANGED
@@ -1 +1 @@
1
- 0.2.25
1
+ 0.2.27
data/lib/cli.rb CHANGED
@@ -105,9 +105,15 @@ class WorklogCLI < Thor
105
105
  end
106
106
 
107
107
  desc 'projects', 'Show all projects defined in the work log'
108
- def projects(options = {})
108
+ option :oneline, type: :boolean, default: false, desc: 'Show only project titles and keys in a single line format'
109
+ def projects
109
110
  worklog = Worklog::Worklog.new
110
- worklog.projects(options)
111
+
112
+ if options[:oneline]
113
+ worklog.projects_oneline(options)
114
+ else
115
+ worklog.projects(options)
116
+ end
111
117
  end
112
118
 
113
119
  desc 'tags', 'Show all tags used in the work log'
data/lib/person.rb CHANGED
@@ -1,6 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Represents a person at work.
4
+ #
5
+ # !attribute [r] handle
6
+ # @return [String] The person's handle (username)
7
+ # !attribute [r] name
8
+ # @return [String] The person's full name
9
+ # !attribute [r] email
10
+ # @return [String, nil] The person's email address, can be nil
11
+ # !attribute [r] team
12
+ # @return [String, nil] The team the person belongs to, can be nil
13
+ # !attribute [r] notes
14
+ # @return [Array<String>] An array of notes about the person
4
15
  class Person
5
16
  attr_reader :handle, :name, :email, :team, :notes
6
17
 
@@ -12,6 +23,26 @@ class Person
12
23
  @notes = notes
13
24
  end
14
25
 
26
+ # Creates a new Person instance from a hash of attributes.
27
+ # @param hash [Hash] A hash containing person attributes
28
+ # @option hash [String] :handle The person's handle (username)
29
+ # @option hash [String] :name The person's full name
30
+ # @option hash [String, nil] :email The person's email address, can be nil
31
+ # @option hash [String, nil] :team The team the person belongs to, can be nil
32
+ # @option hash [Array<String>] :notes An array of notes about the person
33
+ # @return [Person] A new Person instance
34
+ def self.from_hash(hash)
35
+ raise ArgumentError, 'Person handle is required' unless hash[:handle] || hash['handle']
36
+ raise ArgumentError, 'Person name is required' unless hash[:name] || hash['name']
37
+
38
+ handle = hash[:handle] || hash['handle']
39
+ name = hash[:name] || hash['name']
40
+ email = hash[:email] || hash['email']
41
+ team = hash[:team] || hash['team']
42
+ notes = hash[:notes] || hash['notes'] || []
43
+ Person.new(handle, name, email, team, notes)
44
+ end
45
+
15
46
  def to_s
16
47
  return "#{name} (~#{handle})" if @email.nil?
17
48
 
data/lib/storage.rb CHANGED
@@ -157,7 +157,13 @@ module Worklog
157
157
  people_file = File.join(@config.storage_path, 'people.yaml')
158
158
  return [] unless File.exist?(people_file)
159
159
 
160
- YAML.load_file(people_file, permitted_classes: [Person])
160
+ yamltext = File.read(people_file)
161
+ if yamltext != yamltext.gsub(/^- !.*$/, '-')
162
+ WorkLogger.debug 'The people.yaml file contains deprecated syntax. Migrating now.'
163
+ yamltext.gsub!(/^- !.*$/, '-')
164
+ File.write(people_file, yamltext)
165
+ end
166
+ YAML.load(yamltext, permitted_classes: []).map { |person_hash| Person.from_hash(person_hash) }
161
167
  end
162
168
 
163
169
  # Write people to the people file
data/lib/worklog.rb CHANGED
@@ -200,6 +200,23 @@ module Worklog
200
200
  end
201
201
  end
202
202
 
203
+ # Show all projects, one line per project.
204
+ # This is a compact view showing only project names and keys.
205
+ def projects_oneline(_options = {})
206
+ project_storage = ProjectStorage.new(@config)
207
+ projects = project_storage.load_projects
208
+
209
+ # Find longest project name for formatting
210
+ max_len = projects.values.map { |p| p.name.length }.max || 0
211
+
212
+ projects.each_value do |project|
213
+ puts "#{Rainbow(project.name.ljust(max_len)).gold} #{project.key}"
214
+ end
215
+ end
216
+
217
+ # Show all projects with details and recent activity.
218
+ # This method loads all projects and their associated log entries.
219
+ # It also calculates the last activity date for each project based on log entries.
203
220
  def projects(_options = {})
204
221
  project_storage = ProjectStorage.new(@config)
205
222
  projects = project_storage.load_projects
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.25
4
+ version: 0.2.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Friedrich Ewald