open_gpx_2_kml 1.0.4 → 1.0.5

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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- open_gpx_2_kml (1.0.4)
4
+ open_gpx_2_kml (1.0.5)
5
5
  builder (= 3.1.4)
6
6
  geo_swap (= 0.2.1)
7
7
  nokogiri (= 1.5.6)
@@ -11,7 +11,7 @@ module TF1Converter
11
11
  CSV.open(@path, 'wb') do |csv|
12
12
  csv << ['filename', 'name', 'meaning', 'time', 'lat', 'long', 'usng', 'elevation']
13
13
  @waypoints.each do |wp|
14
- csv << [raw_path, wp.name, wp.icon_meaning, wp.timestamp, wp.lat, wp.long, wp.usng, wp.elevation]
14
+ csv << [raw_path, wp.name, wp.icon_meaning, wp.timestamp, wp.lat, wp.long, wp.usng, ele_for(wp)]
15
15
  end
16
16
  end
17
17
  end
@@ -27,5 +27,15 @@ module TF1Converter
27
27
  def self.raw_path(path)
28
28
  path.split('.')[0...-1].join('.')
29
29
  end
30
+
31
+ private
32
+ def ele_for(wp)
33
+ if wp.elevation == Gpx::Waypoint::NoElevation
34
+ ''
35
+ else
36
+ wp.elevation
37
+ end
38
+ end
39
+
30
40
  end
31
41
  end
@@ -35,8 +35,12 @@ module TF1Converter
35
35
  @node.attribute('lon').value
36
36
  end
37
37
 
38
+ class NoElevation; end
39
+
38
40
  def elevation
39
- @node.children.select{ |child| child.name == 'ele' }.first.text
41
+ ele_node = @node.children.select{ |child| child.name == 'ele' }.first
42
+ return ele_node.text if ele_node
43
+ NoElevation
40
44
  end
41
45
 
42
46
  def usng
@@ -73,7 +73,9 @@ module TF1Converter
73
73
  desc << '<br>' << "Filename: #{@filename}"
74
74
  desc << "<br>" << "USNG: #{waypoint.usng}"
75
75
  desc << "<br>" << "Lat,Long: #{waypoint.lat},#{waypoint.long}"
76
- desc << "<br>" << "Elevation: #{waypoint.elevation}"
76
+ if waypoint.elevation.is_a? String
77
+ desc << "<br>" << "Elevation: #{waypoint.elevation}"
78
+ end
77
79
  end
78
80
 
79
81
  end
@@ -1,3 +1,3 @@
1
1
  module TF1Converter
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
@@ -1,15 +1,29 @@
1
1
  require_relative '../../../lib/tf1_converter/csv_file'
2
+ require_relative '../../../lib/tf1_converter/gpx/waypoint'
2
3
 
3
4
  module TF1Converter
4
5
  describe CsvFile do
5
6
 
6
- it 'writes waypoints to the csv file' do
7
- waypoints = [double('waypoint').as_null_object]
8
- base_path = '/some/long.path/with.file/test.gpx'
9
- csv = []
10
- CSV.stub(:open).and_yield(csv)
11
- CsvFile.new(waypoints, base_path).to_csv!
12
- csv[1].first.should == '/some/long.path/with.file/test'
7
+ describe '#to_csv!' do
8
+ it 'writes waypoints to the csv file' do
9
+ waypoints = [double('waypoint').as_null_object]
10
+ base_path = '/some/long.path/with.file/test.gpx'
11
+ csv = []
12
+ CSV.stub(:open).and_yield(csv)
13
+ CsvFile.new(waypoints, base_path).to_csv!
14
+ csv[1].first.should == '/some/long.path/with.file/test'
15
+ end
16
+
17
+ it 'writes a blank string when theres no elevation' do
18
+ waypoint = double('waypoint', elevation: Gpx::Waypoint::NoElevation).as_null_object
19
+ waypoints = [waypoint]
20
+ base_path = '/some/long.path/with.file/test.gpx'
21
+ csv = []
22
+ CSV.stub(:open).and_yield(csv)
23
+ CsvFile.new(waypoints, base_path).to_csv!
24
+ csv[1].last.should == ''
25
+ end
26
+
13
27
  end
14
28
 
15
29
  describe '.translate_filename' do
@@ -105,5 +105,18 @@ module TF1Converter::Gpx
105
105
  end
106
106
 
107
107
  end
108
+
109
+ describe '#elevation' do
110
+ it 'uses the ele value' do
111
+ fragment = %Q{ <wpt> <ele>1.7531</ele> </wpt> }
112
+ waypoint_from(fragment).elevation.should == '1.7531'
113
+ end
114
+
115
+ it 'returns blank if there is no ele' do
116
+ fragment = %Q{ <wpt></wpt> }
117
+ waypoint_from(fragment).elevation.should == Waypoint::NoElevation
118
+ end
119
+ end
120
+
108
121
  end
109
122
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_gpx_2_kml
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-08 00:00:00.000000000 Z
12
+ date: 2013-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -255,7 +255,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
255
255
  version: '0'
256
256
  segments:
257
257
  - 0
258
- hash: -2034610430434596952
258
+ hash: 634324867566425609
259
259
  required_rubygems_version: !ruby/object:Gem::Requirement
260
260
  none: false
261
261
  requirements:
@@ -264,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
264
264
  version: '0'
265
265
  segments:
266
266
  - 0
267
- hash: -2034610430434596952
267
+ hash: 634324867566425609
268
268
  requirements: []
269
269
  rubyforge_project:
270
270
  rubygems_version: 1.8.23