dsu 1.1.0.alpha.1 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0558e3688ef13d3969d4f42575742be25b847b18e822c7042ed2de38ff6450f
4
- data.tar.gz: f72bd36cb559f2f99ba51687ffa2d13cb56e94dfe64a80f2634d8ad727fb3531
3
+ metadata.gz: 01e8ee8331cd245ac664fd67acbc1cb3ffdab02f0693acdce44d73a9f9d7d161
4
+ data.tar.gz: 1e83c417a55ccffe97b616ac907264dd589da4bafc333ff572f44574b4a671c2
5
5
  SHA512:
6
- metadata.gz: bd93da3534ed0d6d11522a4a7e5b9adb9b4ec56eabc0633f5f314ccdaa900f98bb7f451bc86b083bd58b2aafe920ac214ce3b1bd4fee940713af39edcc09d9bd
7
- data.tar.gz: fe1c030e83a19732cabe66389f9849125e5c72e4e5f23a30de2d2cda3b0a01ed26d9fc63077b67c7e10e7b3f54a9c9ce4d4bf893c7ed432c7b0e1b6f1d62e469
6
+ metadata.gz: 0d3c6832cbbea8cc42aef3d947d6040963fb182318578bd98e52a6c2be435767fb2d0a1755927657068a74ebec88003fbfcc17108072a41d2aabc5b6dd3f507c
7
+ data.tar.gz: e0fc66db534b39c8fa72ef2bffaa49f3f3bcde9dc18d8facd5573462cf389188d3359f3501d11570529dd8ee1dee76b1c468ec6cb3aa3ec21ed44d26751d1b0c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.1.1] - 2023-05-23
2
+ * See previous alpha releases for changes.
3
+ ## [1.1.1.alpha.2] - 2023-05-23
4
+ * Changes
5
+ - For convenience, the `dsu list date` command now takes a MNEUMONIC in addition to a DATE. See `dsu list help date` for more information.
6
+ * Bug fixes
7
+ - 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
8
  ## [1.1.0.alpha.1] - 2023-05-23
2
9
  * Changes
3
10
  - 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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dsu (1.1.0.alpha.1)
4
+ dsu (1.1.1)
5
5
  activemodel (~> 7.0, >= 7.0.4.3)
6
6
  activesupport (~> 7.0, >= 7.0.4)
7
7
  colorize (~> 0.8.1)
data/lib/dsu/base_cli.rb CHANGED
@@ -31,7 +31,7 @@ module Dsu
31
31
 
32
32
  def date_option_description
33
33
  <<-OPTION_DESC
34
- DATE:
34
+ DATE
35
35
  \x5
36
36
  This may be any date string that can be parsed using `Time.parse`. Consequently, you may use also use '/' as date separators, as well as omit thee year if the date you want to display is the current year (e.g. <month>/<day>, or 1/31). For example: `require 'time'; Time.parse('01/02/2023'); Time.parse('1/2') # etc.`
37
37
  OPTION_DESC
@@ -39,9 +39,18 @@ module Dsu
39
39
 
40
40
  def mneumonic_option_description
41
41
  <<-OPTION_DESC
42
- MNEUMONIC:
42
+ MNEUMONIC
43
43
  \x5
44
- This may be any of the following: DATE (see DATE)|n|today|t|tomorrow|y|yesterday.
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
@@ -70,7 +70,6 @@ module Dsu
70
70
 
71
71
  Default: "'#{Dsu::Support::FolderLocations.root_folder}/dsu/entries'"
72
72
  LONG_DESC
73
-
74
73
  def init
75
74
  create_config_file!
76
75
  end
@@ -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
- Displays the DSU entries for DATE.
56
- \x5 #{date_option_description}
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(date)
59
- time = Time.parse(date)
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
@@ -75,18 +84,55 @@ module Dsu
75
84
  \x5
76
85
  `dsu dates|dd OPTIONS`
77
86
 
78
- OPTIONS:
87
+ OPTIONS
88
+ \x5
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
+
79
91
  \x5
80
- -f|--from DATE|MNEMONIC: ?.
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 = time_from_mneumonic(command_option: to_command_option) if time_mneumonic?(to_command_option)
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
- validate_argument!(command_option: relative_time, command_option_name: :relative_time)
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
- # if relative_time_mneumonic?(command_option) && !relative_time.nil?
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
- private
46
-
47
- # Returns a Time object from a mneumonic.
48
- def time_for_mneumonic(mneumonic:, relative_time: nil)
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
- # Simply return the time if relative_time is 'today'
62
- # because 'today' relative to any time will always
63
- # point to itself.
64
- return time if today_mneumonic?(relative_time)
45
+ mneumonic.match?(RELATIVE_REGEX)
46
+ end
65
47
 
66
- return time.public_send(relative_time)
67
- end
48
+ private
68
49
 
69
- time = ::Time.now
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)
@@ -91,14 +74,6 @@ module Dsu
91
74
  yesterday_mneumonic?(mneumonic)
92
75
  end
93
76
 
94
- # This method returns true if mneumonic is a valid relative
95
- # time mneumonic.
96
- def relative_time_mneumonic?(mneumonic)
97
- return false unless mneumonic.is_a?(String)
98
-
99
- mneumonic.match?(RELATIVE_REGEX)
100
- end
101
-
102
77
  def today_mneumonic?(mneumonic)
103
78
  TODAY.include?(mneumonic)
104
79
  end
data/lib/dsu/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dsu
4
- VERSION = '1.1.0.alpha.1'
4
+ VERSION = '1.1.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.alpha.1
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gene M. Angelo, Jr.
@@ -216,9 +216,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
216
216
  version: 3.0.1
217
217
  required_rubygems_version: !ruby/object:Gem::Requirement
218
218
  requirements:
219
- - - ">"
219
+ - - ">="
220
220
  - !ruby/object:Gem::Version
221
- version: 1.3.1
221
+ version: '0'
222
222
  requirements: []
223
223
  rubygems_version: 3.3.22
224
224
  signing_key: