dwc-archive 0.4.6 → 0.4.7

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.6
1
+ 0.4.7
@@ -60,3 +60,4 @@ Feature: Reading of a Darwing Core Archive
60
60
  When I create a new DarwinCore instance
61
61
  Then I am able to use DarwinCore#normalize_classification method
62
62
  And get normalized classification in expected format
63
+ And there are paths, synonyms and vernacular names in normalized classification
@@ -170,3 +170,24 @@ Then /^get normalized classification in expected format$/ do
170
170
  key = @normalized_classification.keys[0]
171
171
  @normalized_classification[key].class.should == DarwinCore::TaxonNormalized
172
172
  end
173
+
174
+ Then /^there are paths, synonyms and vernacular names in normalized classification$/ do
175
+ @paths_are_generated = false
176
+ @synonyms_are_generated = false
177
+ @vernaculars_are_generated = false
178
+ @normalized_classification.each do |k, v|
179
+ if v.classification_path.size > 0
180
+ @paths_are_generated = true
181
+ end
182
+ if v.synonyms.size > 0
183
+ @synonyms_are_generated = true
184
+ end
185
+ if v.vernacular_names.size > 0
186
+ @vernaculars_are_generated = true
187
+ end
188
+ break if (@vernaculars_are_generated && @paths_are_generated && @synonyms_are_generated)
189
+ end
190
+ @paths_are_generated.should be_true
191
+ @vernaculars_are_generated.should be_true
192
+ @synonyms_are_generated.should be_true
193
+ end
@@ -37,9 +37,9 @@ class DarwinCore
37
37
 
38
38
  def normalize
39
39
  @res = {}
40
- injest_core
40
+ ingest_core
41
41
  calculate_classification_path
42
- injest_extensions
42
+ ingest_extensions
43
43
  @res
44
44
  end
45
45
 
@@ -76,14 +76,14 @@ class DarwinCore
76
76
  @core[:taxonomicstatus] ? row[@core[:taxonomicstatus]] : nil)
77
77
  end
78
78
 
79
- def injest_core
79
+ def ingest_core
80
80
  raise RuntimeError, "Darwin Core core fields must contain taxon id and scientific name" unless (@core[:id] && @core[:scientificname])
81
81
  puts "Reading core information" if @verbose
82
82
  rows = @dwc.core.read[0]
83
- puts "Injesting information from the core" if @verbose
83
+ puts "Ingesting information from the core" if @verbose
84
84
  rows.each_with_index do |r, i|
85
85
  count = i + 1
86
- puts "Injesting %s'th record" % count if @verbose and count % @verbose_count == 0
86
+ puts "Ingesting %s'th record" % count if @verbose and count % @verbose_count == 0
87
87
  #core has AcceptedNameUsageId
88
88
  if @core[:acceptednameusageid] && r[@core[:acceptednameusageid]] && r[@core[:acceptednameusageid]] != r[@core[:id]]
89
89
  add_synonym_from_core(@core[:acceptednameusageid], r)
@@ -107,7 +107,7 @@ class DarwinCore
107
107
 
108
108
  def calculate_classification_path
109
109
  @res.each do |taxon_id, taxon|
110
- next if taxon.classification_path
110
+ next if !taxon.classification_path.empty?
111
111
  begin
112
112
  get_classification_path(taxon)
113
113
  rescue DarwinCore::ParentNotCurrentError
@@ -117,7 +117,7 @@ class DarwinCore
117
117
  end
118
118
 
119
119
  def get_classification_path(taxon)
120
- return if taxon.classification_path
120
+ return if !taxon.classification_path.empty?
121
121
  if DarwinCore.nil_field?(taxon.parent_id)
122
122
  taxon.classification_path << taxon.current_name_canonical
123
123
  else
@@ -129,28 +129,28 @@ class DarwinCore
129
129
  raise DarwinCore::ParentNotCurrentError, error
130
130
  end
131
131
  if parent_cp
132
- taxon.classification_path = parent_cp + [taxon.current_name_canonical]
132
+ taxon.classification_path << parent_cp + [taxon.current_name_canonical]
133
133
  else
134
134
  get_classification_path(@res[taxon.parent_id])
135
- taxon.classification_path = @res[taxon.parent_id].classification_path + [taxon.current_name_canonical]
135
+ taxon.classification_path << @res[taxon.parent_id].classification_path + [taxon.current_name_canonical]
136
136
  end
137
137
  end
138
138
  end
139
139
 
140
- def injest_extensions
140
+ def ingest_extensions
141
141
  @extensions.each do |e|
142
142
  ext, fields = *e
143
- injest_synonyms(e) if fields.keys.include? :scientificname
144
- injest_vernaculars(e) if fields.keys.include? :vernacularname
143
+ ingest_synonyms(e) if fields.keys.include? :scientificname
144
+ ingest_vernaculars(e) if fields.keys.include? :vernacularname
145
145
  end
146
146
  end
147
147
 
148
- def injest_synonyms(extension)
149
- puts "Injesting synonyms extension" if @verbose
148
+ def ingest_synonyms(extension)
149
+ puts "Ingesting synonyms extension" if @verbose
150
150
  ext, fields = *extension
151
151
  ext.read[0].each_with_index do |r, i|
152
152
  count = i + 1
153
- puts "Injesting %s'th record" % count if @verbose && count % @verbose_count == 0
153
+ puts "Ingesting %s'th record" % count if @verbose && count % @verbose_count == 0
154
154
  @res[r[fields[:id]]].synonyms << SynonymNormalized.new(
155
155
  r[fields[:scientificname]],
156
156
  canonical_name(r[fields[:scientificname]]),
@@ -158,12 +158,12 @@ class DarwinCore
158
158
  end
159
159
  end
160
160
 
161
- def injest_vernaculars(extension)
162
- puts "Injesting vernacular names" if @verbose
161
+ def ingest_vernaculars(extension)
162
+ puts "Ingesting vernacular names" if @verbose
163
163
  ext, fields = *extension
164
164
  ext.read[0].each_with_index do |r, i|
165
165
  count = i + 1
166
- puts "Injesting %s'th record" % count if @verbose && count % @verbose_count == 0
166
+ puts "Ingesting %s'th record" % count if @verbose && count % @verbose_count == 0
167
167
  @res[r[fields[:id]]].vernacular_names << VernacularNormalized.new(
168
168
  r[fields[:vernacularname]],
169
169
  fields[:languagecode] ? r[fields[:languagecode]] : nil)
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: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 6
10
- version: 0.4.6
9
+ - 7
10
+ version: 0.4.7
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-17 00:00:00 -04:00
18
+ date: 2010-09-18 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency