natour 0.9.0 → 0.11.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: 59d15bbec4750fd92158c6cbff64a201bad92792600a03a0f430e0c77ddcbea0
4
- data.tar.gz: 1b6dedc5f83f66173d77a176d2d20815b4055e2b93c98ecd6d6b26117219c03f
3
+ metadata.gz: 6a5853cf54dee642dc7cf5e2fef40e7a3379266ead197977c4804146b8334ef0
4
+ data.tar.gz: 13b08bc14434447bb5e6b18605f1c8a1fdadef8bba17e47154eec829095b3e13
5
5
  SHA512:
6
- metadata.gz: 7dd61ac963164d480e626414bef161e1f1a702d26a2ff71e733a796610b18b7942a5f6ce400329a7c9b3f0566ea501d20f7926285d923d85a4eda4835331f14f
7
- data.tar.gz: 1ad29625fc06e4f738c7e7127d3381aa701ec033618c9d2a5c1b7167b56b1890f3ba4c8035a8bfe4f6dba33ddf5a3d6b842f0650a1da22c19b04b149c51c5977
6
+ metadata.gz: f829da1ae7ae12e9f753274e8200c8d3de4e0d7e6c8cf13d5cdcb6c2c1abb4bf0ce5d8837e22ff32ed4589d2f30c7a4d5175831c24dfe8e642a8cf279be96fa6
7
+ data.tar.gz: d144ee6947ada5321c828772db6364770dc8bea4616a3022e4c1f99bdc9a3df23e9f8bcd9c0e0dcf29fd74c945513539d19050d8780f0805e32e3ecd981ef69b
data/.natour.yml ADDED
@@ -0,0 +1,28 @@
1
+ ---
2
+ :report:
3
+ :create:
4
+ :out_dir: null
5
+ :out_file: null
6
+ :overwrite: false
7
+ :track_formats:
8
+ - :gpx
9
+ - :fit
10
+ :map: true
11
+ :map_layers: []
12
+ :adoc_author: null
13
+ :convert:
14
+ :out_dir: null
15
+ :out_file: null
16
+ :overwrite: false
17
+ :backend: :pdf
18
+ :draft: false
19
+ :draft_backend: null
20
+ :image_maxdim: 1800
21
+ :map:
22
+ :create:
23
+ :out_dir: null
24
+ :out_file: null
25
+ :overwrite: false
26
+ :gps_colors: []
27
+ :map_layers: []
28
+ :image_size: [1200, 900]
data/CHANGELOG.adoc CHANGED
@@ -4,8 +4,27 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on https://keepachangelog.com/en/1.0.0/[Keep a Changelog^], and this project adheres to https://semver.org/spec/v2.0.0.html[Semantic Versioning^].
6
6
 
7
+ IMPORTANT: As per Semantic Versioning, the major version zero is for initial development and anything may change at any time.
8
+
7
9
  == Unreleased
8
10
 
11
+ == 0.11.0 - 2023-04-15
12
+
13
+ === Changed
14
+
15
+ - Specify files to load for a configuration instead of a file and directories.
16
+ - The configuration files must now be named `.natour.yml` (prefixed with a dot).
17
+
18
+ === Fixed
19
+
20
+ - Do not abort creating reports if GPX files do not contain tracks.
21
+
22
+ == 0.10.0 - 2023-02-18
23
+
24
+ === Fixed
25
+
26
+ - Prevent orphaned section titles and table captions in PDF output.
27
+
9
28
  == 0.9.0 - 2022-10-08
10
29
 
11
30
  === Added
@@ -31,21 +50,11 @@ The format is based on https://keepachangelog.com/en/1.0.0/[Keep a Changelog^],
31
50
  === Changed
32
51
 
33
52
  - Rename arguments of `Natour::MapGeoAdmin.save_image`, i.e. `tracks` to `gps_files`, `layers` to `map_layers` and `size` to `image_size`.
34
- +
35
- IMPORTANT: This is a breaking change.
36
53
  - Improve the error reporting on the command line interface in case of file errors.
37
54
  - Rework the configuration; the structure and naming follows the command line interface and the keys are of type Ruby Symbol. For details, see the README file.
38
- +
39
- IMPORTANT: This is a breaking change. Adapt the configuration file accordingly.
40
55
  - Rework the command line interface. Use `natour --help` to get more information.
41
- +
42
- IMPORTANT: This is a breaking change. Adapt the commands accordingly.
43
56
  - Change `backend` and `draft_backend` arguments of `Natour::convert_report` to symbols.
44
- +
45
- IMPORTANT: This is a breaking change. Adapt the configuration file accordingly.
46
57
  - Rename `Natour::create` to `Natour::create_reports` and `Natour::convert` to `Natour::convert_report`.
47
- +
48
- IMPORTANT: This is a breaking change.
49
58
 
50
59
  === Fixed
51
60
 
@@ -102,8 +111,6 @@ IMPORTANT: This is a breaking change.
102
111
  === Removed
103
112
 
104
113
  - Remove redundant method `Natour::Image.portrait?`.
105
- +
106
- IMPORTANT: This is a breaking change. Use `Natour::Image.landscape?` instead.
107
114
 
