natour 0.7.0 → 0.9.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 +81 -31
- data/README.adoc +71 -18
- data/bin/natour +157 -106
- data/lib/natour/asciinurse.rb +18 -8
- data/lib/natour/config.rb +6 -3
- data/lib/natour/{convert.rb → convert_report.rb} +6 -6
- data/lib/natour/{create.rb → create_reports.rb} +5 -3
- data/lib/natour/data/js/loader.js +6 -6
- data/lib/natour/fit_file.rb +2 -2
- data/lib/natour/gps_track.rb +1 -1
- data/lib/natour/gpx_file.rb +1 -1
- data/lib/natour/image.rb +2 -2
- data/lib/natour/map_geo_admin.rb +100 -41
- data/lib/natour/public_transport.rb +2 -2
- data/lib/natour/report.rb +2 -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 +37 -6
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
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
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'pathname'
|
3
1
|
require 'asciidoctor'
|
4
2
|
require 'asciidoctor-pdf'
|
5
|
-
require '
|
3
|
+
require 'fileutils'
|
4
|
+
require 'pathname'
|
6
5
|
require 'time'
|
6
|
+
require 'vips'
|
7
7
|
|
8
8
|
module Natour
|
9
9
|
module_function
|
10
10
|
|
11
|
-
def
|
12
|
-
|
11
|
+
def convert_report(filename, out_dir: nil, out_file: nil, overwrite: false,
|
12
|
+
backend: :pdf, draft: false, draft_backend: nil, image_maxdim: 16000)
|
13
13
|
backend = if draft
|
14
14
|
draft_backend || backend
|
15
15
|
else
|
@@ -65,7 +65,7 @@ module Natour
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
if backend ==
|
68
|
+
if backend == :pdf
|
69
69
|
Dir.mktmpdir do |tmp_dir|
|
70
70
|
tmp_dir = Pathname(tmp_dir)
|
71
71
|
|
@@ -1,12 +1,14 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
1
3
|
module Natour
|
2
4
|
module_function
|
3
5
|
|
4
|
-
def
|
5
|
-
|
6
|
+
def create_reports(dir, out_dir: nil, out_file: nil, overwrite: false,
|
7
|
+
track_formats: %i[gpx fit], create_map: true, map_layers: [], adoc_author: nil)
|
6
8
|
out_dir = Pathname(out_dir || dir)
|
7
9
|
out_file = Pathname(out_file || "#{Pathname(dir).realpath.basename}.adoc")
|
8
10
|
reports = Report.load_directory(
|
9
|
-
dir, track_formats: track_formats, create_map: create_map, map_layers: map_layers
|
11
|
+
dir, track_formats: track_formats, create_map: create_map, overwrite_map: overwrite, map_layers: map_layers
|
10
12
|
)
|
11
13
|
reports.map.with_index(1) do |report, index|
|
12
14
|
filename = if index < 2
|