gpsbabel 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d26cde23bbb38b3f3dbc8a985f707871fa967cec
4
+ data.tar.gz: 66f92e765b2bdc0e927935fb6c7137c038470785
5
+ SHA512:
6
+ metadata.gz: c85a2e6c4dd09753791efd796e090cc07e001d3b653f40c98477b895d7e5da94064191f1171b2aa8e2ac3cad5e119ffe75d2725c8f9871500b13a244f4a688cc
7
+ data.tar.gz: e55f59077771c00ffdc8ebe7b3ad5a0467a9623dd4b6b17920202413243cb84d88608f0f30955790b224b88debbb0bf2a41a8dc5ec65b018e91553022c0a86b3
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gpsbabel.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,11 @@
1
+ guard :rspec, cmd: 'bundle exec rspec' do
2
+ # watch /lib/ files
3
+ watch(%r{^lib/(.+).rb$}) do |m|
4
+ "spec/#{m[1]}_spec.rb"
5
+ end
6
+
7
+ # watch /spec/ files
8
+ watch(%r{^spec/(.+).rb$}) do |m|
9
+ "spec/#{m[1]}.rb"
10
+ end
11
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Collin Price
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # Gpsbabel
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'gpsbabel'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install gpsbabel
20
+
21
+ ## Usage
22
+
23
+ #### Basic
24
+
25
+ Convert `gdb` file into a `gpx` file.
26
+
27
+ GPSBabel.convert({
28
+ input: {
29
+ format: 'gdb',
30
+ file: '/home/user/gps_data/tracks.gdb'
31
+ }
32
+ })
33
+
34
+ This example will create a `gpx` file at `/home/user/gps_data/tracks.gpx`.
35
+
36
+ #### Specify Output
37
+
38
+ GPSBabel.convert({
39
+ input: {
40
+ format: 'gdb',
41
+ file: '/home/user/gps_data/tracks.gdb'
42
+ },
43
+ output: {
44
+ format: 'gpx',
45
+ file: '/home/user/gps_data/converted_tracks.gpx'
46
+ }
47
+ })
48
+
49
+ #### Convert and Extract
50
+
51
+ Only extract specific GPS data from converted file using `options`. Defaults `waypoints`, `routes`, and `tracks` to `true`.
52
+
53
+ GPSBabel.convert({
54
+ input: {
55
+ format: 'gdb',
56
+ file: '/home/user/gps_data/tracks.gdb'
57
+ },
58
+ output: {
59
+ format: 'gpx',
60
+ file: '/home/user/gps_data/converted_tracks.gpx'
61
+ },
62
+ options: {
63
+ waypoints: false,
64
+ routes: false,
65
+ tracks: true
66
+ }
67
+ })
68
+
69
+ #### GPX Version
70
+
71
+ Specify which `gpx` version to convert to. Default: `1.1`
72
+
73
+ GPSBabel.convert({
74
+ input: {
75
+ format: 'gdb',
76
+ file: '/home/user/gps_data/tracks.gdb'
77
+ },
78
+ output: {
79
+ format: 'gpx',
80
+ gpxver: '1.0'
81
+ file: '/home/user/gps_data/converted_tracks.gpx'
82
+ },
83
+ options: {
84
+ waypoints: false,
85
+ routes: false,
86
+ tracks: true
87
+ }
88
+ })
89
+
90
+ ## Contributing
91
+
92
+ 1. Fork it ( https://github.com/[my-github-username]/gpsbabel/fork )
93
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
94
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
95
+ 4. Push to the branch (`git push origin my-new-feature`)
96
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+ require 'bundler/gem_tasks'
5
+
6
+ # Default directory to look in is `/specs`
7
+ # Run with `rake spec`
8
+ RSpec::Core::RakeTask.new(:spec) do |task|
9
+ task.rspec_opts = ['--color', '--format', 'nested']
10
+ end
11
+
12
+ task :default => :spec
data/gpsbabel.gemspec ADDED
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gpsbabel/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gpsbabel"
8
+ spec.version = GPSBabel::VERSION
9
+ spec.authors = ["Collin Price"]
10
+ spec.email = ["collin@collinprice.com"]
11
+ spec.summary = "GPSBabel Ruby wrapper."
12
+ spec.description = "Provides access through Ruby to the command-line application GPSBabel used to manipulate gps data files."
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "cliver"
22
+ spec.add_runtime_dependency "gpx2hash"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+
27
+ spec.add_development_dependency "rspec"
28
+ spec.add_development_dependency "rspec-nc"
29
+ spec.add_development_dependency "guard"
30
+ spec.add_development_dependency "guard-rspec"
31
+ spec.add_development_dependency "pry"
32
+ spec.add_development_dependency "pry-remote"
33
+ spec.add_development_dependency "pry-nav"
34
+ end
data/lib/gpsbabel.rb ADDED
@@ -0,0 +1,74 @@
1
+ require "gpsbabel/version"
2
+ require "cliver"
3
+
4
+ module GPSBabel
5
+
6
+ class FileNotFoundException < Exception; end
7
+ class MissingAttributesException < Exception; end
8
+
9
+ def self.convert attributes
10
+
11
+ # Check valid input attributes are there
12
+ unless (attributes.is_a? Hash) &&
13
+ (attributes.has_key? :input) &&
14
+ (attributes[:input].has_key? :format) &&
15
+ (attributes[:input].has_key? :file)
16
+ raise MissingAttributesException.new "Missing attributes"
17
+ end
18
+
19
+ # Merge options
20
+ options = {
21
+ waypoints: true,
22
+ routes: true,
23
+ tracks: true,
24
+ gpsbabel: 'gpsbabel'
25
+ }
26
+ if attributes.has_key? :options
27
+ options.merge! attributes[:options]
28
+ end
29
+
30
+ # Ensure gpsbabel command-line application is installed.
31
+ Cliver.detect! options[:gpsbabel]
32
+
33
+ # Check input file exists
34
+ unless File.exists? attributes[:input][:file]
35
+ raise FileNotFoundException.new "Unable to open #{attributes[:input][:file]}"
36
+ end
37
+
38
+ # Merge output
39
+ output = {
40
+ format: 'gpx',
41
+ gpxver: '1.1',
42
+ file: File.join(File.dirname(attributes[:input][:file]), File.basename(attributes[:input][:file], File.extname(attributes[:input][:file])) + ".gpx")
43
+ }
44
+ if attributes.has_key? :output
45
+ output.merge! attributes[:output]
46
+ end
47
+
48
+ # Build gpsbabel command
49
+ cmd = options[:gpsbabel]
50
+
51
+ if options[:waypoints]
52
+ cmd << " -w"
53
+ end
54
+ if options[:tracks]
55
+ cmd << " -t"
56
+ end
57
+ if options[:routes]
58
+ cmd << " -r"
59
+ end
60
+
61
+ cmd << " -i #{attributes[:input][:format]} -f #{attributes[:input][:file]}"
62
+ cmd << " -o #{output[:format]}"
63
+ if output[:format] == 'gpx'
64
+ cmd << ",gpxver=#{output[:gpxver]}"
65
+ end
66
+ cmd << " -F #{output[:file]}"
67
+
68
+ if system cmd
69
+ output[:file]
70
+ else
71
+ false
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,3 @@
1
+ module GPSBabel
2
+ VERSION = "0.1.0"
3
+ end
Binary file
@@ -0,0 +1,80 @@
1
+ require 'spec_helper'
2
+
3
+ describe GPSBabel do
4
+ let(:unable_open_input) {{
5
+ input: {
6
+ format: 'gdb',
7
+ file: File.join(File.dirname(__FILE__), "gps_files", "missing.gdb")
8
+ }
9
+ }}
10
+ let(:missing_attributes) {{
11
+ input: {
12
+ format: 'gdb'
13
+ }
14
+ }}
15
+ let(:input_only_attributes) {{
16
+ input: {
17
+ format: 'gdb',
18
+ file: File.join(File.dirname(__FILE__), "gps_files", "test.gdb")
19
+ }
20
+ }}
21
+ let(:io_attritubes) {{
22
+ input: {
23
+ format: 'gdb',
24
+ file: File.join(File.dirname(__FILE__), "gps_files", "test.gdb")
25
+ },
26
+ output: {
27
+ format: 'gpx',
28
+ file: File.join(File.dirname(__FILE__), "gps_files", "test2.gpx")
29
+ }
30
+ }}
31
+ let(:advanced_attributes) {{
32
+ input: {
33
+ format: 'gdb',
34
+ file: File.join(File.dirname(__FILE__), "gps_files", "test.gdb")
35
+ },
36
+ output: {
37
+ format: 'gpx',
38
+ gpxver: '1.0',
39
+ file: File.join(File.dirname(__FILE__), "gps_files", "test3.gpx")
40
+ },
41
+ options: {
42
+ waypoints: true,
43
+ routes: true,
44
+ tracks: true
45
+ }
46
+ }}
47
+
48
+ describe '.convert unable_open_input' do
49
+ it 'FileNotFoundException' do
50
+ expect { subject.convert unable_open_input }.to raise_exception
51
+ end
52
+ end
53
+
54
+ describe '.convert missing_attributes' do
55
+ it 'MissingAttributesException' do
56
+ expect { subject.convert unable_open_input }.to raise_exception
57
+ end
58
+ end
59
+
60
+ describe '.convert input_only_attributes' do
61
+ it 'returns path to converted file' do
62
+ expect(subject.convert input_only_attributes).to eq(File.join(File.dirname(__FILE__), "gps_files", "test.gpx"))
63
+ File.delete File.join(File.dirname(__FILE__), "gps_files", "test.gpx")
64
+ end
65
+ end
66
+
67
+ describe '.convert io_attritubes' do
68
+ it 'returns path to converted file' do
69
+ expect(subject.convert io_attritubes).to eq(io_attritubes[:output][:file])
70
+ File.delete io_attritubes[:output][:file]
71
+ end
72
+ end
73
+
74
+ describe '.convert advanced_attributes' do
75
+ it 'returns path to converted file' do
76
+ expect(subject.convert advanced_attributes).to eq(advanced_attributes[:output][:file])
77
+ File.delete advanced_attributes[:output][:file]
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,2 @@
1
+ require 'pry'
2
+ require 'gpsbabel'
metadata ADDED
@@ -0,0 +1,214 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gpsbabel
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Collin Price
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cliver
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: gpx2hash
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: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-nc
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry-remote
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: pry-nav
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ description: Provides access through Ruby to the command-line application GPSBabel
168
+ used to manipulate gps data files.
169
+ email:
170
+ - collin@collinprice.com
171
+ executables: []
172
+ extensions: []
173
+ extra_rdoc_files: []
174
+ files:
175
+ - ".gitignore"
176
+ - Gemfile
177
+ - Guardfile
178
+ - LICENSE.txt
179
+ - README.md
180
+ - Rakefile
181
+ - gpsbabel.gemspec
182
+ - lib/gpsbabel.rb
183
+ - lib/gpsbabel/version.rb
184
+ - spec/gps_files/test.gdb
185
+ - spec/gpsbabel_spec.rb
186
+ - spec/spec_helper.rb
187
+ homepage: ''
188
+ licenses:
189
+ - MIT
190
+ metadata: {}
191
+ post_install_message:
192
+ rdoc_options: []
193
+ require_paths:
194
+ - lib
195
+ required_ruby_version: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
200
+ required_rubygems_version: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ version: '0'
205
+ requirements: []
206
+ rubyforge_project:
207
+ rubygems_version: 2.2.2
208
+ signing_key:
209
+ specification_version: 4
210
+ summary: GPSBabel Ruby wrapper.
211
+ test_files:
212
+ - spec/gps_files/test.gdb
213
+ - spec/gpsbabel_spec.rb
214
+ - spec/spec_helper.rb