dsu 0.1.0.alpha.1 → 0.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 +13 -0
- data/Gemfile.lock +1 -1
- data/README.md +65 -23
- data/lib/dsu/base_cli.rb +60 -0
- data/lib/dsu/cli.rb +72 -121
- data/lib/dsu/models/entry.rb +4 -13
- data/lib/dsu/models/entry_group.rb +2 -0
- data/lib/dsu/services/configuration_loader_service.rb +14 -8
- data/lib/dsu/subcommands/edit.rb +95 -0
- data/lib/dsu/subcommands/list.rb +70 -0
- data/lib/dsu/support/configuration.rb +7 -1
- data/lib/dsu/support/entry_group_viewable.rb +19 -0
- data/lib/dsu/support/time_formatable.rb +8 -14
- data/lib/dsu/support/times_sortable.rb +40 -0
- data/lib/dsu/version.rb +1 -1
- data/lib/dsu/views/entry_group/edit.rb +63 -0
- data/lib/dsu/views/entry_group/show.rb +3 -7
- data/lib/dsu.rb +0 -28
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4558fb1982f908fef50a51ab4ed6351c3d3ae86c15eb4f7bd75bb34001cdf95
|
4
|
+
data.tar.gz: de047ffc2ebf972aec082ad886e1961d433f2e58e13bafeac85156ba6b91a936
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8e7e4af769b2290898c60147d02672b90e392ee612a553ade98d5cdb65f686bc9ed889746849deb912b18d7e25bbee150929f7e0917f62cfff9a6be51625fc9
|
7
|
+
data.tar.gz: b37d468fbef6a2038c4d92fa347dbfd333d3d8a661f43d57c4a66af42123c3e06e2aca1e6b9866a8ec00862cfe8c82846a488dc95bcc74fe02b3d3d1b3346a24
|
data/CHANGELOG.md
CHANGED
@@ -1,2 +1,15 @@
|
|
1
1
|
## [0.1.0.alpha.1] - 2023-05-06
|
2
2
|
- Initial (alpha) release. See README.md for instructions.
|
3
|
+
|
4
|
+
## [0.1.0.alpha.2] - 2023-05-08
|
5
|
+
* 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`.
|
6
|
+
* WIP (not fully implemented yet)
|
7
|
+
- Added `dsu edit` command to edit an existing entry.
|
8
|
+
* Changes
|
9
|
+
- Remove Entry#long_description and make Entry#description longer (to 256 bytes max).
|
10
|
+
- 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`.
|
11
|
+
- 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".
|
12
|
+
- `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.
|
13
|
+
- `dsu config info` now displays the default configuration being used if no configuration file is being used.
|
14
|
+
* Bug fixes
|
15
|
+
- Fix bug that fails to load/use configuration file options when a config file exists.
|
data/Gemfile.lock
CHANGED
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
|
23
|
-
dsu
|
24
|
-
dsu
|
25
|
-
dsu help [COMMAND]
|
26
|
-
dsu
|
27
|
-
dsu
|
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
|
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
|
-
###
|
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
|
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
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
@@ -93,13 +95,53 @@ Friday, (Yesterday) 2023-05-05
|
|
93
95
|
2. f7d3018c Attend new hire meet & greet
|
94
96
|
```
|
95
97
|
|
98
|
+
### Customizing the `dsu` Configuration File
|
96
99
|
|
97
|
-
|
98
|
-
|
100
|
+
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.
|
101
|
+
|
102
|
+
#### Initializing/Customizing the `dsu` Configuration File
|
103
|
+
|
104
|
+
```shell
|
105
|
+
# Creates a dsu configuration file in your home folder.
|
106
|
+
$ dsu config init
|
107
|
+
|
108
|
+
#=>
|
109
|
+
Configuration file (/Users/<whoami>/.dsu) created.
|
110
|
+
Config file (/Users/<whoami>/.dsu) contents:
|
111
|
+
---
|
112
|
+
entries_display_order: desc
|
113
|
+
entries_file_name: "%Y-%m-%d.json"
|
114
|
+
entries_folder: "/Users/<whoami>/dsu/entries"
|
115
|
+
```
|
116
|
+
|
117
|
+
Where `<whoami>` would be your username (`$ whoami` on nix systems)
|
99
118
|
|
100
|
-
|
119
|
+
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.
|
101
120
|
|
102
|
-
|
121
|
+
##### Configuration File Options
|
122
|
+
###### entries_display_order
|
123
|
+
Valid values are 'asc' and 'desc', and will sort listed DSU entries in ascending or descending order respectfully, by day.
|
124
|
+
|
125
|
+
Default: `'desc'`
|
126
|
+
|
127
|
+
###### entries_file_name
|
128
|
+
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.
|
129
|
+
|
130
|
+
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.
|
131
|
+
|
132
|
+
Default: `'%Y-%m-%d.json'`
|
133
|
+
|
134
|
+
###### entries_folder
|
135
|
+
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.
|
136
|
+
|
137
|
+
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.
|
138
|
+
|
139
|
+
Default: `'/Users/<whoami>/dsu/entries'` on nix systems.
|
140
|
+
|
141
|
+
Where `<whoami>` would be your username (`$ whoami` on nix systems)
|
142
|
+
|
143
|
+
## WIP Notes
|
144
|
+
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.
|
103
145
|
|
104
146
|
## Installation
|
105
147
|
|
@@ -117,7 +159,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
117
159
|
|
118
160
|
## Contributing
|
119
161
|
|
120
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
162
|
+
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
163
|
|
122
164
|
## License
|
123
165
|
|
data/lib/dsu/base_cli.rb
ADDED
@@ -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,88 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
|
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 '
|
12
|
-
require_relative '
|
6
|
+
require_relative 'subcommands/edit'
|
7
|
+
require_relative 'subcommands/list'
|
13
8
|
|
14
9
|
module Dsu
|
15
10
|
#
|
16
11
|
# The `dsu` command.
|
17
12
|
#
|
18
|
-
class CLI <
|
19
|
-
|
13
|
+
class CLI < BaseCLI
|
14
|
+
# map %w[add -a] => :add
|
15
|
+
# map %w[config -c] => :config
|
16
|
+
# map %w[edit -e] => :edit
|
17
|
+
# #map %w[help -h] => :help
|
18
|
+
# map %w[list -l] => :list
|
19
|
+
# map %w[version -v] => :version
|
20
|
+
|
21
|
+
map %w[a -a] => :add
|
22
|
+
map %w[c -c] => :config
|
23
|
+
map %w[e -e] => :edit
|
24
|
+
map %w[l -l] => :list
|
25
|
+
map %w[v -v] => :version
|
26
|
+
|
27
|
+
desc 'add, -a [OPTIONS] DESCRIPTION',
|
28
|
+
'Adds a DSU entry having DESCRIPTION to the date associated with the given OPTION'
|
29
|
+
long_desc <<-LONG_DESC
|
30
|
+
NAME
|
31
|
+
\x5
|
32
|
+
`DSU add, -a [OPTIONS] DESCRIPTION` -- will add a DSU entry having DESCRIPTION to the date associated with the given OPTION.
|
20
33
|
|
21
|
-
|
22
|
-
|
34
|
+
SYNOPSIS
|
35
|
+
\x5
|
36
|
+
`dsu add, -a [-d DATE|-n|-t|-y] DESCRIPTION`
|
23
37
|
|
24
|
-
|
38
|
+
OPTIONS:
|
39
|
+
\x5
|
40
|
+
-d DATE: Adds a DSU entry having DESCRIPTION to the DATE.
|
25
41
|
|
26
|
-
|
27
|
-
def exit_on_failure?
|
28
|
-
false
|
29
|
-
end
|
30
|
-
end
|
42
|
+
\x5 #{date_option_description}
|
31
43
|
|
32
|
-
|
33
|
-
super
|
44
|
+
\x5 -n: Adds a DSU entry having DESCRIPTION to today's date (`Time.now`).
|
34
45
|
|
35
|
-
|
36
|
-
|
46
|
+
\x5 -t: Adds a DSU entry having DESCRIPTION to tomorrow's date (`Time.new.tomorrow`).
|
47
|
+
|
48
|
+
\x5 -y: Adds a DSU entry having DESCRIPTION to yesterday's date (`Time.new.yesterday`).
|
37
49
|
|
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
50
|
LONG_DESC
|
43
51
|
option :date, type: :string, aliases: '-d'
|
44
|
-
option :
|
45
|
-
option :
|
46
|
-
option :today, type: :boolean, aliases: '-
|
47
|
-
|
48
|
-
def add(description
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
52
|
+
option :tomorrow, type: :boolean, aliases: '-t'
|
53
|
+
option :yesterday, type: :boolean, aliases: '-y'
|
54
|
+
option :today, type: :boolean, aliases: '-n', default: true
|
55
|
+
|
56
|
+
def add(description)
|
57
|
+
times = if options[:date].present?
|
58
|
+
time = Time.parse(options[:date])
|
59
|
+
[time, time.yesterday]
|
58
60
|
else
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
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
|
61
|
+
time = Time.now
|
62
|
+
if options[:tomorrow].present?
|
63
|
+
[time.tomorrow, time.tomorrow.yesterday]
|
64
|
+
elsif options[:yesterday].present?
|
65
|
+
[time.yesterday, time.yesterday.yesterday]
|
66
|
+
elsif options[:today].present?
|
67
|
+
[time, time.yesterday]
|
68
|
+
end
|
90
69
|
end
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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)
|
70
|
+
entry = Models::Entry.new(description: description)
|
71
|
+
# NOTE: We need to add the Entry to the date that is the furthest in the future
|
72
|
+
# (time.max) because this is the DSU entry that the user specified.
|
73
|
+
CommandServices::AddEntryService.new(entry: entry, time: times.max).call
|
74
|
+
sorted_dsu_times_for(times: times).each do |t|
|
75
|
+
view_entry_group(time: t)
|
102
76
|
puts
|
103
77
|
end
|
104
78
|
end
|
105
79
|
|
106
|
-
desc '
|
107
|
-
'Displays
|
108
|
-
|
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
|
80
|
+
desc 'list, -l SUBCOMMAND',
|
81
|
+
'Displays DSU entries for the given SUBCOMMAND'
|
82
|
+
subcommand :list, Subcommands::List
|
118
83
|
|
119
84
|
# TODO: Implement this.
|
120
|
-
# desc 'interactive', 'Opens a
|
85
|
+
# desc 'interactive', 'Opens a DSU interactive session'
|
121
86
|
# long_desc ''
|
122
87
|
# option :next_day, type: :boolean, aliases: '-n'
|
123
88
|
# option :previous_day, type: :boolean, aliases: '-p'
|
@@ -135,44 +100,30 @@ module Dsu
|
|
135
100
|
# say 'Done.'
|
136
101
|
# end
|
137
102
|
|
138
|
-
desc 'config SUBCOMMAND',
|
103
|
+
desc 'config, -c SUBCOMMAND',
|
104
|
+
'Manage configuration file for this gem'
|
139
105
|
subcommand :config, Subcommands::Config
|
140
106
|
|
141
|
-
desc '
|
107
|
+
desc 'edit, -e SUBCOMMAND',
|
108
|
+
'Edit DSU entries for the given SUBCOMMAND'
|
109
|
+
subcommand :edit, Subcommands::Edit
|
110
|
+
|
111
|
+
desc 'version, -v',
|
112
|
+
'Displays this gem version'
|
142
113
|
def version
|
143
114
|
say VERSION
|
144
115
|
end
|
145
116
|
|
146
117
|
private
|
147
118
|
|
148
|
-
attr_reader :configuration
|
149
|
-
|
150
119
|
def display_interactive_help
|
151
120
|
say 'Interactive Mode Commands:'
|
152
121
|
say '---'
|
153
122
|
say '[h]: show this help screen'
|
154
|
-
say '[
|
155
|
-
say '[
|
156
|
-
say '[
|
123
|
+
say '[t]: next day'
|
124
|
+
say '[y]: previous day'
|
125
|
+
say '[n]: today'
|
157
126
|
say '[x|q|exit|quit]: Exit interactive mode'
|
158
127
|
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
128
|
end
|
178
129
|
end
|
data/lib/dsu/models/entry.rb
CHANGED
@@ -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:
|
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
|
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
|
@@ -34,6 +34,8 @@ module Dsu
|
|
34
34
|
Dsu::Services::EntryGroupReaderService.entry_group_file_exists?(time: time)
|
35
35
|
end
|
36
36
|
|
37
|
+
# Loads the EntryGroup from the file system and returns an
|
38
|
+
# instantiated EntryGroup object.
|
37
39
|
def load(time: nil)
|
38
40
|
new(**hydrated_entry_group_hash_for(time: time))
|
39
41
|
end
|
@@ -11,23 +11,29 @@ module Dsu
|
|
11
11
|
|
12
12
|
attr_reader :default_options
|
13
13
|
|
14
|
-
def initialize(default_options:
|
15
|
-
|
14
|
+
def initialize(default_options: nil)
|
15
|
+
unless default_options.nil? ||
|
16
|
+
default_options.is_a?(Hash) ||
|
17
|
+
default_options.is_a?(ActiveSupport::HashWithIndifferentAccess)
|
18
|
+
raise ArgumentError, 'default_options must be a Hash'
|
19
|
+
end
|
20
|
+
|
21
|
+
@default_options = default_options || Support::Configuration::DEFAULT_DSU_OPTIONS
|
22
|
+
@default_options = @default_options.with_indifferent_access if @default_options.is_a?(Hash)
|
16
23
|
end
|
17
24
|
|
18
25
|
def call
|
19
|
-
|
26
|
+
return default_options unless config_file?
|
27
|
+
|
28
|
+
config_options.with_indifferent_access
|
20
29
|
end
|
21
30
|
|
22
31
|
private
|
23
32
|
|
24
33
|
attr_writer :default_options
|
25
34
|
|
26
|
-
def
|
27
|
-
|
28
|
-
|
29
|
-
yaml_options = File.read(config_file)
|
30
|
-
YAML.safe_load ERB.new(yaml_options).result
|
35
|
+
def config_options
|
36
|
+
@config_options ||= YAML.safe_load(ERB.new(File.read(config_file)).result)
|
31
37
|
end
|
32
38
|
end
|
33
39
|
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../base_cli'
|
4
|
+
require_relative '../models/entry_group'
|
5
|
+
require_relative '../support/time_formatable'
|
6
|
+
require_relative '../views/entry_group/edit'
|
7
|
+
|
8
|
+
module Dsu
|
9
|
+
module Subcommands
|
10
|
+
class Edit < Dsu::BaseCLI
|
11
|
+
include Support::TimeFormatable
|
12
|
+
|
13
|
+
map %w[d] => :date
|
14
|
+
map %w[n] => :today
|
15
|
+
map %w[t] => :tomorrow
|
16
|
+
map %w[y] => :yesterday
|
17
|
+
|
18
|
+
desc 'today, n',
|
19
|
+
'Edits the DSU entries for today.'
|
20
|
+
long_desc <<-LONG_DESC
|
21
|
+
Edits the DSU entries for today.
|
22
|
+
LONG_DESC
|
23
|
+
def today
|
24
|
+
edit_entry_group(time: Time.now)
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'tomorrow, t',
|
28
|
+
'Edits the DSU entries for tomorrow.'
|
29
|
+
long_desc <<-LONG_DESC
|
30
|
+
Edits the DSU entries for tomorrow.
|
31
|
+
LONG_DESC
|
32
|
+
def tomorrow
|
33
|
+
edit_entry_group(time: Time.now.tomorrow)
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'yesterday, y',
|
37
|
+
'Edits the DSU entries for yesterday.'
|
38
|
+
long_desc <<-LONG_DESC
|
39
|
+
Edits the DSU entries for yesterday.
|
40
|
+
LONG_DESC
|
41
|
+
def yesterday
|
42
|
+
edit_entry_group(time: Time.now.yesterday)
|
43
|
+
end
|
44
|
+
|
45
|
+
desc 'date, d DATE',
|
46
|
+
'Edits the DSU entries for DATE.'
|
47
|
+
long_desc <<-LONG_DESC
|
48
|
+
Edits the DSU entries for DATE.
|
49
|
+
|
50
|
+
\x5 #{date_option_description}
|
51
|
+
LONG_DESC
|
52
|
+
def date(date)
|
53
|
+
edit_entry_group(time: Time.parse(date))
|
54
|
+
rescue ArgumentError => e
|
55
|
+
say "Error: #{e.message}", ERROR
|
56
|
+
exit 1
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def edit_entry_group(time:)
|
62
|
+
formatted_time = formatted_time(time: time)
|
63
|
+
unless Models::EntryGroup.exists?(time: time)
|
64
|
+
say "No DSU entries exist for #{formatted_time}"
|
65
|
+
exit 1
|
66
|
+
end
|
67
|
+
|
68
|
+
say "Editing DSU entries for #{formatted_time}..."
|
69
|
+
entry_group = Models::EntryGroup.load(time: time)
|
70
|
+
# system("${EDITOR:-nano} #{file_path}")
|
71
|
+
|
72
|
+
output = capture_stdxxx do
|
73
|
+
Views::EntryGroup::Edit.new(entry_group: entry_group).render
|
74
|
+
end
|
75
|
+
say output, SUCCESS
|
76
|
+
end
|
77
|
+
|
78
|
+
# https://stackoverflow.com/questions/4459330/how-do-i-temporarily-redirect-stderr-in-ruby/4459463#4459463
|
79
|
+
def capture_stdxxx
|
80
|
+
# The output stream must be an IO-like object. In this case we capture it in
|
81
|
+
# an in-memory IO object so we can return the string value. You can assign any
|
82
|
+
# IO object here.
|
83
|
+
string_io = StringIO.new
|
84
|
+
prev_stdout, $stdout = $stdout, string_io # rubocop:disable Style/ParallelAssignment
|
85
|
+
prev_stderr, $stderr = $stderr, string_io # rubocop:disable Style/ParallelAssignment
|
86
|
+
yield
|
87
|
+
string_io.string
|
88
|
+
ensure
|
89
|
+
# Restore the previous value of stderr and stdout (typically equal to STDERR).
|
90
|
+
$stdout = prev_stdout
|
91
|
+
$stderr = prev_stderr
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../base_cli'
|
4
|
+
|
5
|
+
module Dsu
|
6
|
+
module Subcommands
|
7
|
+
class List < Dsu::BaseCLI
|
8
|
+
map %w[d] => :date
|
9
|
+
map %w[n] => :today
|
10
|
+
map %w[t] => :tomorrow
|
11
|
+
map %w[y] => :yesterday
|
12
|
+
|
13
|
+
desc 'today, n',
|
14
|
+
'Displays the DSU entries for today'
|
15
|
+
long_desc <<-LONG_DESC
|
16
|
+
Displays the DSU entries for today. This command has no options.
|
17
|
+
LONG_DESC
|
18
|
+
def today
|
19
|
+
time = Time.now
|
20
|
+
sorted_dsu_times_for(times: [time, time.yesterday]).each do |t|
|
21
|
+
view_entry_group(time: t)
|
22
|
+
puts
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'tomorrow, t',
|
27
|
+
'Displays the DSU entries for tomorrow'
|
28
|
+
long_desc <<-LONG_DESC
|
29
|
+
Displays the DSU entries for tomorrow. This command has no options.
|
30
|
+
LONG_DESC
|
31
|
+
def tomorrow
|
32
|
+
time = Time.now
|
33
|
+
sorted_dsu_times_for(times: [time.tomorrow, time]).each do |t|
|
34
|
+
view_entry_group(time: t)
|
35
|
+
puts
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'yesterday, y',
|
40
|
+
'Displays the DSU entries for yesterday'
|
41
|
+
long_desc <<-LONG_DESC
|
42
|
+
Displays the DSU entries for yesterday. This command has no options.
|
43
|
+
LONG_DESC
|
44
|
+
def yesterday
|
45
|
+
time = Time.now
|
46
|
+
sorted_dsu_times_for(times: [time.yesterday, time.yesterday.yesterday]).each do |t|
|
47
|
+
view_entry_group(time: t)
|
48
|
+
puts
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
desc 'date, d DATE',
|
53
|
+
'Displays the DSU entries for DATE'
|
54
|
+
long_desc <<-LONG_DESC
|
55
|
+
Displays the DSU entries for DATE.
|
56
|
+
\x5 #{date_option_description}
|
57
|
+
LONG_DESC
|
58
|
+
def date(date)
|
59
|
+
time = Time.parse(date)
|
60
|
+
sorted_dsu_times_for(times: [time, time.yesterday]).each do |t|
|
61
|
+
view_entry_group(time: t)
|
62
|
+
puts
|
63
|
+
end
|
64
|
+
rescue ArgumentError => e
|
65
|
+
say "Error: #{e.message}", ERROR
|
66
|
+
exit 1
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -22,7 +22,7 @@ module Dsu
|
|
22
22
|
# asc or desc, ascending or descending, respectively.
|
23
23
|
'entries_display_order' => 'desc',
|
24
24
|
'entries_file_name' => '%Y-%m-%d.json',
|
25
|
-
'entries_folder' => "#{FolderLocations.root_folder}/dsu/entries"
|
25
|
+
'entries_folder' => "#{FolderLocations.root_folder}/dsu/entries"
|
26
26
|
}.freeze
|
27
27
|
# rubocop:enable Style/StringHashKeys
|
28
28
|
|
@@ -43,6 +43,7 @@ module Dsu
|
|
43
43
|
delete_config_file config_file: config_file
|
44
44
|
end
|
45
45
|
|
46
|
+
# TODO: Move this to a view (e.g. views/configuration/show.rb)
|
46
47
|
def print_config_file
|
47
48
|
if config_file?
|
48
49
|
say "Config file (#{config_file}) contents:", SUCCESS
|
@@ -50,6 +51,11 @@ module Dsu
|
|
50
51
|
say hash.to_yaml.gsub("\n-", "\n\n-"), SUCCESS
|
51
52
|
else
|
52
53
|
say "Config file (#{config_file}) does not exist.", WARNING
|
54
|
+
say ''
|
55
|
+
say 'The default configuration is being used:'
|
56
|
+
DEFAULT_DSU_OPTIONS.each_with_index do |config_entry, index|
|
57
|
+
say "#{index + 1}. #{config_entry[0]}: '#{config_entry[1]}'"
|
58
|
+
end
|
53
59
|
end
|
54
60
|
end
|
55
61
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dsu
|
4
|
+
module Support
|
5
|
+
module EntryGroupViewable
|
6
|
+
module_function
|
7
|
+
|
8
|
+
def view_entry_group(time:)
|
9
|
+
entry_group = if Models::EntryGroup.exists?(time: time)
|
10
|
+
entry_group_json = Services::EntryGroupReaderService.new(time: time).call
|
11
|
+
Services::EntryGroupHydratorService.new(entry_group_json: entry_group_json).call
|
12
|
+
else
|
13
|
+
Models::EntryGroup.new(time: time)
|
14
|
+
end
|
15
|
+
Views::EntryGroup::Show.new(entry_group: entry_group).render
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -13,29 +13,23 @@ module Dsu
|
|
13
13
|
def formatted_time(time:)
|
14
14
|
time = time.localtime if time.utc?
|
15
15
|
|
16
|
-
today_yesterday_or_tomorrow = if today?
|
16
|
+
today_yesterday_or_tomorrow = if time.today?
|
17
17
|
'Today'
|
18
|
-
elsif yesterday?
|
18
|
+
elsif time.yesterday?
|
19
19
|
'Yesterday'
|
20
|
-
elsif tomorrow?
|
20
|
+
elsif time.tomorrow?
|
21
21
|
'Tomorrow'
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
time_zone = timezone_for(time: time)
|
25
25
|
|
26
|
-
time.strftime("%A,
|
27
|
-
end
|
28
|
-
|
29
|
-
def today?(time:)
|
30
|
-
time.strftime('%Y%m%d') == Time.now.strftime('%Y%m%d')
|
31
|
-
end
|
26
|
+
return time.strftime("%A, %Y-%m-%d #{time_zone}") unless today_yesterday_or_tomorrow
|
32
27
|
|
33
|
-
|
34
|
-
time.strftime('%Y%m%d') == 1.day.ago(Time.now).strftime('%Y%m%d')
|
28
|
+
time.strftime("%A, (#{today_yesterday_or_tomorrow}) %Y-%m-%d #{time_zone}")
|
35
29
|
end
|
36
30
|
|
37
|
-
def
|
38
|
-
time.
|
31
|
+
def timezone_for(time:)
|
32
|
+
time.zone
|
39
33
|
end
|
40
34
|
end
|
41
35
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dsu
|
4
|
+
module Support
|
5
|
+
module TimesSortable
|
6
|
+
module_function
|
7
|
+
|
8
|
+
def times_sort(times:, entries_display_order: nil)
|
9
|
+
entries_display_order ||= 'asc'
|
10
|
+
unless %w[asc desc].include? entries_display_order
|
11
|
+
raise "Invalid entries_display_order: #{entries_display_order}"
|
12
|
+
end
|
13
|
+
|
14
|
+
if entries_display_order == 'asc'
|
15
|
+
times.sort # sort ascending
|
16
|
+
elsif entries_display_order == 'desc'
|
17
|
+
times.sort.reverse # sort descending
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def times_for(times:)
|
22
|
+
start_date = times.max
|
23
|
+
return times unless start_date.monday? || start_date.on_weekend?
|
24
|
+
|
25
|
+
# (0..3).map { |num| start_date - num.days }
|
26
|
+
# (start_date..-start_date.friday?).map { |time| time }
|
27
|
+
# (0..3).map { |num| start_date - num.days if start_date.on_weekend? || start_date.monday? }
|
28
|
+
# If the start_date is a weekend or a Monday, then we need to include
|
29
|
+
# start_date along with all the dates up to and including the previous
|
30
|
+
# Monday.
|
31
|
+
(0..3).filter_map do |num|
|
32
|
+
time = start_date - num.days
|
33
|
+
next unless time == start_date || time.on_weekend? || time.friday?
|
34
|
+
|
35
|
+
time
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/dsu/version.rb
CHANGED
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'time'
|
4
|
+
require 'active_support/core_ext/numeric/time'
|
5
|
+
require_relative '../../models/entry_group'
|
6
|
+
require_relative '../../support/colorable'
|
7
|
+
require_relative '../../support/say'
|
8
|
+
require_relative '../../support/time_formatable'
|
9
|
+
|
10
|
+
module Dsu
|
11
|
+
module Views
|
12
|
+
module EntryGroup
|
13
|
+
class Edit
|
14
|
+
include Support::Colorable
|
15
|
+
include Support::Say
|
16
|
+
include Support::TimeFormatable
|
17
|
+
|
18
|
+
def initialize(entry_group:, options: {})
|
19
|
+
raise ArgumentError, 'entry_group is nil' if entry_group.nil?
|
20
|
+
raise ArgumentError, 'entry_group is the wrong object type' unless entry_group.is_a?(Models::EntryGroup)
|
21
|
+
raise ArgumentError, 'options is nil' if options.nil?
|
22
|
+
raise ArgumentError, 'options is the wrong object type' unless options.is_a?(Hash)
|
23
|
+
|
24
|
+
@entry_group = entry_group
|
25
|
+
@options = options || {}
|
26
|
+
end
|
27
|
+
|
28
|
+
def call
|
29
|
+
# Just in case the entry group is invalid, we'll
|
30
|
+
# validate it before displaying it.
|
31
|
+
entry_group.validate!
|
32
|
+
render_entry_group!
|
33
|
+
rescue ActiveModel::ValidationError
|
34
|
+
puts "Error(s) encountered: #{entry_group.errors.full_messages}"
|
35
|
+
raise
|
36
|
+
end
|
37
|
+
alias render call
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
attr_reader :entry_group, :options
|
42
|
+
|
43
|
+
def render_entry_group!
|
44
|
+
say "# Editing DSU Entries for #{formatted_time(time: entry_group.time)}"
|
45
|
+
say('(no entries available for this day)') and return if entry_group.entries.empty?
|
46
|
+
|
47
|
+
say ''
|
48
|
+
|
49
|
+
entry_group.entries.each do |entry|
|
50
|
+
say "#{entry.uuid} #{entry.description}"
|
51
|
+
end
|
52
|
+
|
53
|
+
say ''
|
54
|
+
say '# To EDIT a DSU entry, change the description, then save and close your editor.'
|
55
|
+
say "# To DELETE a DSU entry, delete the entry or replace the sha with a 'd', " \
|
56
|
+
'then save and close your editor.'
|
57
|
+
say '# To REORDER a DSU entry, reorder the DSU entries in order preference, ' \
|
58
|
+
'then save and close your editor.'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -29,18 +29,18 @@ module Dsu
|
|
29
29
|
# Just in case the entry group is invalid, we'll
|
30
30
|
# validate it before displaying it.
|
31
31
|
entry_group.validate!
|
32
|
-
|
32
|
+
render_entry_group!
|
33
33
|
rescue ActiveModel::ValidationError
|
34
34
|
puts "Error(s) encountered: #{entry_group.errors.full_messages}"
|
35
35
|
raise
|
36
36
|
end
|
37
|
-
alias
|
37
|
+
alias render call
|
38
38
|
|
39
39
|
private
|
40
40
|
|
41
41
|
attr_reader :entry_group, :options
|
42
42
|
|
43
|
-
def
|
43
|
+
def render_entry_group!
|
44
44
|
say formatted_time(time: entry_group.time), HIGHLIGHT
|
45
45
|
say('(no entries available for this day)') and return if entry_group.entries.empty?
|
46
46
|
|
@@ -48,10 +48,6 @@ module Dsu
|
|
48
48
|
prefix = "#{format('%03s', index + 1)}. #{entry.uuid}"
|
49
49
|
description = colorize_string(string: entry.description, mode: :bold)
|
50
50
|
say "#{prefix} #{description}"
|
51
|
-
next unless entry.long_description?
|
52
|
-
|
53
|
-
long_description = colorize_string(string: entry.long_description, mode: :bold)
|
54
|
-
say "#{''.ljust(prefix.length)} #{long_description}"
|
55
51
|
end
|
56
52
|
end
|
57
53
|
end
|
data/lib/dsu.rb
CHANGED
@@ -5,34 +5,6 @@ require 'active_support/core_ext/object/blank'
|
|
5
5
|
require 'active_support/core_ext/hash/indifferent_access'
|
6
6
|
require 'active_support/core_ext/numeric/time'
|
7
7
|
|
8
|
-
# # Require relative all files under dsu/services folder (recursively)
|
9
|
-
# Dir.glob("#{__dir__}/dsu/services/**/*.rb").each do |file|
|
10
|
-
# require file
|
11
|
-
# end
|
12
|
-
|
13
|
-
# # Require relative all files under dsu/support folder (recursively)
|
14
|
-
# Dir.glob("#{__dir__}/dsu/support/**/*.rb").each do |file|
|
15
|
-
# require file
|
16
|
-
# end
|
17
|
-
|
18
|
-
# Dir.glob("#{__dir__}/dsu/validators/**/*.rb").each do |file|
|
19
|
-
# require file
|
20
|
-
# end
|
21
|
-
|
22
|
-
# [
|
23
|
-
# "#{__dir__}/dsu/services/**/*.rb"
|
24
|
-
# "#{__dir__}/dsu/support/**/*.rb",
|
25
|
-
# "#{__dir__}/dsu/validators/**/*.rb"
|
26
|
-
# ]
|
27
|
-
|
28
8
|
Dir.glob("#{__dir__}/dsu/**/*.rb").each do |file|
|
29
9
|
require file
|
30
10
|
end
|
31
|
-
|
32
|
-
require_relative 'dsu/cli'
|
33
|
-
require_relative 'dsu/version'
|
34
|
-
|
35
|
-
# The main namespace for this dsu gem.
|
36
|
-
module Dsu
|
37
|
-
# Your code goes here...
|
38
|
-
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dsu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.alpha.
|
4
|
+
version: 0.1.0.alpha.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gene M. Angelo, Jr.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -140,6 +140,7 @@ files:
|
|
140
140
|
- bin/setup
|
141
141
|
- exe/dsu
|
142
142
|
- lib/dsu.rb
|
143
|
+
- lib/dsu/base_cli.rb
|
143
144
|
- lib/dsu/cli.rb
|
144
145
|
- lib/dsu/command_services/add_entry_service.rb
|
145
146
|
- lib/dsu/models/entry.rb
|
@@ -151,6 +152,8 @@ files:
|
|
151
152
|
- lib/dsu/services/entry_group_writer_service.rb
|
152
153
|
- lib/dsu/services/entry_hydrator_service.rb
|
153
154
|
- lib/dsu/subcommands/config.rb
|
155
|
+
- lib/dsu/subcommands/edit.rb
|
156
|
+
- lib/dsu/subcommands/list.rb
|
154
157
|
- lib/dsu/support/ask.rb
|
155
158
|
- lib/dsu/support/colorable.rb
|
156
159
|
- lib/dsu/support/commander/command.rb
|
@@ -159,14 +162,17 @@ files:
|
|
159
162
|
- lib/dsu/support/configuration.rb
|
160
163
|
- lib/dsu/support/entry_group_fileable.rb
|
161
164
|
- lib/dsu/support/entry_group_loadable.rb
|
165
|
+
- lib/dsu/support/entry_group_viewable.rb
|
162
166
|
- lib/dsu/support/field_errors.rb
|
163
167
|
- lib/dsu/support/folder_locations.rb
|
164
168
|
- lib/dsu/support/interactive/cli.rb
|
165
169
|
- lib/dsu/support/say.rb
|
166
170
|
- lib/dsu/support/time_formatable.rb
|
171
|
+
- lib/dsu/support/times_sortable.rb
|
167
172
|
- lib/dsu/validators/entries_validator.rb
|
168
173
|
- lib/dsu/validators/time_validator.rb
|
169
174
|
- lib/dsu/version.rb
|
175
|
+
- lib/dsu/views/entry_group/edit.rb
|
170
176
|
- lib/dsu/views/entry_group/show.rb
|
171
177
|
- sig/dsu.rbs
|
172
178
|
homepage: https://github.com/gangelo/dsu
|