timet 1.5.7 → 1.5.8
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/CHANGELOG.md +15 -0
- data/lib/timet/database_sync_helper.rb +4 -3
- data/lib/timet/time_helper.rb +19 -1
- data/lib/timet/time_statistics.rb +1 -1
- data/lib/timet/time_update_helper.rb +1 -19
- data/lib/timet/validation_edit_helper.rb +1 -1
- data/lib/timet/version.rb +2 -2
- data/lib/timet/week_info.rb +8 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0426dff5bb0b43529afe26f4f3f9f751a43c8ce59a76add257c4da1dceda91e
|
4
|
+
data.tar.gz: 5bb737c4d928d378997df4e40543e52dd7c2eb631beea39f1c3e8dc3c0231b9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 900a95c16f624f45c314af3edacefd58902c5225a0cde0010350ed9b57a83ed69345a7c3744935f082793a8f010efe0d87c5d81d7bee2c621542746a19bb2f96
|
7
|
+
data.tar.gz: 34c77eb47e0f443f33930cb037febdd0b0d298370f56f3553b861b9aff321edc6aed632df055359a924db5a77d86c3cbf967249cc66e308a3fcc8e94eef58626
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
## [1.5.8] - 2025-06-28
|
2
|
+
|
3
|
+
**Improvements:**
|
4
|
+
|
5
|
+
- Updated gem dependencies, including `aws-sdk-s3`, `rake`, `sqlite3`, and `rubocop`.
|
6
|
+
- Refactored `update_time_field` method into `TimeHelper` for better code organization.
|
7
|
+
- Simplified `TimeStatistics#average_by_tag` to use the more concise `(&:mean)` method in `TimeStatistics`.
|
8
|
+
- Improved robustness of `format_time_string` in `TimeHelper`.
|
9
|
+
- Enhanced code clarity in `DatabaseSyncHelper` and `WeekInfo`.
|
10
|
+
- Added `vendor/bundle` and a test calendar file to `.gitignore`.
|
11
|
+
|
12
|
+
**Bug Fixes:**
|
13
|
+
|
14
|
+
- Corrected time collision validation in `ValidationEditHelper` to properly handle exact time matches (`>=`).
|
15
|
+
|
1
16
|
## [1.5.7] - 2025-05-16
|
2
17
|
|
3
18
|
**Improvements:**
|
@@ -40,12 +40,13 @@ module Timet
|
|
40
40
|
# comparing it with the local database, and handling any differences found
|
41
41
|
def self.process_remote_database(local_db, remote_storage, bucket, local_db_path)
|
42
42
|
with_temp_file do |temp_file|
|
43
|
-
|
43
|
+
file_path = temp_file.path
|
44
|
+
remote_storage.download_file(bucket, 'timet.db', file_path)
|
44
45
|
|
45
|
-
if databases_are_in_sync?(
|
46
|
+
if databases_are_in_sync?(file_path, local_db_path)
|
46
47
|
puts 'Local database is up to date'
|
47
48
|
else
|
48
|
-
handle_database_differences(local_db, remote_storage, bucket, local_db_path,
|
49
|
+
handle_database_differences(local_db, remote_storage, bucket, local_db_path, file_path)
|
49
50
|
end
|
50
51
|
end
|
51
52
|
end
|
data/lib/timet/time_helper.rb
CHANGED
@@ -115,7 +115,7 @@ module Timet
|
|
115
115
|
# TimeHelper.format_time_string('127122') # => nil
|
116
116
|
# TimeHelper.format_time_string('abc') # => nil
|
117
117
|
def self.format_time_string(input)
|
118
|
-
return nil if input.
|
118
|
+
return nil if input.to_s.empty?
|
119
119
|
|
120
120
|
digits = input.gsub(/\D/, '')[0..5]
|
121
121
|
return nil if digits.empty?
|
@@ -264,5 +264,23 @@ module Timet
|
|
264
264
|
parsed_time_component.sec
|
265
265
|
)
|
266
266
|
end
|
267
|
+
|
268
|
+
# Updates a time field (start or end) of a tracking item with a formatted date value.
|
269
|
+
#
|
270
|
+
# @param item [Array] The tracking item to be updated.
|
271
|
+
# @param field [String] The time field to be updated.
|
272
|
+
# @param new_time [String] The new time value.
|
273
|
+
#
|
274
|
+
# @return [Time] The updated time value.
|
275
|
+
#
|
276
|
+
# @example Update the 'start' field of a tracking item with a formatted date value
|
277
|
+
# update_time_field(item, 'start', '11:10:00')
|
278
|
+
def self.update_time_field(item, field, new_time)
|
279
|
+
field_index = Timet::Application::FIELD_INDEX[field]
|
280
|
+
timestamp = item[field_index]
|
281
|
+
edit_time = Time.at(timestamp || item[1]).to_s.split
|
282
|
+
edit_time[1] = new_time
|
283
|
+
DateTime.strptime(edit_time.join(' '), '%Y-%m-%d %H:%M:%S %z').to_time
|
284
|
+
end
|
267
285
|
end
|
268
286
|
end
|
@@ -72,7 +72,7 @@ module Timet
|
|
72
72
|
#
|
73
73
|
# @return [Hash<String, Float>] A hash mapping tags to their average durations.
|
74
74
|
def average_by_tag
|
75
|
-
@duration_by_tag.transform_values
|
75
|
+
@duration_by_tag.transform_values(&:mean)
|
76
76
|
end
|
77
77
|
|
78
78
|
# Returns a hash where keys are tags and values are the standard deviation of durations for each tag.
|
@@ -25,7 +25,7 @@ module Timet
|
|
25
25
|
|
26
26
|
return print_error(date_value) unless formatted_date
|
27
27
|
|
28
|
-
new_date = update_time_field(item, field, formatted_date)
|
28
|
+
new_date = TimeHelper.update_time_field(item, field, formatted_date)
|
29
29
|
new_value_epoch = new_date.to_i
|
30
30
|
|
31
31
|
if valid_time_value?(item, field, new_value_epoch, id)
|
@@ -47,24 +47,6 @@ module Timet
|
|
47
47
|
puts "Invalid date: #{message}".red
|
48
48
|
end
|
49
49
|
|
50
|
-
# Updates a time field (start or end) of a tracking item with a formatted date value.
|
51
|
-
#
|
52
|
-
# @param item [Array] The tracking item to be updated.
|
53
|
-
# @param field [String] The time field to be updated.
|
54
|
-
# @param new_time [String] The new time value.
|
55
|
-
#
|
56
|
-
# @return [Time] The updated time value.
|
57
|
-
#
|
58
|
-
# @example Update the 'start' field of a tracking item with a formatted date value
|
59
|
-
# update_time_field(item, 'start', '11:10:00')
|
60
|
-
def update_time_field(item, field, new_time)
|
61
|
-
field_index = Timet::Application::FIELD_INDEX[field]
|
62
|
-
timestamp = item[field_index]
|
63
|
-
edit_time = Time.at(timestamp || item[1]).to_s.split
|
64
|
-
edit_time[1] = new_time
|
65
|
-
DateTime.strptime(edit_time.join(' '), '%Y-%m-%d %H:%M:%S %z').to_time
|
66
|
-
end
|
67
|
-
|
68
50
|
# Validates if a new time value is valid for a specific time field (start or end).
|
69
51
|
#
|
70
52
|
# @param item [Array] The tracking item to be validated.
|
@@ -106,7 +106,7 @@ module Timet
|
|
106
106
|
def check_collision_with_next_item(field, new_epoch, next_item)
|
107
107
|
return unless next_item
|
108
108
|
|
109
|
-
if field == 'start' && new_epoch
|
109
|
+
if field == 'start' && new_epoch >= next_item[1]
|
110
110
|
raise ArgumentError,
|
111
111
|
'New start time collides with next item (starts at ' \
|
112
112
|
"#{Time.at(next_item[1]).strftime('%Y-%m-%d %H:%M:%S')})."
|
data/lib/timet/version.rb
CHANGED
data/lib/timet/week_info.rb
CHANGED
@@ -22,15 +22,14 @@ module Timet
|
|
22
22
|
@date_string = date_string_for_display # Use the passed string for display
|
23
23
|
@current_cweek = date_object.cweek
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
#
|
32
|
-
|
33
|
-
@week_display_string = if is_first_display_of_this_cweek
|
25
|
+
is_first_entry = weeks_array_ref.empty?
|
26
|
+
is_new_week = is_first_entry || @current_cweek != weeks_array_ref.last
|
27
|
+
|
28
|
+
# A separator is needed if this entry starts a new week group, but it's not the very first one.
|
29
|
+
@print_separator_before_this = is_new_week && !is_first_entry
|
30
|
+
|
31
|
+
# The week number is underlined if it's the first time this week appears.
|
32
|
+
@week_display_string = if is_new_week
|
34
33
|
format('%02d', @current_cweek).underline
|
35
34
|
else
|
36
35
|
' '
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Vielma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|