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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b84d84acf68553f1234ec8e3fdb9bb47219bdfcb
4
- data.tar.gz: 19193af36e377171fbd39e6ebd85346581fd6d8e
3
+ metadata.gz: d4a76d415a6baa6c57d481d4cb1540ea7106c003
4
+ data.tar.gz: 108b7112965b2f8433f190c38c9245847695af91
5
5
  SHA512:
6
- metadata.gz: 0fc862e796765e1d7f791bc91ad3eccba1e789719ab55113a52f9fe4f0729c627357a9d5fc25d1d5bb62971c0398c8e342d5d756d8a01b03aceaff1e4fc1e196
7
- data.tar.gz: 8eb5d29518c8d00c8dfdfb121542a6f49efcdff30fc344cadaebed6b7e5797c24d274c36a65ec98d9dc05e8b80b54fc2fb317ee9e21266e858aa09f160d299fb
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
- class AsteriskMiniStatement
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
- attr_reader :to_xml
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
- create.item(time: x[:start], telno: telno, io: io, dur: a.join(' ') )
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
- end
91
+ summary = "
92
+ #{title}
93
+ #{'=' * title.length}
77
94
 
78
- end
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
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asterisk_mini_statement
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file