dwc-archive 0.7.8 → 0.7.9

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -61,10 +61,10 @@ PLATFORMS
61
61
  ruby
62
62
 
63
63
  DEPENDENCIES
64
- bundler
65
- cucumber
66
- jeweler
67
- nokogiri
64
+ bundler (~> 1.0)
65
+ cucumber (~> 1.1.3)
66
+ jeweler (~> 1.6.4)
67
+ nokogiri (~> 1.5.0)
68
68
  parsley-store (~> 0.3.0)
69
- rspec
70
- ruby-debug19
69
+ rspec (~> 2.7.0)
70
+ ruby-debug19 (~> 0.11.6)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.8
1
+ 0.7.9
@@ -197,6 +197,8 @@ Then /^there are paths, synonyms and vernacular names in normalized classificati
197
197
  end
198
198
  if v.vernacular_names.size > 0
199
199
  @vernaculars_are_generated = true
200
+ vn = v.vernacular_names[0]
201
+ (vn.respond_to?('locality') && vn.respond_to?('country_code') && vn.respond_to?('language')).should be_true
200
202
  end
201
203
  break if (@vernaculars_are_generated && @paths_are_generated && @synonyms_are_generated)
202
204
  end
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
  require 'parsley-store'
3
3
 
4
- class DarwinCore
5
-
4
+ class DarwinCore
5
+
6
6
  class TaxonNormalized
7
7
  attr_accessor :id, :parent_id, :classification_path_id, :classification_path, :current_name, :current_name_canonical, :synonyms, :vernacular_names, :rank, :status
8
8
 
@@ -19,7 +19,7 @@ class DarwinCore
19
19
  end
20
20
 
21
21
  class SynonymNormalized < Struct.new(:id, :name, :canonical_name, :status);end
22
- class VernacularNormalized < Struct.new(:name, :language, :locality);end
22
+ class VernacularNormalized < Struct.new(:name, :language, :locality, :country_code);end
23
23
 
24
24
  class ClassificationNormalizer
25
25
  attr_reader :error_names, :tree, :normalized_data
@@ -82,24 +82,24 @@ class DarwinCore
82
82
  nil
83
83
  end
84
84
  end
85
-
85
+
86
86
  def get_fields(element)
87
87
  data = element.fields.inject({}) { |res, f| res[f[:term].split('/')[-1].downcase.to_sym] = f[:index].to_i; res }
88
- data[:id] = element.id[:index]
88
+ data[:id] = element.id[:index]
89
89
  data
90
90
  end
91
91
 
92
92
  def status_synonym?(status)
93
93
  status && !!status.match(/^syn/)
94
94
  end
95
-
95
+
96
96
  def add_synonym_from_core(taxon_id, row)
97
97
  @synonyms[row[@core_fields[:id]]] = taxon_id
98
98
  taxon = @normalized_data[row[taxon_id]] ? @normalized_data[row[taxon_id]] : @normalized_data[row[taxon_id]] = DarwinCore::TaxonNormalized.new
99
99
  synonym = SynonymNormalized.new(
100
100
  row[@core_fields[:id]],
101
- row[@core_fields[:scientificname]],
102
- row[@core_fields[:canonicalname]],
101
+ row[@core_fields[:scientificname]],
102
+ row[@core_fields[:canonicalname]],
103
103
  @core_fields[:taxonomicstatus] ? row[@core_fields[:taxonomicstatus]] : nil)
104
104
  taxon.synonyms << synonym
105
105
  add_name_string(synonym.name)
@@ -148,7 +148,7 @@ class DarwinCore
148
148
  taxon.id = r[@core_fields[:id]]
149
149
  taxon.current_name = r[@core_fields[:scientificname]]
150
150
  taxon.current_name_canonical = r[@core_fields[:canonicalname]]
151
- taxon.parent_id = has_parent_id? ? r[parent_id] : nil
151
+ taxon.parent_id = has_parent_id? ? r[parent_id] : nil
152
152
  taxon.rank = r[@core_fields[:taxonrank]] if @core_fields[:taxonrank]
153
153
  taxon.status = r[@core_fields[:taxonomicstatus]] if @core_fields[:taxonomicstatus]
154
154
  add_name_string(taxon.current_name)
@@ -157,7 +157,7 @@ class DarwinCore
157
157
  end
158
158
  end
159
159
  end
160
-
160
+
161
161
  def has_parent_id?
162
162
  @has_parent_id ||= @core_fields.has_key?(:highertaxonid) || @core_fields.has_key?(:parentnameusageid)
163
163
  end
@@ -188,7 +188,7 @@ class DarwinCore
188
188
  parent_cp = parent_cpid = nil
189
189
  if @normalized_data[taxon.parent_id]
190
190
  parent_cp = @normalized_data[taxon.parent_id].classification_path if @with_canonical_names
191
- parent_cpid = @normalized_data[taxon.parent_id].classification_path_id
191
+ parent_cpid = @normalized_data[taxon.parent_id].classification_path_id
192
192
  else
193
193
  current_parent = @normalized_data[@synonyms[taxon.parent_id]]
194
194
  if current_parent
