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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cf8bbf0e6c172752c80233d8ecf8f85ac5c25b446f8cb45745f2996ee2b3f40
4
- data.tar.gz: ce6748afb060292d02f4fca230ffdaf1e80a24e14b0466c848d33cc46d962622
3
+ metadata.gz: 22a4b5e253e8fa85cdafb97ee6a4221623c24fc96d2d8f521d2ebd0fdcb21968
4
+ data.tar.gz: 82b46195ae8f25b11279d81d793e913ca212566330cf4a494c3c7a522c9c817a
5
5
  SHA512:
6
- metadata.gz: a035d6c8b29e41540049ec74ec89126a3d4aab9f330e5587ff1b8aeefb9e6eb7981cef7783f0664cde4a4ab185507787732558621ac6fbdd68896a9213523a4d
7
- data.tar.gz: 496d5390b3231f236107e014dde5082e7b590bcbf1b3b9e27c9c305eaacc8c7c1d557c224c475152ef20f4b8d2acf620a49780cc6ee1b04b0d099f018f1b4aad
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.1.2)
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.1)
20
+ i18n (0.9.3)
21
21
  concurrent-ruby (~> 1.0)
22
22
  json (2.1.0)
23
- minitest (5.11.1)
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.0)
37
+ rspec-support (3.7.1)
38
38
  simplecov (0.13.0)
39
39
  docile (~> 1.1.0)
40
40
  json (>= 1.8, < 3)
@@ -1,6 +1,6 @@
1
1
  class Hash
2
2
  def to_anvl
3
- lines = self.map { |k, v| [k.to_s.kanvlesc, v.to_s.anvlesc].join(": ") }
3
+ lines = self.map { |k, v| [k.to_s.anvlesc, v.to_s.anvlesc].join(": ") }
4
4
  lines.join("\n").force_encoding(Encoding::UTF_8)
5
5
  end
6
6
  end
@@ -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.kanvlunesc] = v.to_s.strip.anvlunesc
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
@@ -1,3 +1,3 @@
1
1
  module Anvl
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2"
3
3
  end
@@ -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
@@ -7,6 +7,10 @@ SimpleCov.start
7
7
  require 'anvl'
8
8
  require 'rspec'
9
9
 
10
+ def fixture_path
11
+ File.expand_path("../fixtures", __FILE__) + '/'
12
+ end
13
+
10
14
  RSpec.configure do |config|
11
15
  config.expect_with :rspec do |c|
12
16
  c.syntax = :expect
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.1.2
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-08 00:00:00.000000000 Z
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