gpx 0.9.0 → 1.0.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 77fe925f54ad3eb792f09dc5ac6eba67e39052c9
4
- data.tar.gz: f7a763dd97b5f38921254ae6d3ffaae2ce3d3fe8
2
+ SHA256:
3
+ metadata.gz: 4aa764ea01fcc4255a69ff9bad6d1c159fc8ae8a1b29c0e54d05b9fe2b0e0bc9
4
+ data.tar.gz: 699edd3b9dec8cc83ac136c90b81f428a60ed8359aa01445ef3aead1a343c0d1
5
5
  SHA512:
6
- metadata.gz: 442bb28b647d15cbb22fc9fe79aabb9ebcf37c2ae30b9dc510573b88f8d8867f693484d00ab2495820c74d892abc3be062e6bc5bd1b548504fb72b1ad36635ea
7
- data.tar.gz: b9f1a61107b41768feee72c1aeb89b2cac7758a112576095f62f2cfe70947e680796a46b75999e61e33c69876b03c508d785a700649dca3b9cf71e85b127b469
6
+ metadata.gz: 43dc778d82e3b044ef872c219a60a703a6e4e53845817e783c464b36b37b60647eb5c390e2b16df1f1bb51b5359d2eae5a05e39fdb352ee3e2eaec179e007b9e
7
+ data.tar.gz: a6aa72c84b2ff150569506a27889835b818057a549a72d44ad163e81ef5000dd936ca91b8da7faf3a44150ec66bdbe6bb1630291dbeeca5c3416f676130c368a
data/.gitignore CHANGED
@@ -1,3 +1,7 @@
1
1
  tests/output/*
2
2
  .*.swp
3
3
  Gemfile.lock
4
+ pkg
5
+
6
+ # RubyMine files
7
+ /.idea
@@ -0,0 +1,165 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.2
3
+
4
+ Style/Alias:
5
+ Enabled: false
6
+ StyleGuide: http://relaxed.ruby.style/#stylealias
7
+
8
+ Style/AsciiComments:
9
+ Enabled: false
10
+ StyleGuide: http://relaxed.ruby.style/#styleasciicomments
11
+
12
+ Style/BeginBlock:
13
+ Enabled: false
14
+ StyleGuide: http://relaxed.ruby.style/#stylebeginblock
15
+
16
+ Style/BlockDelimiters:
17
+ Enabled: false
18
+ StyleGuide: http://relaxed.ruby.style/#styleblockdelimiters
19
+
20
+ Style/CommentAnnotation:
21
+ Enabled: false
22
+ StyleGuide: http://relaxed.ruby.style/#stylecommentannotation
23
+
24
+ Style/Documentation:
25
+ Enabled: false
26
+ StyleGuide: http://relaxed.ruby.style/#styledocumentation
27
+
28
+ Layout/DotPosition:
29
+ Enabled: false
30
+ StyleGuide: http://relaxed.ruby.style/#layoutdotposition
31
+
32
+ Style/DoubleNegation:
33
+ Enabled: false
34
+ StyleGuide: http://relaxed.ruby.style/#styledoublenegation
35
+
36
+ Style/EndBlock:
37
+ Enabled: false
38
+ StyleGuide: http://relaxed.ruby.style/#styleendblock
39
+
40
+ Style/FormatString:
41
+ Enabled: false
42
+ StyleGuide: http://relaxed.ruby.style/#styleformatstring
43
+
44
+ Style/IfUnlessModifier:
45
+ Enabled: false
46
+ StyleGuide: http://relaxed.ruby.style/#styleifunlessmodifier
47
+
48
+ Style/Lambda:
49
+ Enabled: false
50
+ StyleGuide: http://relaxed.ruby.style/#stylelambda
51
+
52
+ Style/ModuleFunction:
53
+ Enabled: false
54
+ StyleGuide: http://relaxed.ruby.style/#stylemodulefunction
55
+
56
+ Style/MultilineBlockChain:
57
+ Enabled: false
58
+ StyleGuide: http://relaxed.ruby.style/#stylemultilineblockchain
59
+
60
+ Style/NegatedIf:
61
+ Enabled: false
62
+ StyleGuide: http://relaxed.ruby.style/#stylenegatedif
63
+
64
+ Style/NegatedWhile:
65
+ Enabled: false
66
+ StyleGuide: http://relaxed.ruby.style/#stylenegatedwhile
67
+
68
+ Style/ParallelAssignment:
69
+ Enabled: false
70
+ StyleGuide: http://relaxed.ruby.style/#styleparallelassignment
71
+
72
+ Style/PercentLiteralDelimiters:
73
+ Enabled: false
74
+ StyleGuide: http://relaxed.ruby.style/#stylepercentliteraldelimiters
75
+
76
+ Style/PerlBackrefs:
77
+ Enabled: false
78
+ StyleGuide: http://relaxed.ruby.style/#styleperlbackrefs
79
+
80
+ Style/Semicolon:
81
+ Enabled: false
82
+ StyleGuide: http://relaxed.ruby.style/#stylesemicolon
83
+
84
+ Style/SignalException:
85
+ Enabled: false
86
+ StyleGuide: http://relaxed.ruby.style/#stylesignalexception
87
+
88
+ Style/SingleLineBlockParams:
89
+ Enabled: false
90
+ StyleGuide: http://relaxed.ruby.style/#stylesinglelineblockparams
91
+
92
+ Style/SingleLineMethods:
93
+ Enabled: false
94
+ StyleGuide: http://relaxed.ruby.style/#stylesinglelinemethods
95
+
96
+ Layout/SpaceBeforeBlockBraces:
97
+ Enabled: false
98
+ StyleGuide: http://relaxed.ruby.style/#layoutspacebeforeblockbraces
99
+
100
+ Layout/SpaceInsideParens:
101
+ Enabled: false
102
+ StyleGuide: http://relaxed.ruby.style/#layoutspaceinsideparens
103
+
104
+ Style/SpecialGlobalVars:
105
+ Enabled: false
106
+ StyleGuide: http://relaxed.ruby.style/#stylespecialglobalvars
107
+
108
+ Style/StringLiterals:
109
+ Enabled: false
110
+ StyleGuide: http://relaxed.ruby.style/#stylestringliterals
111
+
112
+ Style/WhileUntilModifier:
113
+ Enabled: false
114
+ StyleGuide: http://relaxed.ruby.style/#stylewhileuntilmodifier
115
+
116
+ Style/WordArray:
117
+ Enabled: false
118
+ StyleGuide: http://relaxed.ruby.style/#stylewordarray
119
+
120
+ Lint/AmbiguousRegexpLiteral:
121
+ Enabled: false
122
+ StyleGuide: http://relaxed.ruby.style/#lintambiguousregexpliteral
123
+
124
+ Lint/AssignmentInCondition:
125
+ Enabled: false
126
+ StyleGuide: http://relaxed.ruby.style/#lintassignmentincondition
127
+
128
+ Metrics/AbcSize:
129
+ Enabled: false
130
+
131
+ Metrics/BlockNesting:
132
+ Enabled: false
133
+
134
+ Metrics/ClassLength:
135
+ Enabled: false
136
+
137
+ Metrics/ModuleLength:
138
+ Enabled: false
139
+
140
+ Metrics/CyclomaticComplexity:
141
+ Enabled: false
142
+
143
+ Metrics/LineLength:
144
+ Enabled: false
145
+
146
+ Metrics/MethodLength:
147
+ Enabled: false
148
+
149
+ Metrics/ParameterLists:
150
+ Enabled: false
151
+
152
+ Metrics/PerceivedComplexity:
153
+ Enabled: false
154
+
155
+ Naming/UncommunicativeMethodParamName:
156
+ Enabled: false
157
+
158
+ Naming/VariableNumber:
159
+ Enabled: false
160
+
161
+ Style/DateTime:
162
+ Enabled: false
163
+
164
+ Performance/Caller:
165
+ Enabled: false
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1
4
3
  - 2.2
5
- - 2.3.3
6
- - 2.4.0
4
+ - 2.3
5
+ - 2.4
6
+ - 2.5
7
7
  script: "bundle exec rake ci:build"
@@ -1,3 +1,11 @@
1
+ ## [1.0.0] - 2018-03-06
2
+
3
+ * Fix duplication of points on appending segment to track (#20 via @niborg)
4
+ * Remove pythagorean distance (#28 fixing #27, via @moveson)
5
+ * Ignore empty segments (#29 via @nathanvda)
6
+ * Introduce Rubocop (#31)
7
+ * Explicit test support for Ruby 2.5 (#30)
8
+
1
9
  ## [0.9.0] - 2017-01-05
2
10
 
3
11
  * Upgrade Nokogiri deps to be more explicit, then explicitly bump the Ruby
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) [year] [fullname]
3
+ Copyright (c) 2006 Doug Fales
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -17,7 +17,7 @@ etc).
17
17
 
18
18
  ## Requirements
19
19
 
20
- As of `0.9.0`, `gpx` requires at least Ruby 2.1 to run.
20
+ As of `1.0.0`, `gpx` requires at least Ruby 2.2 to run.
21
21
 
22
22
  ## Examples
23
23
 
data/Rakefile CHANGED
@@ -1,31 +1,34 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
3
  require 'rdoc/task'
4
+ require 'rubocop/rake_task'
4
5
 
5
- desc "Default Task"
6
- task :default => [ :test ]
6
+ RuboCop::RakeTask.new
7
+
8
+ desc 'Default Task'
9
+ task default: %i[test rubocop]
7
10
 
8
11
  namespace :ci do
9
12
  task :build do
10
- puts "Creating tests/output directory..."
11
- FileUtils.mkdir_p "tests/output"
13
+ puts 'Creating tests/output directory...'
14
+ FileUtils.mkdir_p 'tests/output'
12
15
  Rake::Task[:test].invoke
13
16
  end
14
17
  end
15
18
 
16
19
  # Run the unit tests
17
- desc "Run all unit tests"
18
- Rake::TestTask.new("test") { |t|
19
- t.libs << "lib"
20
+ desc 'Run all unit tests'
21
+ Rake::TestTask.new('test') do |t|
22
+ t.libs << 'lib'
20
23
  t.pattern = 'tests/*_test.rb'
21
24
  t.verbose = true
22
- }
25
+ end
23
26
 
24
27
  # Genereate the RDoc documentation
25
- desc "Create documentation"
26
- Rake::RDocTask.new("doc") { |rdoc|
27
- rdoc.title = "Ruby GPX API"
28
+ desc 'Create documentation'
29
+ Rake::RDocTask.new('doc') do |rdoc|
30
+ rdoc.title = 'Ruby GPX API'
28
31
  rdoc.rdoc_dir = 'html'
29
32
  rdoc.rdoc_files.include('README')
30
33
  rdoc.rdoc_files.include('lib/**/*.rb')
