spektrum-log 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spektrum/log.rb +6 -5
- data/lib/spektrum/log/buffered_file.rb +36 -0
- data/lib/spektrum/log/file.rb +38 -39
- data/lib/spektrum/log/version.rb +1 -1
- metadata +25 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8f4d301e8cb4eb91a0a7c28f263b45363331501
|
4
|
+
data.tar.gz: 9045b0d5ab3f64de16bc132050e95cdf2e339c7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 493ff189a92654995314cd6a5b545a87c290381d048287a659bb581aa344cc3c7cd15d9efb8373a691d22ecf7313d9ca16e91c4c245ddb50493232ca9a702af8
|
7
|
+
data.tar.gz: b2432d1fb1b638843c2d47371a9485e785b7bb2c33831a254df71466aed8bc37ecc9bd9e3023ce3e92ad3baa60243cb1c189d89573b5f3e071546188caa51e2d
|
data/lib/spektrum/log.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require 'spektrum/log/buffered_file'
|
2
|
+
require 'spektrum/log/file'
|
3
|
+
require 'spektrum/log/flight'
|
4
|
+
require 'spektrum/log/headers'
|
5
|
+
require 'spektrum/log/records'
|
6
|
+
require 'spektrum/log/version'
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
3
|
+
module Spektrum
|
4
|
+
module Log
|
5
|
+
|
6
|
+
class BufferedFile
|
7
|
+
|
8
|
+
def initialize(uri, mode)
|
9
|
+
@io = open(uri, mode)
|
10
|
+
@buffer = StringIO.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def read(length)
|
14
|
+
fetch_chunk if (@buffer.length - @buffer.pos) < length
|
15
|
+
@buffer.read(length)
|
16
|
+
end
|
17
|
+
|
18
|
+
def close
|
19
|
+
@buffer = nil
|
20
|
+
@io.close
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def fetch_chunk
|
26
|
+
@buffer = StringIO.new.tap do |b|
|
27
|
+
b << @buffer.read
|
28
|
+
b << @io.read(4096)
|
29
|
+
b.seek(0)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
data/lib/spektrum/log/file.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'open-uri'
|
2
|
-
|
3
1
|
module Spektrum
|
4
2
|
module Log
|
5
3
|
|
@@ -23,51 +21,52 @@ module Spektrum
|
|
23
21
|
|
24
22
|
first_word = true
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
file = BufferedFile.new(uri, 'rb')
|
25
|
+
loop do
|
26
|
+
first4 = file.read(4)
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
-
first_word = false
|
28
|
+
# quick check to see if this could even be a Spektrum TLM file
|
29
|
+
if first_word
|
30
|
+
if first4.nil? || (0xFFFFFFFF != first4.unpack('V')[0])
|
31
|
+
raise ArgumentError, 'File does not appear to be a Spektrum log'
|
36
32
|
end
|
33
|
+
first_word = false
|
34
|
+
end
|
37
35
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
45
|
-
break
|
36
|
+
if first4.nil?
|
37
|
+
if headers_complete || !records.empty?
|
38
|
+
# we have records, this is a new entry
|
39
|
+
@flights << Flight.new(headers, records)
|
40
|
+
headers = []
|
41
|
+
records = []
|
46
42
|
end
|
43
|
+
break
|
44
|
+
end
|
47
45
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
rest = file.read(32)
|
59
|
-
headers << Headers.create(rest)
|
60
|
-
|
61
|
-
headers_complete = rest.unpack('S')[0] == 0x1717
|
62
|
-
else
|
63
|
-
data = file.read(16)
|
64
|
-
type = data[0].unpack('C')[0]
|
65
|
-
records << Records.create(type, first, data)
|
46
|
+
first = first4.unpack('V')[0]
|
47
|
+
if 0xFFFFFFFF == first
|
48
|
+
if headers_complete || !records.empty?
|
49
|
+
# we have records, this is a new entry
|
50
|
+
@flights << Flight.new(headers, records)
|
51
|
+
headers = []
|
52
|
+
records = []
|
53
|
+
headers_complete = false
|
66
54
|
end
|
55
|
+
|
56
|
+
rest = file.read(32)
|
57
|
+
headers << Headers.create(rest)
|
58
|
+
|
59
|
+
headers_complete = rest.unpack('S')[0] == 0x1717
|
60
|
+
else
|
61
|
+
data = file.read(16)
|
62
|
+
type = data[0].unpack('C')[0]
|
63
|
+
records << Records.create(type, first, data)
|
67
64
|
end
|
68
65
|
end
|
69
|
-
rescue
|
70
|
-
raise ArgumentError,
|
66
|
+
rescue => e
|
67
|
+
raise ArgumentError, "File does not appear to be a Spektrum log (#{e})"
|
68
|
+
ensure
|
69
|
+
file.close
|
71
70
|
end
|
72
71
|
|
73
72
|
# Gets the total duration of all flights contained within.
|
data/lib/spektrum/log/version.rb
CHANGED
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spektrum-log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Veys
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.3'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -56,84 +56,84 @@ dependencies:
|
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '10.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '10.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '2.13'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '2.13'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: simplecov
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: simplecov-gem-adapter
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: simplecov-rcov
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: ruby_kml
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - ~>
|
129
|
+
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0.1'
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - ~>
|
136
|
+
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0.1'
|
139
139
|
description: Read and interpret Spektrum TLM log files.
|
@@ -143,14 +143,15 @@ executables: []
|
|
143
143
|
extensions: []
|
144
144
|
extra_rdoc_files: []
|
145
145
|
files:
|
146
|
-
- .gitignore
|
147
|
-
- .rspec
|
148
|
-
- .travis.yml
|
146
|
+
- ".gitignore"
|
147
|
+
- ".rspec"
|
148
|
+
- ".travis.yml"
|
149
149
|
- Gemfile
|
150
150
|
- LICENSE
|
151
151
|
- README.md
|
152
152
|
- Rakefile
|
153
153
|
- lib/spektrum/log.rb
|
154
|
+
- lib/spektrum/log/buffered_file.rb
|
154
155
|
- lib/spektrum/log/file.rb
|
155
156
|
- lib/spektrum/log/flight.rb
|
156
157
|
- lib/spektrum/log/headers.rb
|
@@ -200,17 +201,17 @@ require_paths:
|
|
200
201
|
- lib
|
201
202
|
required_ruby_version: !ruby/object:Gem::Requirement
|
202
203
|
requirements:
|
203
|
-
- -
|
204
|
+
- - ">="
|
204
205
|
- !ruby/object:Gem::Version
|
205
206
|
version: '0'
|
206
207
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
208
|
requirements:
|
208
|
-
- -
|
209
|
+
- - ">="
|
209
210
|
- !ruby/object:Gem::Version
|
210
211
|
version: '0'
|
211
212
|
requirements: []
|
212
213
|
rubyforge_project:
|
213
|
-
rubygems_version: 2.
|
214
|
+
rubygems_version: 2.2.1
|
214
215
|
signing_key:
|
215
216
|
specification_version: 4
|
216
217
|
summary: Spektrum TLM log file reader
|