dsu 3.0.0.alpha.12 → 3.0.0.beta.0

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: 74b0eee10983a1ccd33981f635c7bc267dd8db84cfe8496c39fa5386c57096d2
4
- data.tar.gz: f65368dfbb2de3512a73f766f82958de92255e4a72b3e5f58389d0db2ccd86ad
3
+ metadata.gz: 480ee218003cde2deef47853915e5a59a396ca0ea62d65b243e2c789fdffaeb1
4
+ data.tar.gz: 34fcb64b9dfcedf87a3b3ffdd49e6504e4a1662952d027dc9855e7c2e4a17b72
5
5
  SHA512:
6
- metadata.gz: 9c91fa9f3916538d244ffca9456ea089a258fb0701f182d6e40e0fad5c51deec986ac0835e611a3b042cf8c0dc84b27b0a7175a388a9ed38ee34bc34de0a865d
7
- data.tar.gz: 940939975bb206402a13f5c4b1dd8a9f0308fe787fada7e0d59e70a6769eeb960755fd3d4aba7aa480b45cdf9a4c837dfda5382b284c7e5bbb4631d98d4f01ef
6
+ metadata.gz: 40b201d06c9f7271bf3c5c4f962901682c54ec7509dee80156dfed39aa613bf928caa020d24416c0e600504b223e0f1146f7e44a1049711660d639d2524711d5
7
+ data.tar.gz: 56a459e90ea910802709e1893bbd7e8cccb33e9e110f3b5fae7dc118fd393a9873b5953e19ea1d415dd71d42505a31b92e7011b4ed00c44bdfb4ffebd00ac3d1
data/CHANGELOG.md CHANGED
@@ -42,6 +42,7 @@ dsu x dd -f n -t -257
42
42
  dsu-export-default-20240129125946-entry-groups-2023-05-17-thru-2024-01-29.csv
43
43
 
44
44
  ### Bug Fixes
45
+ [x] Fix bug that did not gracefully handle invalid DATEs for the `dsu add --date DATE` command.
45
46
 
46
47
 
47
48
  ## [2.4.4] - 2024-01-28
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dsu (3.0.0.alpha.4)
4
+ dsu (3.0.0.alpha.13)
5
5
  activemodel (>= 7.0.8, < 8.0)
6
6
  activesupport (>= 7.0.8, < 8.0)
7
7
  colorize (>= 1.1, < 2.0)
@@ -32,7 +32,7 @@ GEM
32
32
  colorize (1.1.0)
33
33
  concurrent-ruby (1.2.3)
34
34
  connection_pool (2.4.1)
35
- diff-lcs (1.5.0)
35
+ diff-lcs (1.5.1)
36
36
  docile (1.4.0)
37
37
  dotenv (2.8.1)
38
38
  drb (2.2.0)
@@ -64,7 +64,7 @@ GEM
64
64
  dry-inflector (~> 1.0)
65
65
  dry-logic (~> 1.4)
66
66
  zeitwerk (~> 2.6)
67
- factory_bot (6.4.5)
67
+ factory_bot (6.4.6)
68
68
  activesupport (>= 5.0.0)
69
69
  ffaker (2.23.0)
70
70
  i18n (1.14.1)
@@ -72,7 +72,7 @@ GEM
72
72
  json (2.7.1)
73
73
  language_server-protocol (3.17.0.3)
74
74
  method_source (1.0.0)
75
- minitest (5.21.2)
75
+ minitest (5.22.2)
76
76
  mutex_m (0.2.0)
77
77
  os (1.1.4)
78
78
  parallel (1.24.0)
@@ -95,19 +95,19 @@ GEM
95
95
  rexml (~> 3.1)
96
96
  regexp_parser (2.9.0)
97
97
  rexml (3.2.6)
98
- rspec (3.12.0)
99
- rspec-core (~> 3.12.0)
100
- rspec-expectations (~> 3.12.0)
101
- rspec-mocks (~> 3.12.0)
102
- rspec-core (3.12.2)
103
- rspec-support (~> 3.12.0)
104
- rspec-expectations (3.12.3)
98
+ rspec (3.13.0)
99
+ rspec-core (~> 3.13.0)
100
+ rspec-expectations (~> 3.13.0)
101
+ rspec-mocks (~> 3.13.0)
102
+ rspec-core (3.13.0)
103
+ rspec-support (~> 3.13.0)
104
+ rspec-expectations (3.13.0)
105
105
  diff-lcs (>= 1.2.0, < 2.0)
