summaryrefslogtreecommitdiff
path: root/lib/autorequire/file.rb
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-12-06 22:33:07 +0200
committerPaul Buetow <paul@buetow.org>2024-12-06 22:33:07 +0200
commitbfdcad7efca071374de0be3124dcc92deeab681e (patch)
tree6215f6fcf5287f69840d06ad8c009dab0945ef6d /lib/autorequire/file.rb
parent4a3629e42cb3e1fbca4356cf789a8e79043cdc51 (diff)
auto require
Diffstat (limited to 'lib/autorequire/file.rb')
-rw-r--r--lib/autorequire/file.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/autorequire/file.rb b/lib/autorequire/file.rb
new file mode 100644
index 0000000..2a25a07
--- /dev/null
+++ b/lib/autorequire/file.rb
@@ -0,0 +1,33 @@
+module RCM
+ # Managing files
+ class File
+ attr_reader :path
+
+ def initialize(path)
+ @path = path
+ end
+
+ def content(content = nil)
+ content.nil? ? @content : @content = content
+ end
+
+ def to_s
+ @path
+ end
+
+ def do!
+ puts "Evaluating #{self.class}:#{self}"
+ end
+ end
+
+ # Add file keyword to the DSL
+ class RCM
+ def file(path, &block)
+ return unless @conds_met
+
+ f = File.new(path)
+ f.instance_eval(&block)
+ self << f
+ end
+ end
+end