diff options
| author | Paul Buetow <paul@buetow.org> | 2025-02-16 23:15:45 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-02-16 23:15:45 +0200 |
| commit | a246ade229a2a1578358eb25fe5855bc5cf22732 (patch) | |
| tree | 9637a8cf2a9a891d27c0693fb6bc3283a7a22c9b | |
| parent | 556d1d13ad6ce056fb52d920e36c08192c7103c5 (diff) | |
sugar
| -rw-r--r-- | lib/dslkeywords/resource.rb | 6 | ||||
| -rw-r--r-- | playground/Rakefile | 2 | ||||
| -rw-r--r-- | test/lib/dslkeywords/dependency_test.rb | 3 |
3 files changed, 7 insertions, 4 deletions
diff --git a/lib/dslkeywords/resource.rb b/lib/dslkeywords/resource.rb index 18239fc..4c28809 100644 --- a/lib/dslkeywords/resource.rb +++ b/lib/dslkeywords/resource.rb @@ -33,7 +33,11 @@ module RCM end end - def depends_on?(other) = @depends_on.nil? ? false : @depends_on.key?(other) + def depends_on?(*others) + return false if @depends_on.nil? + + others.flatten.none? { |other| !@depends_on.key?(other) } + end end # A resource is something concrete to be managed, e.g. a file, or a CRON job. diff --git a/playground/Rakefile b/playground/Rakefile index ef53d00..35ae811 100644 --- a/playground/Rakefile +++ b/playground/Rakefile @@ -37,7 +37,7 @@ task :foo do configure do file '/tmp/foo.txt' do ensure_line 'foo' - depends_on file['/tmp/bar.txt'] + depends_on file '/tmp/bar.txt' end file '/tmp/bar.txt' do diff --git a/test/lib/dslkeywords/dependency_test.rb b/test/lib/dslkeywords/dependency_test.rb index 393552f..4a71485 100644 --- a/test/lib/dslkeywords/dependency_test.rb +++ b/test/lib/dslkeywords/dependency_test.rb @@ -24,8 +24,7 @@ class RCMDependencyTest < Minitest::Test end assert_equal 2, foo.depends_on.keys.length - assert foo.depends_on?("notify('bar')") - assert foo.depends_on?("notify('baz')") + assert foo.depends_on?("notify('bar')", "notify('baz')") assert_equal 0, bar.depends_on.keys.length |