31
- }
34
+ end
@@ -1,10 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
-
3
- require File.expand_path('../../lib/gpx', __FILE__)
2
+
3
+ require File.expand_path('../lib/gpx', __dir__)
4
4
 
5
5
  filename = ARGV[0]
6
- gpx = GPX::GPXFile.new(:gpx_file => filename)
6
+ gpx = GPX::GPXFile.new(gpx_file: filename)
7
7
  puts "read track with distance #{gpx.distance}"
8
-
9
-
10
-
@@ -1,63 +1,59 @@
1
1
  #!/usr/bin/env ruby
2
-
3
- require File.expand_path('../../lib/gpx', __FILE__)
4
- require 'optparse'
5
2
 
3
+ require File.expand_path('../lib/gpx', __dir__)
4
+ require 'optparse'
6
5
 
7
6
  def str_to_int_or_time(str)
8
7
  if str =~ /\A\d{10}\Z/
9
- return Time.at(str.to_i)
8
+ Time.at(str.to_i)
10
9
  elsif str =~ /\A\d+\Z/
11
- return str.to_i
10
+ str.to_i
12
11
  else
13
- return DateTime.strptime(str, '%Y%m%d-%H:%M:%S').to_time
12
+ DateTime.strptime(str, '%Y%m%d-%H:%M:%S').to_time
14
13
  end
