natour 0.4.0 → 0.5.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/CHANGELOG.adoc +13 -0
- data/lib/natour.rb +1 -0
- data/lib/natour/asciinurse.rb +34 -23
- data/lib/natour/convert.rb +20 -0
- data/lib/natour/species_list.rb +5 -5
- data/lib/natour/utils/botanical_name_utils.rb +12 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b125a5ba293c91fa5efcb56ee32bc6e5ed52c1b8daf82439bcbec6c7b279a29d
|
|
4
|
+
data.tar.gz: bda03749fc2db89b56adadbb8bfb1522b8e116d294be244f918f9a6142005d07
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c3ddac7902534aec8e14fb546287a45d6fd589c3b4c445b1291bef15d209b7eb9c43484f169ee7e3b9dcac44939b57f4d19d6fae07a261edf6d12499af11d16a
|
|
7
|
+
data.tar.gz: e1eebd6fa2c8704e25afe48c2120a146d0513f17a55df883d68aad05bbedd08e04173455119abe06ab8ef15894358b650a5590be74435ffd166f27e698c6aef6
|
data/CHANGELOG.adoc
CHANGED
|
@@ -6,6 +6,19 @@ The format is based on https://keepachangelog.com/en/1.0.0/[Keep a Changelog^],
|
|
|
6
6
|
|
|
7
7
|
== Unreleased
|
|
8
8
|
|
|
9
|
+
== 0.5.0 - 2021-08-16
|
|
10
|
+
|
|
11
|
+
=== Added
|
|
12
|
+
|
|
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
|
|
16
|
+
|
|
17
|
+
=== Fixed
|
|
18
|
+
|
|
19
|
+
- Support species lists of Flora Helvetica exported from Favoriten
|
|
20
|
+
- Consider botanical names with the authority name preceding the subspecies
|
|
21
|
+
|
|
9
22
|
== 0.4.0 - 2021-05-02
|
|
10
23
|
|
|
11
24
|
=== Added
|
data/lib/natour.rb
CHANGED
data/lib/natour/asciinurse.rb
CHANGED
|
@@ -30,9 +30,10 @@ module Natour
|
|
|
30
30
|
doc << "= #{title}"
|
|
31
31
|
if author
|
|
32
32
|
doc << author
|
|
33
|
-
doc <<
|
|
33
|
+
doc << ':revdate: {docdate}'
|
|
34
34
|
end
|
|
35
35
|
doc << ':figure-caption!:'
|
|
36
|
+
doc << ':table-caption!:'
|
|
36
37
|
doc << ':pdf-page-mode: none'
|
|
37
38
|
doc << ':title-page:'
|
|
38
39
|
if title_image
|
|
@@ -88,35 +89,45 @@ module Natour
|
|
|
88
89
|
end
|
|
89
90
|
end
|
|
90
91
|
unless species_lists.empty?
|
|
91
|
-
birds_info = OpenStruct.new(
|
|
92
|
-
title: 'Vogelarten',
|
|
93
|
-
headers: %w[Deutscher\ Name Wissenschaftlicher\ Name],
|
|
94
|
-
columns: %i[name_de name]
|
|
95
|
-
)
|
|
96
|
-
plants_info = OpenStruct.new(
|
|
97
|
-
title: 'Pflanzenarten',
|
|
98
|
-
headers: %w[Wissenschaftlicher\ Name Deutscher\ Name],
|
|
99
|
-
columns: %i[name name_de]
|
|
100
|
-
)
|
|
101
92
|
doc << '<<<'
|
|
102
93
|
doc << ''
|
|
103
94
|
doc << '== Artenlisten'
|
|
104
95
|
doc << ''
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
96
|
+
index = 1
|
|
97
|
+
groups = species_lists.group_by(&:group)
|
|
98
|
+
[
|
|
99
|
+
OpenStruct.new(
|
|
100
|
+
group: :plants,
|
|
101
|
+
title: 'Pflanzenarten',
|
|
102
|
+
headers: %w[Wissenschaftlicher\ Name Deutscher\ Name],
|
|
103
|
+
columns: %i[name name_de]
|
|
104
|
+
),
|
|
105
|
+
OpenStruct.new(
|
|
106
|
+
group: :birds,
|
|
107
|
+
title: 'Vogelarten',
|
|
108
|
+
headers: %w[Deutscher\ Name Wissenschaftlicher\ Name],
|
|
109
|
+
columns: %i[name_de name]
|
|
110
|
+
)
|
|
111
|
+
].each do |info|
|
|
112
|
+
group = groups.fetch(info.group, [])
|
|
113
|
+
next if group.empty?
|
|
114
|
+
|
|
110
115
|
doc << "=== #{info.title}"
|
|
111
116
|
doc << ''
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
doc << "
|
|
117
|
+
group.each do |species_list|
|
|
118
|
+
caption = '.Tabelle {counter:species_lists}'
|
|
119
|
+
caption << ": #{species_list.description}" if species_list.description
|
|
120
|
+
doc << caption
|
|
121
|
+
doc << '[cols="1,5,5",options=header]'
|
|
122
|
+
doc << '|==='
|
|
123
|
+
doc << "|Nr.|#{info.headers.join('|')}"
|
|
124
|
+
species_list.each do |species|
|
|
125
|
+
doc << "|{counter:species_list#{index}}|#{info.columns.map { |method| species.send(method) }.join('|')}"
|
|
126
|
+
end
|
|
127
|
+
doc << '|==='
|
|
128
|
+
doc << ''
|
|
129
|
+
index += 1
|
|
117
130
|
end
|
|
118
|
-
doc << '|==='
|
|
119
|
-
doc << ''
|
|
120
131
|
end
|
|
121
132
|
end
|
|
122
133
|
doc.join("\n")
|
data/lib/natour/convert.rb
CHANGED
|
@@ -3,6 +3,7 @@ require 'pathname'
|
|
|
3
3
|
require 'asciidoctor'
|
|
4
4
|
require 'asciidoctor-pdf'
|
|
5
5
|
require 'vips'
|
|
6
|
+
require 'time'
|
|
6
7
|
|
|
7
8
|
module Natour
|
|
8
9
|
module_function
|
|
@@ -41,6 +42,25 @@ module Natour
|
|
|
41
42
|
end
|
|
42
43
|
end
|
|
43
44
|
|
|
45
|
+
%w[
|
|
46
|
+
revdate
|
|
47
|
+
docdate
|
|
48
|
+
doctime
|
|
49
|
+
docdatetime
|
|
50
|
+
localdate
|
|
51
|
+
localtime
|
|
52
|
+
localdatetime
|
|
53
|
+
].each do |attr_name|
|
|
54
|
+
date_time = Time.parse(doc.attr(attr_name))
|
|
55
|
+
if attr_name.end_with?('datetime')
|
|
56
|
+
doc.set_attr(attr_name, date_time.strftime('%d.%m.%Y %H:%M:%S'))
|
|
57
|
+
elsif attr_name.end_with?('date')
|
|
58
|
+
doc.set_attr(attr_name, date_time.strftime('%d.%m.%Y'))
|
|
59
|
+
elsif attr_name.end_with?('time')
|
|
60
|
+
doc.set_attr(attr_name, date_time.strftime('%H:%M:%S'))
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
44
64
|
if backend == 'pdf'
|
|
45
65
|
Dir.mktmpdir do |tmp_dir|
|
|
46
66
|
tmp_dir = Pathname(tmp_dir)
|
data/lib/natour/species_list.rb
CHANGED
|
@@ -49,16 +49,16 @@ module Natour
|
|
|
49
49
|
.map { |description| Species.new(*description.scan(/>([^&(]+)</).flatten.reverse) }
|
|
50
50
|
.sort_by(&:name_de).uniq
|
|
51
51
|
[SpeciesList.new(filename, date, :ornitho_ch, :birds, name, nil, items)]
|
|
52
|
-
when /^Favoriten/
|
|
52
|
+
when /^(Favoriten|NUMMER_FLORA)/
|
|
53
53
|
CSV.open(filename, 'r:bom|utf-8', col_sep: ';', skip_blanks: true) do |csv|
|
|
54
|
-
chunks = csv.reject { |row| row.count == 1
|
|
55
|
-
.
|
|
54
|
+
chunks = csv.reject { |row| row.count == 1 }
|
|
55
|
+
.map { |row| row[0] == 'NUMMER_FLORA' ? ['Favoriten'] : row }
|
|
56
56
|
.slice_before { |row| row.count == 1 || row.count == 3 }
|
|
57
57
|
.reject { |rows| rows.count == 1 }
|
|
58
58
|
chunks.map do |rows|
|
|
59
59
|
name, description = rows.shift
|
|
60
60
|
date = DateUtils.parse(name, Pathname(filename).basename).compact.first
|
|
61
|
-
items = rows.map { |row| Species.new(row[1]
|
|
61
|
+
items = rows.map { |row| Species.new(BotanicalNameUtils.parse(row[1]), row[2]) }
|
|
62
62
|
.sort_by(&:name).uniq
|
|
63
63
|
SpeciesList.new(
|
|
64
64
|
filename,
|
|
@@ -75,7 +75,7 @@ module Natour
|
|
|
75
75
|
CSV.open(filename, 'r:bom|utf-16le:utf-8', col_sep: "\t", headers: true) do |csv|
|
|
76
76
|
date = DateUtils.parse(Pathname(filename).basename).compact.first
|
|
77
77
|
items = csv.select { |row| row[0] }
|
|
78
|
-
.map { |row| Species.new(row[11]
|
|
78
|
+
.map { |row| Species.new(BotanicalNameUtils.parse(row[11]), nil) }
|
|
79
79
|
.sort_by(&:name).uniq
|
|
80
80
|
[SpeciesList.new(filename, date, :info_flora, :plants, nil, nil, items)]
|
|
81
81
|
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.
|
|
4
|
+
version: 0.5.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: 2021-
|
|
11
|
+
date: 2021-08-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: asciidoctor
|
|
@@ -199,6 +199,7 @@ files:
|
|
|
199
199
|
- lib/natour/species.rb
|
|
200
200
|
- lib/natour/species_list.rb
|
|
201
201
|
- lib/natour/station.rb
|
|
202
|
+
- lib/natour/utils/botanical_name_utils.rb
|
|
202
203
|
- lib/natour/utils/date_utils.rb
|
|
203
204
|
- lib/natour/utils/stdout_utils.rb
|
|
204
205
|
homepage: https://rubygems.org/gems/natour
|