Module: Vm::Watcher
- Defined in:
- lib/vm-watcher.rb
Defined Under Namespace
Classes: VmObserver, VmWatcher
Class Method Summary
collapse
Class Method Details
.init(args) ⇒ Object
62
63
64
65
66
67
68
|
# File 'lib/vm-watcher.rb', line 62
def self.init(args)
options = parse(args)
watcher = VmWatcher.new(options)
observer = VmObserver.new(watcher, options[:script])
watcher.watch
end
|
.parse(args) ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/vm-watcher.rb', line 70
def self.parse(args)
options = {
:script => 'script/provision',
:watch => "#{Dir.pwd}/**/*",
:interval => 1
}
OptionParser.new do |opts|
opts.banner = "Usage: vm-watcher [options]"
opts.separator ""
opts.separator "Specific options:"
opts.on('-s', '--script SCRIPT', 'Path to the script to call') do |script|
options[:script] = script
end
opts.on('-w', '--watch PATTERN', 'Files pattern to watch') do |pattern|
options[:watch] = pattern
end
opts.on('-i', '--interval SECONDS', 'Sleep time interval before checking modifications') do |interval|
options[:interval] = interval.to_i
end
end.parse!(args)
options
end
|