106
- rspec-support (~> 3.12.0)
107
- rspec-mocks (3.12.6)
106
+ rspec-support (~> 3.13.0)
107
+ rspec-mocks (3.13.0)
108
108
  diff-lcs (>= 1.2.0, < 2.0)
109
- rspec-support (~> 3.12.0)
110
- rspec-support (3.12.1)
109
+ rspec-support (~> 3.13.0)
110
+ rspec-support (3.13.0)
111
111
  rubocop (1.60.2)
112
112
  json (~> 2.3)
113
113
  language_server-protocol (>= 3.17.0)
@@ -145,7 +145,7 @@ GEM
145
145
  tzinfo (2.0.6)
146
146
  concurrent-ruby (~> 1.0)
147
147
  unicode-display_width (2.5.0)
148
- zeitwerk (2.6.12)
148
+ zeitwerk (2.6.13)
149
149
 
150
150
  PLATFORMS
151
151
  x86_64-darwin-19
data/lib/dsu/cli.rb CHANGED
@@ -40,7 +40,8 @@ module Dsu
40
40
  desc I18n.t('commands.add.desc'), I18n.t('commands.add.usage')
41
41
  long_desc I18n.t('commands.add.long_desc',
42
42
  date_option_description: date_option_description, mnemonic_option_description: mnemonic_option_description)
43
- option I18n.t('options.date.name'), aliases: I18n.t('options.date.aliases'), type: :string
43
+ option I18n.t('options.date_or_mnemonic.name'), aliases: I18n.t('options.date_or_mnemonic.aliases'),
44
+ type: :string, banner: I18n.t('options.date_or_mnemonic.banner')
44
45
  option I18n.t('options.tomorrow.name'), aliases: I18n.t('options.tomorrow.aliases'), type: :boolean
45
46
  option I18n.t('options.yesterday.name'), aliases: I18n.t('options.yesterday.aliases'), type: :boolean
46
47
  option I18n.t('options.today.name'), aliases: I18n.t('options.today.aliases'), type: :boolean, default: true
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'active_model'
4
4
  require 'json'
5
+ require_relative '../migration/version'
5
6
 
6
7
  module Dsu
7
8
  module Crud
@@ -14,6 +15,10 @@ module Dsu
14
15
  @file_path = file_path
15
16
  end
16
17
 
18
+ def update_version!
19
+ @version = Migration::VERSION
20
+ end
21
+
17
22
  def delete
18
23
  self.class.delete(file_path: file_path)
19
24
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative '../models/migration_version'
4
- require_relative 'service_20230613121411'
4
+ require_relative 'service_20240210161248'
5
5
  require_relative 'version'
6
6
 
7
7
  module Dsu
@@ -11,14 +11,14 @@ module Dsu
11
11
  def migrate_if!(options: {})
12
12
  version = options.fetch(:version, migration_version)
13
13
  if version == 20230613121411 # rubocop:disable Style/NumericLiterals
14
- Service20230613121411.new(options: options).migrate!
14
+ Service20240210161248.new(options: options).migrate!
15
15
  end
16
16
  end
17
17
 
18
18
  private
19
19
 
20
20
  def migration_version
21
- @migration_version ||= Models::MigrationVersion.new.version
21
+ Models::MigrationVersion.new.version
22
22
  end
23
23
  end
24
24
  end
@@ -3,16 +3,9 @@
3
3
  require_relative '../support/fileable'
4
4
  require_relative 'version'
5
5
 
6
- # TODO: Read raw configuration .json file
7
- # If default_project is not set...
8
- # - Add default_project to configuration .json file and write it out.
9
- # - Reload the configuration file.
10
- # - Create a Models::Project object for the default project and initialize/save it.
11
- # - Move the old entries folder into the default project folder.
12
- # TODO: Add default_project to configuration .json file
13
6
  module Dsu
14
7
  module Migration
15
- class Service20230613121411
8
+ class Service20240210161248
16
9
  include Support::Fileable
17
10
 
18
11
  def initialize(options: {})
@@ -56,11 +49,12 @@ module Dsu
56
49
 
57
50
  %w[light.json christmas.json].each do |theme_file|
58
51
  destination_theme_file_path = File.join(Dsu::Support::Fileable.themes_folder, theme_file)
59
- next if File.exist?(destination_theme_file_path)
52
+ # next if File.exist?(destination_theme_file_path)
60
53
 
61
54
  source_theme_file_path = File.join(Dsu::Support::Fileable.seed_data_folder, 'themes', theme_file)
