dsu 2.3.1 → 2.3.2
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 +7 -0
- data/Gemfile.lock +2 -2
- data/README.md +2 -2
- data/lib/dsu/models/entry_group.rb +8 -2
- data/lib/dsu/presenters/export/all_presenter.rb +3 -1
- data/lib/dsu/presenters/export/dates_presenter.rb +3 -1
- data/lib/dsu/presenters/export/messages.rb +4 -3
- data/lib/dsu/presenters/export/nothing_to_export.rb +13 -0
- data/lib/dsu/services/entry_group/exporter_service.rb +39 -21
- data/lib/dsu/support/ask.rb +6 -2
- data/lib/dsu/validators/entries_validator.rb +1 -0
- data/lib/dsu/version.rb +1 -1
- data/lib/dsu/views/export.rb +2 -0
- data/lib/locales/en/subcommands.yml +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '00852090ac540e878e139eb7abf19fbb28c62876c75ff5e4f94f7eeec2ab63df'
|
4
|
+
data.tar.gz: 911334c622bbfe95ed7a424089f02e641fa1908528201370013ad0ba97f51802
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9337dd2eed163e9a19981b001eeb90b48576dc229d62c14ff0f5a5fffd08b41a666d2ab2c4395db035cc439e96ad5c069e66c92b60fb69cb92fe994285bcc1ad
|
7
|
+
data.tar.gz: 26cc17c475cca588a06f2065427e98dd981f830f936729554fd66fb57c57344741a0792e452fab564babd49f8b14c0e25af619b65d32ecb76165b5ce139c3332
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [2.3.2] 2023-12-30
|
2
|
+
|
3
|
+
Changes
|
4
|
+
|
5
|
+
- Display a "Nothing to export" message if no entries are found, rather than prompting the user "export 0 entry groups" when using the `dsu export` command.
|
6
|
+
- Add specs for Export::AllPresenter and Export::DatesPresenter
|
7
|
+
|
1
8
|
## [2.3.1] 2023-12-25
|
2
9
|
|
3
10
|
Changes
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dsu (2.3.
|
4
|
+
dsu (2.3.2)
|
5
5
|
activemodel (>= 7.0.8, < 8.0)
|
6
6
|
activesupport (>= 7.0.8, < 8.0)
|
7
7
|
colorize (>= 0.8.1, < 1.0)
|
@@ -114,7 +114,7 @@ GEM
|
|
114
114
|
simplecov-html (0.12.3)
|
115
115
|
simplecov_json_formatter (0.1.4)
|
116
116
|
thor (1.3.0)
|
117
|
-
thor_nested_subcommand (1.0.
|
117
|
+
thor_nested_subcommand (1.0.5)
|
118
118
|
tzinfo (2.0.6)
|
119
119
|
concurrent-ruby (~> 1.0)
|
120
120
|
unicode-display_width (2.5.0)
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# `dsu`- Streamline Your Daily Stand-Up Meeting Participation!
|
2
2
|
|
3
3
|
[](https://github.com/gangelo/dsu/actions/workflows/ruby.yml)
|
4
|
-
[](https://badge.fury.io/gh/gangelo%2Fdsu)
|
5
|
+
[](https://badge.fury.io/rb/dsu)
|
6
6
|
[](http://www.rubydoc.info/gems/dsu/)
|
7
7
|
[](https://github.com/gangelo/dsu/issues)
|
8
8
|
[](#license)
|
@@ -191,13 +191,19 @@ module Dsu
|
|
191
191
|
end
|
192
192
|
|
193
193
|
def write(file_data:, file_path:)
|
194
|
-
|
194
|
+
if file_data[:entries].empty?
|
195
|
+
superclass.delete(file_path: file_path)
|
196
|
+
return true
|
197
|
+
end
|
195
198
|
|
196
199
|
super
|
197
200
|
end
|
198
201
|
|
199
202
|
def write!(file_data:, file_path:)
|
200
|
-
|
203
|
+
if file_data[:entries].empty?
|
204
|
+
superclass.delete!(file_path: file_path)
|
205
|
+
return
|
206
|
+
end
|
201
207
|
|
202
208
|
super
|
203
209
|
end
|
@@ -5,6 +5,7 @@ require_relative '../../services/entry_group/exporter_service'
|
|
5
5
|
require_relative '../../support/ask'
|
6
6
|
require_relative '../base_presenter_ex'
|
7
7
|
require_relative 'messages'
|
8
|
+
require_relative 'nothing_to_export'
|
8
9
|
require_relative 'service_callable'
|
9
10
|
|
10
11
|
module Dsu
|
@@ -12,6 +13,7 @@ module Dsu
|
|
12
13
|
module Export
|
13
14
|
class AllPresenter < BasePresenterEx
|
14
15
|
include Messages
|
16
|
+
include NothingToExport
|
15
17
|
include ServiceCallable
|
16
18
|
include Support::Ask
|
17
19
|
|
@@ -25,7 +27,7 @@ module Dsu
|
|
25
27
|
end
|
26
28
|
|
27
29
|
def display_export_prompt
|
28
|
-
yes?(prompt_with_options(prompt: export_prompt, options: export_prompt_options))
|
30
|
+
yes?(prompt_with_options(prompt: export_prompt, options: export_prompt_options), options: options)
|
29
31
|
end
|
30
32
|
|
31
33
|
private
|
@@ -4,6 +4,7 @@ require_relative '../../models/entry_group'
|
|
4
4
|
require_relative '../../support/ask'
|
5
5
|
require_relative '../base_presenter_ex'
|
6
6
|
require_relative 'messages'
|
7
|
+
require_relative 'nothing_to_export'
|
7
8
|
require_relative 'service_callable'
|
8
9
|
|
9
10
|
module Dsu
|
@@ -11,6 +12,7 @@ module Dsu
|
|
11
12
|
module Export
|
12
13
|
class DatesPresenter < BasePresenterEx
|
13
14
|
include Messages
|
15
|
+
include NothingToExport
|
14
16
|
include ServiceCallable
|
15
17
|
include Support::Ask
|
16
18
|
|
@@ -31,7 +33,7 @@ module Dsu
|
|
31
33
|
end
|
32
34
|
|
33
35
|
def display_export_prompt
|
34
|
-
yes?(prompt_with_options(prompt: export_prompt, options: export_prompt_options))
|
36
|
+
yes?(prompt_with_options(prompt: export_prompt, options: export_prompt_options), options: options)
|
35
37
|
end
|
36
38
|
|
37
39
|
private
|
@@ -1,8 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '../../models/entry_group'
|
4
|
-
require_relative '../base_presenter_ex'
|
5
|
-
|
6
3
|
module Dsu
|
7
4
|
module Presenters
|
8
5
|
module Export
|
@@ -11,6 +8,10 @@ module Dsu
|
|
11
8
|
raise NotImplementedError
|
12
9
|
end
|
13
10
|
|
11
|
+
def display_nothing_to_export_message
|
12
|
+
puts apply_theme(I18n.t('subcommands.export.messages.nothing_to_export'), theme_color: color_theme.info)
|
13
|
+
end
|
14
|
+
|
14
15
|
private
|
15
16
|
|
16
17
|
def display_cancelled_message
|
@@ -11,51 +11,69 @@ module Dsu
|
|
11
11
|
include Support::Fileable
|
12
12
|
|
13
13
|
def initialize(entry_groups:, options: {})
|
14
|
-
raise ArgumentError, 'Argument entry_groups is
|
14
|
+
raise ArgumentError, 'Argument entry_groups is blank' if entry_groups.blank?
|
15
|
+
raise ArgumentError, 'Argument entry_groups are not all valid' unless entry_groups.all?(&:valid?)
|
16
|
+
|
17
|
+
validate_entry_group_entries_present! entry_groups
|
15
18
|
|
16
19
|
@entry_groups = entry_groups
|
17
20
|
@options = options
|
18
21
|
end
|
19
22
|
|
20
23
|
def call
|
21
|
-
CSV.open(
|
24
|
+
CSV.open(export_file_path, 'w') do |csv|
|
22
25
|
csv << %i[version entry_group entry_no total_entries entry_group_entry]
|
23
26
|
|
24
27
|
entry_groups.each do |entry_group|
|
25
|
-
|
26
|
-
|
27
|
-
entry_group.entries.each_with_index do |entry, index|
|
28
|
-
csv << [
|
29
|
-
entry_group.version,
|
30
|
-
entry_group.time.to_date,
|
31
|
-
index + 1,
|
32
|
-
entry_group.entries.count,
|
33
|
-
entry.description
|
34
|
-
]
|
35
|
-
end
|
28
|
+
export_entry_group(entry_group: entry_group, csv: csv)
|
36
29
|
end
|
37
30
|
end
|
38
31
|
|
39
|
-
|
32
|
+
export_file_path
|
40
33
|
end
|
41
34
|
|
42
|
-
def
|
43
|
-
@
|
44
|
-
file_name = "dsu-#{export_timestamp}-#{times.min.to_date}-thru-#{times.max.to_date}.csv"
|
45
|
-
File.join(temp_folder, file_name)
|
46
|
-
end
|
35
|
+
def export_file_path
|
36
|
+
@export_file_path ||= File.join(temp_folder, export_file_name)
|
47
37
|
end
|
48
38
|
|
49
39
|
private
|
50
40
|
|
51
41
|
attr_reader :entry_groups, :options
|
52
42
|
|
43
|
+
def export_entry_data(entry_group:, entry:, entry_index:)
|
44
|
+
[
|
45
|
+
entry_group.version,
|
46
|
+
entry_group.time.to_date,
|
47
|
+
entry_index + 1,
|
48
|
+
entry_group.entries.count,
|
49
|
+
entry.description
|
50
|
+
]
|
51
|
+
end
|
52
|
+
|
53
|
+
def export_entry_group(entry_group:, csv:)
|
54
|
+
entry_group.entries.each_with_index do |entry, index|
|
55
|
+
csv << export_entry_data(entry_group: entry_group, entry: entry, entry_index: index)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def export_file_name
|
60
|
+
"dsu-#{timestamp}-#{times.min.to_date}-thru-#{times.max.to_date}.csv"
|
61
|
+
end
|
62
|
+
|
53
63
|
def times
|
54
64
|
@times ||= entry_groups.map(&:time)
|
55
65
|
end
|
56
66
|
|
57
|
-
def
|
58
|
-
Time.now.in_time_zone.strftime('%Y%m%d%H%M%S')
|
67
|
+
def timestamp
|
68
|
+
@timestamp ||= Time.now.in_time_zone.strftime('%Y%m%d%H%M%S')
|
69
|
+
end
|
70
|
+
|
71
|
+
def validate_entry_group_entries_present!(entry_groups)
|
72
|
+
entry_groups.each do |entry_group|
|
73
|
+
next if entry_group.entries.present?
|
74
|
+
|
75
|
+
raise ArgumentError, "Argument entry_groups entry group for #{entry_group.time_yyyy_mm_dd} has no entries"
|
76
|
+
end
|
59
77
|
end
|
60
78
|
end
|
61
79
|
end
|
data/lib/dsu/support/ask.rb
CHANGED
@@ -13,7 +13,10 @@ module Dsu
|
|
13
13
|
def yes?(prompt, options: {})
|
14
14
|
auto_prompt = auto_prompt(prompt, options)
|
15
15
|
|
16
|
-
|
16
|
+
unless auto_prompt.nil?
|
17
|
+
puts prompt
|
18
|
+
return auto_prompt
|
19
|
+
end
|
17
20
|
|
18
21
|
Thor::Base.shell.new.yes?(prompt)
|
19
22
|
end
|
@@ -21,9 +24,10 @@ module Dsu
|
|
21
24
|
private
|
22
25
|
|
23
26
|
def auto_prompt(prompt, options)
|
27
|
+
options = options.with_indifferent_access
|
24
28
|
prompt = Utils.strip_escapes(prompt)
|
25
29
|
@auto_prompt ||= begin
|
26
|
-
value = options.dig(
|
30
|
+
value = options.dig(:prompts, prompt) || options.dig(:prompts, :any)
|
27
31
|
value = (value == 'true' unless value.nil?)
|
28
32
|
value
|
29
33
|
end
|
data/lib/dsu/version.rb
CHANGED
data/lib/dsu/views/export.rb
CHANGED
@@ -280,6 +280,7 @@ en:
|
|
280
280
|
messages:
|
281
281
|
exported: Export successful.
|
282
282
|
exported_to: Entry groups exported to %{file_path}.
|
283
|
+
nothing_to_export: No entry groups to export.
|
283
284
|
cancelled: Cancelled.
|
284
285
|
prompts:
|
285
286
|
export_all_confirm: Export all the entries (%{count} entry groups)?
|
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: 2.3.
|
4
|
+
version: 2.3.2
|
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-12-
|
11
|
+
date: 2023-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -188,6 +188,7 @@ files:
|
|
188
188
|
- lib/dsu/presenters/export/all_presenter.rb
|
189
189
|
- lib/dsu/presenters/export/dates_presenter.rb
|
190
190
|
- lib/dsu/presenters/export/messages.rb
|
191
|
+
- lib/dsu/presenters/export/nothing_to_export.rb
|
191
192
|
- lib/dsu/presenters/export/service_callable.rb
|
192
193
|
- lib/dsu/services/color_theme/hydrator_service.rb
|
193
194
|
- lib/dsu/services/configuration/hydrator_service.rb
|