108
115
  == 0.3.0 - 2021-03-07
109
116
 
@@ -128,8 +135,6 @@ IMPORTANT: This is a breaking change. Use `Natour::Image.landscape?` instead.
128
135
  === Changed
129
136
 
130
137
  - Rename `Natour::SpeciesList.name` to `Natour::SpeciesList.title`.
131
- +
132
- IMPORTANT: This is a breaking change.
133
138
  - Return an empty array from `Natour::SpeciesList.load_file` if the format is unknown.
134
139
  - Change the format of the start time in the AsciiDoc output from _12:30_ to _12:30 Uhr_.
135
140
  - Change the format of the duration in the AsciiDoc output from _1h30_ to _1:30 h_.
data/README.adoc CHANGED
@@ -90,38 +90,11 @@ NOTE: Use `natour --help` to get more information.
90
90
 
91
91
  === Configuration
92
92
 
93
- The configuration is built by loading https://yaml.org/[YAML^] files in hierarchical order. The files must be named `natour.yml` and are loaded first from the home directory of the current user and then from the current working directory. The values of the previously loaded files are overwritten by the values of the files loaded later. The values are stored internally in nested, dictionary-like collections (Ruby `Hash`), where the structure follows to the command line interface. All keys are of type Ruby `Symbol` and correspond to the commands and options, with middle hyphens replaced by underscores, leading hyphens removed, and without the `no-` prefix for boolean switches. The following configuration file shows all entries and their default values.
93
+ The configuration is built by loading https://yaml.org/[YAML^] files in hierarchical order. The files must be named `.natour.yml` and are loaded first from the home directory of the current user and then from the current working directory. The values of the previously loaded files are overwritten by the values of the files loaded later. The values are stored internally in nested, dictionary-like collections (Ruby `Hash`), where the structure follows to the command line interface. All keys are of type Ruby `Symbol` and correspond to the commands and options, with middle hyphens replaced by underscores, leading hyphens removed, and without the `no-` prefix for boolean switches. The following configuration file shows all entries and their default values.
94
94
 
95
95
  [source,yml]
96
96
  ----
97
- ---
98
- :report:
99
- :create:
100
- :out_dir: null
101
- :out_file: null
102
- :overwrite: false
103
- :track_formats:
104
- - :gpx
105
- - :fit
106
- :map: true
107
- :map_layers: []
108
- :adoc_author: null
109
- :convert:
110
- :out_dir: null
111
- :out_file: null
112
- :overwrite: false
113
- :backend: :pdf
114
- :draft: false
115
- :draft_backend: null
116
- :image_maxdim: 1800
117
- :map:
118
- :create:
119
- :out_dir: null
120
- :out_file: null
121
- :overwrite: false
122
- :gps_colors: []
123
- :map_layers: []
124
- :image_size: [1200, 900]
97
+ include::.natour.yml[]
125
98
  ----
126
99
 
