Class: Norikra::Client::Event
- Inherits:
-
Thor
- Object
- Thor
- Norikra::Client::Event
show all
- Includes:
- CLIUtil
- Defined in:
- lib/norikra/client/cli.rb
Instance Method Summary
collapse
Methods included from CLIUtil
#client, #formatter, #parser, #wrap
Instance Method Details
#fetch(query_name) ⇒ Object
215
216
217
218
219
220
221
222
223
224
225
|
# File 'lib/norikra/client/cli.rb', line 215
def fetch(query_name)
formatter = formatter(options[:format])
time_formatter = lambda{|t| Time.at(t).strftime(options[:time_format])}
wrap do
client(parent_options).event(query_name).each do |time,event|
event = {options[:time_key] => Time.at(time).strftime(options[:time_format])}.merge(event)
puts formatter.format(event)
end
end
end
|
#see(query_name) ⇒ Object
231
232
233
234
235
236
237
238
239
240
241
|
# File 'lib/norikra/client/cli.rb', line 231
def see(query_name)
formatter = formatter(options[:format])
time_formatter = lambda{|t| Time.at(t).strftime(options[:time_format])}
wrap do
client(parent_options).see(query_name).each do |time,event|
event = {options[:time_key] => Time.at(time).strftime(options[:time_format])}.merge(event)
puts formatter.format(event)
end
end
end
|
#send(target) ⇒ Object
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
# File 'lib/norikra/client/cli.rb', line 194
def send(target)
client = client(parent_options)
parser = parser(options[:format])
buffer = []
$stdin.each_line do |line|
buffer.push(parser.parse(line))
if buffer.size >= options[:batch_size]
client.send(target, buffer)
buffer = []
end
end
wrap do
client.send(target, buffer) if buffer.size > 0
end
end
|
#sweep(query_group = nil) ⇒ Object
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
|
# File 'lib/norikra/client/cli.rb', line 248
def sweep(query_group=nil)
wrap do
formatter = formatter(options[:format])
time_formatter = lambda{|t| Time.at(t).strftime(options[:time_format])}
data = client(parent_options).sweep(query_group)
data.keys.sort.each do |queryname|
events = data[queryname]
events.each do |time,event|
event = {
options[:time_key] => Time.at(time).strftime(options[:time_format]),
options[:query_name_key] => queryname,
}.merge(event)
puts formatter.format(event)
end
end
end
end
|