relaton-index 0.2.15 → 0.2.16

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: 5ce9d7205daf0975990050a9f2652f35d7fc9cd02a840f49cc268ee3114c0870
4
- data.tar.gz: b0a56e175a3ca0ed09dea40d2b0d6cb1d6b7400f5cb61d67a86185f00d9309d6
3
+ metadata.gz: 4108f8054c21d68ee61c745be7a61c9d35f1dfdc054b1bf3a98b0d3d4bbe7ce1
4
+ data.tar.gz: 765718355ee7cb6182ef08513a2235be8efc45b4e2b086585c9ba6d7c7ff2006
5
5
  SHA512:
6
- metadata.gz: 21cd6e533b27e00ee9b0604eb3a11112dba1c8f69db15996beede0b7ce763ae54ac30242e8a75118c6e525b4bde510bd7b68f347ccbdd180479d38b77f2c88c0
7
- data.tar.gz: 2788d0c92aa0e4fe6540eb4fb5ae4b30917abb304f91b09add060efbcd81977427503c5e7ddc15c17afd1db9735a1abecdfe0a0b760de3d7b89d9e3a41476c59
6
+ metadata.gz: 33a29690bd1296f6c44358a513d016ab433a34f89de508466d919b22a76f834d077a6fb5fb69579b694fcfd440458e53dd5931943c3bd8cb12d4f725509fe265
7
+ data.tar.gz: 1f23d97956f434d7ceb76688da5086e7ee545c7685455f9964ece8db783f326f591a5d4ef984694ce09ee0cd6786fb63d8f24eff06875fc51157985bf8cfef63
@@ -106,12 +106,7 @@ module Relaton
106
106
  yaml = Index.config.storage.read(file)
107
107
  return unless yaml
108
108
 
109
- index = YAML.safe_load yaml, permitted_classes: [Symbol]
110
- return deserialize_pubid(index) if check_format index
111
-
112
- warn_local_index_error "Wrong structure of the"
113
- rescue Psych::SyntaxError
114
- warn_local_index_error "YAML parsing error when reading"
109
+ load_index(yaml) || []
115
110
  end
116
111
 
117
112
  def deserialize_pubid(index)
@@ -134,6 +129,23 @@ module Relaton
134
129
  @progname ||= "relaton-#{@dir}"
135
130
  end
136
131
 
132
+ def load_index(yaml, save = false)
133
+ index = YAML.safe_load(yaml, permitted_classes: [Symbol])
134
+ save index if save
135
+ return deserialize_pubid(index) if check_format index
136
+
137
+ if save
138
+ warn_remote_index_error "Wrong structure of"
139
+ else
140
+ warn_local_index_error "Wrong structure of"
141
+ end
142
+ rescue Psych::SyntaxError
143
+ if save
144
+ warn_remote_index_error "YAML parsing error when reading"
145
+ else
146
+ warn_local_index_error "YAML parsing error when reading"
147
+ end
148
+ end
137
149
  #
138
150
  # Fetch index from external repository and save it to storage
139
151
  #
@@ -144,14 +156,8 @@ module Relaton
144
156
  zip = Zip::InputStream.new resp
145
157
  entry = zip.get_next_entry
146
158
  yaml = entry.get_input_stream.read
147
- index = YAML.safe_load(yaml, permitted_classes: [Symbol])
148
- save index
149
159
  Util.info "Downloaded index from `#{url}`", progname
150
- return index if check_format index
151
-
152
- warn_remote_index_error "Wrong structure of"
153
- rescue Psych::SyntaxError
154
- warn_remote_index_error "YAML parsing error when reading"
160
+ load_index(yaml, save = true)
155
161
  end
156
162
 
157
163
  def warn_remote_index_error(reason)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Relaton
4
4
  module Index
5
- VERSION = "0.2.15"
5
+ VERSION = "0.2.16"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-index
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.15
4
+ version: 0.2.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-08 00:00:00.000000000 Z
11
+ date: 2024-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pubid-core