dsu 1.2.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +65 -21
- data/Gemfile.lock +7 -7
- data/README.md +28 -35
- data/bin/console +23 -1
- data/bin/dsu +3 -0
- data/bin/setup +14 -3
- data/exe/dsu +23 -1
- data/exe/dsu_migrate.rb +43 -0
- data/lib/core/ruby/color_theme_colors.rb +16 -0
- data/lib/core/ruby/color_theme_mode.rb +42 -0
- data/lib/core/ruby/not_today.rb +7 -0
- data/lib/core/ruby/wrap_and_join.rb +31 -0
- data/lib/dsu/base_cli.rb +19 -23
- data/lib/dsu/cli.rb +47 -37
- data/lib/dsu/command_services/add_entry_service.rb +10 -21
- data/lib/dsu/crud/json_file.rb +139 -0
- data/lib/dsu/crud/raw_json_file.rb +51 -0
- data/lib/dsu/env.rb +21 -0
- data/lib/dsu/migration/service.rb +196 -0
- data/lib/dsu/migration/version.rb +7 -0
- data/lib/dsu/models/color_theme.rb +270 -0
- data/lib/dsu/models/configuration.rb +160 -0
- data/lib/dsu/models/entry.rb +6 -2
- data/lib/dsu/models/entry_group.rb +143 -42
- data/lib/dsu/models/migration_version.rb +48 -0
- data/lib/dsu/presenters/base_presenter.rb +32 -0
- data/lib/dsu/presenters/color_theme_presenter.rb +50 -0
- data/lib/dsu/presenters/color_theme_show_presenter.rb +49 -0
- data/lib/dsu/presenters/configuration_presenter.rb +45 -0
- data/lib/dsu/presenters/entry_group_presenter.rb +35 -0
- data/lib/dsu/presenters/entry_presenter.rb +25 -0
- data/lib/dsu/services/color_theme/hydrator_service.rb +42 -0
- data/lib/dsu/services/configuration/hydrator_service.rb +42 -0
- data/lib/dsu/services/entry/hydrator_service.rb +33 -0
- data/lib/dsu/services/entry_group/editor_service.rb +107 -0
- data/lib/dsu/services/entry_group/hydrator_service.rb +37 -0
- data/lib/dsu/services/migration_version/hydrator_service.rb +36 -0
- data/lib/dsu/services/stderr_redirector_service.rb +27 -0
- data/lib/dsu/services/temp_file/reader_service.rb +33 -0
- data/lib/dsu/services/temp_file/writer_service.rb +35 -0
- data/lib/dsu/subcommands/base_subcommand.rb +14 -0
- data/lib/dsu/subcommands/config.rb +92 -32
- data/lib/dsu/subcommands/edit.rb +3 -3
- data/lib/dsu/subcommands/list.rb +70 -93
- data/lib/dsu/subcommands/theme.rb +159 -0
- data/lib/dsu/support/ask.rb +14 -19
- data/lib/dsu/support/color_themable.rb +34 -0
- data/lib/dsu/support/command_help_colorizeable.rb +27 -0
- data/lib/dsu/support/command_hookable.rb +60 -0
- data/lib/dsu/support/command_options/dsu_times.rb +32 -21
- data/lib/dsu/support/command_options/time.rb +7 -1
- data/lib/dsu/support/command_options/time_mneumonic.rb +7 -1
- data/lib/dsu/support/descriptable.rb +6 -4
- data/lib/dsu/support/entry_group_viewable.rb +28 -4
- data/lib/dsu/support/fileable.rb +94 -0
- data/lib/dsu/support/presentable.rb +11 -0
- data/lib/dsu/support/subcommand_help_colorizeable.rb +27 -0
- data/lib/dsu/support/time_comparable.rb +19 -0
- data/lib/dsu/support/time_formatable.rb +12 -0
- data/lib/dsu/support/times_sortable.rb +48 -14
- data/lib/dsu/support/utils.rb +11 -0
- data/lib/dsu/validators/color_theme_validator.rb +74 -0
- data/lib/dsu/validators/entries_validator.rb +4 -8
- data/lib/dsu/validators/version_validator.rb +29 -0
- data/lib/dsu/version.rb +2 -1
- data/lib/dsu/views/color_theme/index.rb +62 -0
- data/lib/dsu/views/color_theme/show.rb +106 -0
- data/lib/dsu/views/configuration/show.rb +41 -0
- data/lib/dsu/views/entry_group/edit.rb +3 -5
- data/lib/dsu/views/entry_group/shared/no_entries_to_display.rb +41 -0
- data/lib/dsu/views/entry_group/show.rb +16 -15
- data/lib/dsu/views/shared/error.rb +17 -0
- data/lib/dsu/views/shared/info.rb +17 -0
- data/lib/dsu/views/shared/message.rb +85 -0
- data/lib/dsu/views/shared/model_errors.rb +31 -0
- data/lib/dsu/views/shared/success.rb +17 -0
- data/lib/dsu/views/shared/warning.rb +17 -0
- data/lib/dsu.rb +22 -1
- data/lib/seed_data/themes/cherry.json +79 -0
- data/lib/seed_data/themes/default.json +79 -0
- data/lib/seed_data/themes/lemon.json +79 -0
- data/lib/seed_data/themes/matrix.json +79 -0
- data/lib/seed_data/themes/whiteout.json +79 -0
- metadata +68 -23
- data/lib/dsu/core/ruby/not_today.rb +0 -11
- data/lib/dsu/services/ai/tense_translator_service.rb +0 -63
- data/lib/dsu/services/configuration_loader_service.rb +0 -55
- data/lib/dsu/services/entry_group_deleter_service.rb +0 -31
- data/lib/dsu/services/entry_group_editor_service.rb +0 -96
- data/lib/dsu/services/entry_group_hydrator_service.rb +0 -43
- data/lib/dsu/services/entry_group_reader_service.rb +0 -36
- data/lib/dsu/services/entry_group_writer_service.rb +0 -46
- data/lib/dsu/services/entry_hydrator_service.rb +0 -35
- data/lib/dsu/services/temp_file_reader_service.rb +0 -31
- data/lib/dsu/services/temp_file_writer_service.rb +0 -33
- data/lib/dsu/support/colorable.rb +0 -14
- data/lib/dsu/support/configurable.rb +0 -15
- data/lib/dsu/support/configuration.rb +0 -112
- data/lib/dsu/support/entry_group_fileable.rb +0 -49
- data/lib/dsu/support/entry_group_loadable.rb +0 -49
- data/lib/dsu/support/folder_locations.rb +0 -21
- data/lib/dsu/support/say.rb +0 -40
- data/lib/dsu/views/edited_entries/shared/errors.rb +0 -39
- data/lib/dsu/views/shared/messages.rb +0 -56
data/lib/dsu/support/say.rb
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'colorized_string'
|
|
4
|
-
|
|
5
|
-
module Dsu
|
|
6
|
-
module Support
|
|
7
|
-
module Say
|
|
8
|
-
class << self
|
|
9
|
-
def say(text, color = nil)
|
|
10
|
-
puts say_string_for(text, color)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def say_string_for(text, color = nil)
|
|
14
|
-
unless color.nil? || color.is_a?(Symbol)
|
|
15
|
-
raise ':color is the wrong type. "Symbol" was expected, but ' \
|
|
16
|
-
"\"#{color.class}\" was returned."
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
return text if color.nil?
|
|
20
|
-
|
|
21
|
-
text.public_send(color)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def say(text, color = nil)
|
|
26
|
-
Say.say(text, color)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# NOTE: some modes (ColorizedString.modes) will cancel out each other if
|
|
30
|
-
# overriden in a block. For example, if you set a string to be bold
|
|
31
|
-
# (i.e. mode: :bold) and then override it in a block (e.g. string.underline)
|
|
32
|
-
# the string will not be bold and underlined, it will just be underlined.
|
|
33
|
-
def colorize_string(string:, color: :default, mode: :default)
|
|
34
|
-
colorized_string = ColorizedString[string].colorize(color: color, mode: mode)
|
|
35
|
-
colorized_string = yield colorized_string if block_given?
|
|
36
|
-
colorized_string
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative '../../shared/messages'
|
|
4
|
-
|
|
5
|
-
module Dsu
|
|
6
|
-
module Views
|
|
7
|
-
module EditedEntries
|
|
8
|
-
module Shared
|
|
9
|
-
class Errors
|
|
10
|
-
def initialize(edited_entries:, options: {})
|
|
11
|
-
raise ArgumentError, 'edited_entries is nil' if edited_entries.nil?
|
|
12
|
-
raise ArgumentError, 'edited_entries is the wrong object type' unless edited_entries.is_a?(Array)
|
|
13
|
-
unless edited_entries.all?(Models::EditedEntry)
|
|
14
|
-
raise ArgumentError, 'edited_entries elements are the wrong object type'
|
|
15
|
-
end
|
|
16
|
-
raise ArgumentError, 'options is nil' if options.nil?
|
|
17
|
-
raise ArgumentError, 'options is the wrong object type' unless options.is_a?(Hash)
|
|
18
|
-
|
|
19
|
-
@edited_entries = edited_entries
|
|
20
|
-
@options = options || {}
|
|
21
|
-
@header = options[:header] || 'The following ERRORS were encountered; these changes were not saved:'
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def render
|
|
25
|
-
return if edited_entries.empty?
|
|
26
|
-
return if edited_entries.all?(&:valid?)
|
|
27
|
-
|
|
28
|
-
messages = edited_entries.map { |edited_entry| edited_entry.errors.full_messages }.flatten
|
|
29
|
-
Views::Shared::Messages.new(messages: messages, message_type: :error, options: { header: header }).render
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
private
|
|
33
|
-
|
|
34
|
-
attr_reader :edited_entries, :header, :options
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative '../../support/colorable'
|
|
4
|
-
require_relative '../../support/say'
|
|
5
|
-
|
|
6
|
-
module Dsu
|
|
7
|
-
module Views
|
|
8
|
-
module Shared
|
|
9
|
-
class Messages
|
|
10
|
-
include Support::Colorable
|
|
11
|
-
include Support::Say
|
|
12
|
-
|
|
13
|
-
MESSAGE_TYPES = %i[error info success warning].freeze
|
|
14
|
-
|
|
15
|
-
def initialize(messages:, message_type:, options: {})
|
|
16
|
-
messages = [messages] unless messages.is_a?(Array)
|
|
17
|
-
|
|
18
|
-
validate_arguments!(messages, message_type, options)
|
|
19
|
-
|
|
20
|
-
@messages = messages.select(&:present?)
|
|
21
|
-
@message_type = message_type
|
|
22
|
-
# We've inluded Support::Colorable, so simply upcase the message_type
|
|
23
|
-
# and convert it to a symbol; this will equate to the color we want.
|
|
24
|
-
@message_color = self.class.const_get(message_type.to_s.upcase)
|
|
25
|
-
@options = options || {}
|
|
26
|
-
@header = options[:header]
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def render
|
|
30
|
-
return if messages.empty?
|
|
31
|
-
|
|
32
|
-
say header, message_color if header.present?
|
|
33
|
-
|
|
34
|
-
messages.each_with_index do |message, index|
|
|
35
|
-
say "#{index + 1}. #{message}", message_color
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
private
|
|
40
|
-
|
|
41
|
-
attr_reader :messages, :message_color, :message_type, :header, :options
|
|
42
|
-
|
|
43
|
-
def validate_arguments!(messages, message_type, options)
|
|
44
|
-
raise ArgumentError, 'messages is nil' if messages.nil?
|
|
45
|
-
raise ArgumentError, 'messages is the wrong object type' unless messages.is_a?(Array)
|
|
46
|
-
raise ArgumentError, 'messages elements are the wrong object type' unless messages.all?(String)
|
|
47
|
-
raise ArgumentError, 'message_type is nil' if message_type.nil?
|
|
48
|
-
raise ArgumentError, 'message_type is the wrong object type' unless message_type.is_a?(Symbol)
|
|
49
|
-
raise ArgumentError, 'message_type is not a valid message type' unless MESSAGE_TYPES.include?(message_type)
|
|
50
|
-
raise ArgumentError, 'options is nil' if options.nil?
|
|
51
|
-
raise ArgumentError, 'options is the wrong object type' unless options.is_a?(Hash)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|