summaryrefslogtreecommitdiff
path: root/lib/dslkeywords/directory.rb
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-01 23:27:15 +0200
committerPaul Buetow <paul@buetow.org>2026-03-01 23:27:15 +0200
commit1217524955c7ea891ea85cb17dfd13f2b7b1fc3d (patch)
treef1ed556cc9308ed153c32ce7a9f812af40742a34 /lib/dslkeywords/directory.rb
parentfba26f6d9f18600dc313b6d4ade65d536e9762e9 (diff)
refactor: extract register_keyword helper to eliminate 4x DSL duplication
Each of the file/symlink/touch/directory DSL methods repeated the same four-step pattern: nil-path identity return, @conds_met guard, create- configure-register, return object. Add a private register_keyword helper to DSL in dsl.rb and collapse each method to a one-liner. No behaviour changed; all 29 tests continue to pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'lib/dslkeywords/directory.rb')
-rw-r--r--lib/dslkeywords/directory.rb10
1 files changed, 1 insertions, 9 deletions
diff --git a/lib/dslkeywords/directory.rb b/lib/dslkeywords/directory.rb
index 6449d74..072c88a 100644
--- a/lib/dslkeywords/directory.rb
+++ b/lib/dslkeywords/directory.rb
@@ -100,15 +100,7 @@ module RCM
class DSL
def directory(file_path = nil, &block)
- return :directory if file_path.nil?
- return unless @conds_met
-
- d = Directory.new(file_path)
- # Use source= for the recursive-copy source path rather than content=,
- # keeping Directory's interface clean and purpose-named.
- d.source(d.instance_eval(&block))
- self << d
- d
+ register_keyword(Directory, :directory, file_path) { |d| d.source(d.instance_eval(&block)) }
end
end
end