dsu 1.2.1 → 2.0.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +55 -21
  3. data/Gemfile.lock +7 -7
  4. data/README.md +28 -35
  5. data/bin/console +23 -1
  6. data/bin/dsu +3 -0
  7. data/bin/setup +14 -3
  8. data/exe/dsu +23 -1
  9. data/exe/dsu_migrate.rb +43 -0
  10. data/lib/core/ruby/color_theme_colors.rb +16 -0
  11. data/lib/core/ruby/color_theme_mode.rb +42 -0
  12. data/lib/core/ruby/not_today.rb +7 -0
  13. data/lib/core/ruby/wrap_and_join.rb +31 -0
  14. data/lib/dsu/base_cli.rb +19 -23
  15. data/lib/dsu/cli.rb +47 -37
  16. data/lib/dsu/command_services/add_entry_service.rb +10 -21
  17. data/lib/dsu/crud/json_file.rb +139 -0
  18. data/lib/dsu/crud/raw_json_file.rb +51 -0
  19. data/lib/dsu/env.rb +21 -0
  20. data/lib/dsu/migration/service.rb +196 -0
  21. data/lib/dsu/migration/version.rb +7 -0
  22. data/lib/dsu/models/color_theme.rb +270 -0
  23. data/lib/dsu/models/configuration.rb +160 -0
  24. data/lib/dsu/models/entry.rb +6 -2
  25. data/lib/dsu/models/entry_group.rb +143 -42
  26. data/lib/dsu/models/migration_version.rb +48 -0
  27. data/lib/dsu/presenters/base_presenter.rb +32 -0
  28. data/lib/dsu/presenters/color_theme_presenter.rb +50 -0
  29. data/lib/dsu/presenters/color_theme_show_presenter.rb +49 -0
  30. data/lib/dsu/presenters/configuration_presenter.rb +45 -0
  31. data/lib/dsu/presenters/entry_group_presenter.rb +35 -0
  32. data/lib/dsu/presenters/entry_presenter.rb +25 -0
  33. data/lib/dsu/services/color_theme/hydrator_service.rb +42 -0
  34. data/lib/dsu/services/configuration/hydrator_service.rb +42 -0
  35. data/lib/dsu/services/entry/hydrator_service.rb +33 -0
  36. data/lib/dsu/services/entry_group/editor_service.rb +107 -0
  37. data/lib/dsu/services/entry_group/hydrator_service.rb +37 -0
  38. data/lib/dsu/services/migration_version/hydrator_service.rb +36 -0
  39. data/lib/dsu/services/stderr_redirector_service.rb +27 -0
  40. data/lib/dsu/services/temp_file/reader_service.rb +33 -0
  41. data/lib/dsu/services/temp_file/writer_service.rb +35 -0
  42. data/lib/dsu/subcommands/base_subcommand.rb +14 -0
  43. data/lib/dsu/subcommands/config.rb +92 -32
  44. data/lib/dsu/subcommands/edit.rb +3 -3
  45. data/lib/dsu/subcommands/list.rb +70 -93
  46. data/lib/dsu/subcommands/theme.rb +159 -0
  47. data/lib/dsu/support/ask.rb +14 -19
  48. data/lib/dsu/support/color_themable.rb +34 -0
  49. data/lib/dsu/support/command_help_colorizeable.rb +27 -0
  50. data/lib/dsu/support/command_hookable.rb +60 -0
  51. data/lib/dsu/support/command_options/dsu_times.rb +32 -21
  52. data/lib/dsu/support/command_options/time.rb +7 -1
  53. data/lib/dsu/support/command_options/time_mneumonic.rb +7 -1
  54. data/lib/dsu/support/descriptable.rb +6 -4
  55. data/lib/dsu/support/entry_group_viewable.rb +28 -4
  56. data/lib/dsu/support/fileable.rb +94 -0
  57. data/lib/dsu/support/presentable.rb +11 -0
  58. data/lib/dsu/support/subcommand_help_colorizeable.rb +27 -0
  59. data/lib/dsu/support/time_comparable.rb +19 -0
  60. data/lib/dsu/support/time_formatable.rb +12 -0
  61. data/lib/dsu/support/times_sortable.rb +48 -14
  62. data/lib/dsu/support/utils.rb +11 -0
  63. data/lib/dsu/validators/color_theme_validator.rb +74 -0
  64. data/lib/dsu/validators/entries_validator.rb +4 -8
  65. data/lib/dsu/validators/version_validator.rb +29 -0
  66. data/lib/dsu/version.rb +2 -1
  67. data/lib/dsu/views/color_theme/index.rb +62 -0
  68. data/lib/dsu/views/color_theme/show.rb +106 -0
  69. data/lib/dsu/views/configuration/show.rb +41 -0
  70. data/lib/dsu/views/entry_group/edit.rb +3 -5
  71. data/lib/dsu/views/entry_group/shared/no_entries_to_display.rb +41 -0
  72. data/lib/dsu/views/entry_group/show.rb +16 -15
  73. data/lib/dsu/views/shared/error.rb +17 -0
  74. data/lib/dsu/views/shared/info.rb +17 -0
  75. data/lib/dsu/views/shared/message.rb +85 -0
  76. data/lib/dsu/views/shared/model_errors.rb +31 -0
  77. data/lib/dsu/views/shared/success.rb +17 -0
  78. data/lib/dsu/views/shared/warning.rb +17 -0
  79. data/lib/dsu.rb +22 -1
  80. data/lib/seed_data/themes/cherry.json +79 -0
  81. data/lib/seed_data/themes/default.json +79 -0
  82. data/lib/seed_data/themes/lemon.json +79 -0
  83. data/lib/seed_data/themes/matrix.json +79 -0
  84. data/lib/seed_data/themes/whiteout.json +79 -0
  85. metadata +70 -25
  86. data/lib/dsu/core/ruby/not_today.rb +0 -11
  87. data/lib/dsu/services/ai/tense_translator_service.rb +0 -63
  88. data/lib/dsu/services/configuration_loader_service.rb +0 -55
  89. data/lib/dsu/services/entry_group_deleter_service.rb +0 -31
  90. data/lib/dsu/services/entry_group_editor_service.rb +0 -96
  91. data/lib/dsu/services/entry_group_hydrator_service.rb +0 -43
  92. data/lib/dsu/services/entry_group_reader_service.rb +0 -36
  93. data/lib/dsu/services/entry_group_writer_service.rb +0 -46
  94. data/lib/dsu/services/entry_hydrator_service.rb +0 -35
  95. data/lib/dsu/services/temp_file_reader_service.rb +0 -31
  96. data/lib/dsu/services/temp_file_writer_service.rb +0 -33
  97. data/lib/dsu/support/colorable.rb +0 -14
  98. data/lib/dsu/support/configurable.rb +0 -15
  99. data/lib/dsu/support/configuration.rb +0 -112
  100. data/lib/dsu/support/entry_group_fileable.rb +0 -49
  101. data/lib/dsu/support/entry_group_loadable.rb +0 -49
  102. data/lib/dsu/support/folder_locations.rb +0 -21
  103. data/lib/dsu/support/say.rb +0 -40
  104. data/lib/dsu/views/edited_entries/shared/errors.rb +0 -39
  105. data/lib/dsu/views/shared/messages.rb +0 -56
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ce3877d498ca52f9395b713e062dd3448ef447028823b880d5a3e514009d8a9
4
- data.tar.gz: 3c3a7ea5fd481d5d1e2ff409a812d5581d779d9061c736a8bd1994276c67e343
3
+ metadata.gz: 86c89574cfe53ed9ee0769415f67b6eebc9d7d87c45cd7d5d706765983feecdc
4
+ data.tar.gz: 9bc71761a554f022605bed9891c251ed8df0ad2d9d2c920056a3c655b4cbfd25
5
5
  SHA512:
