fewald-worklog 0.2.32 → 0.2.33

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: 14033d83050a174467b6159bc1fdbfb7fd3bc7ffc8883f3b04bc241dec77184b
4
- data.tar.gz: 7499e124a43649989ffb3010fcb4965f4110ea7efe7d41a8e49515a0d165e022
3
+ metadata.gz: c28fcf1980d7fba6dbe1585ef1ae6d41520329470c4289f427dc8feb689c4cba
4
+ data.tar.gz: d6db27c34cd1288d19042579426a947b96fa5ca30f7fd7a88887ee220f2adc16
5
5
  SHA512:
6
- metadata.gz: 54887531704ca1ef6cc7ef0303d899b991036add0f914f81d55189a67a5b7d2254fc89dff9114cbb7237a394d69fe020dc0175cd0978a56766def700f8bb226d
7
- data.tar.gz: 1a1207af445e9074d0d66b2802943e71a1a63f7aaaa7ec06f95c10805b3529207acc06ade759a0275bdc675da26ccce6ecdf1200c292bf0817a2a98e6e278975
6
+ metadata.gz: 4116746f5d7df43bfb7764a68c36dfc19d9ed3ccee6c8f1965306db4ffde3e1a7c56608293fc6d8b0c30810149ef0cdbfd83bb9881fb05d84feb0b368079883c
7
+ data.tar.gz: 0ec8ef405b87a6e07c9ca6a4c0191de9fc0c5fbc19bbd30656e332d9a6489db90fa8ae81532c481c9c3a4169fed3d5f9679a7d9cee4e9f5ee07a3af6d3ebc9d6
data/.version CHANGED
@@ -1 +1 @@
1
- 0.2.32
1
+ 0.2.33
data/lib/daily_log.rb CHANGED
@@ -13,7 +13,7 @@ module Worklog
13
13
 
14
14
  def initialize(params = {})
15
15
  @date = params[:date]
16
- @entries = params[:entries]
16
+ @entries = params[:entries] || []
17
17
  end
18
18
 
19
19
  # Returns true if there are people mentioned in any entry of the current day.
data/lib/log_entry.rb CHANGED
@@ -8,6 +8,8 @@ require 'hash'
8
8
  module Worklog
9
9
  # A single log entry in a DailyLog.
10
10
  # @see DailyLog
11
+ # @!attribute [rw] key
12
+ # @return [String] the unique key of the log entry. The key is generated based on the time and message.
11
13
  # @!attribute [rw] time
12
14
  # @return [DateTime] the date and time of the log entry.
13
15
  # @!attribute [rw] tags
@@ -27,11 +29,13 @@ module Worklog
27
29
 
28
30
  include Hashify
29
31
 
30
- attr_accessor :time, :tags, :ticket, :url, :epic, :message, :project
32
+ attr_accessor :key, :time, :tags, :ticket, :url, :epic, :message, :project
31
33
 
32
34
  attr_reader :day
33
35
 
34
36
  def initialize(params = {})
37
+ # key can be nil. This is needed for backwards compatibility with older log entries.
38
+ @key = params[:key]
35
39
  @time = params[:time]
36
40
  # If tags are nil, set to empty array.
37
41
  # This is similar to the CLI default value.
@@ -105,19 +109,12 @@ module Worklog
105
109
  end
106
110
 
107
111
  # Create a LogEntry from a hash with symbolized keys
112
+ # This is an alias for the constructor and here for consistency with other classes.
108
113
  #
109
114
  # @param hash [Hash] the hash to convert
110
115
  # @return [LogEntry] the created LogEntry object
111
116
  def self.from_hash(hash)
112
- new(
113
- time: hash[:time],
114
- tags: hash[:tags],
115
- ticket: hash[:ticket],
116
- url: hash[:url],
117
- epic: hash[:epic],
118
- message: hash[:message],
119
- project: hash[:project]
120
- )
117
+ new(**hash)
121
118
  end
122
119
 
123
120
  # Convert the log entry to YAML format.
data/lib/worklog.rb CHANGED
@@ -6,6 +6,7 @@ require 'rainbow'
6
6
  require 'yaml'
7
7
 
8
8
  require 'configuration'
9
+ require 'digest'
9
10
  require 'hash'
10
11
  require 'daily_log'
11
12
  require 'date_parser'
@@ -86,8 +87,11 @@ module Worklog
86
87
  # Validate that the project exists if provided
87
88
  validate_projects!(options[:project]) if options[:project] && !options[:project].empty?
88
89
 
90
+ # Use the first 7 characters of the SHA256 hash of message as the key
91
+ key = Digest::SHA256.hexdigest(message)[..6]
92
+
89
93
  daily_log = @storage.load_log!(@storage.filepath(date))
90
- new_entry = LogEntry.new(time:, tags: options[:tags], ticket: options[:ticket], url: options[:url],
94
+ new_entry = LogEntry.new(key:, time:, tags: options[:tags], ticket: options[:ticket], url: options[:url],
91
95
  epic: options[:epic], message:, project: options[:project])
92
96
  daily_log.entries << new_entry
93
97
 
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.32
4
+ version: 0.2.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - Friedrich Ewald