dwc-archive 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/dwc-archive.rb +13 -8
  3. metadata +8 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
data/lib/dwc-archive.rb CHANGED
@@ -34,6 +34,15 @@ class DarwinCore
34
34
  return true if [nil, '', '/N'].include?(field)
35
35
  false
36
36
  end
37
+
38
+ def self.clean_all(tmp_dir = DEFAULT_TMP_DIR)
39
+ Dir.entries(tmp_dir).each do |entry|
40
+ path = File.join(tmp_dir, entry)
41
+ if FileTest.directory?(path) && entry.match(/^dwc_[\d]+$/)
42
+ FileUtils.rm_rf(path)
43
+ end
44
+ end
45
+ end
37
46
 
38
47
  def initialize(dwc_path, tmp_dir = DEFAULT_TMP_DIR)
39
48
  @archive = DarwinCore::Archive.new(dwc_path, tmp_dir)
@@ -42,18 +51,14 @@ class DarwinCore
42
51
  @extensions = get_extensions
43
52
  end
44
53
 
54
+ # generates a hash from a classification data with path to each node, list of synonyms and vernacular names.
45
55
  def normalize_classification
46
- return nil unless core.fields.map { |f| f[:term].split('/')[-1].downcase }.include? 'highertaxonid'
56
+ return nil unless has_parent_id?
47
57
  DarwinCore::ClassificationNormalizer.new(self).normalize
48
58
  end
49
59
 
50
- def self.clean_all(tmp_dir = DEFAULT_TMP_DIR)
51
- Dir.entries(tmp_dir).each do |entry|
52
- path = File.join(tmp_dir, entry)
53
- if FileTest.directory?(path) && entry.match(/^dwc_[\d]+$/)
54
- FileUtils.rm_rf(path)
55
- end
56
- end
60
+ def has_parent_id?
61
+ !!@core.fields.join('|').downcase.match(/highertaxonid|parentnameusageid/)
57
62
  end
58
63
 
59
64
  private
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dwc-archive
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 13
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 4
8
- - 0
9
- version: 0.4.0
9
+ - 1
10
+ version: 0.4.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Dmitry Mozzherin
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-09-09 00:00:00 -04:00
18
+ date: 2010-09-10 00:00:00 -04:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -25,6 +26,7 @@ dependencies:
25
26
  requirements:
26
27
  - - ">="
27
28
  - !ruby/object:Gem::Version
29
+ hash: 13
28
30
  segments:
29
31
  - 1
30
32
  - 2
@@ -40,6 +42,7 @@ dependencies:
40
42
  requirements:
41
43
  - - ">="
42
44
  - !ruby/object:Gem::Version
45
+ hash: 3
43
46
  segments:
44
47
  - 0
45
48
  version: "0"
@@ -112,6 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
115
  requirements:
113
116
  - - ">="
114
117
  - !ruby/object:Gem::Version
118
+ hash: 3
115
119
  segments:
116
120
  - 0
117
121
  version: "0"
@@ -120,6 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
124
  requirements:
121
125
  - - ">="
122
126
  - !ruby/object:Gem::Version
127
+ hash: 3
123
128
  segments:
124
129
  - 0
125
130
  version: "0"