6
- metadata.gz: e25b5428fa6779df05b47b37323e5ae25ae776dfa9eb78463f79c2332d84e338b3f668f805ac5c9f24e5702db4d2802e46ee8439fa94d01ffafc6e15093f650a
7
- data.tar.gz: 46aa0bbd606a025f9ffc458c98cc59d0070caac1d89d73eafec90d57da7cc7aedc552ece986fbede7bf7f7977d9afbbd314027f61c371d637d5187ae2968cbd2
6
+ metadata.gz: 4edfddb2a4444d32156db40fe8151f28dd87f08d06ecfef37afd6d0dd7cbc93eee03ff7bcba4cbac420186ed4dfa866b9584875ebcff57ff87755eab8536cfcb
7
+ data.tar.gz: c2702a1537539c022adcd8a684868b5b64e8f4d0c583e81d11feae7eab126b73b3d4c80649b6cba746104a51d67973230b2b2f342374f2b9b796ab16251e347f
data/CHANGELOG.md CHANGED
@@ -1,30 +1,56 @@
1
+ ## 2.0.0.alpha.1 - 2023-08-16
2
+
3
+ - Changes
4
+ - Major refactors to the `dsu` codebase.
5
+ - Added `dsu theme` command to incorporate color themes. See `dsu help theme` for more information.
6
+ - Added `dsu info` command to display details about the current dsu release. See `dsu help info` for more information.
7
+ - Added "migrations", which is really a method of backup whereby user data is backed up to the dsu folder under `backup/<migration version>`. Backups will occur whenever a breaking change is made to any of the dsu models (ColorTheme, Configuration, EntryGroup or MigrationVersion). In this way, users can create their own scripts to migrate their associated model `.json`` files to the latest model version, and move them back into the appropriate dsu folder structure so data can be retained.
8
+ - Changes to command help to be more uniform.
9
+ - Bug fixes
10
+ - Various bug fixes.
11
+
12
+ ## 2.0.0.alpha.0 - 2023-06-26 (yanked)
13
+
1
14
  ## [1.2.1] 2023-06-02
2
- * Bug fixes
15
+
16
+ - Bug fixes
3
17
  - Fixed a bug that raises an error `NoMethodError` for `entry_group_file_exists?` if the `carry_over_entries_to_today` configuration option is set to true, and attempting to edit today's dsu entries.
18
+
4
19
  ## [1.2.0] 2023-05-26
5
- * Changes
20
+
21
+ - Changes
6
22
  - Various refactors.
7
23
  - Bring test coverage to >= 85%.
24
+
8
25
  ## [1.1.2] 2023-05-26
9
- * Changes
26
+
27
+ - Changes
10
28
  - Various refactors.
11
29
  - Add more test coverage.
30
+
12
31
  ## [1.1.1] - 2023-05-23
13
- * See previous alpha releases for changes.
32
+
33
+ - See previous alpha releases for changes.
34
+
14
35
  ## [1.1.1.alpha.2] - 2023-05-23
15
- * Changes
36
+
37
+ - Changes
16
38
  - For convenience, the `dsu list date` command now takes a MNEUMONIC in addition to a DATE. See `dsu list help date` for more information.
17
- * Bug fixes
39
+ - Bug fixes
18
40
  - 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).
41
+
19
42
  ## [1.1.0.alpha.1] - 2023-05-23
20
- * Changes
21
- - 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.
43
+
44
+ - Changes
45
+ - 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.
22
46
  - Added new configuration option `include_all` (`true|false`, default: `false`); if true, when using dsu commands that list date ranges (e.g. `dsu list dates`), the displayed list will include dates that have no dsu entries. If false, the displayed list will only include dates that have dsu entries. For all other `dsu list` commands, if true, this option will behave in the aforementioned manner. If false, the displayed list will unconditionally display the first and last dates regardless of whether or not the DSU date has entries or not; all other dates will not be displayed if the DSU date has no entries.
23
47
  - Changed the look of the editor template when editing entry group entries.
48
+
24
49
  ## [1.0.0] - 2023-05-18
25
- * First official release.
26
- * NOTE: If you have been using the alpha version of `dsu`, you will need to delete the `entries` folder (e.g. `/Users/<whoami>/dsu/entries` on a nix os) as the old entries .json files are incompatible with this official release.
27
- * Changes from the alpha version
50
+
51
+ - First official release.
52
+ - NOTE: If you have been using the alpha version of `dsu`, you will need to delete the `entries` folder (e.g. `/Users/<whoami>/dsu/entries` on a nix os) as the old entries .json files are incompatible with this official release.
53
+ - Changes from the alpha version
28
54
  - When editing an entry group, editor commands are no longer necessary. Simply add, remove or change entries as needed. See the README.md for more information.
29
55
  - When editing an entry group and saving the results, take note of the folowing behavior:
30
56
  - Entering duplicate entries are not allowed, only one entry with a given description is allowed per entry group.
@@ -32,34 +58,42 @@
32
58
  - When editing and encountering any of the aforementioned, the errors will be displayed to the console after the editor file is saved.
33
59
  - Sha's are no longer being used, as I've not found a good use (currently) to use them. I may add them back in the future if I find a good use for them (tracking entries across entry groups, etc.).
34
60
  - When adding an entry (`dsu add OPTION`), it used to be that after the entry was added, the entry group for the date being edited would be displayed, as well as "yesterday's" date. This is no longer the case; now, only the entry group for the date being edited is displayed.
61
+
35
62
  ## [0.1.0.alpha.5] - 2023-05-12
36
- * Changes
63
+
64
+ - Changes
37
65
  - `dsu edit SUBCOMMAND` will now allow editing of an entry group for a date that does not yet exist. This will allow you to add entries in the editor using `+|a|add DESCRIPTION`. Be sure to follow the instructions in the editor when editing entry group entries.
38
66
  - `dsu edit SUBCOMMAND` will gracefully display an error if the entry sha (Entry#uuid) or entry discription (Entry#description) are not unique. In this case, the entry will not be added to the entry group.
39
- NOTE: Not all edge cases are being handled currently by `dsu edit SUBCOMMAND`.
67
+ NOTE: Not all edge cases are being handled currently by `dsu edit SUBCOMMAND`.
40
68
  - `dsu add OPTION` will raise an error if the entry discription (Entry#description) are not unique. This will be handled gracefully in a future release.
69
+
41
70
  ## [0.1.0.alpha.4] - 2023-05-09
42
- * Changes
71
+
72
+ - Changes
43
73
  - Gemfile gemspec description changes.
74
+
44
75
  ## [0.1.0.alpha.3] - 2023-05-09
45
- * Changes
76
+
77
+ - Changes
46
78
  - Entry groups are now editable using the `dsu edit SUBCOMMAND` command. See the README.md or `dsu help edit` for more information.
47
79
  - 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.
48
- * Bug fixes
80
+ - Bug fixes
49
81
  - Fix bug that failed to load default configuration values properly when provided (surfaced in specs).
50
82
 
51
83
  ## [0.1.0.alpha.2] - 2023-05-08
52
- * 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`.
53
- * WIP (not fully implemented yet)
84
+
85
+ - 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`.
86
+ - WIP (not fully implemented yet)
54
87
  - Added `dsu edit` command to edit an existing entry.
55
- * Changes
88
+ - Changes
56
89
  - Remove Entry#long_description and make Entry#description longer (to 256 bytes max).
57
90
  - 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`.