15
14
  end
16
15
 
17
-
18
16
  options = {}
19
17
  OptionParser.new do |opts|
20
- opts.banner = "Usage: smooth [options]"
18
+ opts.banner = 'Usage: smooth [options]'
21
19
 
22
- opts.on("-i", "--input-file FILE", "Input file to read gpx data from (if omitted, data will be read from stdin)") do |v|
20
+ opts.on('-i', '--input-file FILE', 'Input file to read gpx data from (if omitted, data will be read from stdin)') do |v|
23
21
  options[:infile] = v
24
22
  end
25
- opts.on("-o", "--output-file FILE", "Output file to write smoothed gpx data to (if omitted, data will be written to stdout)") do |v|
23
+ opts.on('-o', '--output-file FILE', 'Output file to write smoothed gpx data to (if omitted, data will be written to stdout)') do |v|
26
24
  options[:outfile] = v
27
25
  end
28
- opts.on("-s", "--start-time [YYYYMMDD-HH:MM:SS|EPOCH|OFFSET]", "Start smoothing from time or offset specified (if omitted start from the start of the file)") do |v|
26
+ opts.on('-s', '--start-time [YYYYMMDD-HH:MM:SS|EPOCH|OFFSET]', 'Start smoothing from time or offset specified (if omitted start from the start of the file)') do |v|
29
27
  options[:start] = v