@@ -200,11 +200,11 @@ class DarwinCore
200
200
  else
201
201
  error = "WARNING: The parent of the taxon \'#{taxon.current_name}\' not found"
202
202
  @error_names << {:data => taxon, :error => :deprecated_parent, :current_parent => nil}
203
- end
203
+ end
204
204
  end
205
205
  return 'error' unless parent_cpid
206
206
  if parent_cpid.empty?
207
- res = get_classification_path(@normalized_data[taxon.parent_id])
207
+ res = get_classification_path(@normalized_data[taxon.parent_id])
208
208
  return res if res == 'error'
209
209
  if @with_canonical_names
210
210
  taxon.classification_path += @normalized_data[taxon.parent_id].classification_path + [taxon.current_name_canonical]
@@ -233,7 +233,7 @@ class DarwinCore
233
233
  ingest_vernaculars(e) if fields.keys.include? :vernacularname
234
234
  end
235
235
  end
236
-
236
+
237
237
  def ingest_synonyms(extension)
238
238
  DarwinCore.logger_write(@dwc.object_id, "Ingesting synonyms extension")
239
239
  ext, fields = *extension
@@ -242,8 +242,8 @@ class DarwinCore
242
242
  set_scientific_name(r, fields)
243
243
  synonym = SynonymNormalized.new(
244
244
  nil,
245
- r[fields[:scientificname]],
246
- r[fields[:canonicalname]],
245
+ r[fields[:scientificname]],
246
+ r[fields[:canonicalname]],
247
247
  fields[:taxonomicstatus] ? r[fields[:taxonomicstatus]] : nil)
248
248
  @normalized_data[r[fields[:id]]].synonyms << synonym
249
249
  add_name_string(synonym.name)
@@ -262,15 +262,18 @@ class DarwinCore
262
262
  if fields[:language]
263
263
  language = r[fields[:language]]
264
264
  elsif fields[:languagecode]
265
- language = r[fields[:languagecode]]
265
+ language = r[fields[:languagecode]]
266
266
  end
267
-
267
+
268
268
  locality = fields[:locality] ? r[fields[:locality]] : nil
269
-
269
+
270
+ country_code = fields[:countrycode] ? r[fields[:countrycode]] : nil
271
+
270
272
  vernacular = VernacularNormalized.new(
271
273
  r[fields[:vernacularname]],
272
274
  language,
273
- locality)
275
+ locality,
276
+ country_code)
274
277
  @normalized_data[r[fields[:id]]].vernacular_names << vernacular
275
278
  add_vernacular_name_string(vernacular.name)
276
279
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dwc-archive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.8
4
+ version: 0.7.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-05 00:00:00.000000000Z
12
+ date: 2011-12-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: parsley-store
16
- requirement: &70358171329960 !ruby/object:Gem::Requirement
16
+ requirement: &70152131291540 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.3.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70358171329960
24
+ version_requirements: *70152131291540
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70358171328420 !ruby/object:Gem::Requirement
27
+ requirement: &70152131290940 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.7.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70358171328420
35
+ version_requirements: *70152131290940
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: nokogiri
38
- requirement: &70358171317420 !ruby/object:Gem::Requirement
38
+ requirement: &70152131290300 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.5.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70358171317420
46
+ version_requirements: *70152131290300
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: cucumber
49
- requirement: &70358171315520 !ruby/object:Gem::Requirement
49
+ requirement: &70152131289460 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.1.3
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70358171315520
57
+ version_requirements: *70152131289460
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &70358171313280 !ruby/object:Gem::Requirement
60
+ requirement: &70152131288800 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '1.0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70358171313280
68
+ version_requirements: *70152131288800
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
- requirement: &70358171310420 !ruby/object:Gem::Requirement
71
+ requirement: &70152131288320 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.6.4
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70358171310420
79
+ version_requirements: *70152131288320
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: ruby-debug19
82
- requirement: &70358171307220 !ruby/object:Gem::Requirement
82
+ requirement: &70152131287820 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 0.11.6
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70358171307220
90
+ version_requirements: *70152131287820
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: parsley-store
93
- requirement: &70358171305420 !ruby/object:Gem::Requirement
93
+ requirement: &70152131287300 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 0.3.0
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *70358171305420
101
+ version_requirements: *70152131287300
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rspec
104
- requirement: &70358171280220 !ruby/object:Gem::Requirement
104
+ requirement: &70152131286800 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 1.2.9
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70358171280220
112
+ version_requirements: *70152131286800
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: cucumber
115
- requirement: &70358171279080 !ruby/object:Gem::Requirement
115
+ requirement: &70152131286300 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70358171279080
123
+ version_requirements: *70152131286300
124
124
  description: Darwin Core Archive is the current standard exchange format for GLobal
125
125
  Names Architecture modules. This gem makes it easy to incorporate files in Darwin
126
126
  Core Archive format into a ruby project.
@@ -200,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
200
  version: '0'
201
201
  requirements: []
202
202
  rubyforge_project:
203
- rubygems_version: 1.8.10
203
+ rubygems_version: 1.8.6
204
204
  signing_key:
205
205
  specification_version: 3
206
206
  summary: Handler of Darwin Core Archive files