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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e5f5a2e45afa96d71c1f426004f5b12289131836d83100cf992d74ee709df6f
4
- data.tar.gz: 43e583c04af72c620126e711c4d899f0515abe091ea4cef2b59738060e44daac
3
+ metadata.gz: 72e07d60d1d6e31db56e06232f6295abdeed9b031eeed2d7ac227bc6104f24b9
4
+ data.tar.gz: 7b5f6b9e45aa669e7ae08efe993b6fec3b733c446f38593ffd7c99528c1421ad
5
5
  SHA512:
6
- metadata.gz: af36320501a2ec8430bfbdb3530752f3e0251c7aad344ccee010d6f79c7a376f23b6a7cb3290c00fe9b5376c73c5f5618784ec660d398dce00e48b08fd378621
7
- data.tar.gz: 24d750f23c8a4c89c0092d22f7118ac7b2917b62275b5c1e1a5b4ea3cb77c889a13b586c4e5816488fd042ad3bdd7993a8ca5097d7c5f6817d92adb20438eeae
6
+ metadata.gz: 8a1676216b43cdd1c1ea917fd2f0692ec8cf0c72419deb4df179c3ee1b811d83b4a0f7a0dce29a201569ef1de7a4824221ecda07572437be1314640c9819151a
7
+ data.tar.gz: 54b8a9540a672ea25731f95b7b1a6cf0acde3b5106537758d77d06cfb2f98304bedf21b204164298534e769e02e49e84c1329599810ff0b303b8b23a06109d25
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- relaton (0.6.1)
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.1)
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)
@@ -28,7 +28,11 @@ module Relaton
28
28
  FileUtils::mkdir_p prefix_dir
29
29
  set_version prefix_dir
30
30
  end
31
- File.write filename(key), value, encoding: "utf-8"
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
- File.delete file if File.exist? file
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 File.exist? file
136
+ return unless (f = search_ext(file))
132
137
 
133
- File.read(file, encoding: "utf-8")
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(/(,|_$)/, '')}.#{@ext}"
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
@@ -1,3 +1,3 @@
1
1
  module Relaton
2
- VERSION = "0.6.1".freeze
2
+ VERSION = "0.6.2".freeze
3
3
  end
@@ -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.1
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-16 00:00:00.000000000 Z
11
+ date: 2019-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: relaton-calconnect