/
app
executable file
·48 lines (37 loc) · 1.46 KB
/
app
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env ruby
require 'CSV'
require 'time'
require 'table_print'
require 'methadone'
require 'paint/pa'
include Methadone::Main
include Methadone::CLILogging
calls = []
main do |dir_path|
files = []
Dir.foreach(dir_path) do |item|
next if item == '.' or item== '.*' or item =='..' or item=='.DS_Store' or item=='.git'
files.push("#{dir_path}/#{item}")
end
puts "#{Paint['Processing', :bright, "orange"]} #{Paint[files.count, "snow"]} #{Paint['files in', :bright, "orange"]} #{Paint[dir_path, "snow"]} #{Paint['directory.', :bright, "orange"]}"
puts
files.each do |f|
puts "#{Paint['Working on: ', "snow"]} #{Paint[f, :blue]}"
CSV.foreach(f, :headers => false) do |row|
next if row[9].nil? || row[10].nil?
date = Time.parse(row[0])
connect_time = Time.parse(row[9]).strftime("%l:%M:%S %p")
disconnect_time = Time.parse(row[10]).strftime("%l:%M:%S %p")
seconds = row[30]/1000
voice_tx_duration = Time.at(seconds).strftime("%H:%M:%S")
calls << {:user => if row[122].empty?; "UNKNOWN" else row[122] end, :date => date.strftime("%A %e, %B %Y"), :call => row[13], :start_time => connect_time, :end_time => disconnect_time, :call_duration => voice_tx_duration}
end
puts "Data for: #{calls.each { |h| h[:date]}.uniq}"
tp calls
calls = []
end
end
version '0.0.1b'
description 'Parse Cisco UC540 CDR files, and display meaningful data in table format'
arg :dir_path, :required
go!