58
- - 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".
91
+ - 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".
59
92
  - `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.
60
93
  - `dsu config info` now displays the default configuration being used if no configuration file is being used.
61
- * Bug fixes
94
+ - Bug fixes
62
95
  - Fix bug that fails to load/use configuration file options when a config file exists.
63
96
 
64
97
  ## [0.1.0.alpha.1] - 2023-05-06
98
+
65
99
  - Initial (alpha) release. See README.md for instructions.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dsu (1.2.1)
4
+ dsu (2.0.0.alpha.1)
5
5
  activemodel (~> 7.0, >= 7.0.4.3)
6
6
  activesupport (~> 7.0, >= 7.0.4)
7
7
  colorize (~> 0.8.1)
@@ -12,9 +12,9 @@ PATH
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- activemodel (7.0.4.3)
16
- activesupport (= 7.0.4.3)
17
- activesupport (7.0.4.3)
15
+ activemodel (7.0.5)
16
+ activesupport (= 7.0.5)
17
+ activesupport (7.0.5)
18
18
  concurrent-ruby (~> 1.0, >= 1.0.2)
19
19
  i18n (>= 1.6, < 2)
20
20
  minitest (>= 5.1)
@@ -30,7 +30,7 @@ GEM
30
30
  factory_bot (6.2.1)
31
31
  activesupport (>= 5.0.0)
32
32
  ffaker (2.21.0)
33
- i18n (1.13.0)
33
+ i18n (1.14.0)
34
34
  concurrent-ruby (~> 1.0)
35
35
  json (2.6.3)
36
36
  kwalify (0.7.2)
@@ -67,7 +67,7 @@ GEM
67
67
  diff-lcs (>= 1.2.0, < 2.0)
68
68
  rspec-support (~> 3.12.0)
69
69
  rspec-support (3.12.0)
70
- rubocop (1.51.0)
70
+ rubocop (1.52.0)
71
71
  json (~> 2.3)
72
72
  parallel (~> 1.10)
73
73
  parser (>= 3.2.0.0)
@@ -77,7 +77,7 @@ GEM
77
77
  rubocop-ast (>= 1.28.0, < 2.0)
78
78
  ruby-progressbar (~> 1.7)
79
79
  unicode-display_width (>= 2.4.0, < 3.0)
80
- rubocop-ast (1.28.1)
80
+ rubocop-ast (1.29.0)
81
81
  parser (>= 3.2.1.0)
82
82
  rubocop-capybara (2.18.0)
83
83
  rubocop (~> 1.41)
data/README.md CHANGED
@@ -23,7 +23,9 @@ Commands:
23
23
  dsu config, -c SUBCOMMAND # Manage configuration...
24
24
  dsu edit, -e SUBCOMMAND # Edit DSU entries...
25
25
  dsu help [COMMAND] # Describe available...
26
+ dsu info, -i # Displays information...
26
27
  dsu list, -l SUBCOMMAND # Displays DSU entries...
28
+ dsu theme, -t SUBCOMMAND # Manage DSU themes...
27
29
  dsu version, -v # Displays this gem version
28
30
 
29
31
  Options:
@@ -230,32 +232,36 @@ from: Interative planning meeting 11:00AM.
230
232
 
231
233
  ## Customizing the `dsu` Configuration File
232
234
 
233
- 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.
235
+ It is **not** recommended that you get too attached to the `dsu` configuration options when this gem is in pre-release (e.g. `n.n.n.alpha.n`, `n.n.n.beta.n`, etc.). This is because changes to the configuration file options could change; however, if you're curious, ambitious, or just like living on the edge, have at it. However, just keep in mind that things could change. With an official release (`n.n.n.n`), edit all you want. Regardless, if you *do* want to customize the `dsu` configuration file, you may do the following:
234
236
 
235
- ### Initializing/Customizing the `dsu` Configuration File
237
+ ### Customizing the `dsu` Configuration File
236
238
 
237
239
  ```shell
