coban 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +0 -0
- data/LICENSE +0 -0
- data/README.md +0 -0
- data/ROADMAP.md +0 -0
- data/lib/coban/invalid_message.rb +0 -0
- data/lib/coban/tk103b.rb +14 -3
- data/lib/coban/version.rb +1 -1
- data/lib/coban.rb +0 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdf38b0eee3eec2db353d538522cd6e8691bb38f
|
4
|
+
data.tar.gz: 8987880b9cd235113aa72589601f27143ff84d65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65e1b3664df70b2f2800cd2ce15580167aef234fa5cd503d9aab26a9076cbcd3d10bc5449b932666635a63aef915019cfb399f6aee10ffcd93d931fe53c31179
|
7
|
+
data.tar.gz: d4780cedfd8412b30157b4538104bed0ee426ed3526c511acc92207687bb7980af16eeace4a6469ff3928cc8d776324d70f8686719ad78fa9895e2a1b6779686
|
data/CHANGELOG.md
CHANGED
File without changes
|
data/LICENSE
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/ROADMAP.md
CHANGED
File without changes
|
File without changes
|
data/lib/coban/tk103b.rb
CHANGED
@@ -11,7 +11,11 @@ module Coban
|
|
11
11
|
result = self.message_heartbeat(content)
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
if result == nil
|
15
|
+
InvalidMessage.new "Error parsing message"
|
16
|
+
else
|
17
|
+
return result
|
18
|
+
end
|
15
19
|
rescue
|
16
20
|
InvalidMessage.new "Error parsing message"
|
17
21
|
end
|
@@ -24,6 +28,7 @@ module Coban
|
|
24
28
|
:door, :fuel, :oil, :temperatura
|
25
29
|
]
|
26
30
|
|
31
|
+
# Pre-process and split the raw content into array positions
|
27
32
|
splited_content = content.gsub('imei:','').gsub(';','').split(',', -1)
|
28
33
|
|
29
34
|
result = {
|
@@ -53,8 +58,8 @@ module Coban
|
|
53
58
|
longitude = pre_longitude[0...3].to_i(10) + ( pre_longitude[3...pre_longitude.size].to_f / 60 )
|
54
59
|
longitude *= -1 if splited_content[message_headers.index(:east_west)] == 'W'
|
55
60
|
|
56
|
-
result[:latitude] = latitude
|
57
|
-
result[:longitude] = longitude
|
61
|
+
result[:latitude] = latitude.round(8)
|
62
|
+
result[:longitude] = longitude.round(8)
|
58
63
|
|
59
64
|
date = splited_content[message_headers.index(:date)]
|
60
65
|
time = splited_content[message_headers.index(:time)]
|
@@ -63,16 +68,22 @@ module Coban
|
|
63
68
|
result[:date] = DateTime.strptime('20' + date[0...6] + time.split('.').first,'%Y%m%d%H%M%S')
|
64
69
|
end
|
65
70
|
|
71
|
+
result[:type] = 'message'
|
72
|
+
result[:sub_type] = 'tracker'
|
73
|
+
result[:response] = nil
|
74
|
+
|
66
75
|
return result
|
67
76
|
end
|
68
77
|
|
69
78
|
def self.message_logon(content)
|
70
79
|
result = /##,imei:(?<imei>\d*).*;/.match(content)
|
80
|
+
return nil if result[:imei].empty?
|
71
81
|
return { imei: result[:imei], type: :logon, response: 'LOAD' } if result
|
72
82
|
end
|
73
83
|
|
74
84
|
def self.message_heartbeat(content)
|
75
85
|
result = /(?<imei>\d*)/.match(content)
|
86
|
+
return nil if result[:imei].empty?
|
76
87
|
return { imei: result[:imei], type: :heartbeat, response: 'ON' } if result
|
77
88
|
end
|
78
89
|
end
|
data/lib/coban/version.rb
CHANGED
data/lib/coban.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coban
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Diego Bernardes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,7 +81,7 @@ files:
|
|
81
81
|
- lib/coban/invalid_message.rb
|
82
82
|
- lib/coban/tk103b.rb
|
83
83
|
- lib/coban/version.rb
|
84
|
-
homepage:
|
84
|
+
homepage: ''
|
85
85
|
licenses:
|
86
86
|
- MIT
|
87
87
|
metadata: {}
|
@@ -101,8 +101,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
103
|
rubyforge_project:
|
104
|
-
rubygems_version: 2.2.
|
104
|
+
rubygems_version: 2.2.1
|
105
105
|
signing_key:
|
106
106
|
specification_version: 4
|
107
107
|
summary: Parser for Coban trackers
|
108
108
|
test_files: []
|
109
|
+
has_rdoc:
|