summaryrefslogtreecommitdiff
path: root/lib/dslkeywords/file.rb
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-02-15 09:25:57 +0200
committerPaul Buetow <paul@buetow.org>2025-02-15 09:25:57 +0200
commit6879b03b2735b082b913ab17e63857f464f53c93 (patch)
tree525b1b78983ba3b3d6f4e218daf0055edf7728a9 /lib/dslkeywords/file.rb
parent463f429166c5ace855998b433e865140f9b737ca (diff)
dsl keyword base class added
Diffstat (limited to 'lib/dslkeywords/file.rb')
-rw-r--r--lib/dslkeywords/file.rb18
1 files changed, 5 insertions, 13 deletions
diff --git a/lib/dslkeywords/file.rb b/lib/dslkeywords/file.rb
index 1b99a91..50f753e 100644
--- a/lib/dslkeywords/file.rb
+++ b/lib/dslkeywords/file.rb
@@ -1,24 +1,18 @@
require 'erb'
require 'fileutils'
-require_relative '../options'
-require_relative '../log'
+require_relative 'keyword'
module RCM
# Managing files
- class File
- attr_reader :id, :path
-
- include Options
- include Log
+ class File < Keyword
+ attr_reader :path
def initialize(path)
- @id = "#{self.class}(#{path})"
+ super(path)
@path = path
end
- def to_s = id
-
def content(text = nil)
return @content if text.nil?
@@ -40,9 +34,7 @@ module RCM
def evaluate_ensure_line!
return write_content!(@ensure_line) unless ::File.file?(@path)
-
- lines = ::File.readlines(@path, chomp: true)
- return if lines.include?(@ensure_line)
+ return if ::File.readlines(@path, chomp: true).include?(@ensure_line)
::File.open(@path, 'a') do |fd|
fd.puts(@ensure_line)