dsu 0.1.0.alpha.2 → 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: b4558fb1982f908fef50a51ab4ed6351c3d3ae86c15eb4f7bd75bb34001cdf95
4
- data.tar.gz: de047ffc2ebf972aec082ad886e1961d433f2e58e13bafeac85156ba6b91a936
3
+ metadata.gz: abbd29418f4cd3c86a0e826ed9a43d7aba9e11d455c1fcd34024eeb6f1cff0b2
4
+ data.tar.gz: e99710491e91d8302582bec2e201244616a126d509e8915c57a5b13e54581418
5
5
  SHA512:
6
- metadata.gz: e8e7e4af769b2290898c60147d02672b90e392ee612a553ade98d5cdb65f686bc9ed889746849deb912b18d7e25bbee150929f7e0917f62cfff9a6be51625fc9
7
- data.tar.gz: b37d468fbef6a2038c4d92fa347dbfd333d3d8a661f43d57c4a66af42123c3e06e2aca1e6b9866a8ec00862cfe8c82846a488dc95bcc74fe02b3d3d1b3346a24
6
+ metadata.gz: 46bb2a7b817f6dcc413dbf343598dd9c016752eb84657f7b47c0bb19a923618c0e7ef0dc0e59f2a410808537ead6b26f2e647faabe93932c931cf1040be63acb
7
+ data.tar.gz: 348649411b52ed829e640e7c1e5a7d00c6df99bbaa80051a9f98176d34a0c078db4de035ba2a8137bb3295a57e5a500f223a3c7f7c7bf2868356bc226933467c
data/CHANGELOG.md CHANGED
@@ -1,8 +1,12 @@
1
- ## [0.1.0.alpha.1] - 2023-05-06
2
- - Initial (alpha) release. See README.md for instructions.
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).
3
7
 
4
8
  ## [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`.
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`.
6
10
  * WIP (not fully implemented yet)
7
11
  - Added `dsu edit` command to edit an existing entry.
8
12
  * Changes
@@ -13,3 +17,6 @@
13
17
  - `dsu config info` now displays the default configuration being used if no configuration file is being used.
14
18
  * Bug fixes
15
19
  - Fix bug that fails to load/use configuration file options when a config file exists.
20
+
21
+ ## [0.1.0.alpha.1] - 2023-05-06
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.2)
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
@@ -94,6 +94,94 @@ Friday, (Yesterday) 2023-05-05
94
94
  1. edc25a9a Pick up ticket IN-12345
95
95
  2. f7d3018c Attend new hire meet & greet
96
96
  ```
