howzit 2.1.25 → 2.1.26

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 330829109ccbd73e32ce82690327d2776c1a2f4e60004165fbcde80bdb2b68d6
4
- data.tar.gz: 402805ec02154f4ed0f219bc8975be8b1f24e5ca8726e2eb6040f905f32854c7
3
+ metadata.gz: 19fc185635709d53c4d7dcf0b437d4ec6b00cdd341d734e4655ef4e8e1dbfd3a
4
+ data.tar.gz: 9305e6edf7a8c4f7bf6d2d6a4a1aed14313aac73b658595a877314e929c15c8b
5
5
  SHA512:
6
- metadata.gz: 6f6f3ad81b25dc520f43a4ba1ca063a093dece43129c5ba86ed4364ecc4de5d9222f86ba64dbc91220d73197586846d92ff7f7b98251739881a3d140f453c0ea
7
- data.tar.gz: 7b5eef5eb1cca9c57e3f7fa7af222911d43790b15bfb30b682c1c6f521cd1c54f8995a357141f1533830c888b91d79b107f3ec295b6238360719e1a6f2bb6032
6
+ metadata.gz: a35475dfaf7aa381157964466046ff8c94b0a4282bd9bbb8c067b7d344527d8ba95a296934ce935375111c4c255122cd3c684829d761b4962c517ea6dfadc14b
7
+ data.tar.gz: 41ae72b53d9602fb9b6df8231a4d1db8d9f134b78460e2243e8afaf616528279d0e7b08d68820a330994935579186058838a5d5e5c288b809aa46d0670b71b0f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### 2.1.26
2
+
3
+ 2025-12-26 04:53
4
+
5
+ #### FIXED
6
+
7
+ - Bash script variables in run blocks now preserve ${VAR} syntax when the variable is not defined by howzit, allowing bash to handle them normally instead of being replaced with empty strings.
8
+
1
9
  ### 2.1.25
2
10
 
3
11
  2025-12-19 07:41
@@ -337,7 +337,14 @@ module Howzit
337
337
  gsub!(/\$\{(?<name>[A-Z0-9_]+(?::.*?)?)\}/i) do
338
338
  m = Regexp.last_match
339
339
  arg, default = m['name'].split(/:/).map(&:strip)
340
- Howzit.named_arguments.key?(arg) && !Howzit.named_arguments[arg].nil? ? Howzit.named_arguments[arg] : default
340
+ if Howzit.named_arguments && Howzit.named_arguments.key?(arg) && !Howzit.named_arguments[arg].nil?
341
+ Howzit.named_arguments[arg]
342
+ elsif default
343
+ default
344
+ else
345
+ # Preserve the original ${VAR} syntax if variable is not defined and no default provided
346
+ m[0]
347
+ end
341
348
  end
342
349
  end
343
350
 
@@ -3,5 +3,5 @@
3
3
  # Primary module for this gem.
4
4
  module Howzit
5
5
  # Current Howzit version.
6
- VERSION = '2.1.25'
6
+ VERSION = '2.1.26'
7
7
  end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'StringUtils' do
6
+ describe '#render_named_placeholders' do
7
+ before do
8
+ Howzit.named_arguments = {}
9
+ end
10
+
11
+ it 'preserves ${VAR} syntax when variable is not defined' do
12
+ str = 'echo ${MY_VAR}'.dup
13
+ str.render_named_placeholders
14
+ expect(str).to eq('echo ${MY_VAR}')
15
+ end
16
+
17
+ it 'preserves ${VAR} syntax for multiple undefined variables' do
18
+ str = 'echo ${VAR1} and ${VAR2}'.dup
19
+ str.render_named_placeholders
20
+ expect(str).to eq('echo ${VAR1} and ${VAR2}')
21
+ end
22
+
23
+ it 'replaces ${VAR} with value when variable is defined' do
24
+ Howzit.named_arguments = { 'MY_VAR' => 'hello' }
25
+ str = 'echo ${MY_VAR}'.dup
26
+ str.render_named_placeholders
27
+ expect(str).to eq('echo hello')
28
+ end
29
+
30
+ it 'uses default value when variable is not defined but default is provided' do
31
+ str = 'echo ${MY_VAR:default_value}'.dup
32
+ str.render_named_placeholders
33
+ expect(str).to eq('echo default_value')
34
+ end
35
+
36
+ it 'replaces variable when defined even if default is provided' do
37
+ Howzit.named_arguments = { 'MY_VAR' => 'actual_value' }
38
+ str = 'echo ${MY_VAR:default_value}'.dup
39
+ str.render_named_placeholders
40
+ expect(str).to eq('echo actual_value')
41
+ end
42
+
43
+ it 'preserves ${VAR} in bash script blocks' do
44
+ script = <<~SCRIPT
45
+ #!/bin/bash
46
+ echo "The value is ${ENV_VAR}"
47
+ echo "Another ${OTHER_VAR}"
48
+ SCRIPT
49
+ str = script.dup
50
+ str.render_named_placeholders
51
+ expect(str).to eq(script)
52
+ end
53
+
54
+ it 'handles mixed defined and undefined variables' do
55
+ Howzit.named_arguments = { 'DEFINED_VAR' => 'value1' }
56
+ str = 'echo ${DEFINED_VAR} and ${UNDEFINED_VAR}'.dup
57
+ str.render_named_placeholders
58
+ expect(str).to eq('echo value1 and ${UNDEFINED_VAR}')
59
+ end
60
+
61
+ it 'handles nil named_arguments gracefully' do
62
+ Howzit.named_arguments = nil
63
+ str = 'echo ${MY_VAR}'.dup
64
+ expect { str.render_named_placeholders }.not_to raise_error
65
+ expect(str).to eq('echo ${MY_VAR}')
66
+ end
67
+ end
68
+
69
+ describe '#render_arguments' do
70
+ before do
71
+ Howzit.named_arguments = {}
72
+ Howzit.arguments = nil
73
+ end
74
+
75
+ it 'preserves ${VAR} syntax through render_arguments' do
76
+ str = 'echo ${BASH_VAR}'.dup
77
+ result = str.render_arguments
78
+ expect(result).to eq('echo ${BASH_VAR}')
79
+ end
80
+ end
81
+ end
82
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: howzit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.25
4
+ version: 2.1.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
@@ -315,6 +315,7 @@ files:
315
315
  - spec/ruby_gem_spec.rb
316
316
  - spec/run_report_spec.rb
317
317
  - spec/spec_helper.rb
318
+ - spec/stringutils_spec.rb
318
319
  - spec/task_spec.rb
319
320
  - spec/topic_spec.rb
320
321
  - spec/util_spec.rb
@@ -349,6 +350,7 @@ test_files:
349
350
  - spec/ruby_gem_spec.rb
350
351
  - spec/run_report_spec.rb
351
352
  - spec/spec_helper.rb
353
+ - spec/stringutils_spec.rb
352
354
  - spec/task_spec.rb
353
355
  - spec/topic_spec.rb
354
356
  - spec/util_spec.rb