asterisk_mini_statement 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/asterisk_mini_statement.rb +49 -6
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4a76d415a6baa6c57d481d4cb1540ea7106c003
|
4
|
+
data.tar.gz: 108b7112965b2f8433f190c38c9245847695af91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39b2c1a3c4720be563a5851194e77fc34c27dad9f74c5b9fecfcd228faa19fdd9f285da61c7d2935dfc75bf826a8233d7544011937b75abbb8916e256e697f9a
|
7
|
+
data.tar.gz: 875ce635c5b641a2638b95e53aef9841d3193e36ad419282e0095f4b78ca60929655b510ad9c27f53e8e90cb0e10635c5d8be97d0e0f9fbba4311173affe9389
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -7,9 +7,20 @@ require 'csv'
|
|
7
7
|
require 'polyrex'
|
8
8
|
require 'subunit'
|
9
9
|
|
10
|
-
|
10
|
+
module DateEnhanced
|
11
|
+
|
12
|
+
refine Fixnum do
|
13
|
+
def ordinalize()
|
14
|
+
self.to_s + ( (10...20).include?(self) ? 'th' :
|
15
|
+
%w{ th st nd rd th th th th th th }[self % 10] )
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
11
19
|
|
12
|
-
|
20
|
+
class AsteriskMiniStatement
|
21
|
+
using DateEnhanced
|
22
|
+
|
23
|
+
attr_reader :to_xml, :to_px, :to_s
|
13
24
|
|
14
25
|
def initialize(cdr_file='/var/log/asterisk/cdr-csv/Master.csv',
|
15
26
|
startdate: (Date.today - 8).strftime("%d-%b-%Y"),
|
@@ -64,16 +75,48 @@ class AsteriskMiniStatement
|
|
64
75
|
val > 0 ? r << (val.to_s + label) : r
|
65
76
|
end.take 2
|
66
77
|
|
67
|
-
|
78
|
+
time = x[:start][/\d{2}:\d{2}/]
|
79
|
+
create.item(time: time, telno: telno, io: io, dur: a.join(' ') )
|
68
80
|
end
|
69
81
|
|
70
82
|
end
|
71
83
|
|
72
84
|
end
|
73
|
-
|
85
|
+
|
86
|
+
@to_px = px
|
74
87
|
@to_xml = px.to_xml pretty: true
|
88
|
+
|
89
|
+
title = 'Telephone mini-statement'
|
75
90
|
|
76
|
-
|
91
|
+
summary = "
|
92
|
+
#{title}
|
93
|
+
#{'=' * title.length}
|
77
94
|
|
78
|
-
|
95
|
+
telno: #{px.summary.telno}
|
96
|
+
Period: #{px.summary.period}
|
97
|
+
|
98
|
+
Breakdown:
|
79
99
|
|
100
|
+
Date/time Telephone duration
|
101
|
+
========= =========== ========"
|
102
|
+
|
103
|
+
records = px.records.inject('') do |r, day|
|
104
|
+
date = Date.parse(day.date)
|
105
|
+
r << "\n" + date.strftime("%A #{date.day.ordinalize} %B %Y") + "\n\n"
|
106
|
+
|
107
|
+
day.records.inject(r) do |r2, x|
|
108
|
+
|
109
|
+
r2 << (x.io == 'in' ? '>' : '<')
|
110
|
+
r2 << Time.parse(x.time).strftime(" %l:%M%P: ")
|
111
|
+
r2 << x.telno.ljust(13)
|
112
|
+
r2 << x.dur.rjust(8) + "\n"
|
113
|
+
end
|
114
|
+
|
115
|
+
r << "\n" + '-' * 32 + "\n"
|
116
|
+
end
|
117
|
+
|
118
|
+
@to_s = [summary,records].join("\n")
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|