gpx_track_generator 0.0.2

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.
@@ -0,0 +1,142 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2014-08-04 09:10:49 +0200 using RuboCop version 0.24.1.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 1
9
+ # Configuration parameters: AlignWith, SupportedStyles.
10
+ Lint/EndAlignment:
11
+ Enabled: true
12
+
13
+ # Offense count: 1
14
+ Lint/Eval:
15
+ Enabled: true
16
+
17
+ # Offense count: 1
18
+ Lint/HandleExceptions:
19
+ Enabled: true
20
+
21
+ # Offense count: 1
22
+ # Cop supports --auto-correct.
23
+ Lint/StringConversionInInterpolation:
24
+ Enabled: true
25
+
26
+ # Offense count: 1
27
+ # Cop supports --auto-correct.
28
+ Lint/UnusedBlockArgument:
29
+ Enabled: true
30
+
31
+ # Offense count: 1
32
+ Lint/UselessAccessModifier:
33
+ Enabled: true
34
+
35
+ # Offense count: 7
36
+ # Cop supports --auto-correct.
37
+ Style/AndOr:
38
+ Enabled: true
39
+
40
+ # Offense count: 7
41
+ # Cop supports --auto-correct.
42
+ Style/Blocks:
43
+ Enabled: true
44
+
45
+ # Offense count: 1
46
+ Style/CaseEquality:
47
+ Enabled: true
48
+
49
+ # Offense count: 1
50
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
51
+ Style/ClassAndModuleChildren:
52
+ Enabled: true
53
+
54
+ # Offense count: 1
55
+ # Cop supports --auto-correct.
56
+ Style/CommentIndentation:
57
+ Enabled: true
58
+
59
+ # Offense count: 30
60
+ Style/Documentation:
61
+ Enabled: true
62
+
63
+ # Offense count: 3
64
+ Style/EachWithObject:
65
+ Enabled: true
66
+
67
+ # Offense count: 4
68
+ # Cop supports --auto-correct.
69
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
70
+ Style/HashSyntax:
71
+ Enabled: true
72
+
73
+ # Offense count: 1
74
+ # Cop supports --auto-correct.
75
+ Style/LeadingCommentSpace:
76
+ Enabled: true
77
+
78
+ # Offense count: 151
79
+ # Configuration parameters: AllowURI.
80
+ Metrics/LineLength:
81
+ Max: 225
82
+
83
+ # Offense count: 3
84
+ Style/MultilineBlockChain:
85
+ Enabled: true
86
+
87
+ # Offense count: 1
88
+ # Configuration parameters: CountKeywordArgs.
89
+ Metrics/ParameterLists:
90
+ Max: 6
91
+
92
+ # Offense count: 4
93
+ # Configuration parameters: NamePrefixBlacklist.
94
+ Style/PredicateName:
95
+ Enabled: true
96
+
97
+ # Offense count: 3
98
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
99
+ Style/RaiseArgs:
100
+ Enabled: true
101
+
102
+ # Offense count: 5
103
+ # Configuration parameters: MaxSlashes.
104
+ Style/RegexpLiteral:
105
+ Enabled: true
106
+
107
+ # Offense count: 1
108
+ # Cop supports --auto-correct.
109
+ # Configuration parameters: AllowAsExpressionSeparator.
110
+ Style/Semicolon:
111
+ Enabled: true
112
+
113
+ # Offense count: 2
114
+ # Configuration parameters: Methods.
115
+ Style/SingleLineBlockParams:
116
+ Enabled: true
117
+
118
+ # Offense count: 2
119
+ # Cop supports --auto-correct.
120
+ Style/SpaceInsideParens:
121
+ Enabled: true
122
+
123
+ # Offense count: 5
124
+ # Cop supports --auto-correct.
125
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
126
+ Style/StringLiterals:
127
+ Enabled: true
128
+
129
+ # Offense count: 5
130
+ # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
131
+ Style/TrailingComma:
132
+ Enabled: true
133
+
134
+ # Offense count: 2
135
+ # Cop supports --auto-correct.
136
+ Style/TrailingWhitespace:
137
+ Enabled: true
138
+
139
+ # Offense count: 1
140
+ # Configuration parameters: CountComments.
141
+ Metrics/ClassLength:
142
+ Max: 160
data/cucumber.yml ADDED
@@ -0,0 +1,2 @@
1
+ default: --tags @wip:3 --tags ~@broken --tags ~@broken-external
2
+ all: --tags ~@wip --tags ~@broken --tags ~@broken-external
Binary file
@@ -0,0 +1,10 @@
1
+ Feature: Create GPX Track File
2
+ As a user
3
+ I want to transform existing gpx routes or multiple gpx tracks to one gpx track
4
+ In order to use them on my gps device
5
+
6
+ Scenario: Create from gpx route files
7
+ Given a gpx file named "route1.gpx"
8
+ And a gpx file named "route2.gpx"
9
+ When I successfully run `gpx_track g route1.gpx route2.gpx`
10
+ Then a gpx file named "track.gpx" should exist
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+
3
+ Before do
4
+ @aruba_timeout_seconds = 120
5
+ ENV['MM_ENV'] = 'development'
6
+
7
+ step 'a mocked home directory'
8
+ end
9
+
10
+ # Clean environment
11
+ Around do |_, block|
12
+ old_env = ENV.to_h
13
+
14
+ block.call
15
+
16
+ ENV.replace old_env
17
+ end
18
+
19
+ Given(/^a gpx file named "(.*?)"$/) do |file|
20
+ in_current_dir do
21
+ FileUtils.cp File.expand_path("../../fixtures/#{file}", __FILE__), file
22
+ end
23
+ end
24
+
25
+ Then(/^a gpx file named "(.*?)" should exist$/) do |file|
26
+ step %(a file named "#{file}" should exist)
27
+ end
@@ -0,0 +1,14 @@
1
+ # encoding: utf-8
2
+ require 'aruba/cucumber'
3
+
4
+ # Spec Helpers
5
+ module FeatureHelper
6
+ # Helpers for aruba
7
+ module Aruba
8
+ def dirs
9
+ @dirs ||= %w(tmp cucumber)
10
+ end
11
+ end
12
+ end
13
+
14
+ World(FeatureHelper::Aruba)
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+
3
+ # Test helpers
4
+ module FeatureHelper
5
+ # Helpers for ci
6
+ module Ci
7
+ def ci?
8
+ ENV.key?('TRAVIS_CI') || ENV.key?('CI')
9
+ end
10
+ end
11
+ end
12
+
13
+ World(FeatureHelper::Ci)
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+ require 'simplecov'
3
+ SimpleCov.command_name 'cucumber'
4
+ SimpleCov.start
5
+
6
+ # Pull in all of the gems including those in the `test` group
7
+ require 'bundler'
8
+ Bundler.require :default, :test, :development
9
+
10
+ ENV['TEST'] = 'true'
11
+ ENV['AUTOLOAD_SPROCKETS'] = 'false'
12
+
13
+ PROJECT_ROOT_PATH = File.expand_path('../../../', __FILE__)
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+ module FeatureHelper
3
+ # Helper for fixtures
4
+ module Fixtures
5
+ def fixtures_manager
6
+ @fixtures_manager ||= FeduxOrgStdlib::FixturesManagement::FixturesManager.new
7
+
8
+ @fixtures_manager.load_fixtures(File.expand_path('../../../fixtures', __FILE__))
9
+
10
+ @fixtures_manager
11
+ end
12
+ end
13
+ end
14
+
15
+ World(FeatureHelper::Fixtures)
@@ -0,0 +1,2 @@
1
+ # encoding: utf-8
2
+ require 'active_support/core_ext/kernel/reporting'
@@ -0,0 +1,26 @@
1
+ <?xml version="1.0"?>
2
+ <gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.1" creator="Quo v2" xmlns="http://www.topografix.com/GPX/1/1">
3
+ <metadata>
4
+ <desc>GPX file generated with blub.</desc>
5
+ <link href="http://www.example.com">
6
+ <text>Example</text>
7
+ </link>
8
+ <time>2014-08-28 21:54:34 +0200</time>
9
+ </metadata>
10
+ <rte>
11
+ <name>Route 1</name>
12
+ <desc />
13
+ <rtept lat="56.2065623057112" lon="-4.74487558095559">
14
+ <ele>18.0738189546108</ele>
15
+ <time>2014-08-28 21:54:35 +0200</time>
16
+ <name>WPT 1</name>
17
+ <desc />
18
+ </rtept>
19
+ <rtept lat="56.2065623057113" lon="-4.74487558095560">
20
+ <ele>18.0738189546109</ele>
21
+ <time>2014-08-28 21:54:35 +0200</time>
22
+ <name>WPT 1</name>
23
+ <desc />
24
+ </rtept>
25
+ </rte>
26
+ </gpx>
@@ -0,0 +1,26 @@
1
+ <?xml version="1.0"?>
2
+ <gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.1" creator="Quo v2" xmlns="http://www.topografix.com/GPX/1/1">
3
+ <metadata>
4
+ <desc>GPX file generated with blub.</desc>
5
+ <link href="http://www.example.com">
6
+ <text>Example</text>
7
+ </link>
8
+ <time>2014-08-28 21:54:34 +0200</time>
9
+ </metadata>
10
+ <rte>
11
+ <name>Route 2</name>
12
+ <desc />
13
+ <rtept lat="56.2067034732981" lon="-4.74471150135048">
14
+ <ele>5.41751760323048</ele>
15
+ <time>2014-08-28 21:54:36 +0200</time>
16
+ <name>WPT 2</name>
17
+ <desc />
18
+ </rtept>
19
+ <rtept lat="56.2067034732982" lon="-4.74471150135049">
20
+ <ele>5.41751760323049</ele>
21
+ <time>2014-08-28 21:54:36 +0200</time>
22
+ <name>WPT 2</name>
23
+ <desc />
24
+ </rtept>
25
+ </rte>
26
+ </gpx>
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gpx_track_generator/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'gpx_track_generator'
8
+ spec.version = GpxTrackGenerator::VERSION
9
+ spec.authors = ['Max Meyer']
10
+ spec.email = ['dev@fedux.org']
11
+ spec.summary = 'Generate a gpx track from gpx tracks/routes'
12
+ spec.homepage = 'https://github.com/maxmeyer/gpx_track_generator'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_runtime_dependency 'nokogiri'
21
+ spec.add_runtime_dependency 'thor'
22
+ spec.add_runtime_dependency 'activesupport'
23
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+ module GpxTrackGenerator
3
+ # Runner
4
+ class Runner < Thor
5
+ option :file, default: 'track.gpx', desc: 'GPX track file name'
6
+ desc 'generate', 'Generate gpx track'
7
+ argument :gpx_files, type: :array, desc: 'GPX track or route files'
8
+ def generate
9
+ track = Track.new(gpx_files.map { |f| File.expand_path f })
10
+
11
+ File.write(options[:file], track.to_s)
12
+ end
13
+
14
+ default_command :generate
15
+ end
16
+ end
@@ -0,0 +1,56 @@
1
+ # encoding: utf-8
2
+ module GpxTrackGenerator
3
+ # Track
4
+ class Track
5
+ private
6
+
7
+ attr_reader :files
8
+
9
+ public
10
+
11
+ def initialize(files)
12
+ @files = files
13
+ end
14
+
15
+ def to_s
16
+ build_document
17
+ end
18
+
19
+ private
20
+
21
+ def build_document
22
+ document.child << metadata
23
+ document.child << document.create_element('trk')
24
+
25
+ files.each_with_object(document.css('trk').first) do |e, a|
26
+ a << document.create_element('trkseg')
27
+ node_set = Nokogiri::XML(File.open(e)).remove_namespaces!.css('rtept')
28
+ node_set.each { |n| n.name = 'trkpt' }
29
+
30
+ a.css('trkseg').last << node_set
31
+ end
32
+
33
+ document.to_s
34
+ end
35
+
36
+ def document
37
+ @document ||= Nokogiri::XML(
38
+ <<-EOS.strip_heredoc
39
+ <gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.1" creator="Nokogiri" xmlns="http://www.topografix.com/GPX/1/1"></gpx>
40
+ EOS
41
+ )
42
+ end
43
+
44
+ def metadata
45
+ @metadata ||= Nokogiri::XML::DocumentFragment.parse <<-EOS.strip_heredoc
46
+ <metadata>
47
+ <desc>GPX file generated nokogiri</desc>
48
+ <link href="http://nokogiri.org/">
49
+ <text>Nokogiri</text>
50
+ </link>
51
+ <time>#{Time.now}</time>
52
+ </metadata>
53
+ EOS
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+ # GpxTrackGenerator
3
+ module GpxTrackGenerator
4
+ VERSION = '0.0.2'
5
+ end
@@ -0,0 +1,12 @@
1
+ require 'thor'
2
+ require 'nokogiri'
3
+ require 'thor/actions'
4
+ require 'active_support/core_ext/string/strip'
5
+
6
+ require 'gpx_track_generator/version'
7
+ require 'gpx_track_generator/runner'
8
+ require 'gpx_track_generator/track'
9
+
10
+ # Track generator
11
+ module GpxTrackGenerator
12
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+ $LOAD_PATH << File.expand_path('../../lib', __FILE__)
3
+
4
+ require 'simplecov'
5
+ SimpleCov.command_name 'rspec'
6
+ SimpleCov.start
7
+
8
+ # Pull in all of the gems including those in the `test` group
9
+ require 'bundler'
10
+ Bundler.require :default, :test, :development
11
+
12
+ require 'gpx_track_generator'
13
+
14
+ # Loading support files
15
+ Dir.glob(::File.expand_path('../support/*.rb', __FILE__)).each { |f| require_relative f }
16
+ Dir.glob(::File.expand_path('../shared_examples/*.rb', __FILE__)).each { |f| require_relative f }
17
+
18
+ # Avoid writing "describe MyModule::MyClass do [..]" but "describe MyClass do [..]"
19
+ include GpxTrackGenerator
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+ require 'aruba/api'
3
+ require 'aruba/reporting'
4
+
5
+ # Spec Helpers
6
+ module SpecHelper
7
+ # Helpers for aruba
8
+ module Aruba
9
+ include ::Aruba::Api
10
+
11
+ def dirs
12
+ @dirs ||= %w(tmp rspec)
13
+ end
14
+
15
+ def absolute_path(*args)
16
+ in_current_dir { File.expand_path File.join(*args) }
17
+ end
18
+
19
+ def _create_file(*args)
20
+ super
21
+
22
+ args.first
23
+ end
24
+
25
+ def create_dir(*args)
26
+ super
27
+
28
+ args.first
29
+ end
30
+
31
+ def touch_file(file_name)
32
+ in_current_dir do
33
+ file_name = File.expand_path(file_name)
34
+ _mkdir(File.dirname(file_name))
35
+ FileUtils.touch file_name
36
+ end
37
+
38
+ file_name
39
+ end
40
+ end
41
+ end
42
+
43
+ RSpec.configure do |c|
44
+ c.include SpecHelper::Aruba
45
+ c.before :each do
46
+ clean_current_dir
47
+ restore_env
48
+ end
49
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ # Test helpers
4
+ # Spec Helpers
5
+ module SpecHelper
6
+ # Helpers for ci
7
+ module Ci
8
+ def ci?
9
+ ENV.key?('TRAVIS_CI') || ENV.key?('CI')
10
+ end
11
+ end
12
+ end
13
+
14
+ RSpec.configure do |c|
15
+ c.include SpecHelper::Ci
16
+ end
@@ -0,0 +1,2 @@
1
+ # encoding: utf-8
2
+ require 'active_support/core_ext/kernel/reporting'
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+ RSpec.configure do |config|
3
+ config.filter_run :focus
4
+ config.run_all_when_everything_filtered = true
5
+
6
+ config.default_formatter = 'doc' if config.files_to_run.one?
7
+
8
+ config.profile_examples = 10
9
+ config.order = :random
10
+ Kernel.srand config.seed
11
+
12
+ config.expect_with :rspec do |expectations|
13
+ expectations.syntax = :expect
14
+ end
15
+
16
+ config.mock_with :rspec do |mocks|
17
+ mocks.syntax = :expect
18
+ mocks.verify_partial_doubles = true
19
+ end
20
+ end
@@ -0,0 +1,2 @@
1
+ # encoding: utf-8
2
+ require 'active_support/core_ext/string/strip'
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gpx_track_generator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Max Meyer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - dev@fedux.org
58
+ executables:
59
+ - gpx_track
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".rdebugrc"
65
+ - ".rspec"
66
+ - ".rubocop.yml"
67
+ - ".simplecov"
68
+ - ".travis.yml"
69
+ - ".yardopts"
70
+ - Gemfile
71
+ - Gemfile.lock
72
+ - LICENSE.txt
73
+ - README.md
74
+ - Rakefile
75
+ - bin/gpx_track
76
+ - config/license_finder.yml
77
+ - config/rubocop/exclude.yml
78
+ - config/rubocop/include.yml
79
+ - cucumber.yml
80
+ - doc/licenses/dependencies.db
81
+ - features/create_gpx_track_file.feature
82
+ - features/step_definitions.rb
83
+ - features/support/aruba.rb
84
+ - features/support/ci.rb
85
+ - features/support/env.rb
86
+ - features/support/fixtures.rb
87
+ - features/support/reporting.rb
88
+ - fixtures/route1.gpx
89
+ - fixtures/route2.gpx
90
+ - gpx_track_generator.gemspec
91
+ - lib/gpx_track_generator.rb
92
+ - lib/gpx_track_generator/runner.rb
93
+ - lib/gpx_track_generator/track.rb
94
+ - lib/gpx_track_generator/version.rb
95
+ - spec/spec_helper.rb
96
+ - spec/support/aruba.rb
97
+ - spec/support/ci.rb
98
+ - spec/support/reporting.rb
99
+ - spec/support/rspec.rb
100
+ - spec/support/string.rb
101
+ homepage: https://github.com/maxmeyer/gpx_track_generator
102
+ licenses:
103
+ - MIT
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.2.2
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Generate a gpx track from gpx tracks/routes
125
+ test_files:
126
+ - features/create_gpx_track_file.feature
127
+ - features/step_definitions.rb
128
+ - features/support/aruba.rb
129
+ - features/support/ci.rb
130
+ - features/support/env.rb
131
+ - features/support/fixtures.rb
132
+ - features/support/reporting.rb
133
+ - spec/spec_helper.rb
134
+ - spec/support/aruba.rb
135
+ - spec/support/ci.rb
136
+ - spec/support/reporting.rb
137
+ - spec/support/rspec.rb
138
+ - spec/support/string.rb
139
+ has_rdoc: