spektrum-log 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
File without changes
data/spec/file_spec.rb ADDED
@@ -0,0 +1,120 @@
1
+ require 'spec_helper'
2
+
3
+ describe Spektrum::Log::File do
4
+
5
+ describe '#new' do
6
+
7
+ context 'with data file 1.TLM' do
8
+
9
+ subject { Spektrum::Log::File.new(data_file('1.TLM')) }
10
+
11
+ it { should have(3).flights }
12
+
13
+ its(:duration) { should be_within(0.1).of(34.3) }
14
+
15
+ end
16
+
17
+ context 'with data file 2.TLM' do
18
+
19
+ subject { Spektrum::Log::File.new(data_file('2.TLM')) }
20
+
21
+ it { should have(312).flights }
22
+
23
+ its(:duration) { should be_within(0.1).of(1570.7) }
24
+
25
+ end
26
+
27
+ context 'with data file 3.TLM' do
28
+
29
+ subject { Spektrum::Log::File.new(data_file('3.TLM')) }
30
+
31
+ it { should have(12).flights }
32
+
33
+ its(:duration) { should be_within(0.1).of(144.8) }
34
+
35
+ end
36
+
37
+ context 'with data file 4.TLM' do
38
+
39
+ subject { Spektrum::Log::File.new(data_file('4.TLM')) }
40
+
41
+ it { should have(1).flights }
42
+
43
+ its(:duration) { should be_within(0.1).of(15.9) }
44
+
45
+ end
46
+
47
+ context 'with data file GPS.TLM' do
48
+
49
+ subject { Spektrum::Log::File.new(data_file('GPS.TLM')) }
50
+
51
+ it { should have(2).flights }
52
+
53
+ its(:duration) { should be_within(0.1).of(1431.4) }
54
+
55
+ end
56
+
57
+ context 'with data file GPS2.TLM' do
58
+
59
+ subject { Spektrum::Log::File.new(data_file('GPS2.TLM')) }
60
+
61
+ it { should have(2).flights }
62
+
63
+ its(:duration) { should be_within(0.1).of(851.0) }
64
+
65
+ end
66
+
67
+ context 'with data file X5-GPS1.TLM' do
68
+
69
+ subject { Spektrum::Log::File.new(data_file('X5-GPS1.TLM')) }
70
+
71
+ it { should have(5).flights }
72
+
73
+ its(:duration) { should be_within(0.1).of(1305.2) }
74
+
75
+ end
76
+
77
+ context 'with data file X5-GPS2.TLM' do
78
+
79
+ subject { Spektrum::Log::File.new(data_file('X5-GPS2.TLM')) }
80
+
81
+ it { should have(2).flights }
82
+
83
+ its(:duration) { should be_within(0.1).of(627.7) }
84
+
85
+ end
86
+
87
+ it 'should raise for invalid or missing files' do
88
+ files = invalid_data_files
89
+ files.should have(17).files
90
+
91
+ files.each do |f|
92
+ expect { Spektrum::Log::File.new(f) }.to raise_error
93
+ end
94
+ end
95
+
96
+ end
97
+
98
+ describe '#spektrum?' do
99
+
100
+ it 'should be false for invalid or missing files' do
101
+ files = invalid_data_files
102
+ files.should have(17).files
103
+
104
+ files.each do |f|
105
+ Spektrum::Log::File.spektrum?(f).should be_false
106
+ end
107
+ end
108
+
109
+ it 'should be true for valid files' do
110
+ files = data_files
111
+ files.should have(9).files
112
+
113
+ files.each do |f|
114
+ Spektrum::Log::File.spektrum?(f).should be_true
115
+ end
116
+ end
117
+
118
+ end
119
+
120
+ end
data/spec/flight_spec.rb CHANGED
@@ -2,9 +2,9 @@ require 'spec_helper'
2
2
 
3
3
  describe Spektrum::Log::Flight do
4
4
 
5
- context 'data file 1.TLM' do
5
+ context 'with data file 1.TLM' do
6
6
 
7
- let(:reader) { Spektrum::Log::Reader.new(data_file('1.TLM')) }
7
+ let(:reader) { Spektrum::Log::File.new(data_file('1.TLM')) }
8
8
 
9
9
  context 'flight 1' do
10
10
 
@@ -70,9 +70,9 @@ describe Spektrum::Log::Flight do
70
70
 
71
71
  end
72
72
 
73
- context 'data file 2.TLM' do
73
+ context 'with data file 2.TLM' do
74
74
 
75
- let(:reader) { Spektrum::Log::Reader.new(data_file('2.TLM')) }
75
+ let(:reader) { Spektrum::Log::File.new(data_file('2.TLM')) }
76
76
 
77
77
  context 'flight 1' do
78
78
 
@@ -144,9 +144,9 @@ describe Spektrum::Log::Flight do
144
144
 
145
145
  end
146
146
 
147
- context 'data file 3.TLM' do
147
+ context 'with data file 3.TLM' do
148
148
 
149
- let(:reader) { Spektrum::Log::Reader.new(data_file('3.TLM')) }
149
+ let(:reader) { Spektrum::Log::File.new(data_file('3.TLM')) }
150
150
 
