fewald-worklog 0.2.21 → 0.2.22

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: 03ec04755ea87ebd6808b5b9256ad07a0c95514e35ed719628531cbb5cb5a0d9
4
+ data.tar.gz: e8c62ab27e88132df53066704a09d0baf585b1c5208c1c2481e0b3940f69419c
5
5
  SHA512:
6
- metadata.gz: a9cc6c2ef435e43390491c2d31793c4e2ae8febd54bdd68ea535decb109defd70538bdaaaa1dc70d660c0f1193e9786d4bab66cf1a0619bf5166146b1c8eb95c
7
- data.tar.gz: aa43dfa148848d4161a791105934e36c9caf21929d4e978e3b20468fe076b288b555137cf7b74f06fb17157f9312fcc40050894e494c176334679d61033fa198
6
+ metadata.gz: e735b3fb91b5125e6607e2a2b018fd41038f8b02c32c31fc8bd0f2f56f87ec40ede9731361071071e752addd260f10b65a50bc6678aa8b6d8618bba0acfa975d
7
+ data.tar.gz: 85a223a42f4b88a1957e74f570aca7eac3f879a8967b2a40dc266e192b4a36142ae82635df11cb22fb1d1fc941cffa6bd0c3a4b1ba131bec179c1a60913dacca
data/.version CHANGED
@@ -1 +1 @@
1
- 0.2.21
1
+ 0.2.22
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
@@ -114,7 +114,10 @@ module Worklog
114
114
  # Alias DailyLog to Worklog::DailyLog
115
115
 
116
116
  begin
117
- log = YAML.load_file(file, permitted_classes: [Date, Time, DailyLog, LogEntry])
117
+ yaml_content = File.read(file)
118
+ cleaned_yaml = yaml_content.gsub(%r{!ruby/object:[^\s]+}, '')
119
+ log = DailyLog.from_hash(YAML.safe_load(cleaned_yaml, permitted_classes: [Date, Time], symbolize_names: true))
120
+
118
121
  log.entries.each do |entry|
119
122
  entry.time = Time.parse(entry.time) unless entry.time.respond_to?(:strftime)
120
123
  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.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Friedrich Ewald