timet 1.5.1 → 1.5.2
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 +17 -0
- data/lib/timet/application.rb +30 -5
- data/lib/timet/database.rb +3 -3
- data/lib/timet/time_helper.rb +15 -0
- data/lib/timet/version.rb +2 -2
- 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: f538523396dc470f91334a3abe44915e63dec009a60901a1ae4ef7b432a9a37f
|
4
|
+
data.tar.gz: 262da1d62b413102d4ff33932fa7fb05c10c4b13abcb832d6382683d2d314d8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d1d90414bda675c2f09827ec99c63b4e86e04f826e969d07af15a757e29b1cb868d412d17b7995012b1091173cd50e2093009600bb55888b06ffd1c1a4397e0
|
7
|
+
data.tar.gz: cad0f0569224af29941301173dcfa1045c4419db21265b5cdb2d64e5e14f9eeca52d5ada931be7fed1757305ba55bb05823111d974a40c2e57ca0a25c4f8cff7
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [1.5.2] - 2024-12-12
|
4
|
+
|
5
|
+
**Improvements:**
|
6
|
+
|
7
|
+
- Added command validation during application initialization to ensure only valid arguments are processed.
|
8
|
+
- Updated the `insert_item` method in the `Database` class to accept parameters via `*args` for better flexibility.
|
9
|
+
- Updated dependencies:
|
10
|
+
- `aws-partitions` to `1.1021.0`
|
11
|
+
- `rubocop` to `1.69.2`
|
12
|
+
- `rubocop-rspec` to `3.3.0`
|
13
|
+
- `sqlite3` to `2.4.1`
|
14
|
+
|
15
|
+
**Bug Fixes:**
|
16
|
+
|
17
|
+
- Fixed potential issues with invalid arguments causing the application to crash during initialization.
|
18
|
+
|
3
19
|
## [1.5.1] - 2024-12-07
|
4
20
|
|
5
21
|
**Improvements:**
|
@@ -7,6 +23,7 @@
|
|
7
23
|
- Extracted the logic for syncing items by ID into a separate method `sync_items_by_id` for better readability and maintainability.
|
8
24
|
- Improved the writing of missing environment variables to the .env file in the S3Supabase module by ensuring the file content ends with a newline character.
|
9
25
|
- Refactored the `all_items` method to use `beginning_of_day` for today's timestamp, improving the accuracy of the timestamp calculation.
|
26
|
+
- Fix `beginning_of_day`
|
10
27
|
|
11
28
|
**Bug Fixes:**
|
12
29
|
|
data/lib/timet/application.rb
CHANGED
@@ -25,11 +25,6 @@ module Timet
|
|
25
25
|
include ApplicationHelper
|
26
26
|
include TimeHelper
|
27
27
|
|
28
|
-
def initialize(*args)
|
29
|
-
super
|
30
|
-
@db = Database.new
|
31
|
-
end
|
32
|
-
|
33
28
|
FIELD_INDEX = {
|
34
29
|
'notes' => 4,
|
35
30
|
'tag' => 3,
|
@@ -39,8 +34,38 @@ module Timet
|
|
39
34
|
|
40
35
|
VALID_STATUSES_FOR_INSERTION = %i[no_items complete].freeze
|
41
36
|
|
37
|
+
VALID_ARGUMENTS = %w[
|
38
|
+
cancel
|
39
|
+
delete
|
40
|
+
edit
|
41
|
+
help
|
42
|
+
resume
|
43
|
+
start
|
44
|
+
stop
|
45
|
+
summary
|
46
|
+
sync
|
47
|
+
version
|
48
|
+
].freeze
|
49
|
+
|
42
50
|
BUCKET = 'timet'
|
43
51
|
|
52
|
+
def initialize(*args)
|
53
|
+
super
|
54
|
+
|
55
|
+
# Initialize database without validation in test environment
|
56
|
+
if defined?(RSpec)
|
57
|
+
@db = Database.new
|
58
|
+
else
|
59
|
+
command_name = args[2][:current_command].name
|
60
|
+
if VALID_ARGUMENTS.include?(command_name)
|
61
|
+
@db = Database.new
|
62
|
+
else
|
63
|
+
puts 'Invalid arguments provided. Please check your input.'
|
64
|
+
exit(1)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
44
69
|
desc "start [tag] --notes='' --pomodoro=[min]",
|
45
70
|
'Start time tracking for a task labeled with the provided [tag], notes and "pomodoro time"
|
46
71
|
in minutes (optional).
|
data/lib/timet/database.rb
CHANGED
@@ -94,9 +94,9 @@ module Timet
|
|
94
94
|
# insert_item(1633072800, 'work', 'Completed task X')
|
95
95
|
#
|
96
96
|
# @note The method executes SQL to insert a new row into the 'items' table.
|
97
|
-
def insert_item(*args
|
97
|
+
def insert_item(*args)
|
98
98
|
# Unpacking args into meaningful variables for clarity
|
99
|
-
start, tag, notes = args
|
99
|
+
start, tag, notes, pomodoro, updated_at, created_at = args
|
100
100
|
execute_sql('INSERT INTO items (start, tag, notes, pomodoro, updated_at, created_at) VALUES (?, ?, ?, ?, ?, ?)',
|
101
101
|
[start, tag, notes, pomodoro, updated_at, created_at])
|
102
102
|
end
|
@@ -187,7 +187,7 @@ module Timet
|
|
187
187
|
# @note The method executes SQL to fetch all items from the 'items' table that have a start time greater than
|
188
188
|
# or equal to today.
|
189
189
|
def all_items
|
190
|
-
today =
|
190
|
+
today = TimeHelper.beginning_of_day.to_i
|
191
191
|
execute_sql('SELECT * FROM items WHERE start >= ? AND (deleted IS NULL OR deleted = 0) ORDER BY start DESC',
|
192
192
|
[today])
|
193
193
|
end
|
data/lib/timet/time_helper.rb
CHANGED
@@ -232,5 +232,20 @@ module Timet
|
|
232
232
|
end
|
233
233
|
hour_blocks
|
234
234
|
end
|
235
|
+
|
236
|
+
# Returns a Time object representing the start of the given day (midnight).
|
237
|
+
#
|
238
|
+
# @param time [Time] The time for which to find the beginning of day (defaults to current time).
|
239
|
+
# @return [Time] A new Time object set to midnight (00:00:00) of the given day.
|
240
|
+
#
|
241
|
+
# @example Get beginning of current day
|
242
|
+
# TimeHelper.beginning_of_day # => 2024-12-07 00:00:00
|
243
|
+
#
|
244
|
+
# @example Get beginning of specific day
|
245
|
+
# time = Time.new(2024, 12, 7, 15, 30, 45)
|
246
|
+
# TimeHelper.beginning_of_day(time) # => 2024-12-07 00:00:00
|
247
|
+
def self.beginning_of_day(time = Time.now)
|
248
|
+
Time.new(time.year, time.month, time.day)
|
249
|
+
end
|
235
250
|
end
|
236
251
|
end
|
data/lib/timet/version.rb
CHANGED
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Vielma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|