natour 0.6.0 → 0.7.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 +20 -0
- data/README.adoc +1 -1
- data/bin/natour +5 -4
- data/lib/natour/asciinurse.rb +4 -6
- data/lib/natour/config.rb +1 -1
- data/lib/natour/convert.rb +9 -3
- data/lib/natour/create.rb +2 -1
- data/lib/natour/report.rb +7 -3
- data/lib/natour/species_list.rb +9 -2
- metadata +26 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c649407352883c9e93ab6d6470413127d54803bb35dc72beb83292c9e521626
|
4
|
+
data.tar.gz: dbeb8f8ae4a412d7832c07ab66d717d40bb5e2ecd096fb076655ef65a6840b53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5a810b2ea0220c9eded025e0f00f8e4f782a42b54128f71a2929a84a535e75f45bb3ddff0cf72f7dad08e047c1aaef3b88800e778901405357efd11336b5db0
|
7
|
+
data.tar.gz: a928d426c1840cb57fb7ab58064850572fc2a7e14aeda6086b2c9560c8b2d7e3e8253c268a9070bef91e4c7fb2c0f26daf2e5664a043f29b595d192a0299137f
|
data/CHANGELOG.adoc
CHANGED
@@ -6,6 +6,26 @@ The format is based on https://keepachangelog.com/en/1.0.0/[Keep a Changelog^],
|
|
6
6
|
|
7
7
|
== Unreleased
|
8
8
|
|
9
|
+
== 0.7.0 - 2022-02-14
|
10
|
+
|
11
|
+
=== Added
|
12
|
+
|
13
|
+
- Add support for Ruby 3.0 and 3.1
|
14
|
+
- Support species lists from Vogelführer Birdlife Schweiz
|
15
|
+
|
16
|
+
=== Changed
|
17
|
+
|
18
|
+
- Return the filenames from `create` and `convert`
|
19
|
+
|
20
|
+
=== Removed
|
21
|
+
|
22
|
+
- Drop support for Ruby 2.5
|
23
|
+
|
24
|
+
=== Fixed
|
25
|
+
|
26
|
+
- Add revision date to the AsciiDoc output regardless of the author
|
27
|
+
- Prevent conversion from being aborted if a built-in date/time attribute is missing
|
28
|
+
|
9
29
|
== 0.6.0 - 2021-11-20
|
10
30
|
|
11
31
|
=== Fixed
|
data/README.adoc
CHANGED
data/bin/natour
CHANGED
@@ -28,10 +28,11 @@ option_parser = OptionParser.new do |opts|
|
|
28
28
|
opts.separator(WordWrap.ww(
|
29
29
|
'If PATH refers to a directory, one or more reports are created in ' \
|
30
30
|
'AsciiDoc format. GPS tracks, images and species lists (Kosmos ' \
|
31
|
-
'Vogelführer, ornitho.ch, Flora Helvetica,
|
32
|
-
'are included. Images of the map section
|
33
|
-
'also created and included. If PATH refers
|
34
|
-
'converted to PDF (or any other supported
|
31
|
+
'Vogelführer, Vogelführer Birdlife Schweiz, ornitho.ch, Flora Helvetica,' \
|
32
|
+
' Info Flora Online-Feldbuch) are included. Images of the map section ' \
|
33
|
+
'covered by the GPS tracks are also created and included. If PATH refers' \
|
34
|
+
' to an AsciiDoc file, it is converted to PDF (or any other supported ' \
|
35
|
+
'format).'
|
35
36
|
))
|
36
37
|
opts.separator('')
|
37
38
|
opts.separator('General:')
|
data/lib/natour/asciinurse.rb
CHANGED
@@ -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|
|
data/lib/natour/config.rb
CHANGED
data/lib/natour/convert.rb
CHANGED
@@ -33,6 +33,7 @@ module Natour
|
|
33
33
|
out_file = Pathname(
|
34
34
|
out_file || "#{doc.attr('docname')}#{doc.attr('outfilesuffix')}"
|
35
35
|
)
|
36
|
+
filename = out_dir.join(out_file)
|
36
37
|
|
37
38
|
if draft
|
38
39
|
doc.find_by(context: :image).each do |node|
|
@@ -51,7 +52,10 @@ module Natour
|
|
51
52
|
localtime
|
52
53
|
localdatetime
|
53
54
|
].each do |attr_name|
|
54
|
-
|
55
|
+
attr_value = doc.attr(attr_name)
|
56
|
+
next unless attr_value
|
57
|
+
|
58
|
+
date_time = Time.parse(attr_value)
|
55
59
|
if attr_name.end_with?('datetime')
|
56
60
|
doc.set_attr(attr_name, date_time.strftime('%d.%m.%Y %H:%M:%S'))
|
57
61
|
elsif attr_name.end_with?('date')
|
@@ -85,7 +89,7 @@ module Natour
|
|
85
89
|
FileUtils.mkdir_p(out_dir)
|
86
90
|
mode = File::WRONLY | File::CREAT | File::TRUNC | File::BINARY
|
87
91
|
mode |= File::EXCL unless overwrite
|
88
|
-
File.open(
|
92
|
+
File.open(filename, mode) do |file|
|
89
93
|
doc.write(doc.convert, file)
|
90
94
|
end
|
91
95
|
end
|
@@ -93,9 +97,11 @@ module Natour
|
|
93
97
|
FileUtils.mkdir_p(out_dir)
|
94
98
|
mode = File::WRONLY | File::CREAT | File::TRUNC
|
95
99
|
mode |= File::EXCL unless overwrite
|
96
|
-
File.open(
|
100
|
+
File.open(filename, mode) do |file|
|
97
101
|
doc.write(doc.convert, file)
|
98
102
|
end
|
99
103
|
end
|
104
|
+
|
105
|
+
filename.to_s
|
100
106
|
end
|
101
107
|
end
|
data/lib/natour/create.rb
CHANGED
@@ -8,13 +8,14 @@ module Natour
|
|
8
8
|
reports = Report.load_directory(
|
9
9
|
dir, track_formats: track_formats, create_map: create_map, map_layers: map_layers
|
10
10
|
)
|
11
|
-
reports.
|
11
|
+
reports.map.with_index(1) do |report, index|
|
12
12
|
filename = if index < 2
|
13
13
|
out_dir.join(out_file)
|
14
14
|
else
|
15
15
|
out_dir.join("#{out_file.basename('.*')} (#{index})#{out_file.extname}")
|
16
16
|
end
|
17
17
|
report.save_adoc(filename, overwrite: overwrite, author: adoc_author)
|
18
|
+
filename.to_s
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
data/lib/natour/report.rb
CHANGED
@@ -34,18 +34,22 @@ module Natour
|
|
34
34
|
path = Pathname(dir)
|
35
35
|
title = Pathname.pwd.basename.to_s.encode('utf-8')
|
36
36
|
.gsub(/^\d{4}-\d{2}-\d{2}( |_|-)?/, '')
|
37
|
-
images = Pathname.glob('**/*.{
|
37
|
+
images = Pathname.glob('**/*.{[j|J][p|P][g|G],[j|J][p|P][e|E][g|G]}')
|
38
38
|
.map { |filename| Image.load_file(filename.to_s) }
|
39
39
|
.sort_by { |image| [image.date_time ? 0 : 1, image.date_time, image.path] }
|
40
40
|
species_lists =
|
41
|
-
Pathname.glob('**/*.{
|
41
|
+
Pathname.glob('**/*.{[c|C][s|S][v|V],[k|K][m|M][l|L]}')
|
42
42
|
.map { |filename| SpeciesList.load_file(filename.to_s) }
|
43
43
|
.flatten
|
44
44
|
.sort_by { |species_list| [species_list.type, species_list.date ? 0 : 1, species_list.date] }
|
45
45
|
gps_tracks = if track_formats.empty?
|
46
46
|
[]
|
47
47
|
else
|
48
|
-
|
48
|
+
track_patterns = { gpx: '[g|G][p|P][x|X]', fit: '[f|F][i|I][t|T]' }
|
49
|
+
track_pattern = track_formats.map { |track_format| track_patterns[track_format] }
|
50
|
+
.compact
|
51
|
+
.join(',')
|
52
|
+
Pathname.glob("**/*.{#{track_pattern}}")
|
49
53
|
.map { |filename| GPSTrack.load_file(filename.to_s) }
|
50
54
|
.sort_by { |gps_track| [gps_track.date, gps_track.path] }
|
51
55
|
end
|
data/lib/natour/species_list.rb
CHANGED
@@ -24,9 +24,9 @@ module Natour
|
|
24
24
|
def self.load_file(filename)
|
25
25
|
block = IO.binread(filename, 128)
|
26
26
|
header = if block.unpack('CC') == [0xff, 0xfe]
|
27
|
-
block[2
|
27
|
+
block[2..].force_encoding('utf-16le').encode('utf-8')
|
28
28
|
elsif block.unpack('CCC') == [0xef, 0xbb, 0xbf]
|
29
|
-
block[3
|
29
|
+
block[3..].force_encoding('utf-8')
|
30
30
|
else
|
31
31
|
block
|
32
32
|
end
|
@@ -39,6 +39,13 @@ module Natour
|
|
39
39
|
.sort_by(&:name_de).uniq
|
40
40
|
[SpeciesList.new(filename, date, :kosmos_vogelfuehrer, :birds, nil, nil, items)]
|
41
41
|
end
|
42
|
+
when /^Name/
|
43
|
+
CSV.open(filename, 'r:bom|utf-8', headers: true) do |csv|
|
44
|
+
date = DateUtils.parse(Pathname(filename).basename).compact.first
|
45
|
+
items = csv.map { |row| Species.new(row[1], row[0]) }
|
46
|
+
.sort_by(&:name_de).uniq
|
47
|
+
[SpeciesList.new(filename, date, :birdlife_vogelfuehrer, :birds, nil, nil, items)]
|
48
|
+
end
|
42
49
|
when /^<\?xml.*?www\.ornitho\.ch/m
|
43
50
|
date = DateUtils.parse(Pathname(filename).basename).compact.first
|
44
51
|
doc = Nokogiri.XML(File.read(filename, mode: 'r:utf-8'))
|
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.7.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:
|
11
|
+
date: 2022-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: fit4ruby
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
75
|
+
version: '3.9'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '3.
|
82
|
+
version: '3.9'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: nokogiri
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0.4'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: webrick
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '1.7'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '1.7'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: word_wrap
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,16 +168,16 @@ dependencies:
|
|
154
168
|
name: rubocop
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
156
170
|
requirements:
|
157
|
-
- -
|
171
|
+
- - '='
|
158
172
|
- !ruby/object:Gem::Version
|
159
|
-
version: '1.
|
173
|
+
version: '1.25'
|
160
174
|
type: :development
|
161
175
|
prerelease: false
|
162
176
|
version_requirements: !ruby/object:Gem::Requirement
|
163
177
|
requirements:
|
164
|
-
- -
|
178
|
+
- - '='
|
165
179
|
- !ruby/object:Gem::Version
|
166
|
-
version: '1.
|
180
|
+
version: '1.25'
|
167
181
|
description:
|
168
182
|
email: simon.gysi@gmail.com
|
169
183
|
executables:
|
@@ -202,7 +216,7 @@ files:
|
|
202
216
|
- lib/natour/utils/botanical_name_utils.rb
|
203
217
|
- lib/natour/utils/date_utils.rb
|
204
218
|
- lib/natour/utils/stdout_utils.rb
|
205
|
-
homepage: https://
|
219
|
+
homepage: https://github.com/simongysi/natour
|
206
220
|
licenses:
|
207
221
|
- MIT
|
208
222
|
metadata:
|
@@ -217,7 +231,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
217
231
|
requirements:
|
218
232
|
- - ">="
|
219
233
|
- !ruby/object:Gem::Version
|
220
|
-
version: '2.
|
234
|
+
version: '2.6'
|
221
235
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
222
236
|
requirements:
|
223
237
|
- - ">="
|