fewald-worklog 0.2.21 → 0.2.23

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: a799c589dedc9f7ed68ef9b2acfd8ad08e29f3fb5f3a26d0a90dee1320ee164e
4
- data.tar.gz: 9e38d05b4303b41cf7ae2016d23990290ef2b41eba34db9b8c53f4a7587a84d2
3
+ metadata.gz: 948c6e8bb4859bffc163d5e3a1608568d2edb408bec8e2c7ad34b682d8f9fc07
4
+ data.tar.gz: acdade00ab4828cc48bacc0c6cdb338372a88f27c710a81a557efdf4ac128857
5
5
  SHA512:
6
- metadata.gz: a9cc6c2ef435e43390491c2d31793c4e2ae8febd54bdd68ea535decb109defd70538bdaaaa1dc70d660c0f1193e9786d4bab66cf1a0619bf5166146b1c8eb95c
7
- data.tar.gz: aa43dfa148848d4161a791105934e36c9caf21929d4e978e3b20468fe076b288b555137cf7b74f06fb17157f9312fcc40050894e494c176334679d61033fa198
6
+ metadata.gz: 20b674f1f4f372b1b0ca3531a6471b5f8b6cb2ae4ee158d4572a729ecdc76d06f44de2115aa6143a725f0a47692e788146643b6b4035349f183ec9a8aa0b2f60
7
+ data.tar.gz: 98e8577a4e2a8957eaa58d0e9060352d2692950b5158cee39d0900be6d427c960ce0583db99d9d9e09bbfbc96e8cbb993826965d2fe9de9c6bca880a6cb34c34
data/.version CHANGED
@@ -1 +1 @@
1
- 0.2.21
1
+ 0.2.23
data/lib/daily_log.rb CHANGED
@@ -44,6 +44,17 @@ module Worklog
44
44
  entries.flat_map(&:tags).uniq.sort
45
45
  end
46
46
 
47
+ # Create a DailyLog from a hash with symbolized keys
48
+ #
49
+ # @param hash [Hash] the hash to convert
50
+ # @return [DailyLog] the created DailyLog object
51
+ def self.from_hash(hash)
52
+ new(
53
+ date: hash[:date],
54
+ entries: hash[:entries].map { |entry| LogEntry.from_hash(entry) }
55
+ )
56
+ end
57
+
47
58
  # Equals method to compare two DailyLog objects.
48
59
  #
49
60
  # @param other [DailyLog] the other DailyLog object to compare with
data/lib/log_entry.rb CHANGED
@@ -104,6 +104,22 @@ module Worklog
104
104
  people.size.positive?
105
105
  end
106
106
 
107
+ # Create a LogEntry from a hash with symbolized keys
108
+ #
109
+ # @param hash [Hash] the hash to convert
110
+ # @return [LogEntry] the created LogEntry object
111
+ 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
+ )
121
+ end
122
+
107
123
  # Convert the log entry to YAML format.
108
124
  def to_yaml
109
125
  to_hash.to_yaml
data/lib/storage.rb CHANGED
@@ -6,10 +6,6 @@ require 'log_entry'
6
6
  require 'worklogger'
7
7
  require 'person'
8
8
 
9
- # Alias for classes to handle existing log entries
10
- DailyLog = Worklog::DailyLog
11
- LogEntry = Worklog::LogEntry
12
-
13
9
  module Worklog
14
10
  # Handles storage of daily logs and people
15
11
  class Storage
@@ -110,11 +106,11 @@ module Worklog
110
106
 
111
107
  def load_log!(file)
112
108
  WorkLogger.debug "Loading file #{file}"
113
-
114
- # Alias DailyLog to Worklog::DailyLog
115
-
116
109
  begin
117
- log = YAML.load_file(file, permitted_classes: [Date, Time, DailyLog, LogEntry])
110
+ yaml_content = File.read(file)
111
+ cleaned_yaml = yaml_content.gsub(%r{!ruby/object:[^\s]+}, '')
112
+ log = DailyLog.from_hash(YAML.safe_load(cleaned_yaml, permitted_classes: [Date, Time], symbolize_names: true))
113
+
118
114
  log.entries.each do |entry|
119
115
  entry.time = Time.parse(entry.time) unless entry.time.respond_to?(:strftime)
120
116
  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.2.21
4
+ version: 0.2.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Friedrich Ewald