Implement `file_match' condition keyword
This commit is contained in:
@@ -36,6 +36,7 @@ module Producer
|
||||
define_test :sh, Tests::ShellCommandStatus
|
||||
define_test :file_contains, Tests::FileContains
|
||||
define_test :file_eq, Tests::FileEq
|
||||
define_test :file_match, Tests::FileMatch
|
||||
define_test :env?, Tests::HasEnv
|
||||
define_test :executable?, Tests::HasExecutable
|
||||
define_test :dir?, Tests::HasDir
|
||||
|
18
lib/producer/core/tests/file_match.rb
Normal file
18
lib/producer/core/tests/file_match.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
module Producer
|
||||
module Core
|
||||
module Tests
|
||||
class FileMatch < Test
|
||||
def verify
|
||||
!!(file_content =~ arguments[1])
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def file_content
|
||||
fs.file_read(arguments[0]) or ''
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user