summaryrefslogtreecommitdiff
path: root/lib/dslkeywords
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-01 18:38:49 +0200
committerPaul Buetow <paul@buetow.org>2026-03-01 18:38:49 +0200
commit08129b43792eeec92eacb9f47ce3f879489aa03c (patch)
treef527ba7c71c58536fa68b0acaef41dcd56a3cfc6 /lib/dslkeywords
parent861e526d9ad9228f2b740dbcf00cf39d8fe652f2 (diff)
make rcm usable as a gem from any directory, fix bugs and tests
- Add lib/rcm.rb entry point and bin/rcm CLI executable - Update gemspec: v0.1.0, proper files list, executables, runtime deps - Support standalone arg parsing and --hosts filtering in options - Fix inverted logic and typo in FileBackup#different? (== vs !=, cecksum_b) - Fix unqualified File.directory? resolving to RCM::File in Directory - Fix test_chown assertions running before evaluate! creates files - Add setup to file tests to prevent order-dependent failures Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'lib/dslkeywords')
-rw-r--r--lib/dslkeywords/file.rb4
-rw-r--r--lib/dslkeywords/given.rb4
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/dslkeywords/file.rb b/lib/dslkeywords/file.rb
index aa1b725..9a44f72 100644
--- a/lib/dslkeywords/file.rb
+++ b/lib/dslkeywords/file.rb
@@ -23,7 +23,7 @@ module RCM
def different?(file_a, file_b)
checksum_a = Digest::SHA256.file(file_a).hexdigest
checksum_b = Digest::SHA256.file(file_b).hexdigest
- [checksum_a == checksum_b, checksum_a, cecksum_b]
+ [checksum_a != checksum_b, checksum_a, checksum_b]
end
private
@@ -320,7 +320,7 @@ module RCM
end
do? "Copying #{source_path} -> #{@file_path} resursively" do
- if File.directory?(@file_path)
+ if ::File.directory?(@file_path)
Dir["#{source_path}/*"].each { FileUtils.cp_r(_1, @file_path) }
else
FileUtils.cp_r(source_path, @file_path)
diff --git a/lib/dslkeywords/given.rb b/lib/dslkeywords/given.rb
index fa14e68..ba61703 100644
--- a/lib/dslkeywords/given.rb
+++ b/lib/dslkeywords/given.rb
@@ -17,6 +17,10 @@ module RCM
def met?
return false if @conds.key?(:hostname) && Socket.gethostname != @conds[:hostname].to_s
+ # When --hosts is specified, only run on the listed hosts
+ hosts = option(:hosts)
+ return false if hosts.any? && !hosts.include?(Socket.gethostname)
+
true
end
end