151
151
  context 'flight 1' do
152
152
 
@@ -294,9 +294,9 @@ describe Spektrum::Log::Flight do
294
294
 
295
295
  end
296
296
 
297
- context 'data file 4.TLM' do
297
+ context 'with data file 4.TLM' do
298
298
 
299
- let(:reader) { Spektrum::Log::Reader.new(data_file('4.TLM')) }
299
+ let(:reader) { Spektrum::Log::File.new(data_file('4.TLM')) }
300
300
 
301
301
  context 'flight 1' do
302
302
 
@@ -338,9 +338,9 @@ describe Spektrum::Log::Flight do
338
338
 
339
339
  end
340
340
 
341
- context 'data file GPS.TLM' do
341
+ context 'with data file GPS.TLM' do
342
342
 
343
- let(:reader) { Spektrum::Log::Reader.new(data_file('GPS.TLM')) }
343
+ let(:reader) { Spektrum::Log::File.new(data_file('GPS.TLM')) }
344
344
 
345
345
  context 'flight 1' do
346
346
 
@@ -384,9 +384,9 @@ describe Spektrum::Log::Flight do
384
384
 
385
385
  end
386
386
 
387
- context 'data file GPS2.TLM' do
387
+ context 'with data file GPS2.TLM' do
388
388
 
389
- let(:reader) { Spektrum::Log::Reader.new(data_file('GPS2.TLM')) }
389
+ let(:reader) { Spektrum::Log::File.new(data_file('GPS2.TLM')) }
390
390
 
391
391
  context 'flight 1' do
392
392
 
@@ -428,9 +428,9 @@ describe Spektrum::Log::Flight do
428
428
 
429
429
  end
430
430
 
431
- context 'data file X5-GPS1.TLM' do
431
+ context 'with data file X5-GPS1.TLM' do
432
432
 
433
- let(:reader) { Spektrum::Log::Reader.new(data_file('X5-GPS1.TLM')) }
433
+ let(:reader) { Spektrum::Log::File.new(data_file('X5-GPS1.TLM')) }
434
434
 
435
435
  its 'flights should contain some gps coordinates' do
436
436
 
@@ -502,9 +502,9 @@ describe Spektrum::Log::Flight do
502
502
 
503
503
  end
504
504
 
505
- context 'data file X5-GPS2.TLM' do
505
+ context 'with data file X5-GPS2.TLM' do
506
506
 
507
- let(:reader) { Spektrum::Log::Reader.new(data_file('X5-GPS2.TLM')) }
507
+ let(:reader) { Spektrum::Log::File.new(data_file('X5-GPS2.TLM')) }
508
508
 
509
509
  its 'flights should contain some gps coordinates' do
510
510
 
data/spec/spec_helper.rb CHANGED
@@ -20,7 +20,19 @@ RSpec.configure do |config|
20
20
  config.order = 'random'
21
21
  end
22
22
 
23
+ # root from spec/data
23
24
  def data_file(name)
24
- path = Pathname.new("#{File.dirname(__FILE__)}/../data/#{name}")
25
- path.realpath
26
- end
25
+ File.expand_path("#{File.dirname(__FILE__)}/data/#{name}")
26
+ end
27
+
28
+ def data_files
29
+ dir = "#{File.dirname(__FILE__)}/data/#{dir}"
30
+ Dir.glob("#{dir}/*").select { |e| File.file? e }
31
+ end
32
+
33
+ def invalid_data_files
34
+ dir = "#{File.dirname(__FILE__)}/data/invalid"
35
+ invalid = Dir.glob("#{dir}/**/*").select { |e| File.file? e }
36
+ invalid << __FILE__
37
+ invalid << 'NOFILE.TLM'
38
+ end
metadata CHANGED
@@ -1,36 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spektrum-log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
5
- prerelease:
4
+ version: 0.0.16
6
5
  platform: ruby
7
6
  authors:
8
7
  - Nick Veys
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-04 00:00:00.000000000 Z
11
+ date: 2013-07-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: awesome_print
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bundler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: ci_reporter
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - '='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - '='
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -94,55 +83,48 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: simplecov
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: simplecov-gem-adapter
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - '>='
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - '>='
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: simplecov-rcov
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - '>='
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - '>='
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0'
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: ruby_kml
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
129
  - - ~>
148
130
  - !ruby/object:Gem::Version
@@ -150,7 +132,6 @@ dependencies:
150
132
  type: :runtime
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
136
  - - ~>
156
137
  - !ruby/object:Gem::Version
@@ -169,64 +150,97 @@ files:
169
150
  - LICENSE
170
151
  - README.md
171
152
  - Rakefile
172
- - data/1.TLM
173
- - data/2.TLM
174
- - data/3.TLM
175
- - data/4.TLM
176
- - data/GPS.TLM
177
- - data/GPS2.TLM
178
- - data/X5-GPS1.TLM
179
- - data/X5-GPS2.TLM
180
153
  - lib/spektrum/log.rb
154
+ - lib/spektrum/log/file.rb
181
155
  - lib/spektrum/log/flight.rb
182
156
  - lib/spektrum/log/headers.rb
