markdown_exec 2.8.2 → 2.8.4

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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +52 -0
  3. data/Gemfile.lock +1 -1
  4. data/Rakefile +33 -23
  5. data/bats/{block-types.bats → block-type-bash.bats} +0 -25
  6. data/bats/block-type-link.bats +9 -0
  7. data/bats/block-type-port.bats +16 -0
  8. data/bats/block-type-ux-allowed.bats +29 -0
  9. data/bats/block-type-ux-auto.bats +1 -1
  10. data/bats/block-type-ux-chained.bats +9 -0
  11. data/bats/block-type-ux-echo-hash.bats +14 -0
  12. data/bats/block-type-ux-echo.bats +20 -0
  13. data/bats/block-type-ux-exec.bats +1 -1
  14. data/bats/block-type-ux-hidden.bats +9 -0
  15. data/bats/block-type-ux-invalid.bats +8 -0
  16. data/bats/block-type-ux-preconditions.bats +8 -0
  17. data/bats/block-type-ux-readonly.bats +10 -0
  18. data/bats/block-type-ux-transform.bats +1 -1
  19. data/bats/block-type-vars.bats +3 -3
  20. data/bats/indented-block-type-vars.bats +9 -0
  21. data/bats/indented-multi-line-output.bats +9 -0
  22. data/bats/line-decor-dynamic.bats +8 -0
  23. data/bats/test_helper.bash +19 -2
  24. data/bats/variable-expansion-multiline.bats +8 -0
  25. data/bats/variable-expansion.bats +1 -1
  26. data/bin/tab_completion.sh +0 -5
  27. data/bin/tab_completion.sh.erb +0 -5
  28. data/docs/dev/block-type-ux-allowed.md +80 -0
  29. data/docs/dev/block-type-ux-chained.md +21 -0
  30. data/docs/dev/block-type-ux-echo-hash.md +72 -0
  31. data/docs/dev/block-type-ux-echo.md +21 -0
  32. data/docs/dev/block-type-ux-hidden.md +21 -0
  33. data/docs/dev/block-type-ux-invalid.md +5 -0
  34. data/docs/dev/block-type-ux-preconditions.md +9 -0
  35. data/docs/dev/block-type-ux-readonly.md +7 -0
  36. data/docs/dev/block-type-ux-require.md +8 -4
  37. data/docs/dev/indented-block-type-vars.md +6 -0
  38. data/docs/dev/indented-multi-line-output.md +11 -0
  39. data/docs/dev/line-decor-dynamic.md +10 -0
  40. data/docs/dev/variable-expansion-multiline.md +31 -0
  41. data/lib/ansi_formatter.rb +0 -1
  42. data/lib/ansi_string.rb +10 -1
  43. data/lib/array.rb +0 -1
  44. data/lib/array_util.rb +0 -1
  45. data/lib/block_label.rb +1 -1
  46. data/lib/cached_nested_file_reader.rb +1 -1
  47. data/lib/constants.rb +18 -0
  48. data/lib/directory_searcher.rb +1 -1
  49. data/lib/exceptions.rb +0 -1
  50. data/lib/fcb.rb +51 -8
  51. data/lib/filter.rb +4 -4
  52. data/lib/format_table.rb +1 -0
  53. data/lib/fout.rb +1 -1
  54. data/lib/hash.rb +0 -1
  55. data/lib/hash_delegator.rb +403 -200
  56. data/lib/link_history.rb +17 -17
  57. data/lib/logged_struct.rb +429 -0
  58. data/lib/markdown_exec/version.rb +1 -1
  59. data/lib/markdown_exec.rb +3 -3
  60. data/lib/mdoc.rb +5 -17
  61. data/lib/menu.src.yml +3 -1
  62. data/lib/menu.yml +1 -1
  63. data/lib/namer.rb +4 -5
  64. data/lib/null_result.rb +131 -0
  65. data/lib/object_present.rb +1 -1
  66. data/lib/option_value.rb +1 -1
  67. data/lib/resize_terminal.rb +1 -2
  68. data/lib/saved_assets.rb +1 -1
  69. data/lib/saved_files_matcher.rb +1 -1
  70. data/lib/shell_session.rb +439 -0
  71. data/lib/streams_out.rb +0 -1
  72. data/lib/string_util.rb +11 -1
  73. data/lib/success_result.rb +112 -0
  74. data/lib/text_analyzer.rb +1 -0
  75. data/lib/ww.rb +9 -7
  76. metadata +33 -3
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env -S bundle exec ruby
2
+ # frozen_string_literal: true
3
+
4
+ # encoding=utf-8
5
+
6
+ # frozen_string_literal: true
7
+
8
+ require 'singleton'
9
+
10
+ ##
11
+ # SuccessResult represents a successful outcome when no specific result value is produced.
12
+ #
13
+ # This class follows the Null Object pattern for successful cases, ensuring a consistent
14
+ # interface with methods such as #success? and #failure?. It is implemented as a singleton,
15
+ # meaning there is only one instance of SuccessResult available.
16
+ #
17
+ # Example:
18
+ # result = SomeService.call
19
+ # if result.success?
20
+ # # proceed knowing the operation succeeded
21
+ # else
22
+ # # handle failure
23
+ # end
24
+ #
25
+ class SuccessResult
26
+ include Singleton
27
+
28
+ ##
29
+ # Indicates that the result is a success.
30
+ #
31
+ # @return [Boolean] always true for SuccessResult
32
+ def success?
33
+ true
34
+ end
35
+
36
+ ##
37
+ # Indicates that the result is not a failure.
38
+ #
39
+ # @return [Boolean] always false for SuccessResult
40
+ def failure?
41
+ false
42
+ end
43
+
44
+ ##
45
+ # Provides a default message for the successful result.
46
+ #
47
+ # @return [String] a message indicating success
48
+ def message
49
+ 'Success'
50
+ end
51
+
52
+ ##
53
+ # Returns a string representation of this SuccessResult.
54
+ #
55
+ # @return [String]
56
+ def to_s
57
+ 'SuccessResult'
58
+ end
59
+ end
60
+
61
+ # Default instance for ease-of-use.
62
+ DEFAULT_SUCCESS_RESULT = SuccessResult.instance
63
+
64
+ return unless $PROGRAM_NAME == __FILE__
65
+
66
+ require 'bundler/setup'
67
+ Bundler.require(:default)
68
+
69
+ require 'minitest/autorun'
70
+ require 'mocha/minitest'
71
+
72
+ require_relative 'ww'
73
+
74
+ ##
75
+ # Tests for the SuccessResult class.
76
+ #
77
+ # This suite verifies that the SuccessResult singleton behaves as expected:
78
+ # - It is a singleton (all calls to SuccessResult.instance return the same object)
79
+ # - The #success? method returns true and #failure? returns false
80
+ # - The default message and string representation are correct.
81
+ #
82
+ class SuccessResultTest < Minitest::Test
83
+ def test_singleton
84
+ instance1 = SuccessResult.instance
85
+ instance2 = SuccessResult.instance
86
+ assert_same instance1, instance2, "Expected the singleton instances to be identical"
87
+ end
88
+
89
+ def test_success_method
90
+ sr = SuccessResult.instance
91
+ assert sr.success?, "Expected success? to return true"
92
+ end
93
+
94
+ def test_failure_method
95
+ sr = SuccessResult.instance
96
+ refute sr.failure?, "Expected failure? to return false"
97
+ end
98
+
99
+ def test_message
100
+ sr = SuccessResult.instance
101
+ assert_equal 'Success', sr.message, "Expected message to be 'Success'"
102
+ end
103
+
104
+ def test_to_s
105
+ sr = SuccessResult.instance
106
+ assert_equal 'SuccessResult', sr.to_s, "Expected to_s to return 'SuccessResult'"
107
+ end
108
+
109
+ def test_default_success_result_constant
110
+ assert_same SuccessResult.instance, DEFAULT_SUCCESS_RESULT, "Expected DEFAULT_SUCCESS_RESULT to be the same singleton instance"
111
+ end
112
+ end
data/lib/text_analyzer.rb CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env -S bundle exec ruby
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module TextAnalyzer
data/lib/ww.rb CHANGED
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # encoding=utf-8
4
+ require 'bundler/setup' # Bundler enforces gem versions
4
5
  require 'pp'
