fewald-worklog 0.2.25 → 0.2.26
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 +4 -4
- data/.version +1 -1
- data/lib/person.rb +31 -0
- data/lib/storage.rb +7 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 36b9165b88874b753ed10bbb1a337626257db5de478fc56c15a475212836879a
|
|
4
|
+
data.tar.gz: fe0e5c279c1fb166876892e9642f85761bc6fdbd7d6e24c14b707bd34bd99668
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5a9fafe519688f3b9258aa9b5d433dbec01ea6259fc199e3e302791acfb64a3c2159081b4d749ad86b118da0c5fbca990170c9b42dc986ef0e8bf22ec9e81ddf
|
|
7
|
+
data.tar.gz: a15669d9d071af3ef4124f0c60de3d41a47fb6c1684b90a523c35cfe53576ef9eca9030bed21f8c2b095279327ed84b6e1bde062beb428225bae888f65fc65f7
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.26
|
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
|
-
|
|
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
|