dwc-archive 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/dwc-archive.rb +3 -2
- data/lib/dwc-archive/classification_normalizer.rb +17 -3
- data/lib/dwc-archive/errors.rb +1 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.4
|
data/lib/dwc-archive.rb
CHANGED
@@ -28,7 +28,7 @@ class DarwinCore
|
|
28
28
|
|
29
29
|
VERSION = open(File.join(File.dirname(__FILE__), '..', 'VERSION')).readline.strip
|
30
30
|
|
31
|
-
attr_reader :archive, :core, :metadata, :extensions
|
31
|
+
attr_reader :archive, :core, :metadata, :extensions, :classification_normalizer
|
32
32
|
alias :eml :metadata
|
33
33
|
|
34
34
|
DEFAULT_TMP_DIR = "/tmp"
|
@@ -57,7 +57,8 @@ class DarwinCore
|
|
57
57
|
# generates a hash from a classification data with path to each node, list of synonyms and vernacular names.
|
58
58
|
def normalize_classification(verbose = false)
|
59
59
|
return nil unless has_parent_id?
|
60
|
-
DarwinCore::ClassificationNormalizer.new(self, verbose)
|
60
|
+
@classification_normalizer ||= DarwinCore::ClassificationNormalizer.new(self, verbose)
|
61
|
+
@classification_normalizer.normalize
|
61
62
|
end
|
62
63
|
|
63
64
|
def has_parent_id?
|
@@ -18,6 +18,8 @@ class DarwinCore
|
|
18
18
|
class VernacularNormalized < Struct.new(:name, :language);end
|
19
19
|
|
20
20
|
class ClassificationNormalizer
|
21
|
+
attr_accessor :verbose
|
22
|
+
attr_reader :error_names
|
21
23
|
|
22
24
|
def initialize(dwc_instance, verbose = false)
|
23
25
|
@dwc = dwc_instance
|
@@ -26,7 +28,8 @@ class DarwinCore
|
|
26
28
|
@res = {}
|
27
29
|
@parser = ParsleyStore.new(1,2)
|
28
30
|
@verbose = verbose
|
29
|
-
@verbose_count =
|
31
|
+
@verbose_count = 10000
|
32
|
+
@error_names = []
|
30
33
|
end
|
31
34
|
|
32
35
|
def normalize
|
@@ -101,7 +104,11 @@ class DarwinCore
|
|
101
104
|
def calculate_classification_path
|
102
105
|
@res.each do |taxon_id, taxon|
|
103
106
|
next if taxon.classification_path
|
104
|
-
|
107
|
+
begin
|
108
|
+
get_classification_path(taxon)
|
109
|
+
rescue DarwinCore::ParentNotCurrentError
|
110
|
+
next
|
111
|
+
end
|
105
112
|
end
|
106
113
|
end
|
107
114
|
|
@@ -110,7 +117,13 @@ class DarwinCore
|
|
110
117
|
if DarwinCore.nil_field?(taxon.parent_id)
|
111
118
|
taxon.classification_path = [taxon.current_name_canonical]
|
112
119
|
else
|
113
|
-
|
120
|
+
begin
|
121
|
+
parent_cp = @res[taxon.parent_id].classification_path
|
122
|
+
rescue NoMethodError #name has a parent which is not a current name
|
123
|
+
error = "The parent of the taxon \'#{taxon.current_name}\' is deprecated"
|
124
|
+
@error_names << {:name => taxon, :error => error}
|
125
|
+
raise DarwinCore::ParentNotCurrentError, error
|
126
|
+
end
|
114
127
|
if parent_cp
|
115
128
|
taxon.classification_path = parent_cp + [taxon.current_name_canonical]
|
116
129
|
else
|
@@ -156,3 +169,4 @@ class DarwinCore
|
|
156
169
|
end
|
157
170
|
end
|
158
171
|
|
172
|
+
|
data/lib/dwc-archive/errors.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dwc-archive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 4
|
10
|
+
version: 0.4.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dmitry Mozzherin
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-14 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|