30
28
  end
31
- opts.on("-e", "--end-time [YYYYMMDD-HH:MM:SS|EPOCH|OFFSET]", "Finish smoothing from time or offset specified (if omitted finish at the end of the file)") do |v|
29
+ opts.on('-e', '--end-time [YYYYMMDD-HH:MM:SS|EPOCH|OFFSET]', 'Finish smoothing from time or offset specified (if omitted finish at the end of the file)') do |v|
32
30
  options[:end] = v
33
31
  end
34
32
  end.parse!
35
33
 
36
-
37
- if options[:infile]
38
- input = File.open(options[:infile])
39
- else
40
- input = $stdin
41
- end
34
+ input = if options[:infile]
35
+ File.open(options[:infile])
36
+ else
37
+ $stdin
38
+ end
42
39
 
43
40
  options[:start] = str_to_int_or_time(options[:start]) if options[:start]
44
41
  options[:end] = str_to_int_or_time(options[:end]) if options[:end]
45
42
 
46
- gpx = GPX::GPXFile.new(:gpx_data => input)
47
- $stderr.puts "read track with distance #{gpx.distance}"
43
+ gpx = GPX::GPXFile.new(gpx_data: input)
44
+ warn "read track with distance #{gpx.distance}"
48
45
 
49
- #1419062980
46
+ # 1419062980
50
47
  gpx.tracks.each do |track|
51
48
  track.segments.each do |segment|
52
- segment.smooth_location_by_average({:end => options[:end], :start => options[:start]})
49
+ segment.smooth_location_by_average(end: options[:end], start: options[:start])
53
50
  end
54
51
  end
55
52
  gpx.recalculate_distance
56
- $stderr.puts "smoothed distance #{gpx.distance}"
53
+ warn "smoothed distance #{gpx.distance}"
57
54
 
58
55
  if options[:outfile]
59
56
  gpx.write(options[:outfile], false)
60
57
  else
