natour 0.5.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +85 -23
- data/README.adoc +70 -18
- data/bin/natour +154 -105
- data/lib/natour/asciinurse.rb +7 -8
- data/lib/natour/config.rb +7 -4
- data/lib/natour/{convert.rb → convert_report.rb} +15 -9
- data/lib/natour/{create.rb → create_reports.rb} +7 -4
- data/lib/natour/fit_file.rb +2 -2
- data/lib/natour/gps_track.rb +5 -1
- data/lib/natour/gpx_file.rb +17 -14
- data/lib/natour/image.rb +4 -7
- data/lib/natour/map_geo_admin.rb +72 -28
- data/lib/natour/public_transport.rb +2 -2
- data/lib/natour/report.rb +9 -5
- data/lib/natour/species_list.rb +9 -2
- data/lib/natour/utils/boolean_utils.rb +11 -0
- data/lib/natour/utils/errno_utils.rb +9 -0
- data/lib/natour/version.rb +5 -0
- data/lib/natour.rb +21 -18
- metadata +61 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96d45e360af42e65ff67db55ff6e9814013e0a884ceb5b601ceec10731312181
|
4
|
+
data.tar.gz: f495db38dbdef792422945c891ddf830850a812513663e6cffd72fd4757f1b97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a520888a91305d5cd924d133d1356bc1021b0cf75c2ad7753e577e1a7455afbb610991c080a88ca5dc3e4c0bdc9895e36d518694a9e0b8faa6d27bfe0552ba8
|
7
|
+
data.tar.gz: eb6ca2cbc565dfd79e2ea06413a00a9362996cd45aca70b601e06fca58e6acae5d1bd47f2bbf0d8962f6b1a03922f3477446eca019d5648a1b4ad0334a509938
|
data/CHANGELOG.adoc
CHANGED
@@ -6,63 +6,125 @@ The format is based on https://keepachangelog.com/en/1.0.0/[Keep a Changelog^],
|
|
6
6
|
|
7
7
|
== Unreleased
|
8
8
|
|
9
|
+
== 0.8.0 - 2022-04-22
|
10
|
+
|
11
|
+
=== Added
|
12
|
+
|
13
|
+
- Add command to create map images from GPS tracks, waypoints and routes.
|
14
|
+
- Add command line option to display the version of this gem.
|
15
|
+
|
16
|
+
=== Changed
|
17
|
+
|
18
|
+
- Rename arguments of `Natour::MapGeoAdmin.save_image`, i.e. `tracks` to `gps_files`, `layers` to `map_layers` and `size` to `image_size`.
|
19
|
+
+
|
20
|
+
IMPORTANT: This is a breaking change.
|
21
|
+
- Improve the error reporting on the command line interface in case of file errors.
|
22
|
+
- 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.
|
23
|
+
+
|
24
|
+
IMPORTANT: This is a breaking change. Adapt the configuration file accordingly.
|
25
|
+
- Rework the command line interface. Use `natour --help` to get more information.
|
26
|
+
+
|
27
|
+
IMPORTANT: This is a breaking change. Adapt the commands accordingly.
|
28
|
+
- Change `backend` and `draft_backend` arguments of `Natour::convert_report` to symbols.
|
29
|
+
+
|
30
|
+
IMPORTANT: This is a breaking change. Adapt the configuration file accordingly.
|
31
|
+
- Rename `Natour::create` to `Natour::create_reports` and `Natour::convert` to `Natour::convert_report`.
|
32
|
+
+
|
33
|
+
IMPORTANT: This is a breaking change.
|
34
|
+
|
35
|
+
=== Fixed
|
36
|
+
|
37
|
+
- Do not overwrite map images unless otherwise specified.
|
38
|
+
- Do not abort if the configuration file is empty.
|
39
|
+
|
40
|
+
== 0.7.0 - 2022-02-14
|
41
|
+
|
42
|
+
=== Added
|
43
|
+
|
44
|
+
- Add support for Ruby 3.0 and 3.1.
|
45
|
+
- Support species lists from https://www.birdlife.ch/de/content/eine-neue-moderne-vogel-app-fuer-die-schweiz[Vogelführer Birdlife Schweiz^].
|
46
|
+
|
47
|
+
=== Changed
|
48
|
+
|
49
|
+
- Return the filenames from `Natour::create` and `Natour::convert`.
|
50
|
+
|
51
|
+
=== Removed
|
52
|
+
|
53
|
+
- Drop support for Ruby 2.5.
|
54
|
+
|
55
|
+
=== Fixed
|
56
|
+
|
57
|
+
- Add revision date to the AsciiDoc output regardless of the author.
|
58
|
+
- Prevent conversion from being aborted if a built-in date/time attribute is missing.
|
59
|
+
|
60
|
+
== 0.6.0 - 2021-11-20
|
61
|
+
|
62
|
+
=== Fixed
|
63
|
+
|
64
|
+
- Support GPX files containing only mandatory elements (i.e. no extensions).
|
65
|
+
- Consider also the image dimensions to determine the orientation, even if the tag is present.
|
66
|
+
|
9
67
|
== 0.5.0 - 2021-08-16
|
10
68
|
|
11
69
|
=== Added
|
12
70
|
|
13
|
-
- Reflect the date of the last update in the revision date
|
14
|
-
- Add captions to species lists in the AsciiDoc output
|
15
|
-
- Group species lists by taxonomic groups in the AsciiDoc output
|
71
|
+
- Reflect the date of the last update in the revision date.
|
72
|
+
- Add captions to species lists in the AsciiDoc output.
|
73
|
+
- Group species lists by taxonomic groups in the AsciiDoc output.
|
16
74
|
|
17
75
|
=== Fixed
|
18
76
|
|
19
|
-
- Support species lists of Flora Helvetica exported from
|
20
|
-
- Consider botanical names with the authority name preceding the subspecies
|
77
|
+
- Support species lists of https://www.flora-helvetica.ch/[Flora Helvetica^] exported from _Favoriten_.
|
78
|
+
- Consider botanical names with the authority name preceding the subspecies.
|
21
79
|
|
22
80
|
== 0.4.0 - 2021-05-02
|
23
81
|
|
24
82
|
=== Added
|
25
83
|
|
26
|
-
- Show date/time of images in draft output
|
27
|
-
- Support preferred conversion backend for draft output
|
84
|
+
- Show date/time of images in draft output.
|
85
|
+
- Support preferred conversion backend for draft output.
|
28
86
|
|
29
|
-
===
|
87
|
+
=== Removed
|
30
88
|
|
31
|
-
- Remove redundant method `Image.portrait
|
89
|
+
- Remove redundant method `Natour::Image.portrait?`.
|
90
|
+
+
|
91
|
+
IMPORTANT: This is a breaking change. Use `Natour::Image.landscape?` instead.
|
32
92
|
|
33
93
|
== 0.3.0 - 2021-03-07
|
34
94
|
|
35
95
|
=== Changed
|
36
96
|
|
37
|
-
- Sort the reports according to their GPS track
|
38
|
-
- Bump minimum required Ruby version to 2.5
|
39
|
-
- Change font in PDF output to support ♀ and ♂ symbols
|
97
|
+
- Sort the reports according to their GPS track.
|
98
|
+
- Bump minimum required Ruby version to 2.5.
|
99
|
+
- Change font in PDF output to support ♀ and ♂ symbols.
|
40
100
|
|
41
101
|
=== Fixed
|
42
102
|
|
43
|
-
- Make source code compatible with Ruby
|
103
|
+
- Make source code compatible with Ruby 2.5.
|
44
104
|
|
45
105
|
== 0.2.0 - 2021-01-24
|
46
106
|
|
47
107
|
=== Added
|
48
108
|
|
49
|
-
- Add this gem's name to the footer of the PDF output
|
50
|
-
- Support species lists from https://www.ornitho.ch/[ornitho.ch^] (KML format only)
|
51
|
-
- Classify species lists by taxonomic groups (i.e. `SpeciesList.group`)
|
109
|
+
- Add this gem's name to the footer of the PDF output.
|
110
|
+
- Support species lists from https://www.ornitho.ch/[ornitho.ch^] (KML format only).
|
111
|
+
- Classify species lists by taxonomic groups (i.e. `Natour::SpeciesList.group`).
|
52
112
|
|
53
113
|
=== Changed
|
54
114
|
|
55
|
-
-
|
56
|
-
|
57
|
-
|
58
|
-
-
|
115
|
+
- Rename `Natour::SpeciesList.name` to `Natour::SpeciesList.title`.
|
116
|
+
+
|
117
|
+
IMPORTANT: This is a breaking change.
|
118
|
+
- Return an empty array from `Natour::SpeciesList.load_file` if the format is unknown.
|
119
|
+
- Change the format of the start time in the AsciiDoc output from _12:30_ to _12:30 Uhr_.
|
120
|
+
- Change the format of the duration in the AsciiDoc output from _1h30_ to _1:30 h_.
|
59
121
|
|
60
122
|
=== Fixed
|
61
123
|
|
62
|
-
- Get the date from images even if the orientation tag is missing
|
63
|
-
- Fix typo in help message
|
124
|
+
- Get the date from images even if the orientation tag is missing.
|
125
|
+
- Fix typo in help message.
|
64
126
|
|
65
127
|
== 0.1.0 - 2020-12-04
|
66
128
|
|
67
129
|
=== Added
|
68
|
-
- First release
|
130
|
+
- First release.
|
data/README.adoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= natour
|
2
2
|
|
3
|
-
This https://rubygems.org/[RubyGem^] provides an application and a library
|
3
|
+
This https://rubygems.org/gems/natour[RubyGem^] provides an application and a library to document nature activities.
|
4
4
|
|
5
5
|
== Installation
|
6
6
|
|
@@ -58,49 +58,101 @@ sudo apt install ./google-chrome-stable_current_amd64.deb
|
|
58
58
|
|
59
59
|
== Application
|
60
60
|
|
61
|
-
[
|
62
|
-
|
63
|
-
|
64
|
-
|
61
|
+
Create reports in https://asciidoc.org/[AsciiDoc^] format from a directory with GPS tracks, images and species lists. After editing the AsciiDoc files (e.g. selecting the images and describing the adventure), they can be converted to various formats, including PDF and HTML. A typical directory structure and the necessary commands are shown in the following example.
|
62
|
+
|
63
|
+
....
|
64
|
+
└─ 2022-02-26 Monte Caslano < Root directory
|
65
|
+
├─ Bilder < Directory containing images
|
66
|
+
│ ├─ IMG_7687.JPG
|
67
|
+
│ ├─ IMG_7688.JPG
|
68
|
+
│ ├─ ...
|
69
|
+
│ └─ IMG_7870.JPG
|
70
|
+
├─ 2022-02-26 14.45.27.fit < GPS track exported by GPS device
|
71
|
+
├─ 2022-02-26 14.45.27.gpx < GPS track exported by GPS device
|
72
|
+
├─ 2022-02-26 14.45.27.jpg < Image of the map section created
|
73
|
+
├─ 2022-02-26 Monte Caslano.adoc < Report in AsciiDoc format created
|
74
|
+
├─ 2022-02-26 Monte Caslano.pdf < Report converted from AsciiDoc to PDF
|
75
|
+
├─ 2022-02-26MonteCaslano.csv < Species list exported from Kosmos Vogelführer
|
76
|
+
└─ flora_helvetica_sammlungen.csv < Species list exported from Flora Helvetica
|
77
|
+
....
|
65
78
|
|
66
|
-
|
67
|
-
|
68
|
-
|
79
|
+
[source,shell]
|
80
|
+
----
|
81
|
+
natour report create "2022-02-26 Monte Caslano"
|
82
|
+
----
|
83
|
+
|
84
|
+
[source,shell]
|
85
|
+
----
|
86
|
+
natour report convert "2022-02-26 Monte Caslano/2022-02-26 Monte Caslano.adoc"
|
87
|
+
----
|
88
|
+
|
89
|
+
NOTE: Use `natour --help` to get more information.
|
69
90
|
|
70
91
|
=== Configuration
|
71
92
|
|
72
|
-
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
|
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
|
+
|
95
|
+
[source,yml]
|
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
|
+
:map_layers: []
|
123
|
+
:image_size: [1200, 900]
|
124
|
+
----
|
73
125
|
|
74
126
|
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.
|
75
127
|
|
76
128
|
[source,yml]
|
77
129
|
----
|
78
130
|
---
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
131
|
+
:report:
|
132
|
+
:create:
|
133
|
+
:track_formats:
|
134
|
+
- :fit
|
135
|
+
:map_layers:
|
136
|
+
- ch.swisstopo.swisstlm3d-wanderwege
|
137
|
+
- ch.bav.haltestellen-oev
|
84
138
|
----
|
85
139
|
|
86
140
|
== Library
|
87
141
|
|
88
|
-
=== Basic Use
|
89
|
-
|
90
142
|
The basic use is shown in the following example. For details, see the source code and the unit tests.
|
91
143
|
|
92
144
|
[source,ruby]
|
93
145
|
----
|
94
146
|
require 'natour'
|
95
147
|
|
96
|
-
Natour::
|
148
|
+
Natour::create_reports('path/to/dir')
|
97
149
|
----
|
98
150
|
|
99
151
|
[source,ruby]
|
100
152
|
----
|
101
153
|
require 'natour'
|
102
154
|
|
103
|
-
Natour::
|
155
|
+
Natour::convert_report('path/to/dir/report.adoc')
|
104
156
|
----
|
105
157
|
|
106
158
|
=== Testing
|
data/bin/natour
CHANGED
@@ -1,116 +1,165 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'pathname'
|
5
|
-
require 'optparse'
|
3
|
+
require 'clamp'
|
6
4
|
require 'natour'
|
5
|
+
require 'pathname'
|
6
|
+
require 'word_wrap'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
)
|
8
|
+
class NatourCmd < Clamp::Command
|
9
|
+
class ReportCmd < Clamp::Command
|
10
|
+
class CreateCmd < Clamp::Command
|
11
|
+
banner(WordWrap.ww(
|
12
|
+
'Create reports in AsciiDoc format from a directory. GPS tracks, images and species ' \
|
13
|
+
'lists (Kosmos Vogelführer, Vogelführer Birdlife Schweiz, ornitho.ch, Flora Helvetica, ' \
|
14
|
+
'Info Flora Online-Feldbuch) are included. Images of the map section covered by the GPS ' \
|
15
|
+
'tracks are also created and included.'
|
16
|
+
))
|
17
|
+
option(%w[-d --out-dir], 'DIR', 'Output directory')
|
18
|
+
option(%w[-f --out-file], 'FILE', 'Output filename')
|
19
|
+
option(%W[--\[no-\]overwrite], :flag, 'Overwrite existing files')
|
20
|
+
option(%w[--track-formats], 'FORMATS', 'GPS track formats (gpx, fit)') { |s| s.split(',').map(&:to_sym) }
|
21
|
+
option(%W[--\[no-\]map], :flag, 'Create map images')
|
22
|
+
option(%w[--map-layers], 'LAYERS', 'Add additional layers to map images') { |s| s.split(',') }
|
23
|
+
option(%w[--adoc-author], 'AUTHOR', 'AsciiDoc author (name <email>[; name2 <email2>...])')
|
24
|
+
parameter('PATH', 'Path to directory')
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
opts.on('--image-maxdim DIM', 'Shrink oversized images (PDF only)') do |value|
|
77
|
-
config['image-maxdim'] = value.to_i
|
26
|
+
def execute
|
27
|
+
config = context[:config][:report][:create]
|
28
|
+
Natour.create_reports(
|
29
|
+
path.encode('utf-8').delete_suffix('"').gsub('\\', '/'),
|
30
|
+
out_dir: out_dir || config[:out_dir],
|
31
|
+
out_file: out_file || config[:out_file],
|
32
|
+
overwrite: Natour::BooleanUtils.to_boolean(overwrite?, default_value: config[:overwrite]),
|
33
|
+
track_formats: track_formats || config[:track_formats],
|
34
|
+
create_map: Natour::BooleanUtils.to_boolean(map?, default_value: config[:map]),
|
35
|
+
map_layers: map_layers || config[:map_layers],
|
36
|
+
adoc_author: adoc_author || config[:adoc_author]
|
37
|
+
)
|
38
|
+
rescue Errno::EEXIST, Errno::ENOENT, Errno::EACCES, Errno::EINVAL => e
|
39
|
+
message, _, path = Natour::ErrnoUtils.split_message(e)
|
40
|
+
abort("ERROR: #{message} '#{path}'")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class ConvertCmd < Clamp::Command
|
45
|
+
banner(WordWrap.ww(
|
46
|
+
'Convert a report from AsciiDoc to PDF or HTML (or any other supported format).'
|
47
|
+
))
|
48
|
+
option(%w[-d --out-dir], 'DIR', 'Output directory')
|
49
|
+
option(%w[-f --out-file], 'FILE', 'Output filename')
|
50
|
+
option(%W[--\[no-\]overwrite], :flag, 'Overwrite existing files')
|
51
|
+
option(%w[-b --backend], 'BACKEND', 'Conversion backend (pdf, html5 ...)', &:to_sym)
|
52
|
+
option(%W[--\[no-\]draft], :flag, 'Show additional information (e.g. image paths)')
|
53
|
+
option(%w[--draft-backend], 'BACKEND', 'Preferred conversion backend for draft (pdf, html5 ...)', &:to_sym)
|
54
|
+
option(%w[--image-maxdim], 'DIM', 'Shrink oversized images (PDF only)') { |s| Integer(s) }
|
55
|
+
parameter('PATH', 'Path to AsciiDoc file')
|
56
|
+
|
57
|
+
def execute
|
58
|
+
config = context[:config][:report][:convert]
|
59
|
+
Natour.convert_report(
|
60
|
+
path.encode('utf-8').delete_suffix('"').gsub('\\', '/'),
|
61
|
+
out_dir: out_dir || config[:out_dir],
|
62
|
+
out_file: out_file || config[:out_file],
|
63
|
+
overwrite: Natour::BooleanUtils.to_boolean(overwrite?, default_value: config[:overwrite]),
|
64
|
+
backend: backend || config[:backend],
|
65
|
+
draft: Natour::BooleanUtils.to_boolean(draft?, default_value: config[:draft]),
|
66
|
+
draft_backend: draft_backend || config[:draft_backend],
|
67
|
+
image_maxdim: image_maxdim || config[:image_maxdim]
|
68
|
+
)
|
69
|
+
rescue Errno::EEXIST, Errno::ENOENT, Errno::EACCES, Errno::EISDIR => e
|
70
|
+
message, _, path = Natour::ErrnoUtils.split_message(e)
|
71
|
+
abort("ERROR: #{message} '#{path}'")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
subcommand('create', 'Create AsciiDoc reports from directory', CreateCmd)
|
76
|
+
subcommand('convert', 'Convert AsciiDoc report to PDF or HTML', ConvertCmd)
|
78
77
|
end
|
79
|
-
end
|
80
78
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
79
|
+
class MapCmd < Clamp::Command
|
80
|
+
class CreateCmd < Clamp::Command
|
81
|
+
banner(WordWrap.ww(
|
82
|
+
'Create images of the map section covered by the GPS files. The GPS files must be in GPX' \
|
83
|
+
' or KML format and contain tracks, waypoints or routes. The images are saved in JPG or ' \
|
84
|
+
'PNG format.'
|
85
|
+
))
|
86
|
+
option(%w[-d --out-dir], 'DIR', 'Output directory')
|
87
|
+
option(%w[-f --out-file], 'FILE', 'Output filename')
|
88
|
+
option(%W[--\[no-\]overwrite], :flag, 'Overwrite existing files')
|
89
|
+
option(%w[--map-layers], 'LAYERS', 'Add additional layers to map images') { |s| s.split(',') }
|
90
|
+
option(%w[--image-size], 'WIDTH,HEIGHT', 'Image size') do |s|
|
91
|
+
s.split(',', 2).map { |v| Integer(v) }
|
92
|
+
end
|
93
|
+
parameter('PATH ...', 'Paths to GPS files', attribute_name: :paths)
|
87
94
|
|
88
|
-
|
95
|
+
def execute
|
96
|
+
config = context[:config][:map][:create]
|
97
|
+
Natour::MapGeoAdmin.open do |map|
|
98
|
+
filename = Pathname(out_dir || config[:out_dir] || Pathname(paths.first).dirname)
|
99
|
+
.join(out_file || config[:out_file] || Pathname(paths.first).basename.sub_ext('.jpg'))
|
100
|
+
map.save_image(
|
101
|
+
filename,
|
102
|
+
overwrite: Natour::BooleanUtils.to_boolean(overwrite?, default_value: config[:overwrite]),
|
103
|
+
gps_files: paths,
|
104
|
+
map_layers: map_layers || config[:map_layers],
|
105
|
+
image_size: image_size || config[:image_size]
|
106
|
+
)
|
107
|
+
end
|
108
|
+
rescue Errno::EEXIST, Errno::ENOENT, Errno::EACCES => e
|
109
|
+
message, _, path = Natour::ErrnoUtils.split_message(e)
|
110
|
+
abort("ERROR: #{message} '#{path}'")
|
111
|
+
end
|
112
|
+
end
|
89
113
|
|
90
|
-
|
91
|
-
|
92
|
-
.gsub('\\', '/'))
|
114
|
+
subcommand('create', 'Create map images from GPS files', CreateCmd)
|
115
|
+
end
|
93
116
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
create_map: config['map'],
|
102
|
-
map_layers: config['map-layers'],
|
103
|
-
adoc_author: config['adoc-author']
|
104
|
-
)
|
105
|
-
else
|
106
|
-
Natour.convert(
|
107
|
-
path,
|
108
|
-
out_dir: config['out-dir'],
|
109
|
-
out_file: config['out-file'],
|
110
|
-
overwrite: config['overwrite'],
|
111
|
-
backend: config['backend'],
|
112
|
-
draft: config['draft'],
|
113
|
-
draft_backend: config['draft-backend'],
|
114
|
-
image_maxdim: config['image-maxdim']
|
115
|
-
)
|
117
|
+
subcommand('report', 'Create or convert reports', ReportCmd)
|
118
|
+
subcommand('map', 'Create map images', MapCmd)
|
119
|
+
|
120
|
+
option(%w[-v --version], :flag, 'Display the version') do
|
121
|
+
$stdout.puts("#{invocation_path} #{Natour::VERSION}")
|
122
|
+
exit
|
123
|
+
end
|
116
124
|
end
|
125
|
+
|
126
|
+
config = Natour::Config.load_file(
|
127
|
+
Pathname($PROGRAM_NAME).basename.sub_ext('.yml'),
|
128
|
+
default: {
|
129
|
+
report: {
|
130
|
+
create: {
|
131
|
+
out_dir: nil,
|
132
|
+
out_file: nil,
|
133
|
+
overwrite: false,
|
134
|
+
track_formats: %i[gpx fit],
|
135
|
+
map: true,
|
136
|
+
map_layers: [],
|
137
|
+
adoc_author: nil
|
138
|
+
},
|
139
|
+
convert: {
|
140
|
+
out_dir: nil,
|
141
|
+
out_file: nil,
|
142
|
+
overwrite: false,
|
143
|
+
backend: :pdf,
|
144
|
+
draft: false,
|
145
|
+
draft_backend: nil,
|
146
|
+
image_maxdim: 1800
|
147
|
+
}
|
148
|
+
},
|
149
|
+
map: {
|
150
|
+
create: {
|
151
|
+
out_dir: nil,
|
152
|
+
out_file: nil,
|
153
|
+
overwrite: false,
|
154
|
+
map_layers: [],
|
155
|
+
image_size: [1200, 900]
|
156
|
+
}
|
157
|
+
}
|
158
|
+
}
|
159
|
+
)
|
160
|
+
|
161
|
+
NatourCmd.run(
|
162
|
+
Pathname($PROGRAM_NAME).basename,
|
163
|
+
ARGV,
|
164
|
+
{ config: config }
|
165
|
+
)
|
data/lib/natour/asciinurse.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'fileutils'
|
2
|
-
require 'pathname'
|
3
2
|
require 'ostruct'
|
3
|
+
require 'pathname'
|
4
4
|
|
5
5
|
module Natour
|
6
6
|
module Asciinurse
|
@@ -28,10 +28,8 @@ module Natour
|
|
28
28
|
|
29
29
|
doc = []
|
30
30
|
doc << "= #{title}"
|
31
|
-
if author
|
32
|
-
|
33
|
-
doc << ':revdate: {docdate}'
|
34
|
-
end
|
31
|
+
doc << author if author
|
32
|
+
doc << ':revdate: {docdate}'
|
35
33
|
doc << ':figure-caption!:'
|
36
34
|
doc << ':table-caption!:'
|
37
35
|
doc << ':pdf-page-mode: none'
|
@@ -99,13 +97,13 @@ module Natour
|
|
99
97
|
OpenStruct.new(
|
100
98
|
group: :plants,
|
101
99
|
title: 'Pflanzenarten',
|
102
|
-
headers:
|
100
|
+
headers: ['Wissenschaftlicher Name', 'Deutscher Name'],
|
103
101
|
columns: %i[name name_de]
|
104
102
|
),
|
105
103
|
OpenStruct.new(
|
106
104
|
group: :birds,
|
107
105
|
title: 'Vogelarten',
|
108
|
-
headers:
|
106
|
+
headers: ['Deutscher Name', 'Wissenschaftlicher Name'],
|
109
107
|
columns: %i[name_de name]
|
110
108
|
)
|
111
109
|
].each do |info|
|
@@ -122,7 +120,8 @@ module Natour
|
|
122
120
|
doc << '|==='
|
123
121
|
doc << "|Nr.|#{info.headers.join('|')}"
|
124
122
|
species_list.each do |species|
|
125
|
-
doc <<
|
123
|
+
doc <<
|
124
|
+
"|{counter:species_list#{index}}|#{info.columns.map { |method| species.public_send(method) }.join('|')}"
|
126
125
|
end
|
127
126
|
doc << '|==='
|
128
127
|
doc << ''
|
data/lib/natour/config.rb
CHANGED
@@ -1,17 +1,20 @@
|
|
1
|
+
require 'deep_merge/rails_compat'
|
1
2
|
require 'pathname'
|
2
3
|
require 'yaml'
|
3
4
|
|
4
5
|
module Natour
|
5
6
|
class Config
|
6
7
|
def self.load_file(filename, default: {}, dirs: [Dir.home, Dir.pwd])
|
7
|
-
dirs.map do |dir|
|
8
|
-
YAML.safe_load(
|
8
|
+
configs = dirs.map do |dir|
|
9
|
+
config = YAML.safe_load(
|
9
10
|
File.read(Pathname(dir).join(filename)),
|
10
|
-
[Symbol]
|
11
|
+
permitted_classes: [Symbol]
|
11
12
|
)
|
13
|
+
config || {}
|
12
14
|
rescue Errno::ENOENT
|
13
15
|
{}
|
14
|
-
end
|
16
|
+
end
|
17
|
+
configs.reduce(default) { |dst, src| dst.deeper_merge!(src, overwrite_arrays: true) }
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|