otstatus 0.1.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/otstatus.rb +48 -12
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3372fd858d8fed587c986227cb1e530a0a2a456d
|
4
|
+
data.tar.gz: dc722af8b79ffe69c2d0967e4df204fc05334ca4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f49b93f29d113980e0f59e8df5d3e52cb3f0a8206bf09ab3b4ffc75407f921ac9967f2f1c7fedad2eb91ab29f8798ed77364c5fb219d3316dccfda559137ca4
|
7
|
+
data.tar.gz: 30943fbd2480e83b7fb94d2a75911604ab46191561b623ec51f32883abb955c758acf38b3a21e58718c772dab27dde568c05edddd037039f15f7a0a298c1ed12
|
data/lib/otstatus.rb
CHANGED
@@ -1,17 +1,53 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'eventmachine'
|
2
3
|
require 'nori'
|
3
4
|
|
4
5
|
module OtStatus
|
5
|
-
VERSION = '0.1
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
VERSION = '0.2.1'
|
7
|
+
|
8
|
+
class Query
|
9
|
+
attr_accessor :response
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@response = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def run hostname, port
|
16
|
+
EventMachine.run {
|
17
|
+
EventMachine::connect hostname, port, Connection, self
|
18
|
+
}
|
19
|
+
|
20
|
+
parse @response
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def parse data
|
25
|
+
parser = Nori.new
|
26
|
+
parser.parse(data)['tsqp']
|
27
|
+
end
|
28
|
+
|
29
|
+
class Connection < EventMachine::Connection
|
30
|
+
QUERY = [6.chr, 0.chr, 255.chr, 255.chr, 'info'].join
|
31
|
+
|
32
|
+
attr_reader :query
|
33
|
+
|
34
|
+
def initialize query
|
35
|
+
@query = query
|
36
|
+
end
|
37
|
+
|
38
|
+
def post_init
|
39
|
+
send_data QUERY
|
40
|
+
@data = ""
|
41
|
+
end
|
42
|
+
|
43
|
+
def receive_data data
|
44
|
+
@data << data
|
45
|
+
query.response = @data
|
46
|
+
end
|
47
|
+
|
48
|
+
def unbind
|
49
|
+
EventMachine::stop_event_loop
|
50
|
+
end
|
51
|
+
end
|
16
52
|
end
|
17
53
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: otstatus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jimmy Thelander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: eventmachine
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: nori
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|