97
+ ### Editing DSU Entries
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.
100
+
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
+ ```
97
185
 
98
186
  ### Customizing the `dsu` Configuration File
99
187
 
@@ -109,6 +197,7 @@ $ dsu config init
109
197
  Configuration file (/Users/<whoami>/.dsu) created.
110
198
  Config file (/Users/<whoami>/.dsu) contents:
111
199
  ---
200
+ editor: nano
112
201
  entries_display_order: desc
113
202
  entries_file_name: "%Y-%m-%d.json"
114
203
  entries_folder: "/Users/<whoami>/dsu/entries"
@@ -119,6 +208,11 @@ Where `<whoami>` would be your username (`$ whoami` on nix systems)
119
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.
120
209
 
121
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
+
122
216
  ###### entries_display_order
123
217
  Valid values are 'asc' and 'desc', and will sort listed DSU entries in ascending or descending order respectfully, by day.
124
218
 
@@ -141,7 +235,7 @@ Default: `'/Users/<whoami>/dsu/entries'` on nix systems.
141
235
  Where `<whoami>` would be your username (`$ whoami` on nix systems)
142
236
 
143
237
  ## 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.
238
+ This gem is in development (alpha release).
145
239
 
146
240
  ## Installation
147
241
 
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.
data/lib/dsu/cli.rb CHANGED
@@ -7,17 +7,8 @@ require_relative 'subcommands/edit'
7
7
  require_relative 'subcommands/list'
8
8
 
9
9
  module Dsu
10
- #
11
10
  # The `dsu` command.
12
- #
13
11
  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
12
  map %w[a -a] => :add
22
13
  map %w[c -c] => :config
23
14
  map %w[e -e] => :edit
@@ -2,7 +2,9 @@
2
2
 
3
3
  require 'deco_lite'
4
4
  require_relative '../support/entry_group_loadable'
5
+ require_relative '../services/entry_group_deleter_service'
5
6
  require_relative '../services/entry_group_reader_service'
7
+ require_relative '../services/entry_group_writer_service'
6
8
  require_relative '../validators/entries_validator'
7
9
  require_relative '../validators/time_validator'
8
10
 
@@ -30,6 +32,10 @@ module Dsu
30
32
  end
31
33
 
32
34
  class << self
35
+ def delete(time:, options: {})
36
+ Services::EntryGroupDeleterService.new(time: time, options: options).call
37
+ end
38
+
33
39
  def exists?(time:)
34
40
  Dsu::Services::EntryGroupReaderService.entry_group_file_exists?(time: time)
35
41
  end
@@ -53,6 +59,18 @@ module Dsu
53
59
  %i[time entries]
54
60
  end
55
61
 
62
+ def save!
63
+ validate!
64
+ Services::EntryGroupWriterService.new(entry_group: self).call
65
+ self
66
+ end
67
+
68
+ # Deletes the entry group file from the file system.
69
+ def delete
70
+ self.class.delete(time: time)
71
+ self
72
+ end
73
+
56
74
  def to_h
57
75
  super.tap do |hash|
58
76
  hash[:entries] = hash[:entries].dup
@@ -15,24 +15,22 @@ module Dsu
15
15
  unless default_options.nil? ||
16
16
  default_options.is_a?(Hash) ||
17
17
  default_options.is_a?(ActiveSupport::HashWithIndifferentAccess)
18
- raise ArgumentError, 'default_options must be a Hash'
18
+ raise ArgumentError, 'default_options must be a Hash or ActiveSupport::HashWithIndifferentAccess'
19
19
  end
20
20
 
21
- @default_options = default_options || Support::Configuration::DEFAULT_DSU_OPTIONS
21
+ @default_options ||= default_options || {}
22
22
  @default_options = @default_options.with_indifferent_access if @default_options.is_a?(Hash)
23
23
  end
24
24
 
25
25
  def call
26
- return default_options unless config_file?
27
-
28
- config_options.with_indifferent_access
26
+ config_options.merge(default_options).with_indifferent_access
29
27
  end
30
28
 
31
29
  private
32
30
 
33
- attr_writer :default_options
34
-
35
31
  def config_options
32
+ return Support::Configuration::DEFAULT_DSU_OPTIONS unless config_file?
33
+
36
34
  @config_options ||= YAML.safe_load(ERB.new(File.read(config_file)).result)
37
35
  end
38
36
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dsu
4
+ module Services
5
+ class TempFileReaderService
6
+ def initialize(temp_file_path:, options: {})
7
+ raise ArgumentError, 'temp_file_path is nil' if temp_file_path.nil?
8
+ raise ArgumentError, 'temp_file_path is the wrong object type' unless temp_file_path.is_a?(String)
9
+ raise ArgumentError, 'temp_file_path is empty' if temp_file_path.empty?
10
+ raise ArgumentError, 'temp_file_path does not exist' unless File.exist?(temp_file_path)
11
+ raise ArgumentError, 'options is nil' if options.nil?
12
+ raise ArgumentError, 'options is the wrong object type' unless options.is_a?(Hash)
13
+
14
+ @temp_file_path = temp_file_path
15
+ @options = options || {}
16
+ end
17
+
18
+ def call
19
+ raise ArgumentError, 'no block given' unless block_given?
20
+
21
+ File.foreach(temp_file_path) do |line|
22
+ yield line.strip
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ attr_reader :temp_file_path, :options
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tempfile'
4
+
5
+ module Dsu
6
+ module Services
7
+ class TempFileWriterService
8
+ def initialize(temp_file_content:, options: {})
9
+ raise ArgumentError, 'temp_file_content is nil' if temp_file_content.nil?
10
+ raise ArgumentError, 'temp_file_content is the wrong object type' unless temp_file_content.is_a?(String)
11
+ raise ArgumentError, 'options is nil' if options.nil?
12
+ raise ArgumentError, 'options is the wrong object type' unless options.is_a?(Hash)
13
+
14
+ @temp_file_content = temp_file_content
15
+ @options = options || {}
16
+ end
17
+
18
+ def call
19
+ raise ArgumentError, 'no block given' unless block_given?
20
+
21
+ Tempfile.new('dsu').tap do |file|
22
+ file.write("#{temp_file_content}\n")
23
+ file.close
24
+ yield file.path
25
+ end.unlink
26
+ end
27
+
28
+ private
29
+
30
+ attr_reader :temp_file_content, :options
31
+ end
32
+ end
33
+ end
@@ -33,14 +33,44 @@ module Dsu
33
33
  desc 'init', 'Creates and initializes a .dsu file in your home folder'
34
34
  long_desc <<-LONG_DESC
35
35
  NAME
36
- \x5
37
- `dsu config init` -- will create and initialize a .dsu file
38
- in the "#{Dsu::Support::FolderLocations.root_folder}" folder.
36
+
37
+ `dsu config init` -- will create and initialize a .dsu file ("#{Dsu::Support::FolderLocations.root_folder}/.dsu") that you may edit. Otherwise, the default configuration will be used.
39
38
 
40
39
  SYNOPSIS
41
- \x5
40
+
42
41
  dsu config init
42
+
43
+ CONFIGURATION FILE OPTIONS
44
+
45
+ The following configuration file options are available:
46
+
47
+ editor:
48
+
49
+ The default editor to use when editing entry groups if the EDITOR environment variable on your system is not set. The default is 'nano'. You'll need to change the default editor on Windows systems.
50
+
51
+ entries_display_order:
52
+
53
+ The order by which entries will be displayed, 'asc' or 'desc' (ascending or descending, respectively).
54
+
55
+ Default: 'desc'
56
+
57
+ entries_file_name:
58
+
59
+ 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.
60
+
61
+ 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.
62
+
63
+ Default: '%Y-%m-%d.json'
64
+
65
+ entries_folder:
66
+
67
+ 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.
68
+
69
+ 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.
70
+
71
+ Default: "'#{Dsu::Support::FolderLocations.root_folder}/dsu/entries'"
43
72
  LONG_DESC
73
+
44
74
  def init
45
75
  create_config_file!
46
76
  end
@@ -1,9 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'English'
3
4
  require_relative '../base_cli'
4
5
  require_relative '../models/entry_group'
6
+ require_relative '../services/temp_file_reader_service'
7
+ require_relative '../services/temp_file_writer_service'
5
8
  require_relative '../support/time_formatable'
6
9
  require_relative '../views/entry_group/edit'
10
+ require_relative '../views/entry_group/show'
7
11
 
8
12
  module Dsu
9
13
  module Subcommands
@@ -21,7 +25,7 @@ module Dsu
21
25
  Edits the DSU entries for today.
22
26
  LONG_DESC
23
27
  def today
24
- edit_entry_group(time: Time.now)
28
+ Views::EntryGroup::Show.new(entry_group: edit_entry_group(time: Time.now)).render
25
29
  end
26
30
 
27
31
  desc 'tomorrow, t',
@@ -30,7 +34,7 @@ module Dsu
30
34
  Edits the DSU entries for tomorrow.
31
35
  LONG_DESC
32
36
  def tomorrow
33
- edit_entry_group(time: Time.now.tomorrow)
37
+ Views::EntryGroup::Show.new(entry_group: edit_entry_group(time: Time.now.tomorrow)).render
34
38
  end
35
39
 
36
40
  desc 'yesterday, y',
@@ -39,7 +43,7 @@ module Dsu
39
43
  Edits the DSU entries for yesterday.
40
44
  LONG_DESC
41
45
  def yesterday
42
- edit_entry_group(time: Time.now.yesterday)
46
+ Views::EntryGroup::Show.new(entry_group: edit_entry_group(time: Time.now.yesterday)).render
43
47
  end
44
48
 
45
49
  desc 'date, d DATE',
@@ -50,7 +54,7 @@ module Dsu
50
54
  \x5 #{date_option_description}
51
55
  LONG_DESC
52
56
  def date(date)
53
- edit_entry_group(time: Time.parse(date))
57
+ Views::EntryGroup::Show.new(entry_group: edit_entry_group(time: Time.parse(date))).render
54
58
  rescue ArgumentError => e
55
59
  say "Error: #{e.message}", ERROR
56
60
  exit 1
@@ -67,12 +71,45 @@ module Dsu
67
71
 
68
72
  say "Editing DSU entries for #{formatted_time}..."
69
73
  entry_group = Models::EntryGroup.load(time: time)
70
- # system("${EDITOR:-nano} #{file_path}")
71
74
 
75
+ # This renders the view to a string...
72
76
  output = capture_stdxxx do
73
77
  Views::EntryGroup::Edit.new(entry_group: entry_group).render
74
78
  end
75
- say output, SUCCESS
79
+ # ...which is then written to a temp file.
80
+ Services::TempFileWriterService.new(temp_file_content: output).call do |temp_file_path|
81
+ unless system("${EDITOR:-#{configuration[:editor]}} #{temp_file_path}")
82
+ say "Failed to open temporary file in editor '#{configuration[:editor]}';" \
83
+ "the system error returned was: '#{$CHILD_STATUS}'.", ERROR
84
+ say 'Either set the EDITOR environment variable ' \
85
+ 'or set the dsu editor configuration option (`$ dsu config init`).', ERROR
86
+ say 'Run `$ dsu help config` for more information.', ERROR
87
+ system('dsu help config')
88
+ exit 1
89
+ end
90
+ entries = []
91
+ Services::TempFileReaderService.new(temp_file_path: temp_file_path).call do |temp_file_line|
92
+ # Skip comments and blank lines.
93
+ next if ['#', nil].include? temp_file_line[0]
94
+
95
+ match_data = temp_file_line.match(/(\S+)\s(.+)/)
96
+ # TODO: Error handling if match_data is nil.
97
+ entry_sha = match_data[1]
98
+ entry_description = match_data[2]
99
+
100
+ next if %w[- d delete].include?(entry_sha) # delete the entry
101
+
102
+ entry_sha = nil if %w[+ a add].include?(entry_sha) # add the new entry
103
+ entries << Models::Entry.new(uuid: entry_sha, description: entry_description)
104
+ end
105
+
106
+ entry_group.entries = entries
107
+
108
+ return entry_group.delete if entries.empty?
109
+
110
+ entry_group.save!
111
+ end
112
+ entry_group
76
113
  end
77
114
 
78
115
  # https://stackoverflow.com/questions/4459330/how-do-i-temporarily-redirect-stderr-in-ruby/4459463#4459463
@@ -18,6 +18,11 @@ module Dsu
18
18
 
19
19
  # rubocop:disable Style/StringHashKeys - YAML writing/loading necessitates this
20
20
  DEFAULT_DSU_OPTIONS = {
21
+ # The default editor to use when editing entry groups if the EDITOR
22
+ # environment variable on your system is not set. On nix systmes,
23
+ # the default editor is`nano`. You need to change this default on
24
+ # Windows systems.
25
+ 'editor' => 'nano',
21
26
  # The order by which entries should be displayed by default:
22
27
  # asc or desc, ascending or descending, respectively.
23
28
  'entries_display_order' => 'desc',
@@ -12,14 +12,14 @@ module Dsu
12
12
  def validate(record)
13
13
  raise 'options[:fields] is not defined.' unless options.key? :fields
14
14
  raise 'options[:fields] is not an Array.' unless options[:fields].is_a? Array
15
- raise 'options[:fields] elements are not Symbols.' unless options[:fields].all? { |field| field.is_a? Symbol }
15
+ raise 'options[:fields] elements are not Symbols.' unless options[:fields].all?(Symbol)
16
16
 
17
17
  options[:fields].each do |field|
18
18
  entries = record.send(field)
19
19
 
20
20
  unless entries.is_a?(Array)
21
21
  record.errors.add(field, 'is the wrong object type. ' \
22
- "\"Array\" was expected, but \"#{entries.class}\" was received.")
22
+ "\"Array\" was expected, but \"#{entries.class}\" was received.")
23
23
  next
24
24
  end
25
25
 
@@ -35,7 +35,7 @@ module Dsu
35
35
  next if entry.is_a? Dsu::Models::Entry
36
36
 
37
37
  record.errors.add(field, 'entry Array element is the wrong object type. ' \
38
- "\"Entry\" was expected, but \"#{entry.class}\" was received.",
38
+ "\"Entry\" was expected, but \"#{entry.class}\" was received.",
39
39
  type: Dsu::Support::FieldErrors::FIELD_TYPE_ERROR)
40
40
 
41
41
  next
@@ -47,16 +47,13 @@ module Dsu
47
47
 
48
48
  entry_objects = entries.select { |entry| entry.is_a?(Dsu::Models::Entry) }
49
49
 
50
- entry_objects.map(&:uuid).tap do |uuids|
51
- return if uuids.uniq.length == uuids.length
52
- end
50
+ uuids = entry_objects.map(&:uuid)
51
+ return if uuids.uniq.length == uuids.length
53
52
 
54
- entry_objects.map(&:uuid).tap do |uuids|
55
- non_unique_uuids = uuids.select{ |element| uuids.count(element) > 1 }.uniq
56
- if non_unique_uuids.any?
57
- record.errors.add(field, "contains duplicate UUIDs: #{non_unique_uuids.join(', ')}.",
58
- type: Dsu::Support::FieldErrors::FIELD_DUPLICATE_ERROR)
59
- end
53
+ non_unique_uuids = uuids.select { |element| uuids.count(element) > 1 }.uniq
54
+ if non_unique_uuids.any?
55
+ record.errors.add(field, "contains duplicate UUIDs: #{non_unique_uuids.join(', ')}.",
56
+ type: Dsu::Support::FieldErrors::FIELD_DUPLICATE_ERROR)
60
57
  end
61
58
  end
62
59
  end
data/lib/dsu/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dsu
4
- VERSION = '0.1.0.alpha.2'
4
+ VERSION = '0.1.0.alpha.3'
5
5
  end
@@ -45,17 +45,24 @@ module Dsu
45
45
  say('(no entries available for this day)') and return if entry_group.entries.empty?
46
46
 
47
47
  say ''
48
+ say '# [SHA/COMMAND] [DESCRIPTION]'
48
49
 
49
50
  entry_group.entries.each do |entry|
50
51
  say "#{entry.uuid} #{entry.description}"
51
52
  end
52
53
 
53
54
  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.'
55
+ say '# INSTRUCTIONS:'
56
+ say '# ADD a DSU entry: use one of the following commands: [+|a|add] ' \
57
+ 'followed by the description.'
58
+ say '# EDIT a DSU entry: change the description.'
59
+ say '# DELETE a DSU entry: delete the entry or replace the sha with one ' \
60
+ 'of the following commands: [-|d|delete].'
61
+ say '# NOTE: deleting all the entries will delete the entry group file; '
62
+ say '# this is preferable if this is what you want to do :)'
63
+ say '# REORDER a DSU entry: reorder the DSU entries in order preference.'
64
+ say '#'
65
+ say '# *** When you are done, save and close your editor ***'
59
66
  end
60
67
  end
61
68
  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.2
4
+ version: 0.1.0.alpha.3
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-08 00:00:00.000000000 Z
11
+ date: 2023-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -151,6 +151,8 @@ files:
151
151
  - lib/dsu/services/entry_group_reader_service.rb
152
152
  - lib/dsu/services/entry_group_writer_service.rb
153
153
  - lib/dsu/services/entry_hydrator_service.rb
154
+ - lib/dsu/services/temp_file_reader_service.rb
155
+ - lib/dsu/services/temp_file_writer_service.rb
154
156
  - lib/dsu/subcommands/config.rb
155
157
  - lib/dsu/subcommands/edit.rb
156
158
  - lib/dsu/subcommands/list.rb