61
58
  puts gpx.to_s(false)
62
59
  end
63
-
@@ -1,26 +1,27 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+
2
+ lib = File.expand_path('lib', __dir__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'gpx/version'
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = 'gpx'
8
8
  s.version = GPX::VERSION
9
- s.authors = ["Guillaume Dott", "Doug Fales", "Andrew Hao"]
10
- s.email = ["guillaume+github@dott.fr", "doug.fales@gmail.com", "andrewhao@gmail.com"]
11
- s.summary = %q{A basic API for reading and writing GPX files.}
12
- s.description = %q{A basic API for reading and writing GPX files.}
9
+ s.authors = ['Guillaume Dott', 'Doug Fales', 'Andrew Hao']
10
+ s.email = ['guillaume+github@dott.fr', 'doug.fales@gmail.com', 'andrewhao@gmail.com']
11
+ s.summary = 'A basic API for reading and writing GPX files.'
12
+ s.description = 'A basic API for reading and writing GPX files.'
13
13
 
14
- s.required_ruby_version = '~>2.1'
14
+ s.required_ruby_version = '~>2.2'
15
15
 
16
- s.files = `git ls-files`.split($/)
16
+ s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
17
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
- s.require_paths = ["lib"]
18
+ s.require_paths = ['lib']
19
19
  s.has_rdoc = true
20
20
 
21
- s.homepage = "http://www.github.com/dougfales/gpx"
22
- s.add_dependency 'rake'
21
+ s.homepage = 'http://www.github.com/dougfales/gpx'
23
22
  s.add_dependency 'nokogiri', '~>1.7'
23
+ s.add_dependency 'rake'
24
24
  s.add_development_dependency 'bundler'
25
25
  s.add_development_dependency 'minitest'
26
+ s.add_development_dependency 'rubocop'
26
27
  end
data/lib/gpx.rb CHANGED
@@ -1,38 +1,15 @@
1
- #--
2
- # Copyright (c) 2006 Doug Fales
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining
5
- # a copy of this software and associated documentation files (the
6
- # "Software"), to deal in the Software without restriction, including
7
- # without limitation the rights to use, copy, modify, merge, publish,
8
- # distribute, sublicense, and/or sell copies of the Software, and to
9
- # permit persons to whom the Software is furnished to do so, subject to
10
- # the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be
13
- # included in all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
- #++
23
-
24
1
  require 'time'
25
2
  require 'nokogiri'
26
3
 
27
- require File.expand_path('../gpx/version', __FILE__)
4
+ require File.expand_path('gpx/version', __dir__)
28
5
 
29
- require File.expand_path('../gpx/gpx', __FILE__)
30
- require File.expand_path('../gpx/gpx_file', __FILE__)
31
- require File.expand_path('../gpx/bounds', __FILE__)
32
- require File.expand_path('../gpx/track', __FILE__)
33
- require File.expand_path('../gpx/route', __FILE__)
34
- require File.expand_path('../gpx/segment', __FILE__)
35
- require File.expand_path('../gpx/point', __FILE__)
36
- require File.expand_path('../gpx/trackpoint', __FILE__)
37
- require File.expand_path('../gpx/waypoint', __FILE__)
38
- require File.expand_path('../gpx/magellan_track_log', __FILE__)
6
+ require File.expand_path('gpx/gpx', __dir__)
7
+ require File.expand_path('gpx/gpx_file', __dir__)
8
+ require File.expand_path('gpx/bounds', __dir__)
9
+ require File.expand_path('gpx/track', __dir__)
10
+ require File.expand_path('gpx/route', __dir__)
11
+ require File.expand_path('gpx/segment', __dir__)
12
+ require File.expand_path('gpx/point', __dir__)
13
+ require File.expand_path('gpx/track_point', __dir__)
14
+ require File.expand_path('gpx/waypoint', __dir__)
15
+ require File.expand_path('gpx/magellan_track_log', __dir__)