spektrum-log 0.0.10 → 0.0.11
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/reader.rb +8 -0
- data/lib/spektrum/log/version.rb +1 -1
- data/spec/reader_spec.rb +14 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d12a83ac543c601321ea4e302f68675bac9fe13c
|
4
|
+
data.tar.gz: e92ea2f69badd802397c35324fc7167edc4907d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fb5e5cad6d308a92031d7c2b90c77008eec37d401aa6f854f26eaac99510954fa9f7394eb0b9c8008e01578f59d52ae86bf1b19e0e23cc372713e94ef452bb0
|
7
|
+
data.tar.gz: 0d8c3a79b51fb6f9a38d8a0ddf391e61517e495adf433d295d9751bbb63937911c65cdf723d09650cc9a7d5133546f8ddce752dfd6a6203b3216990a6352ec48
|
data/lib/spektrum/log/reader.rb
CHANGED
@@ -47,7 +47,15 @@ module Spektrum
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
50
|
+
rescue
|
51
|
+
raise ArgumentError, 'File does not appear to be an Spektrum log'
|
52
|
+
end
|
50
53
|
|
54
|
+
# Gets the total duration of all flights contained within.
|
55
|
+
#
|
56
|
+
# @return [Float] total duration of all flights, in seconds
|
57
|
+
def duration
|
58
|
+
@flights.map(&:duration).reduce(&:+)
|
51
59
|
end
|
52
60
|
|
53
61
|
end
|
data/lib/spektrum/log/version.rb
CHANGED
data/spec/reader_spec.rb
CHANGED
@@ -8,6 +8,8 @@ describe Spektrum::Log::Reader do
|
|
8
8
|
|
9
9
|
it { should have(3).flights }
|
10
10
|
|
11
|
+
its(:duration) { should be_within(0.1).of(8.8) }
|
12
|
+
|
11
13
|
end
|
12
14
|
|
13
15
|
context 'data file 2.TLM' do
|
@@ -16,6 +18,8 @@ describe Spektrum::Log::Reader do
|
|
16
18
|
|
17
19
|
it { should have(312).flights }
|
18
20
|
|
21
|
+
its(:duration) { should be_within(0.1).of(878.8) }
|
22
|
+
|
19
23
|
end
|
20
24
|
|
21
25
|
context 'data file 3.TLM' do
|
@@ -24,6 +28,8 @@ describe Spektrum::Log::Reader do
|
|
24
28
|
|
25
29
|
it { should have(12).flights }
|
26
30
|
|
31
|
+
its(:duration) { should be_within(0.1).of(148.4) }
|
32
|
+
|
27
33
|
end
|
28
34
|
|
29
35
|
context 'data file 4.TLM' do
|
@@ -32,6 +38,8 @@ describe Spektrum::Log::Reader do
|
|
32
38
|
|
33
39
|
it { should have(1).flights }
|
34
40
|
|
41
|
+
its(:duration) { should be_within(0.1).of(16.3) }
|
42
|
+
|
35
43
|
end
|
36
44
|
|
37
45
|
context 'data file GPS.TLM' do
|
@@ -40,10 +48,16 @@ describe Spektrum::Log::Reader do
|
|
40
48
|
|
41
49
|
it { should have(2).flights }
|
42
50
|
|
51
|
+
its(:duration) { should be_within(0.1).of(366.4) }
|
52
|
+
|
43
53
|
end
|
44
54
|
|
45
55
|
it 'should raise on bad input' do
|
46
56
|
expect { Spektrum::Log::Reader.new(__FILE__) }.to raise_error
|
47
57
|
end
|
48
58
|
|
59
|
+
it 'should raise when file is not found' do
|
60
|
+
expect { Spektrum::Log::Reader.new(data_file('NOFILE.TLM')) }.to raise_error
|
61
|
+
end
|
62
|
+
|
49
63
|
end
|