mgparser 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/lib/call.rb +98 -0
  2. data/lib/version.rb +1 -1
  3. data/mgparser.gemspec +1 -0
  4. metadata +4 -3
data/lib/call.rb ADDED
@@ -0,0 +1,98 @@
1
+ class Call
2
+ attr_accessor :data
3
+
4
+ def initialize(data)
5
+
6
+ @callprogr_counter = 0
7
+ @matched = 0
8
+
9
+ data.each do |line|
10
+
11
+ if line =~ /Unicast RECV Setup/
12
+ @inbound = true
13
+
14
+ elsif line =~ /CallRouter \[.*\] Src=/
15
+ @caller = line.scan(/e164=(\d{1,})/).first
16
+
17
+ elsif line =~ /CallRouter \[.*\] Dst\d\/2/
18
+ @called = line.scan(/e164=(\d{1,})/).first
19
+
20
+
21
+ elsif line =~ /UseNextDestination - Call \d{1,}-\d{1,}/
22
+ id = line.scan(/UseNextDestination - Call \d{1,}-(\d{1,})/).first
23
+ if @matched < 1
24
+ if @inbound == true
25
+ @matched += 1
26
+ else
27
+ puts "Call ID: #{id} - Caller: #{@caller}"
28
+ puts "Call ID: #{id} - Called: #{@called}"
29
+ end
30
+ else
31
+ puts "Call ID: #{id} - Caller: #{@caller}"
32
+ puts "Call ID: #{id} - Called: #{@called}"
33
+ @matched = 0
34
+ end
35
+
36
+ elsif line =~ /CallManager \[.*\] C\d{1,} - Send CallSetupA/
37
+ id = line.scan(/C(\d{1,})/).first
38
+ if @inbound == true
39
+ puts "Call ID: #{id} - <== ISDN setup received"
40
+ else
41
+ puts "Call ID: #{id} - ==> ISDN setup sent"
42
+ end
43
+ @inbound = false
44
+
45
+ elsif line =~ /"Proceeding Indication" .* for state CallSetup./
46
+ @progress_indication = true
47
+
48
+ elsif line =~ /CallManager \[.*\] C\d{1,} - CallProgressA\(2\)/
49
+ @callprogr_counter += 1
50
+ id = line.scan(/C(\d{1,})/).first
51
+
52
+ if @progress_indication == true
53
+ #puts "Call ID: #{id} - <== \"Proceeding indication\" received from operator"
54
+ @progress_indication = false
55
+ else
56
+ if @callprogr_counter >= 3
57
+ puts "Call ID: #{id} - <== The call will be probably answered by operator\'s voicemail or is being forwarded"
58
+ @callprogr_counter = 0
59
+ else
60
+ puts "Call ID: #{id} - <== \"Call Progress\" received from operator"
61
+ end
62
+ end
63
+
64
+ elsif line =~ /CallManager \[.*\] C\d{1,} - CallProgressA\(3\)/
65
+ id = line.scan(/C(\d{1,})/).first
66
+ puts "Call ID: #{id} - ==> \"Call Progress\" sent to the operator"
67
+
68
+
69
+ elsif line =~ /CallManager \[.*\] C\d{1,} - CallProgressA\(1\)/
70
+ id = line.scan(/C(\d{1,})/).first
71
+ puts "Call ID: #{id} - <== Destination number is ringing"
72
+
73
+
74
+ elsif line =~ /CallManager \[.*\] C\d{1,} - CallConnectA/
75
+ id = line.scan(/C(\d{1,})/).first
76
+ puts "Call ID: #{id} - Call has been answered!"
77
+
78
+
79
+ elsif line =~ /CallManager \[.*\] C\d{1,} - CallMessageA\(2\)/
80
+ id = line.scan(/C(\d{1,})/).first
81
+ @isdn_inbound_disconnect = true
82
+
83
+
84
+ elsif line =~ /CallManager \[.*\] C\d{1,} - Send CallReleaseA\(\d{1,}\)/
85
+ id = line.scan(/C(\d{1,})/).first
86
+ cause = line.scan(/Send CallReleaseA\((\d{1,})/).first
87
+
88
+ if @isdn_inbound_disconnect == true
89
+ puts "Call ID: #{id} - <== Operator requested hangup with cause: \"#{$causes[cause.first]}\""
90
+ @isdn_inbound_disconnect = false
91
+ else
92
+ puts "Call ID: #{id} - ==> Gateway sent hangup with cause: \"#{$causes[cause.first]}\""
93
+ end
94
+
95
+ end
96
+ end
97
+ end
98
+ end
data/lib/version.rb CHANGED
@@ -2,7 +2,7 @@ module Mgparser
2
2
  module VERSION
3
3
  MAJOR = 0 unless defined? MAJOR
4
4
  MINOR = 1 unless defined? MINOR
5
- TINY = 3 unless defined? TINY
5
+ TINY = 4 unless defined? TINY
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.') unless defined? STRING
8
8
  end
data/mgparser.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  bin/mgparser
20
20
  mgparser.gemspec
21
21
  lib/version.rb
22
+ lib/call.rb
22
23
  lib/optparser.rb
23
24
  lib/snmp_gw.rb
24
25
  LICENSE
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mgparser
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dawid Pogorzelski
@@ -74,6 +74,7 @@ files:
74
74
  - bin/mgparser
75
75
  - mgparser.gemspec
76
76
  - lib/version.rb
77
+ - lib/call.rb
77
78
  - lib/optparser.rb
78
79
  - lib/snmp_gw.rb
79
80
  - LICENSE