dsu 0.1.0.alpha.1 → 0.1.0.alpha.3

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: 83344cb778f73a92d994326c2ed1e7b807f7cd76b2f8281e21a4595f5a8dda3e
4
- data.tar.gz: 0d4efd94ab1c8a8030e8ca91479c90102a298fd6562dd70defd76718459819a6
3
+ metadata.gz: abbd29418f4cd3c86a0e826ed9a43d7aba9e11d455c1fcd34024eeb6f1cff0b2
4
+ data.tar.gz: e99710491e91d8302582bec2e201244616a126d509e8915c57a5b13e54581418
5
5
  SHA512:
6
- metadata.gz: 45cddb27387615f47a8a251dffe678ef16119fb0c04b77eb1312d198f5559f877f20b5d761544995238813ea528548b355c66c5331b83751ea02e813ef79986c
7
- data.tar.gz: bb5b48f4df258847f54fa66df6f44d3bfbc143531b24bfff538edd48540e80e88a385eb3bdf7cd5c54ada859579ad93f7c61ae2f4e903c579c05b0a484c518c9
6
+ metadata.gz: 46bb2a7b817f6dcc413dbf343598dd9c016752eb84657f7b47c0bb19a923618c0e7ef0dc0e59f2a410808537ead6b26f2e647faabe93932c931cf1040be63acb
7
+ data.tar.gz: 348649411b52ed829e640e7c1e5a7d00c6df99bbaa80051a9f98176d34a0c078db4de035ba2a8137bb3295a57e5a500f223a3c7f7c7bf2868356bc226933467c
data/CHANGELOG.md CHANGED
@@ -1,2 +1,22 @@
1
+ ## [0.1.0.alpha.3] - 2023-05-09
2
+ * Changes
3
+ - Entry groups are now editable using the `dsu edit SUBCOMMAND` command. See the README.md or `dsu help edit` for more information.
4
+ - Added `editor` configuration option to specify the editor to use when editing an entry group. This configuration option is used if the $EDITOR environment variable is not set.
5
+ * Bug fixes
6
+ - Fix bug that failed to load default configuration values properly when provided (surfaced in specs).
7
+
8
+ ## [0.1.0.alpha.2] - 2023-05-08
9
+ * ATTENTION: After installing this pre-release, run `dsu config info` and take note of the `entries_folder` config option value (e.g. something like '/Users/<whoami>/dsu/entries' on a nix os). You'll need to delete the entry group files therein ( \<YYYY\>\-\<MM\>\-\<DD\>.json e.g. 2023-05-07.json) to avoid errors when running this version of `dsu`.
10
+ * WIP (not fully implemented yet)
11
+ - Added `dsu edit` command to edit an existing entry.
12
+ * Changes
13
+ - Remove Entry#long_description and make Entry#description longer (to 256 bytes max).
14
+ - Added `dsu` short-cut commands|options `a|-a`, `c|-c`, `e|-e` and `l|-l` for `add`, `config`, `edit` and `list` commands respectively. For example, can now do `dsu a` or `dsu -a` instead of `dsu add`.
15
+ - Added `dsu list` short-cut subcommand|options `d|-d`, `n|-n`, `t|-t` and `y|-y` for `date DATE`, `today`, `tomorrow` and `yesterday` subcommands respectively. For example, can now do `dsu n` or `dsu -n` instead of `dsu today` to list your DSU entries for "today".
16
+ - `dsu list` commands now lists all DSU entries from the date being requested (SUBCOMMAND i.e. `today`, `tomorrow`, `yesterday` or `date`), back to and including the previous Friday IF the date being being requested falls on a Monday or weekend. This is so that the DSU entries for the weekend and previous Friday can be shared at DSU if you hold a DSU on the weekend (if you're insane enough to work and have DSU on the weekend) or on a Monday if you happened to work on the weekend as well.
17
+ - `dsu config info` now displays the default configuration being used if no configuration file is being used.
18
+ * Bug fixes
19
+ - Fix bug that fails to load/use configuration file options when a config file exists.
20
+
1
21
  ## [0.1.0.alpha.1] - 2023-05-06
2
22
  - Initial (alpha) release. See README.md for instructions.
data/Gemfile CHANGED
@@ -5,12 +5,12 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in dsu.gemspec
6
6
  gemspec
7
7
 
8
+ gem 'dotenv', '~> 2.8', '>= 2.8.1'
8
9
  gem 'rake', '~> 13.0'
9
10
  gem 'rspec', '~> 3.0'
10
11
  gem 'rubocop', '~> 1.50', '>= 1.50.2'
11
12
  gem 'rubocop-performance', '~> 1.17', '>= 1.17.1'
12
13
  gem 'rubocop-rspec', '~> 2.20'
13
- gem 'dotenv', '~> 2.8', '>= 2.8.1'
14
14
 
15
15
  gem 'factory_bot', '~> 6.2', '>= 6.2.1'
16
16
  gem 'ffaker', '~> 2.21'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dsu (0.1.0.alpha.1)
4
+ dsu (0.1.0.alpha.3)
5
5
  activesupport (~> 7.0, >= 7.0.4)
6
6
  colorize (~> 0.8.1)
7
7
  deco_lite (~> 1.3)
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![License](http://img.shields.io/badge/license-MIT-yellowgreen.svg)](#license)
8
8
 
9
9
  ## About
10
- `dsu` is little gem that helps manage your Agile DSU (Daily Stand Up) participation. How? by providing a simple command line interface (CLI) which allows you to create, read, update, and delete (CRUD) noteworthy activities that you performed during your day. During your DSU, you can then easily recall and share these these activities with your team. Activities are grouped by day and can be viewed in simple text format from the command line. When viewing a particular day, dsu will automatically display the previous day's activities as well. This is useful for remembering what you did yesterday, so you can share your "Today" and "Yesterday" activities with your team during your DSU.
10
+ `dsu` is little gem that helps manage your Agile DSU (Daily Stand Up) participation. How? by providing a simple command line interface (CLI) which allows you to create, read, update, and delete (CRUD) noteworthy activities that you performed during your day. During your DSU, you can then easily recall and share these these activities with your team. Activities are grouped by day and can be viewed in simple text format from the command line. When viewing a particular day, `dsu` will automatically display the previous day's activities as well. This is useful for remembering what you did yesterday, so you can share your "Today" and "Yesterday" activities with your team during your DSU. If the day you are trying to view falls on a weekend or Monday, `dsu` will display back to, and including the weekend and previous Friday inclusive, so that you can share what you did over the weekend (if anything) and the previous Friday.
11
11
 
12
12
  **NOTE:** This gem is in development (alpha version). Please see the [WIP Notes](#wip-notes) section for current `dsu` features.
13
13
 
@@ -19,22 +19,21 @@ After installation (`gem install dsu`), the first thing you may want to do is ru
19
19
  ```shell
20
20
  #=>
21
21
  Commands:
22
- dsu --version, -v # Displays...
23
- dsu add [OPTIONS] DESCRIPTION [LONG-DESCRIPTION] # Adds a dsu entry...
24
- dsu config SUBCOMMAND # Manage...
25
- dsu help [COMMAND] # Describe...
26
- dsu today # Displays...
27
- dsu tomorrow # Displays...
28
- dsu yesterday # Displays...
22
+ dsu add, -a [OPTIONS] DESCRIPTION # Adds a DSU entry having DESCRIPTION to the date associated with the given OPTION
23
+ dsu config, -c SUBCOMMAND # Manage configuration...
24
+ dsu edit, -e SUBCOMMAND # Edit DSU entries...
25
+ dsu help [COMMAND] # Describe available...
26
+ dsu list, -l SUBCOMMAND # Displays DSU entries...
27
+ dsu version, -v # Displays this gem version
29
28
 
30
29
  Options:
31
30
  [--debug], [--no-debug]
32
31
  ```
33
32
 
34
- The next thing you may want to do is add some DSU activities (entries) for a particular day:
33
+ The next thing you may want to do is `add` some DSU activities (entries) for a particular day:
35
34
 
36
35
  ### Adding DSU Entries
37
- `dsu add [OPTIONS] DESCRIPTION [LONG-DESCRIPTION]`
36
+ `dsu add [OPTIONS] DESCRIPTION`
38
37
 
39
38
  Adding DSU entry using this command will _add_ the DSU entry for the given day (or date, `-d`), and also _display_ the given day's (or date's, `-d`) DSU entries, as well as the DSU entries for the previous day relative to the given day or date (`-d`).
40
39
 
@@ -58,18 +57,18 @@ If you need to add a DSU entry for a date other than yesterday, today or tomorro
58
57
 
59
58
  `$ dsu add -d "2022-12-31" "Attend company New Years Coffee Meet & Greet"`
60
59
 
61
- ### Display DSU Entries
62
- You can display DSU entries for a particular day or date (`date`) using any of the following commands. When displaying DSU entries for a particular day or date (`date`), `dsu` will display the given day or date's (`date`) DSU entries, as well as the DSU entries for the _previous_ day, relative to the given day or date (see [WIP Notes](#wip-notes) for caveats when displaying DSU entries for a particular day or date):
60
+ ### Displaying DSU Entries
61
+ You can display DSU entries for a particular day or date (`date`) using any of the following commands. When displaying DSU entries for a particular day or date (`date`), `dsu` will display the given day or date's (`date`) DSU entries, as well as the DSU entries for the _previous_ day, relative to the given day or date. If the date or day you are trying to view falls on a weekend or Monday, `dsu` will display back to, and including the weekend and previous Friday inclusive; this is so that you can share what you did over the weekend (if anything) and the previous Friday at your DSU:
63
62
 
64
- `dsu today`
65
- `dsu tomorrow`
66
- `dsu yesterday`
67
- `dsu date`
63
+ - `$ dsu list today|n`
64
+ - `$ dsu list tomorrow|t`
65
+ - `$ dsu list yesterday|y`
66
+ - `$ dsu list date|d DATE`
68
67
 
69
68
  #### Examples
70
69
  The following displays the entries for "Today", where `Time.now == '2023-05-06 08:54:57.6861 -0400'`
71
70
 
72
- `$ dsu today`
71
+ `$ dsu list today`
73
72
  ```shell
74
73
  #=>
75
74
  Saturday, (Today) 2023-05-06
@@ -81,7 +80,10 @@ Friday, (Yesterday) 2023-05-05
81
80
  2. f7d3018c Attend new hire meet & greet
82
81
  ```
83
82
 
84
- `$ dsu date "2023-05-06"`
83
+ `$ dsu list date "2023-05-06"`
84
+
85
+ Where DATE 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('2023-01-02'); Time.parse('1/2') # etc.`:
86
+
85
87
  ```shell
86
88
  #=>
87
89
  Saturday, (Today) 2023-05-06
@@ -92,14 +94,148 @@ Friday, (Yesterday) 2023-05-05
92
94
  1. edc25a9a Pick up ticket IN-12345
93
95
  2. f7d3018c Attend new hire meet & greet
94
96
  ```
97
+ ### Editing DSU Entries
95
98
 
99
+ You can edit DSU entry groups by date. `dsu` will allow you to edit a DSU entry group using the `dsu edit SUBCOMMAND` date (today|tomorrow|yesterday|date DATE) you specify. `dsu edit` will open your DSU entry group entries in your editor, where you'll be able to perform editing functions against one or all of the entries.
96
100
 
97
- ## WIP Notes
98
- This gem is in development (alpha release) and currently does not provide the ability to UPDATE or DELETE activities. These features will be added in future releases.
101
+ Note: See the "[Customizing the `dsu` Configuration File](#customizing-the-dsu-configuration-file)"" section to configure `dsu` to use the editor of your choice.
102
+
103
+ - `$ dsu edit today|n`
104
+ - `$ dsu edit tomorrow|t`
105
+ - `$ dsu edit yesterday|y`
106
+ - `$ dsu edit date|d DATE`
107
+
108
+ #### Examples
109
+
110
+ The following will edit your DSU entry group entries for "Today", where `Time.now == '2023-05-09 12:13:45.8273 -0400'`. Simply follow the directions in the editor file, then save and close your editor to apply the changes:
111
+
112
+ `$ dsu edit today`
113
+ `$ dsu e n`
114
+
115
+ ```shell
116
+ #=> In your editor, you will see...
117
+ # Editing DSU Entries for Tuesday, (Today) 2023-05-09 EDT
118
+
119
+ # [SHA/COMMAND] [DESCRIPTION]
120
+ 3849f0c0 Interative planning meeting 11:00AM.
121
+ 586478f5 Pair with Chad on ticket 31211.
122
+ 9e5f82c8 Investigate spike ticket 31255.
123
+ 59b25ca7 Review Kelsey's PR ticket 30721.
124
+
125
+ # INSTRUCTIONS:
126
+ # ADD a DSU entry: use one of the following commands: [+|a|add] followed by the description.
127
+ # EDIT a DSU entry: change the description.
128
+ # DELETE a DSU entry: delete the entry or replace the sha with one of the following commands: [-|d|delete].
129
+ # NOTE: deleting all the entries will delete the entry group file;
130
+ # this is preferable if this is what you want to do :)
131
+ # REORDER a DSU entry: reorder the DSU entries in order preference.
132
+ #
133
+ # *** When you are done, save and close your editor ***
134
+ ```
135
+
136
+ ##### Edit an Entry
137
+
138
+ Simply change the entry descripton text.
139
+
140
+ For example...
141
+ ```
142
+ from: 3849f0c0 Interative planning meeting 11:00AM.
143
+ to: 3849f0c0 Interative planning meeting 12:00AM.
144
+ ```
145
+
146
+ ##### Add an Entry
147
+
148
+ Replace the entry `sha` one of the add commands: `[+|a|add]`.
149
+
150
+ For example...
151
+ ```
152
+ + Add me to this entry group.
153
+ ```
154
+
155
+ ##### Delete an Entry
156
+
157
+ Simply delete the entry or replace the entry `sha` one of the delete commands: `[-|d|delete]`.
158
+
159
+ For example...
160
+ ```
161
+ # Delete this this entry from the editor file
162
+ 3849f0c0 Interative planning meeting 11:00AM.
163
+ ```
164
+ or
165
+ ```
166
+ from: 3849f0c0 Interative planning meeting 11:00AM.
167
+ to: - Interative planning meeting 11:00AM.
168
+ ```
169
+
170
+ ##### Reorder Entries
171
+
172
+ Simply reorder the entries in the editor.
173
+
174
+ For example...
175
+ ```
176
+ from: 3849f0c0 Interative planning meeting 11:00AM.
177
+ 586478f5 Pair with Chad on ticket 31211.
178
+ 9e5f82c8 Investigate spike ticket 31255.
179
+ 59b25ca7 Review Kelsey's PR ticket 30721.
180
+ to: 59b25ca7 Review Kelsey's PR ticket 30721.
181
+ 9e5f82c8 Investigate spike ticket 31255.
182
+ 586478f5 Pair with Chad on ticket 31211.
183
+ 3849f0c0 Interative planning meeting 11:00AM.
184
+ ```
185
+
186
+ ### Customizing the `dsu` Configuration File
187
+
188
+ It is **not** recommended that you create and customize a `dsu` configuration file while this gem is in alpha release. This is because changes to what configuration options are available may take place while in alpha that could break `dsu`. If you *do* want to create and customize the `dsu` configuration file reglardless, you may do the following.
189
+
190
+ #### Initializing/Customizing the `dsu` Configuration File
191
+
192
+ ```shell
193
+ # Creates a dsu configuration file in your home folder.
194
+ $ dsu config init
195
+
196
+ #=>
197
+ Configuration file (/Users/<whoami>/.dsu) created.
198
+ Config file (/Users/<whoami>/.dsu) contents:
199
+ ---
200
+ editor: nano
201
+ entries_display_order: desc
202
+ entries_file_name: "%Y-%m-%d.json"
203
+ entries_folder: "/Users/<whoami>/dsu/entries"
204
+ ```
99
205
 
100
- In addition to this...
206
+ Where `<whoami>` would be your username (`$ whoami` on nix systems)
101
207
 
102
- `dsu`'s current behavior when viewing a particular day is to display the _previous_ day's activities. This behavior is not necessarily ideal when sharing activities for a DSU that occurs on a Monday. This is because Monday's DSU typically includes sharing what you did on last FRIDAY (not necessarily "Yesterday"), as well as what you plan on doing "Today". This behavior will be changed in a future release to display the previous Friday's activities (as well as Saturday and Sunday) if "Today" happens to fall on a Monday.
208
+ Once the configuration file is created, you can locate where the `dsu` configuration file is located by running `$ dsu config info` and taking note of the confiruration file path. You may then edit this file using your favorite editor.
209
+
210
+ ##### Configuration File Options
211
+ ###### editor
212
+ This is the default editor to use when editing entry groups if the EDITOR environment variable on your system is not set.
213
+
214
+ Default: `nano` (you'll need to change the default editor on Windows systems)
215
+
216
+ ###### entries_display_order
217
+ Valid values are 'asc' and 'desc', and will sort listed DSU entries in ascending or descending order respectfully, by day.
218
+
219
+ Default: `'desc'`
220
+
221
+ ###### entries_file_name
222
+ The entries file name format. It is recommended that you do not change this. The file name must include `%Y`, `%m` and `%d` `Time` formatting specifiers to make sure the file name is unique and able to be located by `dsu` functions. For example, the default file name is `%Y-%m-%d.json`; however, something like `%m-%d-%Y.json` or `entry-group-%m-%d-%Y.json` would work as well.
223
+
224
+ ATTENTION: Please keep in mind that if you change this value `dsu` will not recognize entry files using a different format. You would (at this time), have to manually rename any existing entry file names to the new format.
225
+
226
+ Default: `'%Y-%m-%d.json'`
227
+
228
+ ###### entries_folder
229
+ This is the folder where `dsu` stores entry files. You may change this to anything you want. `dsu` will create this folder for you, as long as your system's write permissions allow this.
230
+
231
+ ATTENTION: Please keep in mind that if you change this value `dsu` will not be able to find entry files in any previous folder. You would (at this time), have to manually mode any existing entry files to this new folder.
232
+
233
+ Default: `'/Users/<whoami>/dsu/entries'` on nix systems.
234
+
235
+ Where `<whoami>` would be your username (`$ whoami` on nix systems)
236
+
237
+ ## WIP Notes
238
+ This gem is in development (alpha release).
103
239
 
104
240
  ## Installation
105
241
 
@@ -117,7 +253,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
117
253
 
118
254
  ## Contributing
119
255
 
120
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dsu. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/dsu/blob/main/CODE_OF_CONDUCT.md).
256
+ Bug reports and pull requests are welcome on GitHub at https://github.com/gangelo/dsu. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/dsu/blob/main/CODE_OF_CONDUCT.md).
121
257
 
122
258
  ## License
123
259
 
data/bin/console CHANGED
@@ -4,7 +4,6 @@
4
4
  require 'bundler/setup'
5
5
  require 'dsu'
6
6
 
7
-
8
7
  require 'pry-byebug'
9
8
 
10
9
  # So we can use FactoryBot in the console.
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler'
4
+ require 'thor'
5
+ require_relative 'command_services/add_entry_service'
6
+ require_relative 'models/entry_group'
7
+ require_relative 'services/configuration_loader_service'
8
+ require_relative 'services/entry_group_hydrator_service'
9
+ require_relative 'services/entry_group_reader_service'
10
+ require_relative 'support/colorable'
11
+ require_relative 'support/configuration'
12
+ require_relative 'support/entry_group_viewable'
13
+ require_relative 'support/times_sortable'
14
+ require_relative 'version'
15
+ require_relative 'views/entry_group/show'
16
+
17
+ module Dsu
18
+ #
19
+ # The `dsu` command.
20
+ #
21
+ class BaseCLI < ::Thor
22
+ include Support::Colorable
23
+ include Support::EntryGroupViewable
24
+ include Support::TimesSortable
25
+
26
+ class_option :debug, type: :boolean, default: false
27
+
28
+ default_command :help
29
+
30
+ class << self
31
+ def exit_on_failure?
32
+ false
33
+ end
34
+
35
+ def date_option_description
36
+ <<-DATE_OPTION_DESC
37
+ Where DATE 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('2023-01-02'); Time.parse('1/2') # etc.`
38
+ DATE_OPTION_DESC
39
+ end
40
+ end
41
+
42
+ def initialize(*args)
43
+ super
44
+
45
+ @configuration = Services::ConfigurationLoaderService.new.call
46
+ end
47
+
48
+ private
49
+
50
+ attr_reader :configuration
51
+
52
+ def sorted_dsu_times_for(times:)
53
+ times_sort(times: times_for(times: times), entries_display_order: entries_display_order)
54
+ end
55
+
56
+ def entries_display_order
57
+ @entries_display_order ||= configuration[:entries_display_order]
58
+ end
59
+ end
60
+ end
data/lib/dsu/cli.rb CHANGED
@@ -1,123 +1,79 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler'
4
- require 'thor'
5
- require_relative 'command_services/add_entry_service'
6
- require_relative 'models/entry_group'
7
- require_relative 'services/configuration_loader_service'
8
- require_relative 'services/entry_group_hydrator_service'
9
- require_relative 'services/entry_group_reader_service'
3
+ require 'time'
4
+ require_relative 'base_cli'
10
5
  require_relative 'subcommands/config'
11
- require_relative 'version'
12
- require_relative 'views/entry_group/show'
6
+ require_relative 'subcommands/edit'
7
+ require_relative 'subcommands/list'
13
8
 
14
9
  module Dsu
15
- #
16
10
  # The `dsu` command.
17
- #
18
- class CLI < ::Thor
19
- class_option :debug, type: :boolean, default: false
11
+ class CLI < BaseCLI
12
+ map %w[a -a] => :add
13
+ map %w[c -c] => :config
14
+ map %w[e -e] => :edit
15
+ map %w[l -l] => :list
16
+ map %w[v -v] => :version
17
+
18
+ desc 'add, -a [OPTIONS] DESCRIPTION',
19
+ 'Adds a DSU entry having DESCRIPTION to the date associated with the given OPTION'
20
+ long_desc <<-LONG_DESC
21
+ NAME
22
+ \x5
23
+ `DSU add, -a [OPTIONS] DESCRIPTION` -- will add a DSU entry having DESCRIPTION to the date associated with the given OPTION.
20
24
 
21
- map %w[--version -v] => :version
22
- # map %w[--interactive -i] => :interactive
25
+ SYNOPSIS
26
+ \x5
27
+ `dsu add, -a [-d DATE|-n|-t|-y] DESCRIPTION`
23
28
 
24
- default_command :help
29
+ OPTIONS:
30
+ \x5
31
+ -d DATE: Adds a DSU entry having DESCRIPTION to the DATE.
25
32
 
26
- class << self
27
- def exit_on_failure?
28
- false
29
- end
30
- end
33
+ \x5 #{date_option_description}
31
34
 
32
- def initialize(*args)
33
- super
35
+ \x5 -n: Adds a DSU entry having DESCRIPTION to today's date (`Time.now`).
34
36
 
35
- @configuration = Services::ConfigurationLoaderService.new.call
36
- end
37
+ \x5 -t: Adds a DSU entry having DESCRIPTION to tomorrow's date (`Time.new.tomorrow`).
38
+
39
+ \x5 -y: Adds a DSU entry having DESCRIPTION to yesterday's date (`Time.new.yesterday`).
37
40
 
38
- desc 'add [OPTIONS] DESCRIPTION [LONG-DESCRIPTION]',
39
- 'Adds a dsu entry for the date associated with the given option.'
40
- long_desc <<-LONG_DESC
41
- TBD
42
41
  LONG_DESC
43
42
  option :date, type: :string, aliases: '-d'
44
- option :next_day, type: :boolean, aliases: '-n'
45
- option :previous_day, type: :boolean, aliases: '-p'
46
- option :today, type: :boolean, aliases: '-t', default: true
47
-
48
- def add(description, long_description = nil)
49
- entry = Models::Entry.new(description: description, long_description: long_description)
50
- time = if options[:date].present?
51
- Time.parse(options[:date])
52
- elsif options[:next_day].present?
53
- 1.day.from_now
54
- elsif options[:previous_day].present?
55
- 1.day.ago
56
- elsif options[:today].present?
57
- Time.now
43
+ option :tomorrow, type: :boolean, aliases: '-t'
44
+ option :yesterday, type: :boolean, aliases: '-y'
45
+ option :today, type: :boolean, aliases: '-n', default: true
46
+
47
+ def add(description)
48
+ times = if options[:date].present?
49
+ time = Time.parse(options[:date])
50
+ [time, time.yesterday]
58
51
  else
59
- raise 'No date option specified.'
60
- end
61
- display_entry_group(time: 1.day.ago(time))
62
- puts
63
- CommandServices::AddEntryService.new(entry: entry, time: time).call
64
- display_entry_group(time: time)
65
- end
66
-
67
- desc 'today',
68
- 'Displays the dsu entries for today.'
69
- long_desc <<-LONG_DESC
70
- Displays the dsu entries for today. This command has no options.
71
- LONG_DESC
72
- def today
73
- time = Time.now
74
- sort_times(times: [1.day.ago(time), time]).each do |time| # rubocop:disable Lint/ShadowingOuterLocalVariable
75
- display_entry_group(time: time)
76
- puts
77
- end
78
- end
79
-
80
- desc 'tomorrow',
81
- 'Displays the dsu entries for tomorrow.'
82
- long_desc <<-LONG_DESC
83
- Displays the dsu entries for tomorrow. This command has no options.
84
- LONG_DESC
85
- def tomorrow
86
- time = Time.now
87
- sort_times(times: [1.day.from_now(time), time]).each do |time| # rubocop:disable Lint/ShadowingOuterLocalVariable
88
- display_entry_group(time: time)
89
- puts
52
+ time = Time.now
53
+ if options[:tomorrow].present?
54
+ [time.tomorrow, time.tomorrow.yesterday]
55
+ elsif options[:yesterday].present?
56
+ [time.yesterday, time.yesterday.yesterday]
57
+ elsif options[:today].present?
58
+ [time, time.yesterday]
59
+ end
90
60
  end
91
- end
92
-
93
- desc 'yesterday',
94
- 'Displays the dsu entries for yesterday.'
95
- long_desc <<-LONG_DESC
96
- Displays the dsu entries for yesterday. This command has no options.
97
- LONG_DESC
98
- def yesterday
99
- time = Time.now
100
- sort_times(times: [1.day.ago(time), 2.days.ago(time)]).each do |time| # rubocop:disable Lint/ShadowingOuterLocalVariable
101
- display_entry_group(time: time)
61
+ entry = Models::Entry.new(description: description)
62
+ # NOTE: We need to add the Entry to the date that is the furthest in the future
63
+ # (time.max) because this is the DSU entry that the user specified.
64
+ CommandServices::AddEntryService.new(entry: entry, time: times.max).call
65
+ sorted_dsu_times_for(times: times).each do |t|
66
+ view_entry_group(time: t)
102
67
  puts
103
68
  end
104
69
  end
105
70
 
106
- desc 'date',
107
- 'Displays the dsu entries for DATE.'
108
- long_desc <<-LONG_DESC
109
- Displays the dsu entries for DATE, where DATE is any date string that can be parsed using `Time.parse`. For example: `require 'time'; Time.parse("2023-01-01")`.
110
- LONG_DESC
111
- def date(date)
112
- time = Time.parse(date)
113
- sort_times(times: [1.day.ago(time), time]).each do |time| # rubocop:disable Lint/ShadowingOuterLocalVariable
114
- display_entry_group(time: time)
115
- puts
116
- end
117
- end
71
+ desc 'list, -l SUBCOMMAND',
72
+ 'Displays DSU entries for the given SUBCOMMAND'
73
+ subcommand :list, Subcommands::List
118
74
 
119
75
  # TODO: Implement this.
120
- # desc 'interactive', 'Opens a dsu interactive session'
76
+ # desc 'interactive', 'Opens a DSU interactive session'
121
77
  # long_desc ''
122
78
  # option :next_day, type: :boolean, aliases: '-n'
123
79
  # option :previous_day, type: :boolean, aliases: '-p'
@@ -135,44 +91,30 @@ module Dsu
135
91
  # say 'Done.'
136
92
  # end
137
93
 
138
- desc 'config SUBCOMMAND', 'Manage configuration file for this gem'
94
+ desc 'config, -c SUBCOMMAND',
95
+ 'Manage configuration file for this gem'
139
96
  subcommand :config, Subcommands::Config
140
97
 
141
- desc '--version, -v', 'Displays this gem version'
98
+ desc 'edit, -e SUBCOMMAND',
99
+ 'Edit DSU entries for the given SUBCOMMAND'
100
+ subcommand :edit, Subcommands::Edit
101
+
102
+ desc 'version, -v',
103
+ 'Displays this gem version'
142
104
  def version
143
105
  say VERSION
144
106
  end
145
107
 
146
108
  private
147
109
 
148
- attr_reader :configuration
149
-
150
110
  def display_interactive_help
151
111
  say 'Interactive Mode Commands:'
152
112
  say '---'
153
113
  say '[h]: show this help screen'
154
- say '[n]: next day'
155
- say '[p]: previous day'
156
- say '[t]: today'
114
+ say '[t]: next day'
115
+ say '[y]: previous day'
116
+ say '[n]: today'
157
117
  say '[x|q|exit|quit]: Exit interactive mode'
158
118
  end
159
-
160
- def display_entry_group(time:)
161
- entry_group = if Models::EntryGroup.exists?(time: time)
162
- entry_group_json = Services::EntryGroupReaderService.new(time: time).call
163
- Services::EntryGroupHydratorService.new(entry_group_json: entry_group_json).call
164
- else
165
- Models::EntryGroup.new(time: time)
166
- end
167
- Views::EntryGroup::Show.new(entry_group: entry_group).display
168
- end
169
-
170
- def sort_times(times:)
171
- if configuration[:entries_display_order] == 'asc'
172
- times.sort # sort ascending
173
- elsif configuration[:entries_display_order] == 'desc'
174
- times.sort.reverse # sort descending
175
- end
176
- end
177
119
  end
178
120
  end
@@ -11,21 +11,18 @@ module Dsu
11
11
  message: 'is the wrong format. ' \
12
12
  '0-9, a-f, and 8 characters were expected.' \
13
13
  }
14
- validates :description, presence: true, length: { minimum: 2, maximum: 80 }
15
- validates :long_description, length: { minimum: 2, maximum: 256 }, allow_nil: true
14
+ validates :description, presence: true, length: { minimum: 2, maximum: 256 }
16
15
 
17
- def initialize(description:, uuid: nil, long_description: nil)
16
+ def initialize(description:, uuid: nil)
18
17
  raise ArgumentError, 'description is nil' if description.nil?
19
18
  raise ArgumentError, 'description is the wrong object type' unless description.is_a?(String)
20
19
  raise ArgumentError, 'uuid is the wrong object type' unless uuid.is_a?(String) || uuid.nil?
21
- raise ArgumentError, 'long_description is the wrong object type' unless long_description.is_a?(String) || long_description.nil?
22
20
 
23
21
  uuid ||= SecureRandom.uuid[0..7]
24
22
 
25
23
  super(hash: {
26
24
  uuid: uuid,
27
- description: description,
28
- long_description: long_description
25
+ description: description
29
26
  })
30
27
  end
31
28
 
@@ -33,16 +30,10 @@ module Dsu
33
30
  %i[uuid description]
34
31
  end
35
32
 
36
- def long_description?
37
- long_description.present?
38
- end
39
-
40
33
  def ==(other)
41
34
  return false unless other.is_a?(Entry)
42
35
 
43
- uuid == other.uuid &&
44
- description == other.description &&
45
- long_description == other.long_description
36
+ uuid == other.uuid && description == other.description
46
37
  end
47
38
  end
48
39
  end