gpx_track_generator 0.3.3 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3db3b92d3d5ce67dadc6262e30758f7fe1a42189
4
- data.tar.gz: 58539daf9e643ff4d71176ac7ed766f1ced030d1
3
+ metadata.gz: 4cd0de5a966c6ba0dc5ff1bba79a36f05340ecfc
4
+ data.tar.gz: dcde233fec80ff4ad38b038be88934a0970b1fda
5
5
  SHA512:
6
- metadata.gz: 99f13854519d6f4825d70236b275deb586f435b0b6da2c95773cb0fec2e92493a19021ed3ba5cd337990b335c8d1dcc310fe23dad48f5ea470bcf099b17d0e69
7
- data.tar.gz: 5e16184c3264b11a2166748144fe90b7cf398916565ed2ab6072b388b7ebbc5f6a5c6cad973344bbf10adb1a25281e3466d9639605c62bb06e348a423d485a8c
6
+ metadata.gz: 06ca48ed209bba159b632fb28a21b46ef06c8c5eddb8e3437de4bf16f34893f93f9c46830c2600bca799cb3c479f0667d10ef7cd45fc7319110cb10d52e03f03
7
+ data.tar.gz: 1a0698ed9d5697f6f4535ef9994714ac9bd76f8838c2ec443af3813fa556960c8637ff8677260b58a29dece647a8359e1780fb7ff57fef354014c76e6c0e4326
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gpx_track_generator (0.3.3)
4
+ gpx_track_generator (0.3.5)
5
5
  activesupport
6
6
  fedux_org-stdlib
7
7
  nokogiri
@@ -67,11 +67,11 @@ Feature: Create GPX Track File
67
67
  <!-- track2.gpx -->
68
68
  <trkseg>
69
69
  <trkpt lat="57.688634024660372" lon="-6.5744374090151107">
70
- <name>WP 4</name>
70
+ <name>WP 2</name>
71
71
  <ele>16.232316396783801</ele>
72
72
  </trkpt>
73
73
  <trkpt lat="56.688634024660372" lon="-6.5744374090151107">
74
- <name>WP 3</name>
74
+ <name>WP 1</name>
75
75
  <ele>16.232316396783801</ele>
76
76
  </trkpt>
77
77
  </trkseg>
@@ -93,11 +93,11 @@ Feature: Create GPX Track File
93
93
  <!-- track2.gpx -->
94
94
  <trkseg>
95
95
  <trkpt lat="57.688634024660372" lon="-6.5744374090151107">
96
- <name>WP 4</name>
96
+ <name>WP 2</name>
97
97
  <ele>16.232316396783801</ele>
98
98
  </trkpt>
99
99
  <trkpt lat="56.688634024660372" lon="-6.5744374090151107">
100
- <name>WP 3</name>
100
+ <name>WP 1</name>
101
101
  <ele>16.232316396783801</ele>
102
102
  </trkpt>
103
103
  </trkseg>
@@ -4,7 +4,12 @@ module GpxTrackGenerator
4
4
  module Api
5
5
  def self.generate(input_files:, track_name:, output_file:, reverse: false, single_segment: false)
6
6
  files = input_files.map { |f| GpxFile.new(File.expand_path(f)) }
7
- track = Track.new(files, name: track_name, reverse: reverse, single_segment: single_segment)
7
+ track = Track.new(
8
+ files,
9
+ name: track_name,
10
+ reverse: reverse,
11
+ single_segment: single_segment
12
+ )
8
13
 
9
14
  File.write(output_file, track.to_s)
10
15
  end
@@ -31,12 +31,6 @@ module GpxTrackGenerator
31
31
 
32
32
  # rubocop:disable Metrics/PerceivedComplexity
33
33
  def build_document
34
- gpx_files = if reverse
35
- files.reverse
36
- else
37
- files
38
- end
39
-
40
34
  document.child << metadata
41
35
 
42
36
  document.child << document.create_element('trk')
@@ -46,16 +40,18 @@ module GpxTrackGenerator
46
40
  if single_segment
47
41
  document.css('trk').first << document.create_element('trkseg')
48
42
 
49
- gpx_files.each_with_object(document.css('trk').first) do |e, a|
43
+ files.each_with_object(document.css('trk').first) do |e, a|
50
44
  segment = a.css('trkseg').last
51
45
  segment << "<!-- #{e.file_name} -->"
52
46
  segment << (reverse ? e.nodes.reverse : e.nodes)
53
47
  end
54
48
  else
55
- gpx_files.each_with_object(document.css('trk').first) do |e, a|
49
+ files.each_with_object(document.css('trk').first) do |e, a|
56
50
  a << "<!-- #{e.file_name} -->"
57
51
  a << document.create_element('trkseg')
58
- a.css('trkseg').last << (reverse ? e.nodes.reverse : e.nodes)
52
+
53
+ segment = a.css('trkseg').last
54
+ segment << (reverse ? e.nodes.reverse : e.nodes)
59
55
  end
60
56
  end
61
57
 
@@ -65,7 +61,7 @@ module GpxTrackGenerator
65
61
  document.css('trkpt').each_with_index { |e, i| e.css('name').first.content = "WP #{i + 1}" }
66
62
  end
67
63
 
68
- document.human
64
+ document.dup.human
69
65
  end
70
66
  # rubocop:enable Metrics/PerceivedComplexity
71
67
 
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
  # GpxTrackGenerator
3
3
  module GpxTrackGenerator
4
- VERSION = '0.3.3'
4
+ VERSION = '0.3.5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gpx_track_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Meyer