fewald-worklog 0.3.2 → 0.3.4

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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/.version +1 -1
  3. data/lib/person.rb +58 -53
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 484130ef7f6c7cd05ae5dc16c5dc1b69efd05ed3118a085cbf8a1b0c63ab903a
4
- data.tar.gz: 4d58528e9469766ed8c16d8d86c917c0a19276e4a228f0d38f9ecf4877322d39
3
+ metadata.gz: 5469080196a9c73579db866047532ac791b48d2dd1ea470a1996b3175132d669
4
+ data.tar.gz: 6a6540617d20a0ad75b1489774b8507e0558a14389652a6b1add2ca63ba3f909
5
5
  SHA512:
6
- metadata.gz: 9cd48303d01eb81d866b274e2fcd4c4adbf95145848d7fb593cf0428162264a578ad00bb7e4732f62f30938d730563914a1e97ff6997eb33d0f31b4f06317866
7
- data.tar.gz: cacfeb6c3b558ccfe8964f5faba0ec6512f047b625b8b5993294e5f7682193f775fcf4cf2d3dfedc5d6c67e8ce38a85d6f234a7946844cd57a315e661c3ee196
6
+ metadata.gz: 97c033d0d3b61fc15972104f43c6b25ac1e1e8bfbff29031b591849f8e1bd2c5eccfb91c8ada2cf7a15a71f9dcc9abbaf37669a075c4013c47cf364908bb155b
7
+ data.tar.gz: 307dea9173abc3207316aadd0ee6e5fe557966ca72ea857ff4ea69e30866d8c3c3a2dcb8eb74650ada3c482c4e33a85e7555a115837594fc9921253d1b45adb6
data/.version CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.4
data/lib/person.rb CHANGED
@@ -1,57 +1,62 @@
1
1
  # frozen_string_literal: true
2
2
 
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
15
- class Person
16
- attr_reader :handle, :name, :email, :team, :notes
17
-
18
- def initialize(handle:, name:, email:, team:, notes: [])
19
- @handle = handle
20
- @name = name
21
- @email = email
22
- @team = team
23
- @notes = notes
24
- end
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: handle, name: name, email: email, team: team, notes: notes)
44
- end
45
-
46
- def to_s
47
- return "#{name} (~#{handle})" if @email.nil?
48
-
49
- "#{name} (~#{handle}) <#{email}>"
50
- end
51
-
52
- def ==(other)
53
- return false unless other.is_a?(Person)
54
-
55
- handle == other.handle && name == other.name && email == other.email && team == other.team && notes == other.notes
3
+ module Worklog
4
+ # Represents a person at work.
5
+ #
6
+ # !attribute [r] handle
7
+ # @return [String] The person's handle (username)
8
+ # !attribute [r] name
9
+ # @return [String] The person's full name
10
+ # !attribute [r] email
11
+ # @return [String, nil] The person's email address, can be nil
12
+ # !attribute [r] team
13
+ # @return [String, nil] The team the person belongs to, can be nil
14
+ # !attribute [r] notes
15
+ # @return [Array<String>] An array of notes about the person
16
+ class Person
17
+ attr_reader :handle, :github_username, :name, :email, :team, :notes
18
+
19
+ def initialize(handle:, name:, **params)
20
+ # params to symbol keys
21
+ params = params.transform_keys(&:to_sym)
22
+
23
+ @handle = handle
24
+ @name = name
25
+ @github_username = params[:github_username]
26
+ @email = params[:email]
27
+ @team = params[:team]
28
+ @notes = params[:notes] || []
29
+ end
30
+
31
+ # Creates a new Person instance from a hash of attributes.
32
+ # @param hash [Hash] A hash containing person attributes
33
+ # @option hash [String] :handle The person's handle (username)
34
+ # @option hash [String] :name The person's full name
35
+ # @option hash [String, nil] :email The person's email address, can be nil
36
+ # @option hash [String, nil] :team The team the person belongs to, can be nil
37
+ # @option hash [Array<String>] :notes An array of notes about the person
38
+ # @return [Person] A new Person instance
39
+ def self.from_hash(hash)
40
+ hash = hash.transform_keys(&:to_sym)
41
+
42
+ raise ArgumentError, 'Person handle is required' unless hash[:handle]
43
+ raise ArgumentError, 'Person name is required' unless hash[:name]
44
+
45
+ handle = hash[:handle]
46
+ name = hash[:name]
47
+ Person.new(handle: handle, name: name, **hash)
48
+ end
49
+
50
+ def to_s
51
+ return "#{name} (~#{handle})" if @email.nil?
52
+
53
+ "#{name} (~#{handle}) <#{email}>"
54
+ end
55
+
56
+ def ==(other)
57
+ return false unless other.is_a?(Person)
58
+
59
+ handle == other.handle && name == other.name && email == other.email && team == other.team && notes == other.notes
60
+ end
56
61
  end
57
62
  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.3.2
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Friedrich Ewald
@@ -171,10 +171,10 @@ metadata:
171
171
  documentation_uri: https://f-ewald.github.io/worklog
172
172
  rubygems_mfa_required: 'true'
173
173
  post_install_message: |
174
- =====
174
+ ==============================================================================
175
175
  Thanks for installing fewald-worklog! Now you can use it by running wl from your terminal.
176
176
  For more information, visit https://f-ewald.github.io/worklog or run wl help.
177
- =====
177
+ ==============================================================================
178
178
  rdoc_options: []
179
179
  require_paths:
180
180
  - lib