238
- # Creates a dsu configuration file in your home folder.
239
- $ dsu config init
240
-
240
+ # Locate the dsu configuration file in your home folder.
241
+ $ dsu config info
241
242
  #=>
242
- Configuration file (/Users/<whoami>/.dsu) created.
243
- Config file (/Users/<whoami>/.dsu) contents:
244
- ---
245
- editor: nano
246
- entries_display_order: desc
247
- entries_file_name: "%Y-%m-%d.json"
248
- entries_folder: "/Users/gangelo/dsu/entries"
249
- carry_over_entries_to_today: false
250
- include_all: false
243
+ Dsu v2.0.0
244
+
245
+ Configuration file contents (/Users/<whoami>/dsu/.dsu)
246
+ 1. version: '20230613121411'
247
+ 2. editor: 'nano'
248
+ 3. entries_display_order: 'desc'
249
+ 4. carry_over_entries_to_today: 'false'
250
+ 5. include_all: 'false'
251
+ 6. theme_name: 'default'
252
+ ___________________________________
253
+ Theme: default
251
254
  ```
252
255
 
253
256
  Where `<whoami>` would be your username (`$ whoami` on nix systems)
254
257
 
255
- 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.
258
+ Taking note of the confiruration file path above, you may then edit this file using your favorite editor.
256
259
 
257
260
  #### Configuration File Options
258
261
 
262
+ ##### version
263
+ _DO NOT_ edit this value. This value coincides with the `dsu` migration version and should not be edited.
264
+
259
265
  ##### editor
260
266
  This is the default editor to use when editing entry groups if the EDITOR environment variable on your system is not set.
261
267
 
@@ -266,31 +272,18 @@ Valid values are 'asc' and 'desc', and will sort listed DSU entries in ascending
266
272
 
267
273
  Default: `'desc'`
268
274
 
269
- ##### entries_file_name
270
- 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.
271
-
272
- 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.
273
-
274
- Default: `'%Y-%m-%d.json'`
275
-
276
- ##### entries_folder
277
- 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.
278
-
279
- 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.
280
-
281
- Default: `'/Users/<whoami>/dsu/entries'` on nix systems.
282
-
283
- Where `<whoami>` would be your username (`$ whoami` on nix systems)
284
-
285
275
  ##### carry_over_entries_to_today
286
- Applicable to the `dsu edit` command. Valid values are `true|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 into 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.
276
+ Applicable to the `dsu edit` command. Valid values are `true|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 into the current 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 provide no previous DSU entries.
287
277
 
288
- Default: false
278
+ Default: `false`
289
279
 
290
280
  ##### include_all
291
- Applicable to `dsu` commands that display DSU date lists (e.g. `dsu list` commands). Valid values are `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`.
281
+ Applicable to `dsu` commands that display DSU date lists (e.g. `dsu list` commands). Valid values are `true|false`. If `true`, all DSU dates within the specified range will be displayed, regardless of whether or not a particular date has entries. If `false`, only DSU dates between the first and last DSU dates that have entries *will be displayed*.
282
+
283
+ Default: `false`
292
284
 
293
- Default: false
285
+ ##### theme_name
286
+ Valid values are any theme names available as a result of running `dsu theme list`. For example: "cherry", default", "lemon", "matrix" and "whiteout".
294
287
 
295
288
  ## Dates
296
289
 
data/bin/console CHANGED
@@ -2,8 +2,14 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'bundler/setup'
5
- require 'dsu'
6
5
 
6
+ if File.exist?('.env.development')
7
+ # This loads our development environment when running dev.
8
+ require 'dotenv'
9
+ Dotenv.load('.env.development')
10
+ end
11
+
12
+ require 'dsu'
7
13
  require 'pry-byebug'
8
14
 
9
15
  # So we can use FactoryBot in the console.
@@ -11,4 +17,20 @@ require 'factory_bot'
11
17
  require 'ffaker'
12
18
  FactoryBot.find_definitions
13
19
 
20
+ if Dsu.env.development?
21
+ # This simply allows us to use a folder other than dsu folder for the production
22
+ # release, so we don't mess with our current production dsu folder.
23
+ module Dsu
24
+ module Support
25
+ module Fileable
26
+ def root_folder
27
+ File.join(gem_dir, '.development_home')
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ puts "ATTENTION: Dsu root folder is: #{Dsu::Support::Fileable.root_folder}!"
34
+ end
35
+
14
36
  Pry.start
data/bin/dsu ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env zsh
2
+
3
+ bundle exec exe/dsu "$@"
data/bin/setup CHANGED
@@ -1,8 +1,19 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
  IFS=$'\n\t'
4
- set -vx
4
+ # set -vx
5
5
 
6
- bundle install
6
+ # This makes sure all of the scripts we need to load are loaded from
7
+ # the executing script folder so they can be found
8
+ DIR="$( cd "$( dirname $0 )" >/dev/null 2>&1 && pwd )"
9
+ pushd $DIR >/dev/null 2>&1
10
+ ruby ./migrate
11
+ popd >/dev/null 2>&1
12
+
13
+ exit_code=$?
14
+ if [ $exit_code -ne 0 ]; then
15
+ exit $exit_code
16
+ fi
7
17
 
8
- # Do any other automated setup that you need to do here
18
+ set -vx
19
+ bundle install
data/exe/dsu CHANGED
@@ -6,6 +6,28 @@ require 'rubygems'
6
6
  lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
7
7
  $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
8
8
 
9
+ if File.exist?('.env.development')
10
+ # This loads our development environment when running dev.
11
+ require 'dotenv'
12
+ Dotenv.load('.env.development')
13
+ end
14
+
9
15
  require 'dsu'
10
16
 
11
- Dsu::CLI.start
17
+ if Dsu.env.development?
18
+ # This simply allows us to use a folder other than dsu folder for the production
19
+ # release, so we don't mess with our current production dsu folder.
20
+ module Dsu
21
+ module Support
22
+ module Fileable
23
+ def root_folder
24
+ File.join(gem_dir, '.development_home')
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ puts "ATTENTION: Dsu root folder is: #{Dsu::Support::Fileable.root_folder}!"
31
+ end
32
+
33
+ Dsu::CLI.start(ARGV)
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require 'bundler/setup'
6
+ # require 'highline'
7
+ require 'dsu'
8
+
9
+ # def run_migrations?
10
+ # puts '***********************************************'
11
+ # puts '*** Migrations are pending! ***'
12
+ # puts '*** This is a pre-release version of dsu. ***'
13
+ # puts '*** It is highly recommended you exit ***'
14
+ # puts '*** this installation! ***'
15
+ # puts '***********************************************'
16
+ # prompt = 'What do you want to do?' \
17
+ # "\n c = Continue (install and run migrations)." \
18
+ # "\n x = Exit (recommended)." \
19
+ # "\n> "
20
+ # input = HighLine.new.ask(prompt, String) do |question|
21
+ # question.default = 'x'
22
+ # question.readline = true
23
+ # question.in = %w[x c]
24
+ # end
25
+ # input == 'c'
26
+ # end
27
+
28
+ def run_migrations!
29
+ # return 1 unless run_migrations?
30
+
31
+ puts 'Running migrations...'
32
+ Dsu::Migration::Service.run_migrations!
33
+ 0
34
+ rescue StandardError => e
35
+ puts "Error running migrations: #{e.message}"
36
+ 1
37
+ end
38
+
39
+ if Dsu::Migration::Service.run_migrations?
40
+ exit run_migrations!
41
+ else
42
+ exit 0
43
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ColorThemeColors
4
+ DEFAULT_THEME_COLORS = { color: :default, mode: :default, background: :default }.freeze
5
+
6
+ # Ensures that default colors and mode are represented in the returned Hash.
7
+ def merge_default_colors
8
+ # TODO: Error checking.
9
+ DEFAULT_THEME_COLORS.merge(dup)
10
+ end
11
+
12
+ def merge_default_colors!
13
+ # TODO: Error checking.
14
+ merge!(merge_default_colors)
15
+ end
16
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ # TODO: Error checking.
4
+ # TODO: Keep <method>! (bang)?
5
+ module ColorThemeMode
6
+ def default!
7
+ dup.merge({ mode: :default })
8
+ end
9
+
10
+ def bold!
11
+ dup.merge({ mode: :bold })
12
+ end
13
+
14
+ def italic!
15
+ dup.merge({ mode: :italic })
16
+ end
17
+
18
+ def underline!
19
+ dup.merge({ mode: :underline })
20
+ end
21
+
22
+ def blink!
23
+ dup.merge({ mode: :blink })
24
+ end
25
+
26
+ def swap!
27
+ dup.merge({ mode: :swap })
28
+ end
29
+
30
+ def hide!
31
+ dup.merge({ mode: :hide })
32
+ end
33
+
34
+ def mode!(mode)
35
+ dup.merge({ mode: mode })
36
+ end
37
+
38
+ def light!
39
+ light_color = "light_#{self[:color].to_s.gsub('light_', '')}".to_sym
40
+ dup.merge({ color: light_color })
41
+ end
42
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NotToday
4
+ def not_today?
5
+ !today?
6
+ end
7
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WrapAndJoin
4
+ class << self
5
+ def included(base)
6
+ base.const_set(:WRAP_AND_JOIN_JOIN_TOKEN, ', ')
7
+ end
8
+ end
9
+
10
+ def wrap_and_join(wrapper: %w["], join: Array::WRAP_AND_JOIN_JOIN_TOKEN)
11
+ validate_wrapper!(wrapper)
12
+ validate_join!(join)
13
+
14
+ wrapper << wrapper.first if wrapper.count == 1
15
+ map { |element| "#{wrapper[0]}#{element}#{wrapper[1]}" }.join(join)
16
+ end
17
+
18
+ private
19
+
20
+ def validate_wrapper!(wrapper)
21
+ raise ArgumentError, 'wrapper is nil' if wrapper.nil?
22
+ raise ArgumentError, 'wrapper must be an Array' unless wrapper.is_a?(Array)
23
+ raise ArgumentError, 'wrapper must be an Array of 1 or 2 wrapper elements' unless wrapper.count.between?(1, 2)
24
+ end
25
+
26
+ def validate_join!(join)
27
+ return if join.nil?
28
+
29
+ raise ArgumentError, 'join must be a String' unless join.is_a?(String)
30
+ end
31
+ end
data/lib/dsu/base_cli.rb CHANGED
@@ -3,12 +3,13 @@
3
3
  require 'bundler'
4
4
  require 'thor'
5
5
  require_relative 'command_services/add_entry_service'
6
+ require_relative 'models/color_theme'
7
+ require_relative 'models/configuration'
6
8
  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'
9
+ require_relative 'services/stdout_redirector_service'
10
+ require_relative 'support/color_themable'
11
+ require_relative 'support/command_help_colorizeable'
12
+ require_relative 'support/command_hookable'
12
13
  require_relative 'support/entry_group_viewable'
13
14
  require_relative 'support/times_sortable'
14
15
  require_relative 'version'
@@ -16,7 +17,9 @@ require_relative 'views/entry_group/show'
16
17
 
17
18
  module Dsu
18
19
  class BaseCLI < ::Thor
19
- include Support::Colorable
20
+ include Support::ColorThemable
21
+ include Support::CommandHelpColorizable
22
+ include Support::CommandHookable
20
23
  include Support::EntryGroupViewable
21
24
  include Support::TimesSortable
22
25
 
@@ -24,6 +27,12 @@ module Dsu
24
27
 
25
28
  default_command :help
26
29
 
30
+ def initialize(*args)
31
+ super
32
+
33
+ @configuration = Models::Configuration.new
34
+ end
35
+
27
36
  class << self
28
37
  def exit_on_failure?
29
38
  false
@@ -32,7 +41,7 @@ module Dsu
32
41
  def date_option_description
33
42
  <<-OPTION_DESC
34
43
  DATE
35
- \x5
44
+
36
45
  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
46
  OPTION_DESC
38
47
  end
@@ -40,37 +49,24 @@ module Dsu
40
49
  def mneumonic_option_description
41
50
  <<-OPTION_DESC
42
51
  MNEUMONIC
43
- \x5
52
+
44
53
  This may be any of the following: n|today|t|tomorrow|y|yesterday|+n|-n.
45
54
 
46
- \x5
47
55
  Where n, t, y are aliases for today, tomorrow, and yesterday, respectively.
48
56
 
49
- \x5
50
57
  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
58
 
52
- \x5
53
59
  In some cases the behavior RDNs have on some commands are context dependent; in such cases the behavior will be noted.
54
60
  OPTION_DESC
55
61
  end
56
62
  end
57
63
 
58
- def initialize(*args)
59
- super
60
-
61
- @configuration = Services::ConfigurationLoaderService.new.call
62
- end
63
-
64
64
  private
65
65
 
66
66
  attr_reader :configuration
67
67
 
68
- def sorted_dsu_times_for(times:)
69
- times_sort(times: times_for(times: times), entries_display_order: entries_display_order)
70
- end
71
-
72
- def entries_display_order
73
- @entries_display_order ||= configuration[:entries_display_order]
68
+ def color_theme
69
+ Models::ColorTheme.current_or_default
74
70
  end
75
71
  end
76
72
  end