Class: Input::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/xify/input/shell.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Shell

Returns a new instance of Shell.



3
4
5
# File 'lib/xify/input/shell.rb', line 3

def initialize(config)
  @config = config
end

Instance Method Details

#run {|Xify::Event.new @config['author'], out, parent: @config['shell']| ... } ⇒ Object

Yields:

  • (Xify::Event.new @config['author'], out, parent: @config['shell'])


7
8
9
10
# File 'lib/xify/input/shell.rb', line 7

def run
  out = `#{@config['shell']}`.chomp
  yield Xify::Event.new @config['author'], out, parent: @config['shell'] if out && out.length != 0
end

#updates(&block) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/xify/input/shell.rb', line 12

def updates(&block)
  return run(&block) unless @config['trigger']

  opts = {}
  opts[:first] = :now if @config['trigger']['now']
  Rufus::Scheduler.singleton.repeat @config['trigger']['schedule'], opts do
    run(&block)
  end
end