markdown_exec 3.0.4 → 3.0.5
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 +12 -0
- data/Gemfile.lock +1 -1
- data/bats/block-type-ux-echo-hash-transform.bats +8 -0
- data/bats/block-type-ux-echo.bats +2 -1
- data/docs/dev/block-type-ux-echo-hash-transform.md +40 -0
- data/docs/dev/block-type-ux-echo.md +3 -0
- data/lib/hash_delegator.rb +31 -14
- data/lib/markdown_exec/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3f36dcdba359857aa80f8888d8eaf61e5d2675952a5809341bd993cf30c9ef1
|
4
|
+
data.tar.gz: cc753bd25f2b229b6c3d7bab99249c2b6786e4b3efa3ca56c098ff4838f9ad78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f982dcfa66c59168f8cdf6b1d9d5fc9af2b946f8d9dc42b4d8af9061bb94758784916f1d2afafe7bb215f60d8588900aff43132a8418199f19abbb1b033087cc
|
7
|
+
data.tar.gz: a7219bde3d387303ca86ea096dc9fbcb059c028c74d9bff1696d9f6bb2d8b77715e9080aec424e4ea35a53462fe895ea6210e930ab6d6a1129172fd95f6a9312
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [3.0.5] - 2025-05-23
|
4
|
+
|
5
|
+
### Changed
|
6
|
+
|
7
|
+
- Values for UX echo are validated and transformed.
|
8
|
+
|
9
|
+
## [3.0.4] - 2025-05-28
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
|
13
|
+
- Apply shell option when not specified for a block.
|
14
|
+
|
3
15
|
## [3.0.3] - 2025-05-23
|
4
16
|
|
5
17
|
### Changed
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,8 @@
|
|
1
|
+
#!/usr/bin/env bats
|
2
|
+
|
3
|
+
load 'test_helper'
|
4
|
+
|
5
|
+
@test 'Each key in the echo hash is processed.' {
|
6
|
+
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-echo-hash-transform.md \
|
7
|
+
'Tapanuli Orangutan_Species: PONGO TAPANULIENSIS_Genus: PONGO_Tapanuli Orangutan_Family: H:Hominidae_Order: P:Primates'
|
8
|
+
}
|
@@ -10,7 +10,8 @@ load 'test_helper'
|
|
10
10
|
@test 'inherited lines' {
|
11
11
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-echo.md \
|
12
12
|
'(menu_with_inherited_lines)' \
|
13
|
-
'VAR=
|
13
|
+
'VAR=markdown_exec_IAB='
|
14
|
+
# 'VAR=markdown_exec_VAR=markdown_exec_IAB='
|
14
15
|
}
|
15
16
|
|
16
17
|
@test 'selected block - output of wc includes whitespace' {
|
@@ -0,0 +1,40 @@
|
|
1
|
+
/ Each key in the echo hash is processed.
|
2
|
+
/
|
3
|
+
/ Each value is transformed.
|
4
|
+
```ux
|
5
|
+
echo:
|
6
|
+
Species: Pongo tapanuliensis
|
7
|
+
Genus: Pongo
|
8
|
+
format: Tapanuli Orangutan
|
9
|
+
name: Species
|
10
|
+
transform: :upcase
|
11
|
+
```
|
12
|
+
Species: ${Species}
|
13
|
+
Genus: ${Genus}
|
14
|
+
/
|
15
|
+
/ Each value is validated and transformed.
|
16
|
+
```ux
|
17
|
+
echo:
|
18
|
+
Family: Hominidae
|
19
|
+
Order: Primates
|
20
|
+
format: Tapanuli Orangutan
|
21
|
+
name: Family
|
22
|
+
transform: '%{capital}:%{name}'
|
23
|
+
validate: >
|
24
|
+
^(?<name>(?<capital>.?).*)$
|
25
|
+
```
|
26
|
+
Family: ${Family}
|
27
|
+
Order: ${Order}
|
28
|
+
//
|
29
|
+
// Each key in the exec hash is processed.
|
30
|
+
/```ux
|
31
|
+
/exec:
|
32
|
+
/ Species2: printf %s 'Histiophryne psychedelica'
|
33
|
+
/ Genus2: printf %s 'Histiophryne'
|
34
|
+
/format: Psychedelic Frogfish
|
35
|
+
/name: Species2
|
36
|
+
/transform: :downcase
|
37
|
+
/```
|
38
|
+
/Species2: ${Species2}
|
39
|
+
/Genus2: ${Genus2}
|
40
|
+
@import bats-document-configuration.md
|
data/lib/hash_delegator.rb
CHANGED
@@ -1094,17 +1094,18 @@ module MarkdownExec
|
|
1094
1094
|
@ux_most_recent_filename = @delegate_object[:filename]
|
1095
1095
|
|
1096
1096
|
(blocks.each.with_object([]) do |block, merged_options|
|
1097
|
-
command_result_w_e_t_nl =
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1097
|
+
command_result_w_e_t_nl =
|
1098
|
+
code_from_ux_block_to_set_environment_variables(
|
1099
|
+
block,
|
1100
|
+
mdoc,
|
1101
|
+
force: @delegate_object[:ux_auto_load_force_default],
|
1102
|
+
only_default: true,
|
1103
|
+
silent: true
|
1104
|
+
)
|
1104
1105
|
if command_result_w_e_t_nl.failure?
|
1105
1106
|
merged_options
|
1106
1107
|
else
|
1107
|
-
merged_options.push(command_result_w_e_t_nl.
|
1108
|
+
merged_options.push(command_result_w_e_t_nl.new_lines)
|
1108
1109
|
end
|
1109
1110
|
end).to_a
|
1110
1111
|
end
|
@@ -1115,6 +1116,7 @@ module MarkdownExec
|
|
1115
1116
|
selected, mdoc, inherited_code: nil, force: true, only_default: false,
|
1116
1117
|
silent:
|
1117
1118
|
)
|
1119
|
+
ret_command_result = nil
|
1118
1120
|
exit_prompt = @delegate_object[:prompt_filespec_back]
|
1119
1121
|
|
1120
1122
|
required = mdoc.collect_recursively_required_code(
|
@@ -1169,7 +1171,20 @@ module MarkdownExec
|
|
1169
1171
|
end
|
1170
1172
|
return command_result_w_e_t_nl if command_result_w_e_t_nl.failure?
|
1171
1173
|
|
1174
|
+
command_result_w_e_t_nl.new_lines =
|
1175
|
+
command_result_w_e_t_nl.new_lines.map do |name_force|
|
1176
|
+
transformed = if command_result_w_e_t_nl.transformable
|
1177
|
+
transform_export_value(name_force[:text], export)
|
1178
|
+
else
|
1179
|
+
name_force[:text]
|
1180
|
+
end
|
1181
|
+
ENV[name_force[:name]] = transformed
|
1182
|
+
code_line_safe_assign(
|
1183
|
+
name_force[:name], transformed, force: name_force[:force]
|
1184
|
+
)
|
1185
|
+
end
|
1172
1186
|
required_lines.concat(command_result_w_e_t_nl.new_lines)
|
1187
|
+
|
1173
1188
|
if SelectResponse.continue?(command_result_w_e_t_nl.stdout)
|
1174
1189
|
if command_result_w_e_t_nl.transformable
|
1175
1190
|
command_result_w_e_t_nl.stdout = transform_export_value(
|
@@ -1179,16 +1194,18 @@ module MarkdownExec
|
|
1179
1194
|
|
1180
1195
|
if command_result_w_e_t_nl.exportable
|
1181
1196
|
ENV[export.name] = command_result_w_e_t_nl.stdout.to_s
|
1182
|
-
required_lines.push code_line_safe_assign(
|
1183
|
-
|
1197
|
+
required_lines.push code_line_safe_assign(
|
1198
|
+
export.name, command_result_w_e_t_nl.stdout, force: force
|
1199
|
+
)
|
1184
1200
|
end
|
1185
1201
|
end
|
1202
|
+
ret_command_result = command_result_w_e_t_nl
|
1186
1203
|
else
|
1187
1204
|
raise "Invalid data type: #{data.inspect}"
|
1188
1205
|
end
|
1189
1206
|
end
|
1190
1207
|
|
1191
|
-
CommandResult.new(stdout: required_lines)
|
1208
|
+
ret_command_result || CommandResult.new(stdout: required_lines)
|
1192
1209
|
end
|
1193
1210
|
|
1194
1211
|
# sets ENV
|
@@ -2621,8 +2638,8 @@ module MarkdownExec
|
|
2621
2638
|
command_result.warning = warning_required_empty(export) unless silent
|
2622
2639
|
else
|
2623
2640
|
ENV[name] = command_result.stdout.to_s
|
2624
|
-
new_lines <<
|
2625
|
-
|
2641
|
+
new_lines << { name: name, force: force,
|
2642
|
+
text: command_result.stdout }
|
2626
2643
|
end
|
2627
2644
|
end
|
2628
2645
|
|
@@ -4395,7 +4412,6 @@ module MarkdownExec
|
|
4395
4412
|
marker = Random.new.rand.to_s
|
4396
4413
|
|
4397
4414
|
code = (code_lines || []) + ["echo -n \"#{marker}#{raw}\""]
|
4398
|
-
# !!t code
|
4399
4415
|
File.write filespec, HashDelegator.join_code_lines(code)
|
4400
4416
|
File.chmod 0o755, filespec
|
4401
4417
|
|
@@ -4506,6 +4522,7 @@ module MarkdownExec
|
|
4506
4522
|
return value unless export.transform.present?
|
4507
4523
|
|
4508
4524
|
if export.transform.is_a? Symbol
|
4525
|
+
### TBD validate for symbol
|
4509
4526
|
value.send(export.transform)
|
4510
4527
|
else
|
4511
4528
|
format(
|
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: 3.0.
|
4
|
+
version: 3.0.5
|
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-
|
11
|
+
date: 2025-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clipboard
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- bats/block-type-ux-auto.bats
|
117
117
|
- bats/block-type-ux-chained.bats
|
118
118
|
- bats/block-type-ux-default.bats
|
119
|
+
- bats/block-type-ux-echo-hash-transform.bats
|
119
120
|
- bats/block-type-ux-echo-hash.bats
|
120
121
|
- bats/block-type-ux-echo.bats
|
121
122
|
- bats/block-type-ux-exec.bats
|
@@ -168,6 +169,7 @@ files:
|
|
168
169
|
- docs/dev/block-type-ux-auto.md
|
169
170
|
- docs/dev/block-type-ux-chained.md
|
170
171
|
- docs/dev/block-type-ux-default.md
|
172
|
+
- docs/dev/block-type-ux-echo-hash-transform.md
|
171
173
|
- docs/dev/block-type-ux-echo-hash.md
|
172
174
|
- docs/dev/block-type-ux-echo.md
|
173
175
|
- docs/dev/block-type-ux-exec.md
|