Class: Eve::FileNotifierServer

Inherits:
Object
  • Object
show all
Defined in:
lib/eve/file_notifier_server.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, data) ⇒ FileNotifierServer

Returns a new instance of FileNotifierServer.



7
8
9
10
11
12
13
14
15
# File 'lib/eve/file_notifier_server.rb', line 7

def initialize(connection,data)
  @connection = connection
  @server = data[:server]
  @port = data[:port]
  @source = data[:source]
  @appid = data[:appid]
  @callbacks = data[:callbacks] || []
  @inits = data[:inits] || []
end

Instance Attribute Details

#appidObject

Returns the value of attribute appid.



5
6
7
# File 'lib/eve/file_notifier_server.rb', line 5

def appid
  @appid
end

#callbacksObject

Returns the value of attribute callbacks.



5
6
7
# File 'lib/eve/file_notifier_server.rb', line 5

def callbacks
  @callbacks
end

#connectionObject

Returns the value of attribute connection.



5
6
7
# File 'lib/eve/file_notifier_server.rb', line 5

def connection
  @connection
end

#initsObject

Returns the value of attribute inits.



5
6
7
# File 'lib/eve/file_notifier_server.rb', line 5

def inits
  @inits
end

#portObject

Returns the value of attribute port.



5
6
7
# File 'lib/eve/file_notifier_server.rb', line 5

def port
  @port
end

#serverObject

Returns the value of attribute server.



5
6
7
# File 'lib/eve/file_notifier_server.rb', line 5

def server
  @server
end

#sourceObject

Returns the value of attribute source.



5
6
7
# File 'lib/eve/file_notifier_server.rb', line 5

def source
  @source
end

Class Method Details

.handle_args(args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/eve/file_notifier_server.rb', line 17

def self.handle_args(args)
  {
    :server => Application.extract_arg("--server",args,nil),
    :port => Application.extract_arg("--port",args,nil),
    :source => Application.extract_arg("--source",args,nil),
    :appid => Application.extract_arg("--id",args,nil),
    :callbacks => Application.extract_arg("--callback",args,[]),
    :inits => Application.extract_arg("--init",args,[])
  }
end

Instance Method Details

#appObject



28
29
30
31
32
33
34
# File 'lib/eve/file_notifier_server.rb', line 28

def app
  if @connection.app.nil?
    display = :stdio
    @connection.app = Eve::Application.new(:display => display, :system_calls_display => { :filename => "./eve_system_calls.log" })
  end
  @connection.app
end

#file_modifiedObject



45
46
47
# File 'lib/eve/file_notifier_server.rb', line 45

def file_modified
  @callbacks.each { |cb| app.cmd(cb) }
end

#post_initObject



36
37
38
39
40
41
42
43
# File 'lib/eve/file_notifier_server.rb', line 36

def post_init
  if @server.nil?
    app.cmd("appid #{@appid}")
  else
    app.cmd("event #{@server}:#{@port}")  
  end
  @inits.each { |x| app.cmd(x) }
end