anvl-converter 0.1.2 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/lib/anvl/core_ext/ruby/hash.rb +1 -1
- data/lib/anvl/core_ext/ruby/string.rb +2 -10
- data/lib/anvl/version.rb +1 -1
- data/spec/fixtures/datacite.txt +2 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/string_spec.rb +7 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22a4b5e253e8fa85cdafb97ee6a4221623c24fc96d2d8f521d2ebd0fdcb21968
|
4
|
+
data.tar.gz: 82b46195ae8f25b11279d81d793e913ca212566330cf4a494c3c7a522c9c817a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b373884813705be4265fb7017cac11bc48b1c7fc73bcab7ce59d8ab58739e3ddf43ad923ee4192d493a1227423cdb22e71399ddb7eda5bfb494f78db1675efe
|
7
|
+
data.tar.gz: 799abda97fc24c972a563ee7c0a70c92e3fc60a9b4cc544892923accd91acf88e2dd64d66e2e4d433cb62c28de7b724777402d99fe845c3dc23a7e7548641f18
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
anvl-converter (0.
|
4
|
+
anvl-converter (0.2)
|
5
5
|
activesupport (>= 4.2.5, < 6)
|
6
6
|
|
7
7
|
GEM
|
@@ -17,10 +17,10 @@ GEM
|
|
17
17
|
concurrent-ruby (1.0.5)
|
18
18
|
diff-lcs (1.3)
|
19
19
|
docile (1.1.5)
|
20
|
-
i18n (0.9.
|
20
|
+
i18n (0.9.3)
|
21
21
|
concurrent-ruby (~> 1.0)
|
22
22
|
json (2.1.0)
|
23
|
-
minitest (5.11.
|
23
|
+
minitest (5.11.3)
|
24
24
|
rake (12.3.0)
|
25
25
|
rspec (3.7.0)
|
26
26
|
rspec-core (~> 3.7.0)
|
@@ -34,7 +34,7 @@ GEM
|
|
34
34
|
rspec-mocks (3.7.0)
|
35
35
|
diff-lcs (>= 1.2.0, < 2.0)
|
36
36
|
rspec-support (~> 3.7.0)
|
37
|
-
rspec-support (3.7.
|
37
|
+
rspec-support (3.7.1)
|
38
38
|
simplecov (0.13.0)
|
39
39
|
docile (~> 1.1.0)
|
40
40
|
json (>= 1.8, < 3)
|
@@ -5,7 +5,7 @@ class String
|
|
5
5
|
# ignore
|
6
6
|
elsif line.include?(":")
|
7
7
|
k, v = line.split(":", 2)
|
8
|
-
sum[k.to_s.strip.
|
8
|
+
sum[k.to_s.strip.anvlunesc] = v.to_s.strip.anvlunesc
|
9
9
|
elsif line.start_with?(" ")
|
10
10
|
sum[sum.keys.last] += " " + line.strip
|
11
11
|
end
|
@@ -17,19 +17,11 @@ class String
|
|
17
17
|
HashWithIndifferentAccess.new(hsh)
|
18
18
|
end
|
19
19
|
|
20
|
-
def kanvlesc
|
21
|
-
self.anvlesc.gsub(/:/, "%3A")
|
22
|
-
end
|
23
|
-
|
24
20
|
def anvlesc
|
25
21
|
self.gsub(/%/, "%25").gsub(/\n/, "%0A").gsub(/\r/, "%0D")
|
26
22
|
end
|
27
23
|
|
28
|
-
def kanvlunesc
|
29
|
-
self.gsub(/%3A/, ":").anvlunesc
|
30
|
-
end
|
31
|
-
|
32
24
|
def anvlunesc
|
33
|
-
self.gsub(/%25/, "%").gsub(/%0A/, "\n").gsub(/%0D/, "\r")
|
25
|
+
self.gsub(/%25/, "%").gsub(/%0A/, "\n").gsub(/%0D/, "\r").gsub(/%3A/, ":")
|
34
26
|
end
|
35
27
|
end
|
data/lib/anvl/version.rb
CHANGED
@@ -0,0 +1,2 @@
|
|
1
|
+
datacite: <?xml version="1.0" encoding="UTF-8"?>%0A<resource xmlns="http%3A//datacite.org/schema/kernel-3" xmlns%3Axsi="http%3A//www.w3.org/2001/XMLSchema-instance" xsi%3AschemaLocation="http%3A//datacite.org/schema/kernel-3 http%3A//schema.datacite.org/meta/kernel-3/metadata.xsd">%0A <identifier identifierType="DOI">10.5072/FK2/sbdbtest/501</identifier> %0A <creators>%0A %0A %0A %0A %0A <creator> %0A <creatorName>Meyer, Pete</creatorName> %0A <affiliation>HMS</affiliation> %0A </creator>%0A %0A %0A %0A %0A %0A %0A %0A %0A %0A </creators>%0A <titles>%0A <title>X-Ray Diffraction data from demoglobin, source of 193L structure</title> %0A </titles>%0A <publisher> %0A SBGrid Data Bank%0A </publisher>%0A <publicationYear> %0A 2017%0A </publicationYear>%0A <subjects>%0A <subject> %0A demoglobin%0A </subject>%0A </subjects>%0A <contributors>%0A %0A %0A %0A <contributor contributorType="DataCollector">%0A %0A <contributorName>Meyer, Pete</contributorName> %0A <affiliation>HMS</affiliation> %0A </contributor>%0A %0A %0A <contributor contributorType="Distributor">%0A %0A <contributorName>Meyer, Pete</contributorName> %0A <affiliation>HMS</affiliation> %0A </contributor>%0A %0A %0A %0A %0A <contributor contributorType="ProjectLeader"> %0A %0A <contributorName>Sliz, Piotr</contributorName> %0A <affiliation>Harvard Medical School</affiliation> %0A </contributor>%0A %0A %0A </contributors>%0A <dates> %0A <date dateType="Collected"> %0A 2017-11-26%0A </date>%0A <date dateType="Submitted">%0A 2017-11-27%0A </date>%0A </dates>%0A <resourceType resourceTypeGeneral="Dataset">X-Ray Diffraction</resourceType> %0A <relatedIdentifiers>%0A %0A <relatedIdentifier relatedIdentifierType="DOI" relationType="IsSourceOf" > %0A 10.2210/pdb193L/pdb%0A </relatedIdentifier> %0A %0A %0A </relatedIdentifiers>%0A <descriptions>%0A <description descriptionType="Abstract"> %0A anomalous%0A </description>%0A %0A </descriptions>%0A</resource>%0A
|
2
|
+
_target: http%3A//data.sbgrid.org/dataset/501
|
data/spec/spec_helper.rb
CHANGED
data/spec/string_spec.rb
CHANGED
@@ -48,5 +48,12 @@ when/created: 1888
|
|
48
48
|
expect(anvl[:what]).to eq("The Yeomen of the Guard")
|
49
49
|
expect(anvl[:"when/created"]).to eq("1888")
|
50
50
|
end
|
51
|
+
|
52
|
+
it "datacite example" do
|
53
|
+
str = File.read(fixture_path + 'datacite.txt')
|
54
|
+
anvl = str.from_anvl
|
55
|
+
expect(anvl[:datacite].split("\n")[2].strip).to eq("<identifier identifierType=\"DOI\">10.5072/FK2/sbdbtest/501</identifier>")
|
56
|
+
expect(anvl[:_target]).to eq("http://data.sbgrid.org/dataset/501")
|
57
|
+
end
|
51
58
|
end
|
52
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anvl-converter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Fenner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- lib/anvl/core_ext/ruby/hash.rb
|
126
126
|
- lib/anvl/core_ext/ruby/string.rb
|
127
127
|
- lib/anvl/version.rb
|
128
|
+
- spec/fixtures/datacite.txt
|
128
129
|
- spec/hash_spec.rb
|
129
130
|
- spec/spec_helper.rb
|
130
131
|
- spec/string_spec.rb
|