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 +4 -4
- data/.version +1 -1
- data/lib/daily_log.rb +11 -0
- data/lib/log_entry.rb +16 -0
- data/lib/storage.rb +4 -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: 03ec04755ea87ebd6808b5b9256ad07a0c95514e35ed719628531cbb5cb5a0d9
|
4
|
+
data.tar.gz: e8c62ab27e88132df53066704a09d0baf585b1c5208c1c2481e0b3940f69419c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e735b3fb91b5125e6607e2a2b018fd41038f8b02c32c31fc8bd0f2f56f87ec40ede9731361071071e752addd260f10b65a50bc6678aa8b6d8618bba0acfa975d
|
7
|
+
data.tar.gz: 85a223a42f4b88a1957e74f570aca7eac3f879a8967b2a40dc266e192b4a36142ae82635df11cb22fb1d1fc941cffa6bd0c3a4b1ba131bec179c1a60913dacca
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
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
|
-
|
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
|