Class: MarkdownExec::SavedAsset
Overview
SavedAsset
This class provides utilities to format and derive asset names based on given parameters. The ‘script_name` method derives a name for a script based on filename, prefix, time, and blockname. Similarly, the `stdout_name` method derives a name for stdout redirection.
Constant Summary collapse
- FNR11 =
%r{/|:}.freeze
- FNR12 =
'_'
- DEFAULT_FTIME =
'%F-%H-%M-%S'
Class Method Summary collapse
-
.script_name(filename:, prefix:, time:, blockname:, ftime: DEFAULT_FTIME, join_str: '_', pattern: FNR11, replace: FNR12, exts: '.sh') ⇒ Object
Generates a formatted script name based on the provided parameters.
-
.stdout_name(filename:, prefix:, time:, blockname:, ftime: DEFAULT_FTIME, join_str: '_', pattern: FNR11, replace: FNR12, exts: '.out.txt') ⇒ Object
Generates a formatted stdout name based on the provided parameters.
Class Method Details
.script_name(filename:, prefix:, time:, blockname:, ftime: DEFAULT_FTIME, join_str: '_', pattern: FNR11, replace: FNR12, exts: '.sh') ⇒ Object
Generates a formatted script name based on the provided parameters.
20 21 22 23 24 |
# File 'lib/saved_assets.rb', line 20 def self.script_name(filename:, prefix:, time:, blockname:, ftime: DEFAULT_FTIME, join_str: '_', pattern: FNR11, replace: FNR12, exts: '.sh') fne = filename.gsub(pattern, replace) bne = blockname.gsub(pattern, replace) "#{[prefix, time.strftime(ftime), fne, ',', bne].join(join_str)}#{exts}" end |
.stdout_name(filename:, prefix:, time:, blockname:, ftime: DEFAULT_FTIME, join_str: '_', pattern: FNR11, replace: FNR12, exts: '.out.txt') ⇒ Object
Generates a formatted stdout name based on the provided parameters.
27 28 29 30 31 |
# File 'lib/saved_assets.rb', line 27 def self.stdout_name(filename:, prefix:, time:, blockname:, ftime: DEFAULT_FTIME, join_str: '_', pattern: FNR11, replace: FNR12, exts: '.out.txt') fne = filename.gsub(pattern, replace) bne = blockname.gsub(pattern, replace) "#{[prefix, time.strftime(ftime), fne, ',', bne].join(join_str)}#{exts}" end |