relaton 0.6.1 → 0.6.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 +2 -2
- data/lib/relaton/db_cache.rb +25 -5
- data/lib/relaton/version.rb +1 -1
- data/spec/relaton_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72e07d60d1d6e31db56e06232f6295abdeed9b031eeed2d7ac227bc6104f24b9
|
4
|
+
data.tar.gz: 7b5f6b9e45aa669e7ae08efe993b6fec3b733c446f38593ffd7c99528c1421ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a1676216b43cdd1c1ea917fd2f0692ec8cf0c72419deb4df179c3ee1b811d83b4a0f7a0dce29a201569ef1de7a4824221ecda07572437be1314640c9819151a
|
7
|
+
data.tar.gz: 54b8a9540a672ea25731f95b7b1a6cf0acde3b5106537758d77d06cfb2f98304bedf21b204164298534e769e02e49e84c1329599810ff0b303b8b23a06109d25
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
relaton (0.6.
|
4
|
+
relaton (0.6.2)
|
5
5
|
relaton-calconnect (~> 0.2.0)
|
6
6
|
relaton-gb (~> 0.7.0)
|
7
7
|
relaton-iec (~> 0.5.0)
|
@@ -94,7 +94,7 @@ GEM
|
|
94
94
|
relaton-iec (0.5.1)
|
95
95
|
addressable
|
96
96
|
relaton-iso-bib (~> 0.4.0)
|
97
|
-
relaton-ietf (0.7.
|
97
|
+
relaton-ietf (0.7.2)
|
98
98
|
relaton-bib (~> 0.4.0)
|
99
99
|
relaton-iso (0.7.1)
|
100
100
|
relaton-iec (~> 0.5.0)
|
data/lib/relaton/db_cache.rb
CHANGED
@@ -28,7 +28,11 @@ module Relaton
|
|
28
28
|
FileUtils::mkdir_p prefix_dir
|
29
29
|
set_version prefix_dir
|
30
30
|
end
|
31
|
-
|
31
|
+
ex = if value =~ /^not_found/ then "notfound"
|
32
|
+
elsif value =~ /^redirection/ then "redirect"
|
33
|
+
else @ext
|
34
|
+
end
|
35
|
+
File.write "#{filename(key)}.#{ex}", value, encoding: "utf-8"
|
32
36
|
end
|
33
37
|
|
34
38
|
# Read item
|
@@ -77,7 +81,8 @@ module Relaton
|
|
77
81
|
# @param key [String]
|
78
82
|
def delete(key)
|
79
83
|
file = filename key
|
80
|
-
|
84
|
+
f = search_ext(file)
|
85
|
+
File.delete f if f
|
81
86
|
end
|
82
87
|
|
83
88
|
# Check if version of the DB match to the gem grammar hash.
|
@@ -128,9 +133,9 @@ module Relaton
|
|
128
133
|
# @return [String, NilClass]
|
129
134
|
def get(key)
|
130
135
|
file = filename key
|
131
|
-
return unless
|
136
|
+
return unless (f = search_ext(file))
|
132
137
|
|
133
|
-
File.read(
|
138
|
+
File.read(f, encoding: "utf-8")
|
134
139
|
end
|
135
140
|
|
136
141
|
private
|
@@ -154,7 +159,22 @@ module Relaton
|
|
154
159
|
else
|
155
160
|
key.gsub(/[-:\s]/, "_")
|
156
161
|
end
|
157
|
-
"#{@dir}/#{fn.sub(/(,|_$)/, '')}
|
162
|
+
"#{@dir}/#{fn.sub(/(,|_$)/, '')}"
|
163
|
+
end
|
164
|
+
|
165
|
+
#
|
166
|
+
# Checks if there is file with xml or txt extension and return filename with the extension.
|
167
|
+
#
|
168
|
+
# @param file [String]
|
169
|
+
# @return [String, NilClass]
|
170
|
+
def search_ext(file)
|
171
|
+
if File.exist?("#{file}.#{@ext}")
|
172
|
+
"#{file}.#{@ext}"
|
173
|
+
elsif File.exist? "#{file}.notfound"
|
174
|
+
"#{file}.notfound"
|
175
|
+
elsif File.exist? "#{file}.redirect"
|
176
|
+
"#{file}.redirect"
|
177
|
+
end
|
158
178
|
end
|
159
179
|
|
160
180
|
# Return item's subdir
|
data/lib/relaton/version.rb
CHANGED
data/spec/relaton_spec.rb
CHANGED
@@ -148,7 +148,7 @@ RSpec.describe Relaton::Db do
|
|
148
148
|
VCR.use_cassette "rfc_8341" do
|
149
149
|
bib = @db.fetch "RFC 8341", nil, {}
|
150
150
|
expect(bib).to be_instance_of RelatonIetf::IetfBibliographicItem
|
151
|
-
expect(bib.to_xml).to include "<bibitem id=\"RFC8341\">"
|
151
|
+
expect(bib.to_xml).to include "<bibitem id=\"RFC8341\" type=\"standard\">"
|
152
152
|
expect(File.exist?("testcache")).to be true
|
153
153
|
expect(File.exist?("testcache2")).to be true
|
154
154
|
testcache = Relaton::DbCache.new "testcache"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: relaton-calconnect
|