redk-smdr 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/Guardfile +43 -0
- data/LICENSE.txt +21 -0
- data/NOTES.md +41 -0
- data/README.md +35 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/bin/smdr_client.rb +24 -0
- data/bin/smdr_fake_server.rb +20 -0
- data/lib/redk/smdr/client.rb +21 -0
- data/lib/redk/smdr/matcher/extended.rb +66 -0
- data/lib/redk/smdr/matcher.rb +11 -0
- data/lib/redk/smdr/version.rb +5 -0
- data/lib/redk/smdr.rb +9 -0
- data/redk-smdr.gemspec +25 -0
- metadata +133 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 13986f156dbcfb7f72fa369e4609d59d317a4cb0
|
4
|
+
data.tar.gz: 297a1a3c689339c68aeef0e4aa2da74cda852022
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4f2e42721a0baff6be0a9924d15b50409222e791574a13e0dd233d590b2271161313a1a36e29b456073c6bfba92459c641c0b3ed3687464ce3904a9e732e8453
|
7
|
+
data.tar.gz: 132d0e841e31d5e93adcc978b2eb874e5024e188aef9e6cbae9ad9f8d8367c5f326a3da0d8f5b6f906b2914879df6396cf2db6b5b986dcef19ba7a616f651309
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
19
|
+
# rspec may be run, below are examples of the most common uses.
|
20
|
+
# * bundler: 'bundle exec rspec'
|
21
|
+
# * bundler binstubs: 'bin/rspec'
|
22
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
+
# installed the spring binstubs per the docs)
|
24
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
+
# * 'just' rspec: 'rspec'
|
26
|
+
|
27
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
28
|
+
require "guard/rspec/dsl"
|
29
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
30
|
+
|
31
|
+
# Feel free to open issues for suggestions and improvements
|
32
|
+
|
33
|
+
# RSpec files
|
34
|
+
rspec = dsl.rspec
|
35
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
36
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
37
|
+
watch(rspec.spec_files)
|
38
|
+
|
39
|
+
# Ruby files
|
40
|
+
ruby = dsl.ruby
|
41
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
42
|
+
|
43
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 defektive
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/NOTES.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# This should help in the future
|
2
|
+
|
3
|
+
go [here](http://steve-wilkinson.co.uk/Mitel_%203300_%20ver5/sysadmin/features_optional/smdr_extended_reporting.html) inspect the tbody in question
|
4
|
+
then let the code below do the rest
|
5
|
+
|
6
|
+
```
|
7
|
+
String.prototype.toKey = function (){
|
8
|
+
return this.trim().toLowerCase().replace(/[^0-9a-z_]+/g, "_")
|
9
|
+
}
|
10
|
+
|
11
|
+
String.prototype.toIndexValues = function (){
|
12
|
+
if(this.indexOf("-") === -1) {
|
13
|
+
return [parseInt(this, 10) - 1, parseInt(this, 10) - 1];
|
14
|
+
} else {
|
15
|
+
var st = this.split("-");
|
16
|
+
st[0] = parseInt(st[0]) - 1;
|
17
|
+
st[1] = parseInt(st[1]) - 1;
|
18
|
+
|
19
|
+
return st
|
20
|
+
}
|
21
|
+
return this.trim().replace(/\s+/g, "_")
|
22
|
+
}
|
23
|
+
|
24
|
+
function getMatcher(tbody) {
|
25
|
+
var tr = tbody.querySelectorAll("tr"),
|
26
|
+
trLen = tr.length,
|
27
|
+
data = {},
|
28
|
+
tds;
|
29
|
+
|
30
|
+
var str = "{\n"
|
31
|
+
for(var i=1; i < trLen; i++) {
|
32
|
+
tds = tr[i].querySelectorAll("td")
|
33
|
+
if(tds[0].textContent == "Spacer") continue
|
34
|
+
|
35
|
+
str += "\t" + tds[0].textContent.toKey() +": " + JSON.stringify(tds[1].textContent.toIndexValues()) +",\n"
|
36
|
+
}
|
37
|
+
str += "}"
|
38
|
+
console.log(str)
|
39
|
+
}
|
40
|
+
getMatcher($0)
|
41
|
+
```
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Redk::Smdr
|
2
|
+
|
3
|
+
A simple smdr parser and client
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'redk-smdr'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install redk-smdr
|
20
|
+
|
21
|
+
|
22
|
+
## Development
|
23
|
+
|
24
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
25
|
+
|
26
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/xREDk/smdr.
|
31
|
+
|
32
|
+
|
33
|
+
## License
|
34
|
+
|
35
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "redk/smdr"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/bin/smdr_client.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "thor"
|
3
|
+
require "redk/smdr"
|
4
|
+
|
5
|
+
|
6
|
+
class SMDRClient < Thor
|
7
|
+
method_option :host, :type => :string, :aliases => "-h", :default => 'localhost', :desc => "Specify what host to connect to"
|
8
|
+
method_option :port, :type => :numeric, :aliases => "-p", :default => 1752, :desc => "Specify what port to connect to"
|
9
|
+
desc "connect to HOST", "connect to HOST and start printing parsed records"
|
10
|
+
def client()
|
11
|
+
client = Redk::Smdr::Client.new(options[:host], options[:port])
|
12
|
+
puts "Connecting to #{options[:host]}:#{options[:port]}"
|
13
|
+
client.read do |data|
|
14
|
+
data.each do |key, value|
|
15
|
+
puts "\t#{key} => #{value}"
|
16
|
+
end
|
17
|
+
puts "---"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
default_task :client
|
22
|
+
end
|
23
|
+
|
24
|
+
SMDRClient.start(ARGV)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'socket'
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.expand_path('../../spec', __FILE__)
|
5
|
+
require 'spec_helper'
|
6
|
+
|
7
|
+
server = TCPServer.new 1752
|
8
|
+
loop do
|
9
|
+
begin
|
10
|
+
puts "Listening..."
|
11
|
+
client = server.accept
|
12
|
+
puts "connected to #{client}"
|
13
|
+
loop do
|
14
|
+
client.puts test_log_line
|
15
|
+
sleep rand 3
|
16
|
+
end
|
17
|
+
rescue
|
18
|
+
client.close
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
require 'socket'
|
3
|
+
|
4
|
+
class Redk::Smdr::Client
|
5
|
+
|
6
|
+
def initialize(host, port=1752)
|
7
|
+
@host = host
|
8
|
+
@port = port
|
9
|
+
end
|
10
|
+
|
11
|
+
def read
|
12
|
+
socket = TCPSocket.open(@host, @port)
|
13
|
+
begin
|
14
|
+
while line = socket.gets
|
15
|
+
yield Redk::Smdr::Matcher.match(line, Redk::Smdr::Matcher::Extended.level_2)
|
16
|
+
end
|
17
|
+
ensure
|
18
|
+
socket.close
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
|
2
|
+
module Redk::Smdr::Matcher::Extended
|
3
|
+
def self.level_1
|
4
|
+
{
|
5
|
+
long_call: [0,0],
|
6
|
+
date: [1,5],
|
7
|
+
start_time: [7,12],
|
8
|
+
duration_of_call: [14,23],
|
9
|
+
calling_party: [25,31],
|
10
|
+
attendant: [32,32],
|
11
|
+
time_to_answer: [33,36],
|
12
|
+
digits_dialed_on_the_trunk: [38,63,"58"],
|
13
|
+
meter_pulses: [null,63],
|
14
|
+
call_completion_status: [64,64],
|
15
|
+
speed_call_or_call_forward_flags: [65,65],
|
16
|
+
called_party: [66,72],
|
17
|
+
ldn_called: [74,80],
|
18
|
+
transfer_conference_call: [81,81],
|
19
|
+
third_party: [83,89],
|
20
|
+
account_code: [91,102],
|
21
|
+
route_optimization_flag: [103,103],
|
22
|
+
system_identifier: [104,106],
|
23
|
+
mlpp_precedence_level: [108,108],
|
24
|
+
ani: [110,129],
|
25
|
+
dnis: [131,140],
|
26
|
+
suite_identifier: [142,148],
|
27
|
+
call_identifier: [150,157],
|
28
|
+
call_sequence_identifier: [159,159],
|
29
|
+
associated_call_identifier: [161,168],
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.level_2
|
34
|
+
{
|
35
|
+
long_call: [0,0],
|
36
|
+
date: [1,5],
|
37
|
+
start_time: [7,15],
|
38
|
+
duration_of_call: [17,26],
|
39
|
+
calling_party: [28,34],
|
40
|
+
attendant: [36,36],
|
41
|
+
time_to_answer: [37,39],
|
42
|
+
digits_dialed_on_the_trunk: [41,66],
|
43
|
+
call_completion_status: [67,67],
|
44
|
+
speed_call_or_call_forward_flags: [68,68],
|
45
|
+
called_party: [69,75],
|
46
|
+
ldn_called: [77,83],
|
47
|
+
transfer_conference_call: [84,84],
|
48
|
+
third_party: [86,92],
|
49
|
+
account_code: [94,105],
|
50
|
+
route_optimization_flag: [106,106],
|
51
|
+
system_identifier: [107,109],
|
52
|
+
mlpp_precedence_level: [111,111],
|
53
|
+
ani: [113,132],
|
54
|
+
dnis: [134,143],
|
55
|
+
suite_identifier: [145,151],
|
56
|
+
call_identifier: [153,160],
|
57
|
+
call_sequence_identifier: [162,162],
|
58
|
+
associated_call_identifier: [164,171],
|
59
|
+
tbcttwo_b_channel_transfer_id: [173,179],
|
60
|
+
calling_external_hot_desk_user: [180,186],
|
61
|
+
called_external_hot_desk_user: [188,194],
|
62
|
+
calling_party_location_identifier: [196,200],
|
63
|
+
called_party_location_identifier: [202,206]
|
64
|
+
}
|
65
|
+
end
|
66
|
+
end
|
data/lib/redk/smdr.rb
ADDED
data/redk-smdr.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'redk/smdr/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "redk-smdr"
|
8
|
+
spec.version = Redk::Smdr::VERSION
|
9
|
+
spec.authors = ["defektive"]
|
10
|
+
spec.email = ["sirbradleyd@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A simple smdr client}
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "thor", "~> 0.19"
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "guard-rspec"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: redk-smdr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- defektive
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.19'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.19'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard-rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- sirbradleyd@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- Gemfile
|
94
|
+
- Guardfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- NOTES.md
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/console
|
100
|
+
- bin/setup
|
101
|
+
- bin/smdr_client.rb
|
102
|
+
- bin/smdr_fake_server.rb
|
103
|
+
- lib/redk/smdr.rb
|
104
|
+
- lib/redk/smdr/client.rb
|
105
|
+
- lib/redk/smdr/matcher.rb
|
106
|
+
- lib/redk/smdr/matcher/extended.rb
|
107
|
+
- lib/redk/smdr/version.rb
|
108
|
+
- redk-smdr.gemspec
|
109
|
+
homepage:
|
110
|
+
licenses:
|
111
|
+
- MIT
|
112
|
+
metadata: {}
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
requirements: []
|
128
|
+
rubyforge_project:
|
129
|
+
rubygems_version: 2.4.8
|
130
|
+
signing_key:
|
131
|
+
specification_version: 4
|
132
|
+
summary: A simple smdr client
|
133
|
+
test_files: []
|