tf1_converter 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,45 @@
1
+ require_relative '../../../../lib/tf1_converter/gpx/waypoint'
2
+
3
+ module TF1Converter::Gpx
4
+ describe Waypoint do
5
+ let(:icon_map) { {} }
6
+ let(:node) { double }
7
+ let(:waypoint) { Waypoint.new(node, icon_map) }
8
+
9
+ describe '#icon_name' do
10
+ it 'returns a matching name from the map' do
11
+ node.stub_chain(:children, :select, :first, :text){ 'meaningoflife' }
12
+ icon_map['meaningoflife'] = {'icon' => '42.png'}
13
+ waypoint.icon_name.should == '42.png'
14
+ end
15
+
16
+ it 'returns a default value if there is no sym node' do
17
+ node.stub_chain(:children, :select){ [] }
18
+ waypoint.icon_name.should == 'default.png'
19
+ end
20
+
21
+ it 'gives a default value if there is no hash match' do
22
+ node.stub_chain(:children, :select, :first, :text){ '' }
23
+ waypoint.icon_name.should == 'default.png'
24
+ end
25
+ end
26
+
27
+ describe '#icon_meaning' do
28
+ it 'returns a matching meaning from the map' do
29
+ node.stub_chain(:children, :select, :first, :text){ 'meaningoflife' }
30
+ icon_map['meaningoflife'] = {'meaning' => 'life'}
31
+ waypoint.icon_meaning.should == 'life'
32
+ end
33
+
34
+ it 'gives a default if no sym node' do
35
+ node.stub_chain(:children, :select){ [] }
36
+ waypoint.icon_meaning.should == 'Default'
37
+ end
38
+
39
+ it 'gives a default value if there is no hash match' do
40
+ node.stub_chain(:children, :select, :first, :text){ '' }
41
+ waypoint.icon_meaning.should == 'Default'
42
+ end
43
+ end
44
+ end
45
+ end
@@ -3,11 +3,19 @@ require_relative '../../../lib/tf1_converter'
3
3
 
4
4
  module TF1Converter
5
5
  describe Translation do
6
- it "translates a file correctly" do
6
+ before do
7
7
  execution_time = Time.local(2008, 9, 1, 12, 0, 0)
8
8
  Timecop.freeze(execution_time)
9
- local_dir = File.dirname(__FILE__)
10
- path = File.expand_path('../../fixtures', local_dir)
9
+ end
10
+
11
+ after do
12
+ Timecop.return
13
+ end
14
+
15
+ let(:local_dir) { File.dirname(__FILE__) }
16
+ let(:path) { File.expand_path('../../fixtures', local_dir) }
17
+
18
+ it "translates a file correctly" do
11
19
  input = File.open("#{path}/test.gpx", 'r')
12
20
  output = File.open("#{path}/test.kml", 'w')
13
21
  expected = File.open("#{path}/expected.kml", 'r')
@@ -16,7 +24,14 @@ module TF1Converter
16
24
 
17
25
  result = File.open("#{path}/test.kml", 'r')
18
26
  result.read.should == expected.read
19
- Timecop.return
27
+ end
28
+
29
+ it 'translates a tracks-only file' do
30
+ input = File.open("#{path}/ftwood2.gpx", 'r')
31
+ output = File.open("#{path}/ftwood2.kml", 'w')
32
+ TF1Converter::Config.load(File.expand_path('../../../example/config.yml', local_dir))
33
+ #should not raise error
34
+ TF1Converter::Translation.from(input).into(output)
20
35
  end
21
36
  end
22
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tf1_converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -169,9 +169,13 @@ files:
169
169
  - lib/tf1_converter/version.rb
170
170
  - output/test.kml
171
171
  - spec/fixtures/expected.kml
172
+ - spec/fixtures/ftwood2.gpx
173
+ - spec/fixtures/ftwood2.kml
174
+ - spec/fixtures/ftwood2_expected.kml
172
175
  - spec/fixtures/test.gpx
173
176
  - spec/fixtures/test.kml
174
177
  - spec/lib/tf1_converter/gpx/track_spec.rb
178
+ - spec/lib/tf1_converter/gpx/waypoint_spec.rb
175
179
  - spec/lib/tf1_converter/translation_spec.rb
176
180
  - tf1_converter.gemspec
177
181
  homepage: ''
@@ -188,7 +192,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
188
192
  version: '0'
189
193
  segments:
190
194
  - 0
191
- hash: -3878995865958803192
195
+ hash: 1117436177532010926
192
196
  required_rubygems_version: !ruby/object:Gem::Requirement
193
197
  none: false
194
198
  requirements:
@@ -197,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
201
  version: '0'
198
202
  segments:
199
203
  - 0
200
- hash: -3878995865958803192
204
+ hash: 1117436177532010926
201
205
  requirements: []
202
206
  rubyforge_project:
203
207
  rubygems_version: 1.8.23
@@ -206,7 +210,11 @@ specification_version: 3
206
210
  summary: A GPX to KML converter for Missouri Task Force 1
207
211
  test_files:
208
212
  - spec/fixtures/expected.kml
213
+ - spec/fixtures/ftwood2.gpx
214
+ - spec/fixtures/ftwood2.kml
215
+ - spec/fixtures/ftwood2_expected.kml
209
216
  - spec/fixtures/test.gpx
210
217
  - spec/fixtures/test.kml
211
218
  - spec/lib/tf1_converter/gpx/track_spec.rb
219
+ - spec/lib/tf1_converter/gpx/waypoint_spec.rb
212
220
  - spec/lib/tf1_converter/translation_spec.rb