5
6
  require 'stringio'
6
7
 
7
- LOG_LEVELS = %i[debug info warn error fatal]
8
+ LOG_LEVELS = %i[debug info warn error fatal].freeze
8
9
 
9
10
  $debug = $DEBUG || !ENV['WW'].nil?
10
11
 
@@ -15,7 +16,8 @@ if $debug && ENV['WW_MINIMUM'].nil?
15
16
  end
16
17
 
17
18
  def ww(*objs, **kwargs)
18
- return objs.size == 1 ? objs.first : objs unless $debug
19
+ # return the last item in the list, as the label is usually first
20
+ return objs.last unless $debug
19
21
 
20
22
  ww0(*objs, **kwargs.merge(locations: caller_locations))
21
23
  end
@@ -55,12 +57,11 @@ def ww0(*objs,
55
57
  # Combine all parts into the final message
56
58
  header = "#{time_prefix}#{level_prefix} #{category_prefix}"
57
59
  trace = backtrace + objs
60
+ io = StringIO.new
58
61
  formatted_message = if single_line
59
- io = StringIO.new
60
62
  PP.singleline_pp(trace, io)
61
63
  "#{header} #{io.string}"
62
64
  else
63
- io = StringIO.new
64
65
  PP.pp(trace, io)
65
66
  "#{header}\n#{io.string}"
66
67
  end
@@ -76,14 +77,15 @@ def ww0(*objs,
76
77
  file.puts(formatted_message)
77
78
  end
78
79
 
79
- objs.size == 1 ? objs.first : objs
80
+ # return the last item in the list, as the label is usually first
81
+ objs.last
80
82
  end
81
83
 
82
84
  class Array
83
85
  unless defined?(deref)
84
86
  def deref
85
- map(&:deref).select do |line|
86
- !%r{^/(vendor|\.bundle)/}.match(line)
87
+ map(&:deref).reject do |line|
88
+ %r{^/(vendor|\.bundle)/}.match(line)
87
89
  end
88
90
  end
89
91
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdown_exec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.2
4
+ version: 2.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fareed Stevenson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-19 00:00:00.000000000 Z
11
+ date: 2025-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard
@@ -108,14 +108,24 @@ files:
108
108
  - assets/select_a_file.png
109
109
  - bats/bats.bats
110
110
  - bats/block-hide.bats
111
+ - bats/block-type-bash.bats
112
+ - bats/block-type-link.bats
111
113
  - bats/block-type-opts.bats
114
+ - bats/block-type-port.bats
115
+ - bats/block-type-ux-allowed.bats
112
116
  - bats/block-type-ux-auto.bats
117
+ - bats/block-type-ux-chained.bats
118
+ - bats/block-type-ux-echo-hash.bats
119
+ - bats/block-type-ux-echo.bats
113
120
  - bats/block-type-ux-exec.bats
121
+ - bats/block-type-ux-hidden.bats
122
+ - bats/block-type-ux-invalid.bats
123
+ - bats/block-type-ux-preconditions.bats
124
+ - bats/block-type-ux-readonly.bats
114
125
  - bats/block-type-ux-require.bats
115
126
  - bats/block-type-ux-row-format.bats
116
127
  - bats/block-type-ux-transform.bats
117
128
  - bats/block-type-vars.bats
118
- - bats/block-types.bats
119
129
  - bats/border.bats
120
130
  - bats/cli.bats
121
131
  - bats/command-substitution.bats
@@ -123,6 +133,9 @@ files:
123
133
  - bats/fail.bats
124
134
  - bats/history.bats
125
135
  - bats/import.bats
136
+ - bats/indented-block-type-vars.bats
137
+ - bats/indented-multi-line-output.bats
138
+ - bats/line-decor-dynamic.bats
126
139
  - bats/line-wrapping.bats
127
140
  - bats/markup.bats
128
141
  - bats/mde.bats
@@ -133,6 +146,7 @@ files:
133
146
  - bats/table-column-truncate.bats
134
147
  - bats/table.bats
135
148
  - bats/test_helper.bash
149
+ - bats/variable-expansion-multiline.bats
136
150
  - bats/variable-expansion.bats
137
151
  - bin/bmde
138
152
  - bin/colorize_env_vars.sh
@@ -146,8 +160,16 @@ files:
146
160
  - docs/dev/block-type-bash.md
147
161
  - docs/dev/block-type-opts.md
148
162
  - docs/dev/block-type-port.md
163
+ - docs/dev/block-type-ux-allowed.md
149
164
  - docs/dev/block-type-ux-auto.md
165
+ - docs/dev/block-type-ux-chained.md
166
+ - docs/dev/block-type-ux-echo-hash.md
167
+ - docs/dev/block-type-ux-echo.md
150
168
  - docs/dev/block-type-ux-exec.md
169
+ - docs/dev/block-type-ux-hidden.md
170
+ - docs/dev/block-type-ux-invalid.md
171
+ - docs/dev/block-type-ux-preconditions.md
172
+ - docs/dev/block-type-ux-readonly.md
151
173
  - docs/dev/block-type-ux-require.md
152
174
  - docs/dev/block-type-ux-row-format.md
153
175
  - docs/dev/block-type-ux-transform.md
@@ -159,6 +181,9 @@ files:
159
181
  - docs/dev/document-shell.md
160
182
  - docs/dev/import-missing.md
161
183
  - docs/dev/import.md
184
+ - docs/dev/indented-block-type-vars.md
185
+ - docs/dev/indented-multi-line-output.md
186
+ - docs/dev/line-decor-dynamic.md
162
187
  - docs/dev/line-wrapping.md
163
188
  - docs/dev/linked-file.md
164
189
  - docs/dev/load1.sh
@@ -176,6 +201,7 @@ files:
176
201
  - docs/dev/table-indent.md
177
202
  - docs/dev/table-invalid.md
178
203
  - docs/dev/text-decoration.md
204
+ - docs/dev/variable-expansion-multiline.md
179
205
  - docs/dev/variable-expansion.md
180
206
  - examples/bash-blocks.md
181
207
  - examples/block-names.md
@@ -248,12 +274,14 @@ files:
248
274
  - lib/input_sequencer.rb
249
275
  - lib/instance_method_wrapper.rb
250
276
  - lib/link_history.rb
277
+ - lib/logged_struct.rb
251
278
  - lib/markdown_exec.rb
252
279
  - lib/markdown_exec/version.rb
253
280
  - lib/mdoc.rb
254
281
  - lib/menu.src.yml
255
282
  - lib/menu.yml
256
283
  - lib/namer.rb
284
+ - lib/null_result.rb
257
285
  - lib/object_present.rb
258
286
  - lib/option_value.rb
259
287
  - lib/regexp.rb
@@ -262,8 +290,10 @@ files:
262
290
  - lib/saved_assets.rb
263
291
  - lib/saved_files_matcher.rb
264
292
  - lib/shared.rb
293
+ - lib/shell_session.rb
265
294
  - lib/streams_out.rb
266
295
  - lib/string_util.rb
296
+ - lib/success_result.rb
267
297
  - lib/table_extractor.rb
268
298
  - lib/tap.rb
269
299
  - lib/text_analyzer.rb