simple-trail 0.1.3 → 0.2.0

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
  SHA256:
3
- metadata.gz: 459bc2473757a35abbd5659ecf848e89dfc31e09e6febd66bb730fa3c872fc6e
4
- data.tar.gz: 2e28ca43a36e63de9fdf2ea295b1c4d3166544b4ec581f3daf9ae81ad74247bd
3
+ metadata.gz: aba06ca65c57e7950b28e45822dcddaa944b6375eb6e8d1ceedaee8031f1e163
4
+ data.tar.gz: 3b82b1e9d848442630deaa9b09ea4fa02c51dce42cf86a980d1abb823746a82e
5
5
  SHA512:
6
- metadata.gz: ba4d5bd4951e88a62175e7c5c13520e0c3eaee7a662db893007a7568dd6e2c29a53a310a6f7e19c157afa00f993e6f491b11d397a49428114e5f8bda20eaf778
7
- data.tar.gz: d4684d613afba62b5c2a0ca890566bdbb33d029b64f7e207e96157aa6985222ae78c5940c4d21e3d2d12327c20a5858dab192b4fd5d05ccdffbf97f4c276265e
6
+ metadata.gz: 40c43bd89ba95b26820580c88afbd6b327fac9c1edb4ab42a38441703d1d93be7c3f5cf33a9ee9fe99848875030a2de788a55c14db4c8fd7483090f154c7bd72
7
+ data.tar.gz: 98cd69d440cd930578cea1ebc9b0240f885fa508f62860e7acd75668a89b2e692304e8d5cc90720818b71dcb1bcaa6c5d5ca9abb0892b98c0ea79e3f9b2533c7
@@ -0,0 +1,29 @@
1
+ require 'nokogiri'
2
+
3
+ module Generator
4
+ class Gpx
5
+ attr_reader :output
6
+
7
+ def initialize(points:, name: 'GPX file')
8
+ @points = points
9
+ @name = name
10
+ end
11
+
12
+ def gpx
13
+ builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
14
+ xml.gpx(version: '1.0') {
15
+ xml.name { @name }
16
+ xml.trk {
17
+ xml.trkseg {
18
+ @points.map do |point|
19
+ xml.trkpt(lat: point[:lat], lon: point[:lon])
20
+ end
21
+ }
22
+ }
23
+ }
24
+ end
25
+
26
+ @output = builder.to_xml
27
+ end
28
+ end
29
+ end
data/lib/simple_trail.rb CHANGED
@@ -8,6 +8,7 @@ require File.expand_path('simple_trail/manipulation/statistics', __dir__)
8
8
  require File.expand_path('simple_trail/manipulation/straightener', __dir__)
9
9
  require File.expand_path('simple_trail/manipulation/unifier', __dir__)
10
10
  require File.expand_path('simple_trail/manipulation/enricher', __dir__)
11
+ require File.expand_path('simple_trail/generator/gpx', __dir__)
11
12
 
12
13
  module SimpleTrail
13
14
  Geokit.default_units = :kms
data/simple-trail.gemspec CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = 'simple-trail'
8
- s.version = '0.1.3'
8
+ s.version = '0.2.0'
9
9
  s.date = '2020-08-03'
10
10
  s.summary = 'Readind and manipulating GPX and other trail representation file'
11
11
  s.description = 'Optimazing and manipulating GPX file data. For my private purposes mostly'
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.license = 'MIT'
19
19
  s.add_dependency 'geokit', '1.13'
20
20
  s.add_dependency 'xmlhasher', '~> 1.0'
21
+ s.add_dependency 'nokogiri', '~> 1.13'
21
22
  s.add_development_dependency 'pry', '~> 0.13'
22
23
  s.add_development_dependency 'rspec', '~> 3.9'
23
24
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Generator::Gpx do
6
+ it 'generates output' do
7
+ parser = Parser::Gpx.new('./spec/examples/test_1.gpx')
8
+ parser.read
9
+
10
+ points = parser.points
11
+
12
+ service = described_class.new(points: points)
13
+ expect{service.gpx}.not_to raise_error
14
+ output = service.output
15
+ expect(output).not_to be_nil
16
+
17
+ random_point = points.sample
18
+ expect(output.match(/#{random_point[:lon]}/)).not_to be_nil
19
+ expect(output.match(/#{random_point[:lat]}/)).not_to be_nil
20
+ end
21
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-trail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Staszek Zawadzki
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.13'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.13'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: pry
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -76,6 +90,7 @@ files:
76
90
  - README.md
77
91
  - install.sh
78
92
  - lib/simple_trail.rb
93
+ - lib/simple_trail/generator/gpx.rb
79
94
  - lib/simple_trail/manipulation/enricher.rb
80
95
  - lib/simple_trail/manipulation/statistics.rb
81
96
  - lib/simple_trail/manipulation/straightener.rb
@@ -100,6 +115,7 @@ files:
100
115
  - spec/examples/test_9.gpx
101
116
  - spec/examples/test_with_segments.gpx
102
117
  - spec/examples/zyleta2021.gpx
118
+ - spec/generator/gpx_spec.rb
103
119
  - spec/manipulation/enricher_spec.rb
104
120
  - spec/manipulation/statistics_spec.rb
105
121
  - spec/manipulation/straightener_spec.rb
@@ -126,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
142
  - !ruby/object:Gem::Version
127
143
  version: '0'
128
144
  requirements: []
129
- rubygems_version: 3.1.4
145
+ rubygems_version: 3.2.15
130
146
  signing_key:
131
147
  specification_version: 4
132
148
  summary: Readind and manipulating GPX and other trail representation file
@@ -149,6 +165,7 @@ test_files:
149
165
  - spec/examples/test_9.gpx
150
166
  - spec/examples/test_with_segments.gpx
151
167
  - spec/examples/zyleta2021.gpx
168
+ - spec/generator/gpx_spec.rb
152
169
  - spec/manipulation/enricher_spec.rb
153
170
  - spec/manipulation/statistics_spec.rb
154
171
  - spec/manipulation/straightener_spec.rb