dwc-archive 0.9.11 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.rspec +2 -1
- data/.rubocop.yml +23 -0
- data/.ruby-version +1 -1
- data/.travis.yml +4 -7
- data/CHANGELOG +4 -0
- data/Gemfile +3 -1
- data/LICENSE +1 -1
- data/README.md +114 -109
- data/Rakefile +13 -36
- data/dwc-archive.gemspec +23 -19
- data/features/step_definitions/dwc-creator_steps.rb +5 -5
- data/features/step_definitions/dwc-reader_steps.rb +47 -28
- data/features/support/env.rb +1 -1
- data/lib/dwc_archive.rb +124 -0
- data/lib/dwc_archive/archive.rb +60 -0
- data/lib/dwc_archive/classification_normalizer.rb +382 -0
- data/lib/dwc_archive/core.rb +25 -0
- data/lib/{dwc-archive → dwc_archive}/errors.rb +10 -0
- data/lib/dwc_archive/expander.rb +88 -0
- data/lib/{dwc-archive → dwc_archive}/extension.rb +5 -3
- data/lib/dwc_archive/generator.rb +91 -0
- data/lib/{dwc-archive → dwc_archive}/generator_eml_xml.rb +40 -33
- data/lib/{dwc-archive → dwc_archive}/generator_meta_xml.rb +21 -20
- data/lib/dwc_archive/gnub_taxon.rb +14 -0
- data/lib/dwc_archive/ingester.rb +106 -0
- data/lib/dwc_archive/metadata.rb +57 -0
- data/lib/dwc_archive/taxon_normalized.rb +23 -0
- data/lib/dwc_archive/version.rb +6 -0
- data/lib/dwc_archive/xml_reader.rb +90 -0
- data/spec/files/file with characters(3).gz b/data/spec/files/file with → characters(3).tar.gz +0 -0
- data/spec/files/generator_eml.xml +1 -1
- data/spec/lib/classification_normalizer_spec.rb +96 -105
- data/spec/lib/core_spec.rb +43 -41
- data/spec/lib/darwin_core_spec.rb +108 -138
- data/spec/lib/generator_eml_xml_spec.rb +12 -11
- data/spec/lib/generator_meta_xml_spec.rb +12 -11
- data/spec/lib/generator_spec.rb +73 -74
- data/spec/lib/gnub_taxon_spec.rb +15 -17
- data/spec/lib/metadata_spec.rb +50 -41
- data/spec/lib/taxon_normalized_spec.rb +62 -65
- data/spec/lib/xml_reader_spec.rb +9 -12
- data/spec/spec_helper.rb +54 -51
- metadata +101 -87
- data/.rvmrc +0 -1
- data/lib/dwc-archive.rb +0 -107
- data/lib/dwc-archive/archive.rb +0 -40
- data/lib/dwc-archive/classification_normalizer.rb +0 -427
- data/lib/dwc-archive/core.rb +0 -19
- data/lib/dwc-archive/expander.rb +0 -85
- data/lib/dwc-archive/generator.rb +0 -86
- data/lib/dwc-archive/ingester.rb +0 -101
- data/lib/dwc-archive/metadata.rb +0 -48
- data/lib/dwc-archive/version.rb +0 -3
- data/lib/dwc-archive/xml_reader.rb +0 -80
@@ -1,21 +1,22 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe DarwinCore::Generator::EmlXml do
|
4
|
-
subject
|
4
|
+
subject { DarwinCore::Generator::EmlXml.new(data, path) }
|
5
5
|
let(:data) { EML_DATA }
|
6
6
|
let(:path) { DarwinCore::DEFAULT_TMP_DIR }
|
7
7
|
|
8
|
-
describe
|
9
|
-
it
|
10
|
-
expect(eml).to be_kind_of DarwinCore::Generator::EmlXml
|
11
|
-
end
|
8
|
+
describe ".new" do
|
9
|
+
it { is_expected.to be_kind_of DarwinCore::Generator::EmlXml }
|
12
10
|
end
|
13
11
|
|
14
|
-
describe
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
describe "#create" do
|
13
|
+
let(:content) do
|
14
|
+
subject.create
|
15
|
+
File.read(File.join(path, "eml.xml"))
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should create eml xml" do
|
19
|
+
expect(content).to match(/Test Classification/)
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
@@ -1,21 +1,22 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe DarwinCore::Generator::MetaXml do
|
4
|
-
subject
|
4
|
+
subject { DarwinCore::Generator::MetaXml.new(data, path) }
|
5
5
|
let(:data) { META_DATA }
|
6
6
|
let(:path) { DarwinCore::DEFAULT_TMP_DIR }
|
7
7
|
|
8
|
-
describe
|
9
|
-
it
|
10
|
-
expect(meta).to be_kind_of DarwinCore::Generator::MetaXml
|
11
|
-
end
|
8
|
+
describe ".new" do
|
9
|
+
it { is_expected.to be_kind_of DarwinCore::Generator::MetaXml }
|
12
10
|
end
|
13
11
|
|
14
|
-
describe
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
describe "#create" do
|
13
|
+
let(:content) do
|
14
|
+
subject.create
|
15
|
+
File.read(File.join(path, "meta.xml"))
|
16
|
+
end
|
17
|
+
|
18
|
+
it "creates metadata file" do
|
19
|
+
expect(content).to match(%r{<location>core.csv</location>})
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
data/spec/lib/generator_spec.rb
CHANGED
@@ -1,125 +1,124 @@
|
|
1
|
-
#
|
2
|
-
require_relative '../spec_helper'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
3
|
describe DarwinCore::Generator do
|
5
4
|
subject(:gen) { DarwinCore::Generator.new(dwc_path, tmp_dir) }
|
6
5
|
let(:tmp_dir) { DarwinCore::DEFAULT_TMP_DIR }
|
7
|
-
let(:dwc_path) { File.join(tmp_dir,
|
6
|
+
let(:dwc_path) { File.join(tmp_dir, "spec_dwca.tar.gz") }
|
7
|
+
|
8
|
+
def generate_dwca(gen)
|
9
|
+
gen.add_core(CORE_DATA.dup, "core.csv", true)
|
10
|
+
gen.add_extension(EXTENSION_DATA.dup, "vern.csv", true,
|
11
|
+
"http://rs.gbif.org/terms/1.0/VernacularName")
|
12
|
+
gen.add_meta_xml
|
13
|
+
gen.add_eml_xml(EML_DATA)
|
14
|
+
end
|
8
15
|
|
9
|
-
describe
|
10
|
-
it
|
11
|
-
expect(gen).to be_kind_of DarwinCore::Generator
|
16
|
+
describe ".new" do
|
17
|
+
it "initializes empty DwCA" do
|
18
|
+
expect(gen).to be_kind_of DarwinCore::Generator
|
12
19
|
end
|
13
20
|
end
|
14
21
|
|
15
|
-
describe
|
16
|
-
it
|
17
|
-
gen.add_core(CORE_DATA.dup,
|
18
|
-
core = File.read(File.join(gen.path,
|
19
|
-
expect(core).to match
|
22
|
+
describe "#add_core" do
|
23
|
+
it "adds core to DwCA instance" do
|
24
|
+
gen.add_core(CORE_DATA.dup, "core.csv", true)
|
25
|
+
core = File.read(File.join(gen.path, "core.csv"))
|
26
|
+
expect(core).to match(/taxonID,parentNameUsageID,scientificName/)
|
20
27
|
end
|
21
28
|
|
22
|
-
context
|
23
|
-
it
|
29
|
+
context "urls are not given in header" do
|
30
|
+
it "raises error" do
|
24
31
|
data = CORE_DATA.dup
|
25
|
-
data[0] = data[0].map { |f| f.split(
|
26
|
-
expect { gen.add_core(data,
|
27
|
-
|
32
|
+
data[0] = data[0].map { |f| f.split("/")[-1] }
|
33
|
+
expect { gen.add_core(data, "core.csv", true) }.
|
34
|
+
to raise_error DarwinCore::GeneratorError
|
28
35
|
end
|
29
36
|
end
|
30
37
|
end
|
31
38
|
|
32
|
-
describe
|
33
|
-
it
|
34
|
-
gen.add_extension(EXTENSION_DATA.dup,
|
35
|
-
|
36
|
-
true,
|
37
|
-
|
38
|
-
extension = File.read(File.join(gen.path,
|
39
|
-
|
40
|
-
expect(extension).to match
|
39
|
+
describe "#add_extension" do
|
40
|
+
it "adds extension to DwCA instance" do
|
41
|
+
gen.add_extension(EXTENSION_DATA.dup,
|
42
|
+
"vern.csv",
|
43
|
+
true,
|
44
|
+
"http://rs.gbif.org/terms/1.0/VernacularName")
|
45
|
+
extension = File.read(File.join(gen.path, "vern.csv"))
|
46
|
+
|
47
|
+
expect(extension).to match(/Береза/)
|
41
48
|
end
|
42
49
|
end
|
43
50
|
|
44
|
-
describe
|
45
|
-
it
|
46
|
-
gen.add_core(CORE_DATA.dup,
|
47
|
-
gen.add_extension(EXTENSION_DATA.dup,
|
48
|
-
|
49
|
-
true,
|
50
|
-
|
51
|
+
describe "#add_meta_xml" do
|
52
|
+
it "creates metadata for DwCA" do
|
53
|
+
gen.add_core(CORE_DATA.dup, "core.csv", true)
|
54
|
+
gen.add_extension(EXTENSION_DATA.dup,
|
55
|
+
"vern.csv",
|
56
|
+
true,
|
57
|
+
"http://rs.gbif.org/terms/1.0/VernacularName")
|
51
58
|
|
52
59
|
gen.add_meta_xml
|
53
|
-
meta = File.read(File.join(gen.path,
|
54
|
-
meta_from_file= File.read(
|
55
|
-
|
56
|
-
|
60
|
+
meta = File.read(File.join(gen.path, "meta.xml")).strip
|
61
|
+
meta_from_file = File.read(
|
62
|
+
File.expand_path("../files/generator_meta.xml", __dir__)
|
63
|
+
).strip
|
57
64
|
expect(meta).to eq meta_from_file
|
58
65
|
end
|
59
66
|
end
|
60
67
|
|
61
|
-
describe
|
62
|
-
it
|
68
|
+
describe "#add_eml_data" do
|
69
|
+
it "adds eml data" do
|
63
70
|
gen.add_eml_xml(EML_DATA)
|
64
|
-
eml = File.read(File.join(gen.path,
|
65
|
-
eml.gsub!(%r
|
71
|
+
eml = File.read(File.join(gen.path, "eml.xml")).strip
|
72
|
+
eml.gsub!(%r{(<pubDate>).*?(</pubDate>)}, '\12013-12-30 14:45:33 -0500\2')
|
66
73
|
eml.gsub!(/(packageId=").*?"/, '\11234/2013-12-30::19:45:33"')
|
67
74
|
|
68
|
-
eml_from_file = File.read(
|
69
|
-
|
70
|
-
|
75
|
+
eml_from_file = File.read(
|
76
|
+
File.expand_path("../files/generator_eml.xml", __dir__)
|
77
|
+
).strip
|
71
78
|
expect(eml.strip).to eq eml_from_file.strip
|
72
79
|
end
|
73
80
|
end
|
74
81
|
|
75
|
-
describe
|
76
|
-
it
|
77
|
-
expect(gen.path).to match
|
82
|
+
describe "#path" do
|
83
|
+
it "returns temporary path for assembling DwCA" do
|
84
|
+
expect(gen.path).to match(/dwc_\d+$/)
|
78
85
|
end
|
79
86
|
end
|
80
87
|
|
81
|
-
describe
|
82
|
-
|
83
|
-
gen.add_core(CORE_DATA.dup, 'core.csv', true)
|
84
|
-
gen.add_extension(EXTENSION_DATA.dup,
|
85
|
-
'vern.csv',
|
86
|
-
true,
|
87
|
-
'http://rs.gbif.org/terms/1.0/VernacularName')
|
88
|
+
describe "#files" do
|
89
|
+
before(:example) { generate_dwca(gen) }
|
88
90
|
|
89
|
-
|
90
|
-
expect(gen.files).
|
91
|
+
it "returns created files" do
|
92
|
+
expect(gen.files).
|
93
|
+
to match_array ["core.csv", "eml.xml", "meta.xml", "vern.csv"]
|
91
94
|
end
|
92
95
|
end
|
93
96
|
|
94
|
-
describe
|
95
|
-
|
96
|
-
FileUtils.rm dwc_path if File.
|
97
|
-
gen
|
98
|
-
|
99
|
-
'vern.csv',
|
100
|
-
true,
|
101
|
-
'http://rs.gbif.org/terms/1.0/VernacularName')
|
97
|
+
describe "#pack" do
|
98
|
+
before(:example) do
|
99
|
+
FileUtils.rm dwc_path if File.exist?(dwc_path)
|
100
|
+
generate_dwca(gen)
|
101
|
+
end
|
102
102
|
|
103
|
-
|
104
|
-
gen.add_eml_xml(EML_DATA)
|
103
|
+
it "creates final DwCA file" do
|
105
104
|
gen.pack
|
106
|
-
expect(File.
|
105
|
+
expect(File.exist?(dwc_path)).to be true
|
107
106
|
end
|
108
107
|
end
|
109
108
|
|
110
|
-
describe
|
111
|
-
|
112
|
-
|
113
|
-
|
109
|
+
describe "#clean" do
|
110
|
+
before(:example) { gen.add_eml_xml(EML_DATA) }
|
111
|
+
|
112
|
+
it "removes temporary directory for DwCA" do
|
113
|
+
expect(File.exist?(gen.path)).to be true
|
114
114
|
gen.clean
|
115
|
-
expect(File.
|
115
|
+
expect(File.exist?(gen.path)).to be false
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
-
describe
|
120
|
-
it
|
119
|
+
describe "#eml_xml_data" do
|
120
|
+
it "returns current eml data" do
|
121
121
|
expect(gen.eml_xml_data).to be_kind_of Hash
|
122
122
|
end
|
123
123
|
end
|
124
|
-
|
125
124
|
end
|
data/spec/lib/gnub_taxon_spec.rb
CHANGED
@@ -1,34 +1,32 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe DarwinCore::GnubTaxon do
|
4
4
|
subject(:dwca) { DarwinCore.new(file_path) }
|
5
5
|
subject(:normalizer) { DarwinCore::ClassificationNormalizer.new(dwca) }
|
6
|
-
let(:file_dir) { File.expand_path(
|
6
|
+
let(:file_dir) { File.expand_path("../files", __dir__) }
|
7
7
|
let(:file_path) { File.join(file_dir, file_name) }
|
8
|
-
let(:file_name) {
|
8
|
+
let(:file_name) { "gnub.tar.gz" }
|
9
9
|
|
10
|
-
it
|
10
|
+
it "should get uuids from GNUB" do
|
11
11
|
normalizer.normalize
|
12
|
-
tn = normalizer.normalized_data[
|
12
|
+
tn = normalizer.normalized_data["9c399f90-cfb8-5a7f-9a21-18285a473488"]
|
13
13
|
expect(tn).to be_kind_of DarwinCore::GnubTaxon
|
14
14
|
expect(tn).to be_kind_of DarwinCore::TaxonNormalized
|
15
|
-
expect(tn.uuid).to eq
|
16
|
-
expect(tn.uuid_path).to eq [
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
expect(tn.uuid).to eq "8faa91f6-663f-4cfe-b785-0ab4e9415a51"
|
16
|
+
expect(tn.uuid_path).to eq %w[
|
17
|
+
9a9f9eeb-d5f9-4ff6-b6cb-a5ad345e33c3
|
18
|
+
bf4c91c0-3d1f-44c7-9d3b-249382182a26
|
19
|
+
8faa91f6-663f-4cfe-b785-0ab4e9415a51
|
20
|
+
]
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
it 'should not be of GnubTaxon type' do
|
23
|
+
context "not a gnub data" do
|
24
|
+
let(:file_name) { "data.tar.gz" }
|
25
|
+
it "should not be of GnubTaxon type" do
|
27
26
|
normalizer.normalize
|
28
|
-
tn = normalizer.normalized_data[
|
27
|
+
tn = normalizer.normalized_data["leptogastrinae:tid:42"]
|
29
28
|
expect(tn).to be_kind_of DarwinCore::TaxonNormalized
|
30
29
|
expect(tn).not_to be_kind_of DarwinCore::GnubTaxon
|
31
30
|
end
|
32
31
|
end
|
33
|
-
|
34
32
|
end
|
data/spec/lib/metadata_spec.rb
CHANGED
@@ -1,80 +1,89 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe DarwinCore::Metadata do
|
4
|
-
subject(:dwca) { DarwinCore.new(file_path) }
|
5
4
|
subject(:eml) { DarwinCore::Metadata.new(dwca.archive) }
|
6
|
-
let(:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
let(:dwca) { DarwinCore.new(file_path) }
|
6
|
+
let(:file_path) do
|
7
|
+
File.join(File.expand_path("../files", __dir__), file_name)
|
8
|
+
end
|
9
|
+
let(:file_name) { "data.tar.gz" }
|
10
|
+
|
11
|
+
describe ".new" do
|
12
|
+
it "initializes" do
|
12
13
|
expect(eml).to be_kind_of DarwinCore::Metadata
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
|
-
describe
|
17
|
-
it
|
17
|
+
describe "#data" do
|
18
|
+
it "returns hash of metadata" do
|
18
19
|
expect(eml.data).to be_kind_of Hash
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
22
|
-
describe
|
23
|
-
it
|
24
|
-
expect(eml.id).to eq
|
23
|
+
describe "#id" do
|
24
|
+
it "returns id of the archive if it exists" do
|
25
|
+
expect(eml.id).to eq "leptogastrinae:version:2.5"
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
|
-
describe
|
29
|
-
context
|
30
|
-
|
29
|
+
describe "#package_id" do
|
30
|
+
context "no package id is given" do
|
31
|
+
before(:example) do
|
32
|
+
@attributes = eml.data[:eml].delete(:attributes)
|
33
|
+
end
|
34
|
+
|
35
|
+
after(:example) do
|
36
|
+
eml.data[:eml][:attributes] = @attributes
|
37
|
+
end
|
38
|
+
|
39
|
+
it "returns id of the DwCA file if exists" do
|
40
|
+
expect { eml.data[:eml][:attributes][:packageId] }.
|
41
|
+
to raise_exception NoMethodError
|
31
42
|
expect(eml.package_id).to be_nil
|
32
43
|
end
|
33
44
|
end
|
34
45
|
end
|
35
46
|
|
36
|
-
describe
|
37
|
-
it
|
47
|
+
describe "#title" do
|
48
|
+
it "returns name of the archive" do
|
38
49
|
expect(eml.title).
|
39
|
-
to eq
|
50
|
+
to eq "Leptogastrinae (Diptera: Asilidae) Classification"
|
40
51
|
end
|
41
52
|
end
|
42
53
|
|
43
|
-
describe
|
44
|
-
it
|
54
|
+
describe "#authors" do
|
55
|
+
it "returns authors of the archive" do
|
45
56
|
expect(eml.authors).
|
46
57
|
to eq [
|
47
|
-
{:
|
48
|
-
|
49
|
-
|
50
|
-
{:
|
51
|
-
:
|
52
|
-
:
|
58
|
+
{ first_name: "Keith",
|
59
|
+
last_name: "Bayless",
|
60
|
+
email: "keith.bayless@gmail.com" },
|
61
|
+
{ first_name: "Torsten",
|
62
|
+
last_name: "Dikow",
|
63
|
+
email: "dshorthouse@eol.org" }
|
64
|
+
]
|
53
65
|
end
|
54
66
|
|
55
|
-
describe
|
56
|
-
it
|
67
|
+
describe "#abstract" do
|
68
|
+
it "returns abstract of an article" do
|
57
69
|
expect(eml.abstract).
|
58
|
-
to eq
|
70
|
+
to eq "These are all the names in the Leptogastrinae classification."
|
59
71
|
end
|
60
72
|
end
|
61
73
|
|
62
|
-
describe
|
63
|
-
it
|
74
|
+
describe "#citation" do
|
75
|
+
it "returns citation of the archive" do
|
64
76
|
expect(eml.citation).
|
65
|
-
to eq
|
77
|
+
to eq "Dikow, Torsten. 2010. The Leptogastrinae classification."
|
66
78
|
end
|
67
79
|
end
|
68
80
|
|
69
|
-
describe
|
70
|
-
it
|
71
|
-
expect(eml.url).
|
72
|
-
|
73
|
-
|
74
|
-
'leptogastrinae.tar.gz'
|
81
|
+
describe "#url" do
|
82
|
+
it "returns url to the archive" do
|
83
|
+
expect(eml.url).
|
84
|
+
to eq "http://leptogastrinae.lifedesks.org/files/leptogastrinae/"\
|
85
|
+
"classification_export/shared/leptogastrinae.tar.gz"
|
75
86
|
end
|
76
87
|
end
|
77
|
-
|
78
88
|
end
|
79
89
|
end
|
80
|
-
|
@@ -1,99 +1,97 @@
|
|
1
|
-
|
2
|
-
# encoding: utf-8
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
3
|
describe DarwinCore::TaxonNormalized do
|
5
4
|
subject(:dwca) { DarwinCore.new(file_path) }
|
6
5
|
subject(:normalizer) { DarwinCore::ClassificationNormalizer.new(dwca) }
|
7
|
-
let(:file_dir) { File.expand_path(
|
6
|
+
let(:file_dir) { File.expand_path("../files", __dir__) }
|
8
7
|
|
9
|
-
context
|
10
|
-
let(:file_path) { File.join(file_dir,
|
8
|
+
context "typical case" do
|
9
|
+
let(:file_path) { File.join(file_dir, "data.tar.gz") }
|
11
10
|
let(:normalized) { normalizer.normalize }
|
12
|
-
let(:tn) { normalized[
|
11
|
+
let(:tn) { normalized["leptogastrinae:tid:2681"] }
|
13
12
|
|
14
|
-
it
|
13
|
+
it "has TaxonNormalized type" do
|
15
14
|
expect(tn).to be_kind_of DarwinCore::TaxonNormalized
|
16
15
|
end
|
17
16
|
|
18
|
-
describe
|
19
|
-
it
|
20
|
-
expect(tn.id).to eq
|
17
|
+
describe "#id" do
|
18
|
+
it "returns taxon_id" do
|
19
|
+
expect(tn.id).to eq "leptogastrinae:tid:2681"
|
21
20
|
end
|
22
21
|
end
|
23
22
|
|
24
|
-
describe
|
25
|
-
it
|
26
|
-
expect(tn.id).to eq
|
23
|
+
describe "#local_id" do
|
24
|
+
it "returns local id" do
|
25
|
+
expect(tn.id).to eq "leptogastrinae:tid:2681"
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
30
|
-
describe
|
31
|
-
it
|
32
|
-
expect(tn.global_id).to eq
|
29
|
+
describe "#global_id" do
|
30
|
+
it "returns global id" do
|
31
|
+
expect(tn.global_id).to eq "843ff0df-4bcd-4aad-ba94-643f8695a292"
|
33
32
|
end
|
34
33
|
end
|
35
34
|
|
36
|
-
describe
|
37
|
-
it
|
35
|
+
describe "#source" do
|
36
|
+
it "returns url to the data" do
|
38
37
|
expect(tn.source).
|
39
|
-
to eq
|
38
|
+
to eq "http://leptogastrinae.lifedesks.org/pages/2681"
|
40
39
|
end
|
41
|
-
end
|
40
|
+
end
|
42
41
|
|
43
|
-
describe
|
44
|
-
it
|
45
|
-
expect(tn.parent_id).to eq
|
42
|
+
describe "#parent_id" do
|
43
|
+
it "returns ancestor's id" do
|
44
|
+
expect(tn.parent_id).to eq "leptogastrinae:tid:2584"
|
46
45
|
end
|
47
46
|
end
|
48
|
-
|
49
|
-
describe
|
50
|
-
it
|
47
|
+
|
48
|
+
describe "#classification_path_id" do
|
49
|
+
it "returns an array" do
|
51
50
|
expect(tn.classification_path_id).to be_kind_of Array
|
52
51
|
end
|
53
52
|
|
54
|
-
it
|
53
|
+
it "returns ids of classification path elements" do
|
55
54
|
expect(tn.classification_path_id).
|
56
|
-
to eq [
|
57
|
-
|
58
|
-
|
59
|
-
|
55
|
+
to eq ["leptogastrinae:tid:42",
|
56
|
+
"leptogastrinae:tid:2045",
|
57
|
+
"leptogastrinae:tid:2584",
|
58
|
+
"leptogastrinae:tid:2681"]
|
60
59
|
end
|
61
60
|
end
|
62
61
|
|
63
|
-
describe
|
62
|
+
describe "#classification_path" do
|
64
63
|
let(:cp) { tn.classification_path }
|
65
|
-
it
|
64
|
+
it "returns array of name strings of the classification path" do
|
66
65
|
expect(cp).to be_kind_of Array
|
67
|
-
expect(cp).to eq ["Leptogastrinae",
|
68
|
-
"Leptogastrini",
|
69
|
-
"Leptogaster",
|
70
|
-
"Leptogaster flavipes"]
|
66
|
+
expect(cp).to eq ["Leptogastrinae",
|
67
|
+
"Leptogastrini",
|
68
|
+
"Leptogaster",
|
69
|
+
"Leptogaster flavipes"]
|
71
70
|
end
|
72
71
|
end
|
73
72
|
|
74
|
-
describe
|
75
|
-
it
|
73
|
+
describe "#linnean_classification_path" do
|
74
|
+
it "returns empty array for parent/child based classification" do
|
76
75
|
expect(tn.linnean_classification_path).to be_kind_of Array
|
77
76
|
expect(tn.linnean_classification_path).to be_empty
|
78
77
|
end
|
79
78
|
end
|
80
79
|
|
81
|
-
describe
|
82
|
-
it
|
83
|
-
expect(tn.current_name).to eq
|
80
|
+
describe "#current_name" do
|
81
|
+
it "returns name marked as currently valid for the taxon" do
|
82
|
+
expect(tn.current_name).to eq "Leptogaster flavipes Loew, 1862"
|
84
83
|
end
|
85
84
|
end
|
86
|
-
|
87
|
-
describe
|
88
|
-
it
|
89
|
-
expect(tn.current_name_canonical).to eq
|
85
|
+
|
86
|
+
describe "#current_name_canonical" do
|
87
|
+
it "returns canonical form of valid name" do
|
88
|
+
expect(tn.current_name_canonical).to eq "Leptogaster flavipes"
|
90
89
|
end
|
91
90
|
end
|
92
91
|
|
93
|
-
describe
|
94
|
-
context
|
95
|
-
|
96
|
-
it 'returns empty array' do
|
92
|
+
describe "#synonyms" do
|
93
|
+
context "synonyms not found" do
|
94
|
+
it "returns empty array" do
|
97
95
|
expect(tn.synonyms).to be_kind_of Array
|
98
96
|
synonym = tn.synonyms[0]
|
99
97
|
expect(synonym).to be_kind_of DarwinCore::SynonymNormalized
|
@@ -101,26 +99,26 @@ describe DarwinCore::TaxonNormalized do
|
|
101
99
|
end
|
102
100
|
end
|
103
101
|
|
104
|
-
context
|
105
|
-
let(:tn) { normalized[
|
106
|
-
it
|
102
|
+
context "synonyms found" do
|
103
|
+
let(:tn) { normalized["leptogastrinae:tid:2858"] }
|
104
|
+
it "returns array of synonyms" do
|
107
105
|
expect(tn.synonyms).to be_kind_of Array
|
108
106
|
expect(tn.synonyms).to be_empty
|
109
107
|
end
|
110
108
|
end
|
111
109
|
end
|
112
110
|
|
113
|
-
describe
|
114
|
-
context
|
115
|
-
it
|
111
|
+
describe "#vernacular_names" do
|
112
|
+
context "vernacular names not found" do
|
113
|
+
it "returns empty array" do
|
116
114
|
expect(tn.vernacular_names).to be_kind_of Array
|
117
115
|
expect(tn.vernacular_names).to be_empty
|
118
116
|
end
|
119
117
|
end
|
120
118
|
|
121
|
-
context
|
122
|
-
let(:tn) { normalized[
|
123
|
-
it
|
119
|
+
context "vernacular names found" do
|
120
|
+
let(:tn) { normalized["leptogastrinae:tid:42"] }
|
121
|
+
it "returns array with vernacular name structure" do
|
124
122
|
expect(tn.vernacular_names).to be_kind_of Array
|
125
123
|
vn = tn.vernacular_names[0]
|
126
124
|
expect(vn).to be_kind_of DarwinCore::VernacularNormalized
|
@@ -129,17 +127,16 @@ describe DarwinCore::TaxonNormalized do
|
|
129
127
|
end
|
130
128
|
end
|
131
129
|
|
132
|
-
describe
|
133
|
-
it
|
134
|
-
expect(tn.rank).to eq
|
130
|
+
describe "#rank" do
|
131
|
+
it "returns rank of the taxon" do
|
132
|
+
expect(tn.rank).to eq "species"
|
135
133
|
end
|
136
134
|
end
|
137
135
|
|
138
|
-
describe
|
139
|
-
it
|
136
|
+
describe "#status" do
|
137
|
+
it "returns status of taxon" do
|
140
138
|
expect(tn.status).to be_nil
|
141
139
|
end
|
142
140
|
end
|
143
141
|
end
|
144
|
-
|
145
142
|
end
|