dsu 0.1.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/.reek.yml +20 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +192 -0
  5. data/.ruby-version +1 -0
  6. data/CHANGELOG.md +2 -0
  7. data/CODE_OF_CONDUCT.md +84 -0
  8. data/Gemfile +19 -0
  9. data/Gemfile.lock +133 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +128 -0
  12. data/Rakefile +12 -0
  13. data/bin/console +15 -0
  14. data/bin/setup +8 -0
  15. data/exe/dsu +11 -0
  16. data/lib/dsu/cli.rb +178 -0
  17. data/lib/dsu/command_services/add_entry_service.rb +61 -0
  18. data/lib/dsu/models/entry.rb +49 -0
  19. data/lib/dsu/models/entry_group.rb +70 -0
  20. data/lib/dsu/services/configuration_loader_service.rb +34 -0
  21. data/lib/dsu/services/entry_group_deleter_service.rb +31 -0
  22. data/lib/dsu/services/entry_group_hydrator_service.rb +43 -0
  23. data/lib/dsu/services/entry_group_reader_service.rb +36 -0
  24. data/lib/dsu/services/entry_group_writer_service.rb +45 -0
  25. data/lib/dsu/services/entry_hydrator_service.rb +35 -0
  26. data/lib/dsu/subcommands/config.rb +49 -0
  27. data/lib/dsu/support/ask.rb +38 -0
  28. data/lib/dsu/support/colorable.rb +13 -0
  29. data/lib/dsu/support/commander/command.rb +130 -0
  30. data/lib/dsu/support/commander/command_help.rb +62 -0
  31. data/lib/dsu/support/commander/subcommand.rb +45 -0
  32. data/lib/dsu/support/configuration.rb +89 -0
  33. data/lib/dsu/support/entry_group_fileable.rb +41 -0
  34. data/lib/dsu/support/entry_group_loadable.rb +52 -0
  35. data/lib/dsu/support/field_errors.rb +11 -0
  36. data/lib/dsu/support/folder_locations.rb +21 -0
  37. data/lib/dsu/support/interactive/cli.rb +161 -0
  38. data/lib/dsu/support/say.rb +40 -0
  39. data/lib/dsu/support/time_formatable.rb +42 -0
  40. data/lib/dsu/validators/entries_validator.rb +64 -0
  41. data/lib/dsu/validators/time_validator.rb +34 -0
  42. data/lib/dsu/version.rb +5 -0
  43. data/lib/dsu/views/entry_group/show.rb +60 -0
  44. data/lib/dsu.rb +38 -0
  45. data/sig/dsu.rbs +4 -0
  46. metadata +199 -0
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../models/entry'
4
+ require_relative '../support/field_errors'
5
+
6
+ # https://guides.rubyonrails.org/active_record_validations.html#validates-with
7
+ module Dsu
8
+ module Validators
9
+ class EntriesValidator < ActiveModel::Validator
10
+ include Dsu::Support::FieldErrors
11
+
12
+ def validate(record)
13
+ raise 'options[:fields] is not defined.' unless options.key? :fields
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 }
16
+
17
+ options[:fields].each do |field|
18
+ entries = record.send(field)
19
+
20
+ unless entries.is_a?(Array)
21
+ record.errors.add(field, 'is the wrong object type. ' \
22
+ "\"Array\" was expected, but \"#{entries.class}\" was received.")
23
+ next
24
+ end
25
+
26
+ validate_entry_types field, entries, record
27
+ validate_unique_entry_uuids field, entries, record
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def validate_entry_types(field, entries, record)
34
+ entries.each do |entry|
35
+ next if entry.is_a? Dsu::Models::Entry
36
+
37
+ record.errors.add(field, 'entry Array element is the wrong object type. ' \
38
+ "\"Entry\" was expected, but \"#{entry.class}\" was received.",
39
+ type: Dsu::Support::FieldErrors::FIELD_TYPE_ERROR)
40
+
41
+ next
42
+ end
43
+ end
44
+
45
+ def validate_unique_entry_uuids(field, entries, record)
46
+ return unless entries.is_a? Array
47
+
48
+ entry_objects = entries.select { |entry| entry.is_a?(Dsu::Models::Entry) }
49
+
50
+ entry_objects.map(&:uuid).tap do |uuids|
51
+ return if uuids.uniq.length == uuids.length
52
+ end
53
+
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
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ # https://guides.rubyonrails.org/active_record_validations.html#validates-with
4
+ module Dsu
5
+ module Validators
6
+ class TimeValidator < ActiveModel::Validator
7
+ def validate(record)
8
+ raise 'options[:fields] is not defined.' unless options.key? :fields
9
+ raise 'options[:fields] is not an Array.' unless options[:fields].is_a? Array
10
+ raise 'options[:fields] elements are not Symbols.' unless options[:fields].all?(Symbol)
11
+
12
+ options[:fields].each do |field|
13
+ time = record.send(field)
14
+
15
+ if time.nil?
16
+ record.errors.add(field, :blank)
17
+ next
18
+ end
19
+
20
+ unless time.is_a?(Time)
21
+ record.errors.add(field, 'is the wrong object type. ' \
22
+ "\"Time\" was expected, but \"#{time.class}\" was received.")
23
+ next
24
+ end
25
+
26
+ if time.utc?
27
+ record.errors.add(field, 'is not in localtime format.')
28
+ next
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dsu
4
+ VERSION = '0.1.0.alpha.1'
5
+ end
@@ -0,0 +1,60 @@
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 Show
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
+ display_entry_group!
33
+ rescue ActiveModel::ValidationError
34
+ puts "Error(s) encountered: #{entry_group.errors.full_messages}"
35
+ raise
36
+ end
37
+ alias display call
38
+
39
+ private
40
+
41
+ attr_reader :entry_group, :options
42
+
43
+ def display_entry_group!
44
+ say formatted_time(time: entry_group.time), HIGHLIGHT
45
+ say('(no entries available for this day)') and return if entry_group.entries.empty?
46
+
47
+ entry_group.entries.each_with_index do |entry, index|
48
+ prefix = "#{format('%03s', index + 1)}. #{entry.uuid}"
49
+ description = colorize_string(string: entry.description, mode: :bold)
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
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
data/lib/dsu.rb ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'time'
4
+ require 'active_support/core_ext/object/blank'
5
+ require 'active_support/core_ext/hash/indifferent_access'
6
+ require 'active_support/core_ext/numeric/time'
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
+ Dir.glob("#{__dir__}/dsu/**/*.rb").each do |file|
29
+ require file
30
+ 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
data/sig/dsu.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Dsu
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,199 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dsu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.alpha.1
5
+ platform: ruby
6
+ authors:
7
+ - Gene M. Angelo, Jr.
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-05-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '7.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 7.0.4
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '7.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 7.0.4
33
+ - !ruby/object:Gem::Dependency
34
+ name: colorize
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.8.1
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 0.8.1
47
+ - !ruby/object:Gem::Dependency
48
+ name: deco_lite
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.3'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.3'
61
+ - !ruby/object:Gem::Dependency
62
+ name: os
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.1'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 1.1.4
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '1.1'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 1.1.4
81
+ - !ruby/object:Gem::Dependency
82
+ name: thor
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '1.2'
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 1.2.1
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '1.2'
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 1.2.1
101
+ - !ruby/object:Gem::Dependency
102
+ name: thor_nested_subcommand
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "~>"
106
+ - !ruby/object:Gem::Version
107
+ version: '1.0'
108
+ type: :runtime
109
+ prerelease: false
110
+ version_requirements: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - "~>"
113
+ - !ruby/object:Gem::Version
114
+ version: '1.0'
115
+ description: |2
116
+ 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.
117
+
118
+ NOTE: This gem is currently in development (alpha release) and does not provide the ability to UPDATE or DELETE activities. These features will be added in future releases.
119
+
120
+ IN ADDITION TO THIS: dsu's current behavior when viewing a particular day is to display the previous day's activities. This behavior is not necessarily ideal when sharing activities for a DSU that occurs on a Monday. This is because Monday's DSU typically includes sharing what you did on last FRIDAY (not necessarily "Yesterday"), as well as what you plan on doing "Today". This behavior will be changed in a future release as well, to display the previous Friday's activities (as well as Saturday and Sunday) if "Today" happens to be Monday.
121
+ email:
122
+ - public.gma@gmail.com
123
+ executables:
124
+ - dsu
125
+ extensions: []
126
+ extra_rdoc_files: []
127
+ files:
128
+ - ".reek.yml"
129
+ - ".rspec"
130
+ - ".rubocop.yml"
131
+ - ".ruby-version"
132
+ - CHANGELOG.md
133
+ - CODE_OF_CONDUCT.md
134
+ - Gemfile
135
+ - Gemfile.lock
136
+ - LICENSE.txt
137
+ - README.md
138
+ - Rakefile
139
+ - bin/console
140
+ - bin/setup
141
+ - exe/dsu
142
+ - lib/dsu.rb
143
+ - lib/dsu/cli.rb
144
+ - lib/dsu/command_services/add_entry_service.rb
145
+ - lib/dsu/models/entry.rb
146
+ - lib/dsu/models/entry_group.rb
147
+ - lib/dsu/services/configuration_loader_service.rb
148
+ - lib/dsu/services/entry_group_deleter_service.rb
149
+ - lib/dsu/services/entry_group_hydrator_service.rb
150
+ - lib/dsu/services/entry_group_reader_service.rb
151
+ - lib/dsu/services/entry_group_writer_service.rb
152
+ - lib/dsu/services/entry_hydrator_service.rb
153
+ - lib/dsu/subcommands/config.rb
154
+ - lib/dsu/support/ask.rb
155
+ - lib/dsu/support/colorable.rb
156
+ - lib/dsu/support/commander/command.rb
157
+ - lib/dsu/support/commander/command_help.rb
158
+ - lib/dsu/support/commander/subcommand.rb
159
+ - lib/dsu/support/configuration.rb
160
+ - lib/dsu/support/entry_group_fileable.rb
161
+ - lib/dsu/support/entry_group_loadable.rb
162
+ - lib/dsu/support/field_errors.rb
163
+ - lib/dsu/support/folder_locations.rb
164
+ - lib/dsu/support/interactive/cli.rb
165
+ - lib/dsu/support/say.rb
166
+ - lib/dsu/support/time_formatable.rb
167
+ - lib/dsu/validators/entries_validator.rb
168
+ - lib/dsu/validators/time_validator.rb
169
+ - lib/dsu/version.rb
170
+ - lib/dsu/views/entry_group/show.rb
171
+ - sig/dsu.rbs
172
+ homepage: https://github.com/gangelo/dsu
173
+ licenses:
174
+ - MIT
175
+ metadata:
176
+ homepage_uri: https://github.com/gangelo/dsu
177
+ source_code_uri: https://github.com/gangelo/dsu
178
+ changelog_uri: https://github.com/gangelo/dsu/blob/main/CHANGELOG.md
179
+ rubygems_mfa_required: 'true'
180
+ post_install_message:
181
+ rdoc_options: []
182
+ require_paths:
183
+ - lib
184
+ required_ruby_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: 3.0.1
189
+ required_rubygems_version: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">"
192
+ - !ruby/object:Gem::Version
193
+ version: 1.3.1
194
+ requirements: []
195
+ rubygems_version: 3.3.22
196
+ signing_key:
197
+ specification_version: 4
198
+ summary: dsu (Agile Daily Stand Up/DSU) mini-manager.
199
+ test_files: []