62
55
  FileUtils.cp(source_theme_file_path, destination_theme_file_path) unless pretend?
63
- puts I18n.t('migrations.information.theme_copied', from: source_theme_file_path, to: destination_theme_file_path)
56
+ puts I18n.t('migrations.information.theme_copied',
57
+ from: source_theme_file_path, to: destination_theme_file_path)
64
58
  end
65
59
  end
66
60
 
@@ -121,20 +115,20 @@ module Dsu
121
115
  puts 'Updating color themes...'
122
116
  puts
123
117
 
124
- return if pretend? || Dir.exist?(themes_folder)
125
-
126
118
  puts 'Copying color themes...'
127
119
  puts
128
120
 
129
- FileUtils.mkdir_p(themes_folder)
130
- FileUtils.cp_r(File.join(backup_folder, 'themes', '.'), themes_folder)
121
+ unless pretend?
122
+ FileUtils.mkdir_p(themes_folder)
123
+ FileUtils.cp_r(File.join(backup_folder, 'themes', '.'), themes_folder)
124
+ end
131
125
 
132
126
  puts 'Updating color theme version...'
133
127
  puts
134
128
 
135
129
  Models::ColorTheme.all.each do |color_theme|
136
130
  puts "Updating color theme version: #{color_theme.theme_name}..."
137
- color_theme.version = Dsu::Migration::VERSION
131
+ color_theme.update_version!
138
132
  color_theme.save! unless pretend?
139
133
  end
140
134
  end
@@ -81,6 +81,12 @@ module Dsu
81
81
  write! unless exist?
82
82
  end
83
83
 
84
+ class << self
85
+ def exist?
86
+ File.exist?(Support::Fileable.config_path)
87
+ end
88
+ end
89
+
84
90
  # Temporarily sets the configuration to the given config_hash.
85
91
  # To reset the configuration to its original state, call #reload
86
92
  def replace!(config_hash: {})
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dsu
4
+ module Presenters
5
+ module Project
6
+ module Defaultable
7
+ private
8
+
9
+ def make_default?
10
+ options.fetch(:default, false)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -2,11 +2,14 @@
2
2
 
3
3
  require_relative '../../models/project'
4
4
  require_relative '../base_presenter_ex'
5
+ require_relative 'defaultable'
5
6
 
6
7
  module Dsu
7
8
  module Presenters
8
9
  module Project
9
10
  class UseByNumberPresenter < BasePresenterEx
11
+ include Defaultable
12
+
10
13
  attr_reader :project_number
11
14
 
12
15
  delegate :project_name, to: :project, allow_nil: true
@@ -23,6 +26,7 @@ module Dsu
23
26
  def respond(response:)
24
27
  return false unless response
25
28
 
29
+ project.default! if make_default? && project&.present?
26
30
  project.use! if project&.present?
27
31
  end
28
32
 
@@ -2,11 +2,14 @@
2
2
 
3
3
  require_relative '../../models/project'
4
4
  require_relative '../base_presenter_ex'
5
+ require_relative 'defaultable'
5
6
 
6
7
  module Dsu
7
8
  module Presenters
8
9
  module Project
9
10
  class UsePresenter < BasePresenterEx
11
+ include Defaultable
12
+
10
13
  attr_reader :project_name
11
14
 
12
15
  delegate :description, to: :project, prefix: true, allow_nil: true
@@ -22,6 +25,7 @@ module Dsu
22
25
  def respond(response:)
23
26
  return false unless response
24
27
 
28
+ project.default! if make_default? && project&.present?
25
29
  project.use! if project&.present?
26
30
  end
27
31
 
@@ -23,7 +23,6 @@ module Dsu
23
23
 
24
24
  desc I18n.t('subcommands.project.create.desc'), I18n.t('subcommands.project.create.usage')
25
25
  long_desc I18n.t('subcommands.project.create.long_desc')
26
- option :prompts, type: :hash, default: {}, hide: true, aliases: '-p'
27
26
  def create(project_name = nil, description = nil)
28
27
  project_name = project_name.to_s.strip
29
28
  description = description.to_s.strip
@@ -41,7 +40,6 @@ module Dsu
41
40
 
42
41
  desc I18n.t('subcommands.project.delete.desc'), I18n.t('subcommands.project.delete.usage')
43
42
  long_desc I18n.t('subcommands.project.delete.long_desc')
44
- option :prompts, type: :hash, default: {}, hide: true, aliases: '-p'
45
43
  def delete(project_name_or_number = nil)