183
- - lib/spektrum/log/reader.rb
184
157
  - lib/spektrum/log/records.rb
185
158
  - lib/spektrum/log/version.rb
186
159
  - spec/basic_data_record_spec.rb
160
+ - spec/data/1.TLM
161
+ - spec/data/2.TLM
162
+ - spec/data/3.TLM
163
+ - spec/data/4.TLM
164
+ - spec/data/GPS.TLM
165
+ - spec/data/GPS2.TLM
166
+ - spec/data/X5-GPS1.TLM
167
+ - spec/data/X5-GPS2.TLM
168
+ - spec/data/X5-GPS3.TLM
169
+ - spec/data/invalid/castle/long-flight.csv
170
+ - spec/data/invalid/castle/multi-line-notes.csv
171
+ - spec/data/invalid/castle/multi-session-1.csv
172
+ - spec/data/invalid/castle/multi-session-2.csv
173
+ - spec/data/invalid/castle/sample-1.csv
174
+ - spec/data/invalid/eagle_tree/empty.fdr
175
+ - spec/data/invalid/eagle_tree/funjet-gps.fdr
176
+ - spec/data/invalid/eagle_tree/multi-session-1.fdr
177
+ - spec/data/invalid/eagle_tree/multi-session-2.fdr
178
+ - spec/data/invalid/eagle_tree/old-1.fdr
179
+ - spec/data/invalid/eagle_tree/old-2.fdr
180
+ - spec/data/invalid/eagle_tree/old-3.fdr
181
+ - spec/data/invalid/eagle_tree/t600-1.fdr
182
+ - spec/data/invalid/eagle_tree/t600-2.fdr
183
+ - spec/data/invalid/empty.file
184
+ - spec/file_spec.rb
187
185
  - spec/flight_log_record_spec.rb
188
186
  - spec/flight_spec.rb
189
187
  - spec/gps_record1_spec.rb
190
188
  - spec/gps_record2_spec.rb
191
- - spec/reader_spec.rb
192
189
  - spec/spec_helper.rb
193
190
  - spektrum-log.gemspec
194
191
  homepage: ''
195
192
  licenses:
196
193
  - MIT
194
+ metadata: {}
197
195
  post_install_message:
198
196
  rdoc_options: []
199
197
  require_paths:
200
198
  - lib
201
199
  required_ruby_version: !ruby/object:Gem::Requirement
202
- none: false
203
200
  requirements:
204
- - - ! '>='
201
+ - - '>='
205
202
  - !ruby/object:Gem::Version
206
203
  version: '0'
207
- segments:
208
- - 0
209
- hash: -2804857274968739668
210
204
  required_rubygems_version: !ruby/object:Gem::Requirement
211
- none: false
212
205
  requirements:
213
- - - ! '>='
206
+ - - '>='
214
207
  - !ruby/object:Gem::Version
215
208
  version: '0'
216
- segments:
217
- - 0
218
- hash: -2804857274968739668
219
209
  requirements: []
220
210
  rubyforge_project:
221
- rubygems_version: 1.8.25
211
+ rubygems_version: 2.0.3
222
212
  signing_key:
223
- specification_version: 3
213
+ specification_version: 4
224
214
  summary: Spektrum TLM log file reader
225
215
  test_files:
226
216
  - spec/basic_data_record_spec.rb
217
+ - spec/data/1.TLM
218
+ - spec/data/2.TLM
219
+ - spec/data/3.TLM
220
+ - spec/data/4.TLM
221
+ - spec/data/GPS.TLM
222
+ - spec/data/GPS2.TLM
223
+ - spec/data/X5-GPS1.TLM
224
+ - spec/data/X5-GPS2.TLM
225
+ - spec/data/X5-GPS3.TLM
226
+ - spec/data/invalid/castle/long-flight.csv
227
+ - spec/data/invalid/castle/multi-line-notes.csv
228
+ - spec/data/invalid/castle/multi-session-1.csv
229
+ - spec/data/invalid/castle/multi-session-2.csv
230
+ - spec/data/invalid/castle/sample-1.csv
231
+ - spec/data/invalid/eagle_tree/empty.fdr
232
+ - spec/data/invalid/eagle_tree/funjet-gps.fdr
233
+ - spec/data/invalid/eagle_tree/multi-session-1.fdr
234
+ - spec/data/invalid/eagle_tree/multi-session-2.fdr
235
+ - spec/data/invalid/eagle_tree/old-1.fdr
236
+ - spec/data/invalid/eagle_tree/old-2.fdr
237
+ - spec/data/invalid/eagle_tree/old-3.fdr
238
+ - spec/data/invalid/eagle_tree/t600-1.fdr
239
+ - spec/data/invalid/eagle_tree/t600-2.fdr
240
+ - spec/data/invalid/empty.file
241
+ - spec/file_spec.rb
227
242
  - spec/flight_log_record_spec.rb
228
243
  - spec/flight_spec.rb
229
244
  - spec/gps_record1_spec.rb
230
245
  - spec/gps_record2_spec.rb
231
- - spec/reader_spec.rb
232
246
  - spec/spec_helper.rb