«
Rule languages supports watching directories and files
rule 'watch directory' do
watch OpenHAB.conf_root + 'foo'
run { |event| logger.info("#{event.path.basename} - #{event.type}") }
end
action | file | log | |
---|---|---|---|
create | qux | qux - created | |
delete | bar | bar - deleted | |
modify | baz | baz - modified |
rule 'watch directory' do
watch OpenHAB.conf_root/'foo', glob: '*.erb'
run { |event| logger.info("#{event.path.basename} - #{event.type}") }
end
action | file | should | log | |
---|---|---|---|---|
create | qux.erb | should | qux.erb - created | |
delete | bar.erb | should | bar.erb - deleted | |
modify | baz.erb | should | baz.erb - modified | |
create | qux | should not | qux - created | |
delete | bar | should not | qux - deleted | |
modify | baz | should not | baz - modified |
rule 'watch file' do
watch OpenHAB.conf_root + 'foo/bar'
run { |event| logger.info("#{event.path.basename} - #{event.type}") }
end
action | file | should | log | |
---|---|---|---|---|
modify | bar | should | bar - modified | |
delete | bar | should | bar - deleted | |
modify | baz | should not | baz - modified | |
delete | baz | should not | baz - deleted |
rule 'watch file' do
watch OpenHAB.conf_root + 'foo/bar'
run { |event| logger.info("#{event.path.basename} - #{event.type}") }
end
action | file | should | log | |
---|---|---|---|---|
create | bar | should | bar - created | |
create | baz | should not | baz - created |
rule 'watch directory' do
watch OpenHAB.conf_root + 'foo/*.erb'
run { |event| logger.info("#{event.path.basename} - #{event.type}") }
end
action | file | should | log | |
---|---|---|---|---|
create | qux.erb | should | qux.erb - created | |
delete | bar.erb | should | bar.erb - deleted | |
modify | baz.erb | should | baz.erb - modified | |
create | qux | should not | qux - created | |
delete | bar | should not | qux - deleted | |
modify | baz | should not | baz - modifie |
rule 'watch directory' do
watch OpenHAB.conf_root + 'foo', for: <event_type>
run { |event| logger.info("#{event.path.basename} - #{event.type}") }
end
action | file | event_type | should | log | |
---|---|---|---|---|---|
delete | bar | :deleted | should | bar - deleted | |
delete | bar | [:deleted, :modified] | should | bar - deleted | |
delete | bar | :modified | should not | bar - deleted | |
delete | bar | [:modified,:created] | should not | bar - deleted |