46
44
  options = configuration.to_h.merge(self.options).with_indifferent_access
47
45
  presenter = delete_presenter_for(project_name_or_number, options: options)
@@ -50,7 +48,6 @@ module Dsu
50
48
 
51
49
  desc I18n.t('subcommands.project.list.desc'), I18n.t('subcommands.project.list.usage')
52
50
  long_desc I18n.t('subcommands.project.list.long_desc')
53
- option :prompts, type: :hash, default: {}, hide: true, aliases: '-p'
54
51
  def list
55
52
  options = configuration.to_h.merge(self.options).with_indifferent_access
56
53
  presenter = Presenters::Project::ListPresenter.new(options: options)
@@ -59,7 +56,6 @@ module Dsu
59
56
 
60
57
  desc I18n.t('subcommands.project.rename.desc'), I18n.t('subcommands.project.rename.usage')
61
58
  long_desc I18n.t('subcommands.project.rename.long_desc')
62
- option :prompts, type: :hash, default: {}, hide: true, aliases: '-p'
63
59
  def rename(project_name_or_number = nil, new_project_name = nil, new_project_description = nil)
64
60
  project_name_or_number = project_name_or_number.to_s.strip
65
61
  new_project_name = new_project_name&.to_s&.strip
@@ -77,9 +73,10 @@ module Dsu
77
73
  rename_view_for(project_name_or_number, presenter: presenter, options: options).render
78
74
  end
79
75
 
80
- desc I18n.t('subcommands.project.use.desc'), I18n.t('subcommands.project.use.usage')
76
+ desc I18n.t('subcommands.project.use.desc'),
77
+ I18n.t('subcommands.project.use.usage')
81
78
  long_desc I18n.t('subcommands.project.use.long_desc')
82
- option :prompts, type: :hash, default: {}, hide: true, aliases: '-p'
79
+ option :default, type: :boolean, required: false, default: false, aliases: '-d', banner: 'DEFAULT_PROJECT'
83
80
  def use(project_name_or_number = nil)
84
81
  options = configuration.to_h.merge(self.options).with_indifferent_access
85
82
  presenter = use_presenter_for(project_name_or_number, options: options)
@@ -39,6 +39,8 @@ module Dsu
39
39
  end
40
40
 
41
41
  def default_project_name
42
+ return Models::Configuration::DEFAULT_CONFIGURATION[:default_project] unless Models::Configuration.exist?
43
+
42
44
  Models::Configuration.new.default_project
43
45
  end
44
46
 
@@ -78,11 +80,6 @@ module Dsu
78
80
  end
79
81
  alias current_project_file_persisted? current_project_file_exist?
80
82
 
81
- # Does dsu/projects folder exist?
82
- def projects_folder_exist?
83
- Dir.exist?(projects_folder)
84
- end
85
-
86
83
  # Does dsu/projects/<project_name> folder exist?
87
84
  def project_folder_exist?(project_name:)
88
85
  Dir.exist?(project_folder_for(project_name: project_name))
data/lib/dsu/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dsu
4
- VERSION_REGEX = /\A\d+\.\d+\.\d+(\.(alpha|rc)\.\d+)?\z/
5
- VERSION = '3.0.0.alpha.12'
4
+ VERSION_REGEX = /\A\d+\.\d+\.\d+(\.(alpha|beta|rc)\.\d+)?\z/
5
+ VERSION = '3.0.0.beta.0'
6
6
  end
data/lib/dsu.rb CHANGED
@@ -25,6 +25,8 @@ Dir.glob("#{__dir__}/dsu/**/*.rb").each do |file|
25
25
  end
26
26
 
27
27
  unless Dsu.env.test? || Dsu.env.development?
28
+ # TODO: This is upgrading from migrations version 0 to 20230613121411
29
+ # Move this to to its own class and call from Migration::Factory.
28
30
  if Dsu::Migration::Service.run_migrations?
29
31
  begin
30
32
  Dsu::Migration::Service.new.call
@@ -120,6 +120,10 @@ en:
120
120
  date:
121
121
  aliases: -d
122
122
  name: 'date'
123
+ date_or_mnemonic:
124
+ aliases: -d
125
+ name: 'date'
126
+ banner: 'DATE|MNEMONIC'
123
127
  today:
124
128
  aliases: -n
125
129
  name: 'today'
@@ -553,11 +553,11 @@ en:
553
553
 
554
554
  PROJECT_NUMBER
