timet 0.8.2 → 0.9.0
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 +59 -20
- data/README.md +19 -0
- data/lib/timet/application.rb +14 -12
- data/lib/timet/database.rb +3 -23
- data/lib/timet/time_helper.rb +1 -1
- data/lib/timet/time_report.rb +22 -4
- data/lib/timet/validation_edit_helper.rb +2 -0
- data/lib/timet/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74f9106fb9a60ccd2e2446a58350d3de263459df41ffdf1aa57ca62d267da985
|
4
|
+
data.tar.gz: 77de65d76048301e01e0fb1607862ead7e69ead1647546974ac48b027222b73b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 409da2fabebd3071832c3c67498015a358cf973e9a41da970969aee97e53e779c8372e9c72c3dad835020644cf163be0138097337ca5589343f3f2364d2d177f
|
7
|
+
data.tar.gz: 537cd9eeba10e3bd43246d3c92f736b91ce171568437e15a22b0a0460171185cc5482f3b45348ef759b4daebb016d59126205f2192a168e618f0445b4384b88b
|
data/CHANGELOG.md
CHANGED
@@ -1,23 +1,59 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.9.0] - 2024-10-03
|
4
|
+
|
5
|
+
**Improvements:**
|
6
|
+
|
7
|
+
- Enhanced the gemspec metadata by adding a documentation URI for better discoverability and reference.
|
8
|
+
- Improved the `summary` and `edit` methods for better readability and functionality.
|
9
|
+
- Simplified the `summary` method by using safe navigation operators and improved conditional checks.
|
10
|
+
- Modified the `edit` method to use the return value of `validate_and_update` for displaying the updated item.
|
11
|
+
- Updated the `validate_and_update` method to return the updated item after performing the update.
|
12
|
+
- Enhanced the `TimeReport` class and added comprehensive RSpec tests.
|
13
|
+
- Enhanced the `filter_items` method to support valid date range filters.
|
14
|
+
- Added a `valid_date_format?` method to validate date formats.
|
15
|
+
- Updated the `formatted_filter` method to handle valid date range filters.
|
16
|
+
- Removed the `helpers.rb` file as it was no longer needed.
|
17
|
+
- Added comprehensive RSpec tests for the `TimeReport` class, covering initialization, filtering, and date format validation.
|
18
|
+
- Modified the `stop` method in `Timet::Application` to use the `update_item` method from `Database` instead of the deprecated `update` method.
|
19
|
+
- Updated the `stop` method to fetch the last item's ID and update the 'end' field directly.
|
20
|
+
- Updated test cases in `application_spec.rb` to reflect the changes in the `stop` method.
|
21
|
+
- Removed test cases for the deprecated `update` method in `database_spec.rb`.
|
22
|
+
|
23
|
+
**Bug fixes:**
|
24
|
+
|
25
|
+
- Fix bug in calculate_end_time method
|
26
|
+
|
27
|
+
**Additional Considerations:**
|
28
|
+
|
29
|
+
- The changes in this PR aim to improve code quality, maintainability, and test coverage.
|
30
|
+
- The removal of the `helpers.rb` file and unused methods helps to streamline the codebase and reduce technical debt.
|
31
|
+
- The updated `stop` method now uses the `update_item` method, ensuring consistency across the codebase.
|
32
|
+
- Comprehensive tests have been added for the `TimeReport` class to ensure robust functionality and prevent regressions.
|
33
|
+
|
3
34
|
## [0.8.2] - 2024-10-02
|
4
35
|
|
5
36
|
**Improvements:**
|
37
|
+
|
6
38
|
- Added optional field and new_value parameters to the edit command.
|
7
39
|
- Updated the edit method logic to prompt for field and new_value if they are not provided.
|
8
40
|
- Enhanced test coverage to include scenarios where field and new_value are provided directly and when they are not.
|
9
41
|
- Updated the README to reflect the new features of the edit command, including both interactive and direct specification modes.
|
10
42
|
|
11
43
|
**Additional Considerations:**
|
44
|
+
|
12
45
|
- The changes ensure that the edit command is more versatile and user-friendly, catering to both interactive users and those who prefer scripting or automation.
|
13
46
|
|
14
47
|
## [0.8.1] - 2024-10-02
|
48
|
+
|
15
49
|
**Bug fixes:**
|
16
|
-
|
50
|
+
|
51
|
+
- Fixed a LoadError caused by the byebug gem being required after its removal.
|
17
52
|
|
18
53
|
## [0.8.0] - 2024-10-01
|
19
54
|
|
20
55
|
**Improvements:**
|
56
|
+
|
21
57
|
- Introduced TimeHelper module to encapsulate time-related functionalities.
|
22
58
|
- Replaced direct calls to Time.now.to_i with TimeHelper.current_timestamp for consistency and modularity.
|
23
59
|
- Moved current_timestamp method to TimeHelper to centralize time-related logic.
|
@@ -50,6 +86,7 @@
|
|
50
86
|
- Added a confirmation message when the CSV file is successfully exported.
|
51
87
|
|
52
88
|
**Bug fixes:**
|
89
|
+
|
53
90
|
- Updated timestamp_to_time method to return nil if the input timestamp is nil.
|
54
91
|
- Removed unnecessary &.then syntax for clarity and consistency.
|
55
92
|
- Corrected the test expectations to use the correct Unix timestamp.
|
@@ -61,6 +98,7 @@
|
|
61
98
|
- Added validation to prevent updating start or end times with nil values.
|
62
99
|
|
63
100
|
**Tasks:**
|
101
|
+
|
64
102
|
- Added ENV['TZ'] = 'UTC' to spec_helper.rb to ensure that all RSpec tests run in the UTC time zone.
|
65
103
|
- Updated tests to reflect the new structure and ensure items are returned for export.
|
66
104
|
- Updated and added tests to cover the new export logic.
|
@@ -78,6 +116,7 @@
|
|
78
116
|
- Updated database_spec.rb to reflect the correct status for in-progress items.
|
79
117
|
|
80
118
|
**Additional Considerations:**
|
119
|
+
|
81
120
|
- Ensured that all timestamps are handled in UTC to avoid timezone issues across different environments.
|
82
121
|
- Updated the test to reflect the correct UTC time zone.
|
83
122
|
- Ensured consistency in timestamp handling across methods.
|
@@ -85,6 +124,7 @@
|
|
85
124
|
- Made the application easier to maintain and extend in the future.
|
86
125
|
|
87
126
|
**Refactor and enhance time formatting methods**
|
127
|
+
|
88
128
|
- Refactored `format_time_string` method in `TimeHelper` to improve readability and maintainability.
|
89
129
|
- Added detailed documentation for the `format_time_string` method.
|
90
130
|
- Simplified the logic for parsing and validating time components.
|
@@ -96,31 +136,30 @@
|
|
96
136
|
|
97
137
|
## [0.2.2] - 2024-09-27
|
98
138
|
|
99
|
-
|
100
|
-
|
139
|
+
- **Improvements**:
|
140
|
+
- Updated SQLite3 gem version to 2.1.0
|
101
141
|
|
102
142
|
## [0.2.1] - 2024-09-24
|
103
143
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
144
|
+
- **Improved `resume` behavior:**
|
145
|
+
- If no notes are provided, it will attempt to retrieve them from the last tracked task.
|
146
|
+
- **Enhanced `export_sheet` functionality:**
|
147
|
+
- A new `notes` column has been added to the exported CSV file.
|
148
|
+
- **Minor bug fixes:**
|
149
|
+
- Resolved issues related to resuming tasks with notes and deleting items.
|
111
150
|
|
112
151
|
## [0.2.0] - 2024-09-24
|
113
152
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
153
|
+
- **Improved code quality:**
|
154
|
+
- Enforces consistent quoting style with `RuboCop` integration.
|
155
|
+
- Removes unused gems (`mini_portile2`) from the `Gemfile`.
|
156
|
+
- **Database enhancements:**
|
157
|
+
- Adds a new column named "notes" to the `items` table to store additional information about tracked time entries.
|
158
|
+
- **Command-line improvements:**
|
159
|
+
- Allows adding notes to a new time entry using the `start` command with the `--notes` option (e.g., `timet start work --notes="meeting with client"`).
|
160
|
+
- Improves formatting and clarity of some command descriptions.
|
161
|
+
- **General code formatting:**
|
162
|
+
- Uses single quotes (`'`) for strings and source paths in the `Gemfile`.
|
124
163
|
|
125
164
|
## [0.1.0] - 2024-08-01
|
126
165
|
|
data/README.md
CHANGED
@@ -150,6 +150,25 @@ gem install timet
|
|
150
150
|
| `timet delete [id]` | Delete a task by its ID. | `timet d [id]` |
|
151
151
|
| `timet cancel` | Cancel active time tracking. | `timet c` |
|
152
152
|
| `timet edit [id]` | Update a task's notes, tag, start or end fields. | `timet e [1]` |
|
153
|
+
| `timet su [date]` | Display a report of tracked time for a specific date. | `timet su 2024-01-03` |
|
154
|
+
| `timet su [start_date]..[end_date]` | Display a report of tracked time for a date range. | `timet su 2024-01-02..2024-01-03` |
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
### Date Range in Summary
|
159
|
+
|
160
|
+
The `timet summary` command now supports specifying a date range for generating reports. This allows users to filter and summarize data within specific date intervals. The date format is in ISO 8601 format (YYYY-MM-DD).
|
161
|
+
|
162
|
+
#### Examples:
|
163
|
+
- **Single Date**: Display a report for a specific date.
|
164
|
+
```sh
|
165
|
+
timet su 2024-01-03
|
166
|
+
```
|
167
|
+
|
168
|
+
- **Date Range**: Display a report for a date range.
|
169
|
+
```sh
|
170
|
+
timet su 2024-01-02..2024-01-03
|
171
|
+
```
|
153
172
|
|
154
173
|
|
155
174
|
## Data
|
data/lib/timet/application.rb
CHANGED
@@ -22,7 +22,7 @@ module Timet
|
|
22
22
|
|
23
23
|
def initialize(*args)
|
24
24
|
super
|
25
|
-
@db =
|
25
|
+
@db = Database.new
|
26
26
|
end
|
27
27
|
|
28
28
|
FIELD_INDEX = {
|
@@ -34,7 +34,7 @@ module Timet
|
|
34
34
|
|
35
35
|
VALID_STATUSES_FOR_INSERTION = %i[no_items complete].freeze
|
36
36
|
|
37
|
-
desc "start [tag] --notes='
|
37
|
+
desc "start [tag] --notes=''", "start time tracking --notes='my notes...'"
|
38
38
|
option :notes, type: :string, desc: 'Add a note'
|
39
39
|
def start(tag, notes = nil)
|
40
40
|
start_time = TimeHelper.current_timestamp
|
@@ -46,8 +46,10 @@ module Timet
|
|
46
46
|
|
47
47
|
desc 'stop', 'stop time tracking'
|
48
48
|
def stop
|
49
|
-
|
50
|
-
|
49
|
+
if @db.last_item_status == :in_progress
|
50
|
+
last_id = @db.fetch_last_id
|
51
|
+
@db.update_item(last_id, 'end', TimeHelper.current_timestamp)
|
52
|
+
end
|
51
53
|
result = @db.last_item
|
52
54
|
|
53
55
|
return unless result
|
@@ -73,16 +75,17 @@ module Timet
|
|
73
75
|
end
|
74
76
|
|
75
77
|
desc 'summary (su) [filter] [tag] --csv=csv_filename',
|
76
|
-
|
77
|
-
and export to csv_filename"
|
78
|
+
' [filter] => [today (t), yesterday (y), week (w), month (m), [start_date]..[end_date]] [tag]'
|
78
79
|
option :csv, type: :string, desc: 'Export to CSV file'
|
79
80
|
def summary(filter = nil, tag = nil)
|
80
|
-
csv_filename = options[:csv]
|
81
|
+
csv_filename = options[:csv]&.split('.')&.first
|
81
82
|
summary = TimeReport.new(@db, filter, tag, csv_filename)
|
83
|
+
|
82
84
|
summary.display
|
83
|
-
|
85
|
+
items = summary.items
|
86
|
+
if csv_filename && items.any?
|
84
87
|
summary.export_sheet
|
85
|
-
elsif
|
88
|
+
elsif items.empty?
|
86
89
|
puts 'No items found to export'
|
87
90
|
end
|
88
91
|
end
|
@@ -99,9 +102,8 @@ module Timet
|
|
99
102
|
new_value = prompt_for_new_value(item, field)
|
100
103
|
end
|
101
104
|
|
102
|
-
validate_and_update(item, field, new_value)
|
103
|
-
|
104
|
-
summary.display
|
105
|
+
updated_item = validate_and_update(item, field, new_value)
|
106
|
+
display_item(updated_item)
|
105
107
|
end
|
106
108
|
|
107
109
|
desc 'delete (d) [id]', 'delete a task'
|
data/lib/timet/database.rb
CHANGED
@@ -42,24 +42,16 @@ module Timet
|
|
42
42
|
execute_sql('INSERT INTO items (start, tag, notes) VALUES (?, ?, ?)', [start, tag, notes])
|
43
43
|
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
last_id = fetch_last_id
|
48
|
-
return unless last_id
|
45
|
+
def update_item(id, field, value)
|
46
|
+
return if %w[start end].include?(field) && value.nil?
|
49
47
|
|
50
|
-
execute_sql(
|
48
|
+
execute_sql("UPDATE items SET #{field}='#{value}' WHERE id = #{id}")
|
51
49
|
end
|
52
50
|
|
53
51
|
def delete_item(id)
|
54
52
|
execute_sql("DELETE FROM items WHERE id = #{id}")
|
55
53
|
end
|
56
54
|
|
57
|
-
def update_item(id, field, value)
|
58
|
-
return if %w[start end].include?(field) && value.nil?
|
59
|
-
|
60
|
-
execute_sql("UPDATE items SET #{field}='#{value}' WHERE id = #{id}")
|
61
|
-
end
|
62
|
-
|
63
55
|
# Fetches the ID of the last inserted item
|
64
56
|
def fetch_last_id
|
65
57
|
result = execute_sql('SELECT id FROM items ORDER BY id DESC LIMIT 1').first
|
@@ -79,18 +71,6 @@ module Timet
|
|
79
71
|
execute_sql("select * from items where id=#{id}").first
|
80
72
|
end
|
81
73
|
|
82
|
-
# Calculates the total time elapsed since the last recorded time.
|
83
|
-
def total_time
|
84
|
-
last_item = execute_sql('SELECT * FROM items ORDER BY id DESC LIMIT 1').first
|
85
|
-
return '00:00:00' unless last_item
|
86
|
-
|
87
|
-
start_time = last_item[1]
|
88
|
-
end_time = last_item[2]
|
89
|
-
|
90
|
-
total_seconds = end_time ? end_time - start_time : TimeHelper.current_timestamp - start_time
|
91
|
-
seconds_to_hms(total_seconds)
|
92
|
-
end
|
93
|
-
|
94
74
|
def all_items
|
95
75
|
execute_sql("SELECT * FROM items where start >= '#{Date.today.to_time.to_i}' ORDER BY id DESC")
|
96
76
|
end
|
data/lib/timet/time_helper.rb
CHANGED
data/lib/timet/time_report.rb
CHANGED
@@ -92,6 +92,9 @@ module Timet
|
|
92
92
|
if date_ranges.key?(filter)
|
93
93
|
start_date, end_date = date_ranges[filter]
|
94
94
|
filter_by_date_range(start_date, end_date, tag)
|
95
|
+
elsif valid_date_format?(filter)
|
96
|
+
start_date, end_date = filter.split('..').map { |x| Date.parse(x) }
|
97
|
+
filter_by_date_range(start_date, end_date, tag)
|
95
98
|
else
|
96
99
|
puts 'Invalid filter. Supported filters: today, yesterday, week, month'
|
97
100
|
[]
|
@@ -118,12 +121,27 @@ module Timet
|
|
118
121
|
end
|
119
122
|
|
120
123
|
def formatted_filter(filter)
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
124
|
+
filter_map = {
|
125
|
+
'today' => %w[today t],
|
126
|
+
'yesterday' => %w[yesterday y],
|
127
|
+
'week' => %w[week w],
|
128
|
+
'month' => %w[month m]
|
129
|
+
}
|
130
|
+
|
131
|
+
filter_map.each do |key, values|
|
132
|
+
return key if values.include?(filter)
|
133
|
+
end
|
134
|
+
|
135
|
+
return filter if filter && valid_date_format?(filter)
|
125
136
|
|
126
137
|
'today'
|
127
138
|
end
|
139
|
+
|
140
|
+
def valid_date_format?(date_string)
|
141
|
+
date_format_single = /^\d{4}-\d{2}-\d{2}$/
|
142
|
+
date_format_range = /^\d{4}-\d{2}-\d{2}\.\.\d{4}-\d{2}-\d{2}$/
|
143
|
+
|
144
|
+
date_string.match?(date_format_single) || date_string.match?(date_format_range)
|
145
|
+
end
|
128
146
|
end
|
129
147
|
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: 0.
|
4
|
+
version: 0.9.0
|
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-10-
|
11
|
+
date: 2024-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -93,6 +93,7 @@ metadata:
|
|
93
93
|
homepage_uri: https://frankvielma.github.io/posts/timet-a-powerful-command-line-tool-for-tracking-your-time/
|
94
94
|
source_code_uri: https://github.com/frankvielma/timet
|
95
95
|
changelog_uri: https://github.com/frankvielma/timet/blob/main/CHANGELOG.md
|
96
|
+
documentation_uri: https://rubydoc.info/gems/timet
|
96
97
|
rubygems_mfa_required: 'true'
|
97
98
|
post_install_message:
|
98
99
|
rdoc_options: []
|