dsu 1.1.0.alpha.1 → 1.1.0.alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/lib/dsu/base_cli.rb +10 -1
- data/lib/dsu/subcommands/list.rb +54 -8
- data/lib/dsu/support/command_options/dsu_times.rb +5 -1
- data/lib/dsu/support/command_options/time_mneumonic.rb +13 -30
- data/lib/dsu/version.rb +1 -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: 3777862e1325eb15cbc55524b264de3bd503be3b551b8ed9dccbb913e4193dc8
|
4
|
+
data.tar.gz: 046f11a023fc2ade553fe962ec20a33e7ea72f9b03a8ad01917c5cc01ec6cd93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4dfa639c9749044a738e0584f7bd84baf7a7ae509db6a7bb0787fa2b3dd0c92a0deac2d15a15865fdce7d9bed6adfef57b2ce6d244f10864febfc1a6e0ec6957
|
7
|
+
data.tar.gz: 83aa24e6ee5178c4e4aaf5e4d3847c0b9e21ed498d7a0751e093d06f6acee84496ce2e40c3c89ca6c849336a6c9ec0a0e9c7fbbe8dd6b45092d37c63e5d828b5
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## [1.1.1.alpha.2] - 2023-05-23
|
2
|
+
* Changes
|
3
|
+
- For convenience, the `dsu list date` command now takes a MNEUMONIC in addition to a DATE. See `dsu list help date` for more information.
|
4
|
+
* Bug fixes
|
5
|
+
- Fix a bug that did not display `dsu list dates SUBCOMMAND` date list properly when the `--from` option was a date mneumonic and the `--to` optoin was a relative time mneumonic (e.g. `dsu list dates -f today -t +1`). In this case, DSU dates `Time.now` and `Time.now.tomorrow` should be displayed; instead, the bug would consider the `--to` option as relative to `Time.now`, so only 1 DSU date (`Time.now` would be returned).
|
1
6
|
## [1.1.0.alpha.1] - 2023-05-23
|
2
7
|
* Changes
|
3
8
|
- Added new configuration option `carry_over_entries_to_today` (`true|false`, default: `false`); if true, when editing DSU entries **for the first time** on any given day (e.g. `dsu edit today`), DSU entries from the previous day will be copied to the editing session. If there are no DSU entries from the previous day, `dsu` will search backwards up to 7 days to find a DSU date that has entries to copy. If after searching back 7 days, no DSU entries are found, the editor session will simply start with no previous DSU entries.
|
data/Gemfile.lock
CHANGED
data/lib/dsu/base_cli.rb
CHANGED
@@ -41,7 +41,16 @@ module Dsu
|
|
41
41
|
<<-OPTION_DESC
|
42
42
|
MNEUMONIC:
|
43
43
|
\x5
|
44
|
-
This may be any of the following:
|
44
|
+
This may be any of the following: n|today|t|tomorrow|y|yesterday|+n|-n.
|
45
|
+
|
46
|
+
\x5
|
47
|
+
Where n, t, y are aliases for today, tomorrow, and yesterday, respectively.
|
48
|
+
|
49
|
+
\x5
|
50
|
+
Where +n, -n are relative date mneumonics (RDNs). Generally speaking, RDNs are relative to the current date. For example, a RDN of +1 would be equal to `Time.now + 1.day` (tomorrow), and a RDN of -1 would be equal to `Time.now - 1.day` (yesterday).
|
51
|
+
|
52
|
+
\x5
|
53
|
+
In some cases the behavior RDNs have on some commands are context dependent; in such cases the behavior will be noted.
|
45
54
|
OPTION_DESC
|
46
55
|
end
|
47
56
|
end
|
data/lib/dsu/subcommands/list.rb
CHANGED
@@ -49,14 +49,23 @@ module Dsu
|
|
49
49
|
view_list_for(times: times)
|
50
50
|
end
|
51
51
|
|
52
|
-
desc 'date, d DATE',
|
53
|
-
'Displays the DSU entries for DATE'
|
52
|
+
desc 'date, d DATE|MNEUMONIC',
|
53
|
+
'Displays the DSU entries for the DATE or MNEUMONIC provided'
|
54
54
|
long_desc <<-LONG_DESC
|
55
|
-
|
56
|
-
|
55
|
+
Displays the DSU entries for the DATE or MNEUMONIC provided.
|
56
|
+
|
57
|
+
\x5
|
58
|
+
#{date_option_description}
|
59
|
+
|
60
|
+
\x5
|
61
|
+
#{mneumonic_option_description}
|
57
62
|
LONG_DESC
|
58
|
-
def date(
|
59
|
-
time =
|
63
|
+
def date(param)
|
64
|
+
time = if time_mneumonic?(param)
|
65
|
+
time_from_mneumonic(command_option: param)
|
66
|
+
else
|
67
|
+
Time.parse(param)
|
68
|
+
end
|
60
69
|
times = sorted_dsu_times_for(times: [time, time.yesterday])
|
61
70
|
view_list_for(times: times)
|
62
71
|
rescue ArgumentError => e
|
@@ -77,16 +86,53 @@ module Dsu
|
|
77
86
|
|
78
87
|
OPTIONS:
|
79
88
|
\x5
|
80
|
-
-
|
89
|
+
-a|--include-all true|false: If true, all DSU dates within the specified range will be displayed. If false, DSU dates between the first and last DSU dates that have NO entries will NOT be displayed.. The default is taken from the dsu configuration setting :include_all, see `dsu config info`.
|
90
|
+
|
91
|
+
\x5
|
92
|
+
-f|--from DATE|MNEMONIC: The DATE or MNEUMONIC that represents the start of the range of DSU dates to display. If a relative mneumonic is used (+/-n, e.g +1, -1, etc.), the date calculated will be relative to the current date (e.g. `<MNEUMONIC>.to_i.days.from_now(Time.now)`).
|
81
93
|
|
82
94
|
\x5
|
83
|
-
-t|--to DATE|MNEMONIC:
|
95
|
+
-t|--to DATE|MNEMONIC: The DATE or MNEUMONIC that represents the end of the range of DSU dates to display. If a relative mneumonic is used (+/-n, e.g +1, -1, etc.), the date calculated will be relative to the date that resulting from the `--from` option date calculation.
|
84
96
|
|
85
97
|
\x5
|
86
98
|
#{date_option_description}
|
87
99
|
|
88
100
|
\x5
|
89
101
|
#{mneumonic_option_description}
|
102
|
+
|
103
|
+
\x5
|
104
|
+
EXAMPLES
|
105
|
+
|
106
|
+
\x5
|
107
|
+
NOTE: All examples are subject to the `--include-all` option.
|
108
|
+
|
109
|
+
\x5
|
110
|
+
# The below will display the DSU entries for the range of dates from 1/1 to 1/4.
|
111
|
+
\x5`dsu list dates --from 1/1 --to +3`
|
112
|
+
|
113
|
+
\x5
|
114
|
+
# will display the DSU entries for the range of dates from 1/2 to 1/5.
|
115
|
+
\x5`dsu list dates --from 1/5 --to -3`
|
116
|
+
|
117
|
+
\x5
|
118
|
+
# (assuming "today" is 1/10) will display the DSU entries for the last week 1/10 to 1/3.
|
119
|
+
\x5`dsu list dates --from today --to -7`
|
120
|
+
|
121
|
+
\x5
|
122
|
+
# (assuming "today" is 5/23) will display the DSU entries for the last week 5/16 to 5/22.
|
123
|
+
#
|
124
|
+
# This example simply illustrates the fact that you can use relative mneumonics for
|
125
|
+
# both `--from` and `--to` options; this doesn't mean you should do so...
|
126
|
+
#
|
127
|
+
# While you can use relative mneumonics for both `--from` and `--to` options,
|
128
|
+
# there is always a more intuitive way. The below example basically lists one week
|
129
|
+
# of DSU entries back 1 week from yesterday's date:
|
130
|
+
\x5`dsu list dates --from -7 --to +6`
|
131
|
+
|
132
|
+
\x5
|
133
|
+
# This can MUCH easily be accomplished by simply using the `yesterday` mneumonic:
|
134
|
+
# (assuming "today" is 5/23) will display the DSU entries back 1 week from yesterday's date 5/16 to 5/22.
|
135
|
+
\x5`dsu list dates --from yesterday --to -6`
|
90
136
|
LONG_DESC
|
91
137
|
# -f, --from FROM [DATE|MNEMONIC] (e.g. -f, --from 1/1[/yyy]|n|t|y|today|tomorrow|yesterday)
|
92
138
|
option :from, type: :string, aliases: '-f', banner: 'DATE|MNEMONIC'
|
@@ -19,7 +19,11 @@ module Dsu
|
|
19
19
|
from_time = time_from_mneumonic(command_option: from_command_option) if time_mneumonic?(from_command_option)
|
20
20
|
from_time ||= time_from_date_string(command_option: from_command_option)
|
21
21
|
|
22
|
-
to_time =
|
22
|
+
to_time = if relative_time_mneumonic?(to_command_option)
|
23
|
+
time_from_mneumonic(command_option: to_command_option, relative_time: from_time)
|
24
|
+
elsif time_mneumonic?(to_command_option)
|
25
|
+
time_from_mneumonic(command_option: to_command_option)
|
26
|
+
end
|
23
27
|
to_time ||= time_from_date_string(command_option: to_command_option)
|
24
28
|
|
25
29
|
[from_time, to_time].sort
|
@@ -22,16 +22,11 @@ module Dsu
|
|
22
22
|
# a relative time mneumonic. Otherwise, it is optional.
|
23
23
|
def time_from_mneumonic!(command_option:, relative_time: nil)
|
24
24
|
validate_argument!(command_option: command_option, command_option_name: :command_option)
|
25
|
-
unless relative_time.nil?
|
26
|
-
|
25
|
+
unless relative_time.nil? || relative_time.is_a?(::Time)
|
26
|
+
raise ArgumentError, "relative_time is not a Time object: \"#{relative_time}\""
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
# # If command_option is a relative time mneumonic, we need to get the time
|
31
|
-
# # relative to relative_time using ::Time.now, and use the command_option
|
32
|
-
# # as the relative time.
|
33
|
-
# return time_from_mneumonic!(command_option: relative_time, relative_time: command_option)
|
34
|
-
# end
|
29
|
+
relative_time ||= ::Time.now
|
35
30
|
|
36
31
|
time_for_mneumonic(mneumonic: command_option, relative_time: relative_time)
|
37
32
|
end
|
@@ -42,31 +37,19 @@ module Dsu
|
|
42
37
|
mneumonic?(mneumonic) || relative_time_mneumonic?(mneumonic)
|
43
38
|
end
|
44
39
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
# If relative_time is a relative time mneumonic, then we need to first
|
50
|
-
# convert mneumonic to a Time object first, so that we can calculate
|
51
|
-
# `relative_time.to_i.days.from_now(time)` to get the correct Time we
|
52
|
-
# need.
|
53
|
-
if relative_time_mneumonic?(relative_time)
|
54
|
-
time = time_for_mneumonic(mneumonic: mneumonic)
|
55
|
-
return relative_time_for(days_from_now: relative_time, time: time)
|
56
|
-
end
|
57
|
-
|
58
|
-
if mneumonic?(mneumonic) && mneumonic?(relative_time)
|
59
|
-
time = time_for_mneumonic(mneumonic: mneumonic)
|
40
|
+
# This method returns true if mneumonic is a valid relative
|
41
|
+
# time mneumonic.
|
42
|
+
def relative_time_mneumonic?(mneumonic)
|
43
|
+
return false unless mneumonic.is_a?(String)
|
60
44
|
|
61
|
-
|
62
|
-
|
63
|
-
# point to itself.
|
64
|
-
return time if today_mneumonic?(relative_time)
|
45
|
+
mneumonic.match?(RELATIVE_REGEX)
|
46
|
+
end
|
65
47
|
|
66
|
-
|
67
|
-
end
|
48
|
+
private
|
68
49
|
|
69
|
-
|
50
|
+
# Returns a Time object from a mneumonic.
|
51
|
+
def time_for_mneumonic(mneumonic:, relative_time:)
|
52
|
+
time = relative_time
|
70
53
|
if today_mneumonic?(mneumonic)
|
71
54
|
time
|
72
55
|
elsif tomorrow_mneumonic?(mneumonic)
|
data/lib/dsu/version.rb
CHANGED