diff options
| author | Paul Buetow <paul@buetow.org> | 2025-02-14 21:35:40 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-02-14 21:35:40 +0200 |
| commit | a2edd9ec657dca835ce1a73807a86a9c44fdfec8 (patch) | |
| tree | 678076fbd778b10264ed0b23857c8e5accdcc693 /lib/dslkeywords/file.rb | |
| parent | 07e5f8d4402346ccb336cc0680cad98d0d5ba920 (diff) | |
initial tests
Diffstat (limited to 'lib/dslkeywords/file.rb')
| -rw-r--r-- | lib/dslkeywords/file.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/dslkeywords/file.rb b/lib/dslkeywords/file.rb index 403f01e..58d7a47 100644 --- a/lib/dslkeywords/file.rb +++ b/lib/dslkeywords/file.rb @@ -19,10 +19,10 @@ module RCM def to_s = id - def content(content = nil) - return @content if content.nil? + def content(text = nil) + return @content if text.nil? - @content = content.instance_of?(Array) ? content.join("\n") : content + @content = text.instance_of?(Array) ? text.join("\n") : text end def create_parent_directory = @create_parent = true @@ -49,12 +49,12 @@ module RCM end end - def write_content!(content) + def write_content!(text) create_parent_directory! - debug content if option :debug + debug text if option :debug info "Creating file #{@path}" tmp_path = "#{@path}.tmp" - ::File.write(tmp_path, content) + ::File.write(tmp_path, text) ::File.rename(tmp_path, @path) end @@ -67,8 +67,8 @@ module RCM end def real_content - content = @from_sourcefile ? ::File.read(@content) : @content - @from_template ? ERB.new(content).result : content + text = @from_sourcefile ? ::File.read(@content) : @content + @from_template ? ERB.new(text).result : text end end @@ -77,6 +77,8 @@ module RCM def file(path, &block) return unless @conds_met + p :FOO, path + f = File.new(path) f.content(f.instance_eval(&block)) self << f |
