Top Level Namespace

Defined Under Namespace

Modules: Bind

Instance Method Summary collapse

Instance Method Details

#common_options(options) ⇒ Object



14
15
16
17
18
19
# File 'lib/bind/command_helpers.rb', line 14

def common_options options
  options.actions ||= []
  options.actions << lambda { |file| eval options.eval } if options.eval
  options.require.each { |lib| require lib } if options.require
  options.debug = $stdout if options.verbose
end

#expand_path(path) ⇒ Object



21
22
23
# File 'lib/bind/command_helpers.rb', line 21

def expand_path path
  path.include?('://') ? path : File.expand_path(path)
end

#listener(options) ⇒ Object



10
11
12
# File 'lib/bind/command_helpers.rb', line 10

def listener options
  Bind::Listener.new options.__hash__
end

#set_common_options(c) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/bind/command_helpers.rb', line 2

def set_common_options c
  c.option '-i', '--interval SECONDS', Integer, 'Interval in seconds in which to listen for an event.'
  c.option '-t', '--timeout SECONDS', Integer, 'Timeout after n seconds.'
  c.option '-r', '--require LIBS', Array, 'Require ruby libraries.'
  c.option '-e', '--eval STRING', String, 'Evaluate a string of Ruby in context of Bind, so the file local variable is available.'
  c.option '-V', '--verbose', 'Log information to STDOUT.'
end