127
100
  How to restrict GPS tracks to the FIT format (see https://developer.garmin.com/fit/[FIT SDK^]) and add additional map layers (see https://api3.geo.admin.ch/api/faq/index.html#which-layers-are-available[API FAQ - GeoAdmin API 3.0 documentation^]) is shown in the example below.
data/bin/natour CHANGED
@@ -125,41 +125,11 @@ class NatourCmd < Clamp::Command
125
125
  end
126
126
  end
127
127
 
128
- config = Natour::Config.load_file(
129
- Pathname($PROGRAM_NAME).basename.sub_ext('.yml'),
130
- default: {
131
- report: {
132
- create: {
133
- out_dir: nil,
134
- out_file: nil,
135
- overwrite: false,
136
- track_formats: %i[gpx fit],
137
- map: true,
138
- map_layers: [],
139
- adoc_author: nil
140
- },
141
- convert: {
142
- out_dir: nil,
143
- out_file: nil,
144
- overwrite: false,
145
- backend: :pdf,
146
- draft: false,
147
- draft_backend: nil,
148
- image_maxdim: 1800
149
- }
150
- },
151
- map: {
152
- create: {
153
- out_dir: nil,
154
- out_file: nil,
155
- overwrite: false,
156
- gps_colors: [],
157
- map_layers: [],
158
- image_size: [1200, 900]
159
- }
160
- }
161
- }
162
- )
128
+ config = Natour::Config.load_files([
129
+ "#{__dir__}/../.natour.yml",
130
+ Pathname(Dir.home).join('.natour.yml'),
131
+ Pathname(Dir.pwd).join('.natour.yml')
132
+ ])
163
133
 
164
134
  NatourCmd.run(
165
135
  Pathname($PROGRAM_NAME).basename,
@@ -124,7 +124,7 @@ module Natour
124
124
  end
125
125
  cols = [1] + [5 * info.columns.size / columns.size] * columns.size
126
126
  doc << caption
127
- doc << "[cols=\"#{cols.join(',')}\",options=header]"
127
+ doc << "[%breakable,cols=\"#{cols.join(',')}\",options=header]"
128
128
  doc << '|==='
129
129
  doc << "|Nr.|#{columns.map(&:header).join('|')}"
130
130
  species_list.each do |species|
data/lib/natour/config.rb CHANGED
@@ -4,12 +4,9 @@ require 'yaml'
4
4
 
5
5
  module Natour
6
6
  class Config
7
- def self.load_file(filename, default: {}, dirs: [Dir.home, Dir.pwd])
8
- configs = dirs.map do |dir|
9
- config = YAML.safe_load(
10
- File.read(Pathname(dir).join(filename)),
11
- permitted_classes: [Symbol]
12
- )
7
+ def self.load_files(filenames, default: {})
8
+ configs = filenames.map do |filename|
9
+ config = YAML.safe_load(File.read(filename), permitted_classes: [Symbol])
13
10
  config || {}
14
11
  rescue Errno::ENOENT
15
12
  {}
@@ -8,7 +8,9 @@ font:
8
8
  bold: dejavuserifcondensed-bold.ttf
9
9
  bold_italic: dejavuserifcondensed-bold_italic.ttf
10
10
  base:
11
- font-family: DejaVu Serif Condensed
11
+ font_family: DejaVu Serif Condensed
12
+ heading:
13
+ min_height_after: auto
12
14
  footer:
13
15
  recto:
14
16
  left:
@@ -29,7 +29,8 @@ module Natour
29
29
  format = Pathname(filename).extname.to_s.delete_prefix('.').to_sym if format == :auto
30
30
  case format
31
31
  when :gpx
32
- GPXFile.new(filename)
32
+ gpx_file = GPXFile.new(filename)
33
+ gpx_file if gpx_file.types.include?(:track)
33
34
  when :fit
34
35
  FITFile.new(filename)
35
36
  end
@@ -9,9 +9,16 @@ module Natour
9
9
  'xmlns:gpxtrkx' => 'http://www.garmin.com/xmlschemas/TrackStatsExtension/v1'
10
10
  }.freeze
11
11
 
12
+ attr_reader :types
13
+
12
14
  def initialize(filename)
13
15
  @doc = Nokogiri.XML(File.read(filename, mode: 'r:utf-8'))
14
16
 
17
+ @types = []
18
+ @types << :waypoint if @doc.at('/xmlns:gpx/xmlns:wpt', GPX_XMLNS)
19
+ @types << :route if @doc.at('/xmlns:gpx/xmlns:rte', GPX_XMLNS)
20
+ @types << :track if @doc.at('/xmlns:gpx/xmlns:trk', GPX_XMLNS)
21
+
15
22
  stats = @doc.at('/xmlns:gpx/xmlns:trk/xmlns:extensions/gpxtrkx:TrackStatsExtension', GPX_XMLNS)
16
23
  if stats
17
24
  ascent = stats.at('./gpxtrkx:Ascent', GPX_XMLNS).text.to_i
@@ -23,7 +30,7 @@ module Natour
23
30
  start_point = to_track_point(@doc.at('/xmlns:gpx/xmlns:trk/xmlns:trkseg[1]/xmlns:trkpt[1]', GPX_XMLNS))
24
31
  end_point = to_track_point(@doc.at('/xmlns:gpx/xmlns:trk/xmlns:trkseg[last()]/xmlns:trkpt[last()]', GPX_XMLNS))
25
32
 
26
- super(filename, start_point.time&.to_date, ascent, descent, distance, duration, start_point, end_point)
33
+ super(filename, start_point&.time&.to_date, ascent, descent, distance, duration, start_point, end_point)
27
34
  end
28
35
 
29
36
  def to_gpx
@@ -33,6 +40,8 @@ module Natour
33
40
  private
34
41
 
35
42
  def to_track_point(trkpt)
43
+ return nil unless trkpt
44
+
36
45
  GPSTrackPoint.new(
37
46
  trkpt['lat'].to_f,
38
47
  trkpt['lon'].to_f,
data/lib/natour/report.rb CHANGED
@@ -51,6 +51,7 @@ module Natour
51
51
  .join(',')
52
52
  Pathname.glob("**/*.{#{track_pattern}}")
53
53
  .map { |filename| GPSTrack.load_file(filename.to_s) }
54
+ .compact
54
55
  .sort_by { |gps_track| [gps_track.date, gps_track.path] }
55
56
  end
56
57
 
@@ -3,7 +3,9 @@ module Natour
3
3
  module_function
4
4
 
5
5
  def split_message(error)
6
- error.message.split(/ @ | - /, 3)
6
+ tokens = error.message.split(/ @ | - /, 3)
7
+ tokens.insert(1, *[nil] * (3 - tokens.size))
8
+ tokens
7
9
  end
8
10
  end
9
11
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Natour
4
- VERSION = '0.9.0'
4
+ VERSION = '0.11.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: natour
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Gysi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-08 00:00:00.000000000 Z
11
+ date: 2023-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.5'
33
+ version: '2.3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.5'
40
+ version: '2.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: clamp
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -213,6 +213,7 @@ executables:
213
213
  extensions: []
214
214
  extra_rdoc_files: []
215
215
  files:
216
+ - ".natour.yml"
216
217
  - CHANGELOG.adoc
217
218
  - LICENSE
218
219
  - README.adoc