natour 0.11.0 → 0.12.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 +4 -4
- data/.natour.yml +1 -0
- data/CHANGELOG.adoc +16 -1
- data/README.adoc +29 -1
- data/bin/natour +4 -1
- data/lib/natour/asciinurse.rb +14 -10
- data/lib/natour/create_reports.rb +3 -2
- data/lib/natour/public_transport.rb +1 -1
- data/lib/natour/species_list.rb +2 -2
- data/lib/natour/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ac583bda8dbd5de8b922cc64bee346916b01c07b4ee986b845ef3c2c87985d0
|
4
|
+
data.tar.gz: 3e89dd11b0dda46ba30fdc62aec372068f5390209f7d119182d9340e4d5fbbfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96b0e7a19722f0749d08fe5a51cc9b8491b1e0f04533aed2a07f0fc091ae27eb5df2f1e0c4dc1fd67ef21673840744b9aab27f28bd12376b7dfdd3c126d7b441
|
7
|
+
data.tar.gz: 55f7c5dbfa646ac25e715f3dc7a1b169fc72bc223bf49893f19bbd6d0cc3c5b773ad1bef64f3520ebe4290d1ec2ea7a28b1da745157de877cce9a485bcc55467
|
data/.natour.yml
CHANGED
data/CHANGELOG.adoc
CHANGED
@@ -8,6 +8,21 @@ IMPORTANT: As per Semantic Versioning, the major version zero is for initial dev
|
|
8
8
|
|
9
9
|
== Unreleased
|
10
10
|
|
11
|
+
== 0.12.0 - 2023-11-22
|
12
|
+
|
13
|
+
=== Added
|
14
|
+
|
15
|
+
- Add command line option to use short species names in the AsciiDoc output. The species names are truncated by removing the authority (botany only).
|
16
|
+
|
17
|
+
=== Changed
|
18
|
+
|
19
|
+
- Do not use shorthand syntax for the breakable option in the AsciiDoc output.
|
20
|
+
|
21
|
+
=== Fixed
|
22
|
+
|
23
|
+
- Do not abort report creation if species lists are empty (assume default columns for the AsciiDoc output).
|
24
|
+
- Fix search of public transport stations if distance is missing (e.g. if the coordinates are outside of Switzerland).
|
25
|
+
|
11
26
|
== 0.11.0 - 2023-04-15
|
12
27
|
|
13
28
|
=== Changed
|
@@ -33,7 +48,7 @@ IMPORTANT: As per Semantic Versioning, the major version zero is for initial dev
|
|
33
48
|
|
34
49
|
=== Changed
|
35
50
|
|
36
|
-
- Omit empty columns of species lists in AsciiDoc output.
|
51
|
+
- Omit empty columns of species lists in the AsciiDoc output.
|
37
52
|
|
38
53
|
=== Fixed
|
39
54
|
|
data/README.adoc
CHANGED
@@ -94,7 +94,35 @@ The configuration is built by loading https://yaml.org/[YAML^] files in hierarch
|
|
94
94
|
|
95
95
|
[source,yml]
|
96
96
|
----
|
97
|
-
|
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
|
+
:short_species_names: false
|
110
|
+
:convert:
|
111
|
+
:out_dir: null
|
112
|
+
:out_file: null
|
113
|
+
:overwrite: false
|
114
|
+
:backend: :pdf
|
115
|
+
:draft: false
|
116
|
+
:draft_backend: null
|
117
|
+
:image_maxdim: 1800
|
118
|
+
:map:
|
119
|
+
:create:
|
120
|
+
:out_dir: null
|
121
|
+
:out_file: null
|
122
|
+
:overwrite: false
|
123
|
+
:gps_colors: []
|
124
|
+
:map_layers: []
|
125
|
+
:image_size: [1200, 900]
|
98
126
|
----
|
99
127
|
|
100
128
|
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
@@ -21,6 +21,7 @@ class NatourCmd < Clamp::Command
|
|
21
21
|
option(%W[--\[no-\]map], :flag, 'Create map images')
|
22
22
|
option(%w[--map-layers], 'LAYERS', 'Add additional layers to map images') { |s| s.split(',') }
|
23
23
|
option(%w[--adoc-author], 'AUTHOR', 'AsciiDoc author (name <email>[; name2 <email2>...])')
|
24
|
+
option(%W[--\[no-\]short-species-names], :flag, 'Use short species names (botany only)')
|
24
25
|
parameter('PATH', 'Path to directory')
|
25
26
|
|
26
27
|
def execute
|
@@ -33,7 +34,9 @@ class NatourCmd < Clamp::Command
|
|
33
34
|
track_formats: track_formats || config[:track_formats],
|
34
35
|
create_map: Natour::BooleanUtils.to_boolean(map?, default_value: config[:map]),
|
35
36
|
map_layers: map_layers || config[:map_layers],
|
36
|
-
adoc_author: adoc_author || config[:adoc_author]
|
37
|
+
adoc_author: adoc_author || config[:adoc_author],
|
38
|
+
short_species_names: Natour::BooleanUtils.to_boolean(short_species_names?,
|
39
|
+
default_value: config[:short_species_names])
|
37
40
|
)
|
38
41
|
rescue Errno::EEXIST, Errno::ENOENT, Errno::EACCES, Errno::EISDIR, Errno::EINVAL => e
|
39
42
|
message, _, path = Natour::ErrnoUtils.split_message(e)
|
data/lib/natour/asciinurse.rb
CHANGED
@@ -4,7 +4,7 @@ require 'pathname'
|
|
4
4
|
|
5
5
|
module Natour
|
6
6
|
module Asciinurse
|
7
|
-
def save_adoc(filename, overwrite: false, author: nil)
|
7
|
+
def save_adoc(filename, overwrite: false, author: nil, short_species_names: false)
|
8
8
|
dir = Pathname(filename).dirname
|
9
9
|
FileUtils.mkdir_p(dir)
|
10
10
|
mode = File::WRONLY | File::CREAT | File::TRUNC
|
@@ -14,12 +14,13 @@ module Natour
|
|
14
14
|
doc_root: Pathname(path).realpath
|
15
15
|
.relative_path_from(dir.realpath)
|
16
16
|
.to_s.force_encoding('utf-8'),
|
17
|
-
author: author
|
17
|
+
author: author,
|
18
|
+
short_species_names: short_species_names
|
18
19
|
))
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
22
|
-
def to_adoc(doc_root: '.', author: nil)
|
23
|
+
def to_adoc(doc_root: '.', author: nil, short_species_names: false)
|
23
24
|
distance = ->(gps_track) { "#{gps_track.distance / 1000} km" if gps_track&.distance }
|
24
25
|
ascent = ->(gps_track) { "#{gps_track.ascent} m" if gps_track&.ascent }
|
25
26
|
descent = ->(gps_track) { "#{gps_track.descent} m" if gps_track&.descent }
|
@@ -98,16 +99,19 @@ module Natour
|
|
98
99
|
group: :plants,
|
99
100
|
title: 'Pflanzenarten',
|
100
101
|
columns: [
|
101
|
-
OpenStruct.new(
|
102
|
-
|
102
|
+
OpenStruct.new(
|
103
|
+
header: 'Wissenschaftlicher Name',
|
104
|
+
accessor: ->(species) { short_species_names ? BotanicalNameUtils.parse(species.name) : species.name }
|
105
|
+
),
|
106
|
+
OpenStruct.new(header: 'Deutscher Name', accessor: ->(species) { species.name_de })
|
103
107
|
]
|
104
108
|
),
|
105
109
|
OpenStruct.new(
|
106
110
|
group: :birds,
|
107
111
|
title: 'Vogelarten',
|
108
112
|
columns: [
|
109
|
-
OpenStruct.new(header: 'Deutscher Name', accessor:
|
110
|
-
OpenStruct.new(header: 'Wissenschaftlicher Name', accessor:
|
113
|
+
OpenStruct.new(header: 'Deutscher Name', accessor: ->(species) { species.name_de }),
|
114
|
+
OpenStruct.new(header: 'Wissenschaftlicher Name', accessor: ->(species) { species.name })
|
111
115
|
]
|
112
116
|
)
|
113
117
|
].each do |info|
|
@@ -120,16 +124,16 @@ module Natour
|
|
120
124
|
caption = '.Tabelle {counter:species_lists}'
|
121
125
|
caption << ": #{species_list.description}" if species_list.description
|
122
126
|
columns = info.columns.select do |column|
|
123
|
-
species_list.any? { |species| !
|
127
|
+
species_list.count.zero? || species_list.any? { |species| !column.accessor.call(species).nil? }
|
124
128
|
end
|
125
129
|
cols = [1] + [5 * info.columns.size / columns.size] * columns.size
|
126
130
|
doc << caption
|
127
|
-
doc << "[
|
131
|
+
doc << "[cols=\"#{cols.join(',')}\",options=\"header,breakable\"]"
|
128
132
|
doc << '|==='
|
129
133
|
doc << "|Nr.|#{columns.map(&:header).join('|')}"
|
130
134
|
species_list.each do |species|
|
131
135
|
doc <<
|
132
|
-
"|{counter:species_list#{index}}|#{columns.map { |column|
|
136
|
+
"|{counter:species_list#{index}}|#{columns.map { |column| column.accessor.call(species) }
|
133
137
|
.join('|')}"
|
134
138
|
end
|
135
139
|
doc << '|==='
|
@@ -4,7 +4,8 @@ module Natour
|
|
4
4
|
module_function
|
5
5
|
|
6
6
|
def create_reports(dir, out_dir: nil, out_file: nil, overwrite: false,
|
7
|
-
track_formats: %i[gpx fit], create_map: true, map_layers: [],
|
7
|
+
track_formats: %i[gpx fit], create_map: true, map_layers: [],
|
8
|
+
adoc_author: nil, short_species_names: false)
|
8
9
|
out_dir = Pathname(out_dir || dir)
|
9
10
|
out_file = Pathname(out_file || "#{Pathname(dir).realpath.basename}.adoc")
|
10
11
|
reports = Report.load_directory(
|
@@ -16,7 +17,7 @@ module Natour
|
|
16
17
|
else
|
17
18
|
out_dir.join("#{out_file.basename('.*')} (#{index})#{out_file.extname}")
|
18
19
|
end
|
19
|
-
report.save_adoc(filename, overwrite: overwrite, author: adoc_author)
|
20
|
+
report.save_adoc(filename, overwrite: overwrite, author: adoc_author, short_species_names: short_species_names)
|
20
21
|
filename.to_s
|
21
22
|
end
|
22
23
|
end
|
@@ -16,7 +16,7 @@ module Natour
|
|
16
16
|
return unless response.is_a?(Net::HTTPSuccess)
|
17
17
|
|
18
18
|
stations = JSON.parse(response.body, symbolize_names: true)
|
19
|
-
stations.reject! { |station| station[:dist] > radius }
|
19
|
+
stations.reject! { |station| !station.key?(:dist) || station[:dist] > radius }
|
20
20
|
station_types = %w[
|
21
21
|
sl-icon-type-train
|
22
22
|
sl-icon-type-strain
|
data/lib/natour/species_list.rb
CHANGED
@@ -65,7 +65,7 @@ module Natour
|
|
65
65
|
chunks.map do |rows|
|
66
66
|
name, description = rows.shift
|
67
67
|
date = DateUtils.parse(name, Pathname(filename).basename).compact.first
|
68
|
-
items = rows.map { |row| Species.new(
|
68
|
+
items = rows.map { |row| Species.new(row[1], row[2]) }
|
69
69
|
.sort_by(&:name).uniq
|
70
70
|
SpeciesList.new(
|
71
71
|
filename,
|
@@ -82,7 +82,7 @@ module Natour
|
|
82
82
|
CSV.open(filename, 'r:bom|utf-16le:utf-8', col_sep: "\t", headers: true) do |csv|
|
83
83
|
date = DateUtils.parse(Pathname(filename).basename).compact.first
|
84
84
|
items = csv.select { |row| row[0] }
|
85
|
-
.map { |row| Species.new(
|
85
|
+
.map { |row| Species.new(row[11], nil) }
|
86
86
|
.sort_by(&:name).uniq
|
87
87
|
[SpeciesList.new(filename, date, :info_flora, :plants, nil, nil, items)]
|
88
88
|
end
|
data/lib/natour/version.rb
CHANGED
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.
|
4
|
+
version: 0.12.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: 2023-
|
11
|
+
date: 2023-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|