555
555
 
556
- The number of the project to delete. If PROJECT_NUMBER is used, the project equating to the nth project in the list of projects will be used (see `dsu project list`).
556
+ The number of the project to delete. If PROJECT_NUMBER is used, the project equating to the nth project in the list of projects will be deleted (see `dsu project list`).
557
557
 
558
558
  NOTES
559
559
 
560
- PROJECT_NAME and PROJECT_NUMBER are optional. If neither are provided, the current, default project will be used.
560
+ PROJECT_NAME and PROJECT_NUMBER are optional. If neither are provided, the current, default project will be deleted.
561
561
 
562
562
  EXAMPLES
563
563
 
@@ -614,7 +614,7 @@ en:
614
614
 
615
615
  PROJECT_NUMBER
616
616
 
617
- The number of the project to rename. If PROJECT_NUMBER is used, the project equating to the nth project in the list of projects will be used (see `dsu project list`).
617
+ The number of the project to rename. If PROJECT_NUMBER is used, the project equating to the nth project in the list of projects will be renamed (see `dsu project list`).
618
618
 
619
619
  NEW_PROJECT_NAME
620
620
 
@@ -648,14 +648,18 @@ en:
648
648
  - Y
649
649
  - n
650
650
  use:
651
- desc: use|u [PROJECT_NAME|PROJECT_NUMBER]
651
+ desc: use|u [OPTIONS] [PROJECT_NAME|PROJECT_NUMBER]
652
652
  usage: Selects the DSU project to use, based on the given PROJECT_NAME or PROJECT_NUMBER
653
653
  long_desc: |
654
654
  Selects the DSU project to use, based on the given PROJECT_NAME or PROJECT_NUMBER.
655
655
 
656
- dsu project use [PROJECT_NAME|PROJECT_NUMBER]
656
+ dsu project use [OPTIONS] [PROJECT_NAME|PROJECT_NUMBER]
657
657
 
658
- dsu p u [PROJECT_NAME|PROJECT_NUMBER]
658
+ dsu p u [OPTIONS] [PROJECT_NAME|PROJECT_NUMBER]
659
+
660
+ OPTIONS:
661
+
662
+ -d|--default true|false (default: false): If true, the PROJECT_NAME|PROJECT_NUMBER will become the default project.
659
663
 
660
664
  PROJECT_NAME
661
665
 
@@ -688,6 +692,12 @@ en:
688
692
  $ dsu project use 2
689
693
 
690
694
  $ dsu p u 2
695
+
696
+ These will use "Project A" and make it the default project if it is not the default project.
697
+
698
+ $ dsu project use --default "Project A"
699
+
700
+ $ dsu p u -d "Project A"
691
701
  messages:
692
702
  using_project: Now using project "%{project_name}".
693
703
  prompts:
@@ -32,7 +32,7 @@
32
32
  "background": "default"
33
33
  },
34
34
  "footer": {
35
- "color": "light_default",
35
+ "color": "default",
36
36
  "mode": "default",
37
37
  "background": "default"
38
38
  },
@@ -42,7 +42,7 @@
42
42
  "background": "default"
43
43
  },
44
44
  "index": {
45
- "color": "light_default",
45
+ "color": "default",
46
46
  "mode": "italic",
47
47
  "background": "default"
48
48
  },
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: 3.0.0.alpha.12
4
+ version: 3.0.0.beta.0
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: 2024-02-11 00:00:00.000000000 Z
11
+ date: 2024-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -171,7 +171,7 @@ files:
171
171
  - lib/dsu/env.rb
172
172
  - lib/dsu/migration/factory.rb
173
173
  - lib/dsu/migration/service.rb
174
- - lib/dsu/migration/service_20230613121411.rb
174
+ - lib/dsu/migration/service_20240210161248.rb
175
175
  - lib/dsu/migration/version.rb
176
176
  - lib/dsu/models/color_theme.rb
177
177
  - lib/dsu/models/configuration.rb
@@ -197,6 +197,7 @@ files:
197
197
  - lib/dsu/presenters/import/import_entry.rb
198
198
  - lib/dsu/presenters/import/import_file.rb
199
199
  - lib/dsu/presenters/project/create_presenter.rb
200
+ - lib/dsu/presenters/project/defaultable.rb
200
201
  - lib/dsu/presenters/project/delete_by_number_presenter.rb
201
202
  - lib/dsu/presenters/project/delete_presenter.rb
202
203
  - lib/dsu/presenters/project/list_presenter.rb