relaton-index 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f5ff0818b55748f6a7f41bc1d905055a2226a54f1fdf8e7bdee8f00abda5db1
4
- data.tar.gz: 76e77fe86f641f9f8f97a7e972562f576583766940d5fd763e784caf4143ef80
3
+ metadata.gz: 5c6f43554b0c62821e94d987ba3d9f9fab5be724206b33bb076062bc95ac2784
4
+ data.tar.gz: a0173e701a42f1ddb9851817471454598f9b60106c238fb6fc65100190ebb6b2
5
5
  SHA512:
6
- metadata.gz: 7a6b728ad113d6e994a04ad5058224dfd9084bc8345272f5c71882629cce416f56993e01c909012a8a79e281b44f6f4683b687c1aa2db3744c64d0108bb95820
7
- data.tar.gz: 28371d4298c344861d2934aa20b7d82f434abecc24913cc284e8231a86d0b9d48a6669336a1a9fb7ffb2c6d769b445dc014ace31efe97bac1ec0524746e2b2bd
6
+ metadata.gz: 51016e19a53b7a161112ad5a041af0d80d01b06cda5a304fad3786a024136ab77ddf66de95cdbcba6f69f6ba9bd9dc4b1cf5df020fbd93a59ab34163d6d0a566
7
+ data.tar.gz: 6a47dd6e50f542aea778755cbfb7dbdfb40364cdf7ef95fbea862ec058914d216dc3e3566dd100f75e3cae6f59444edab4517fd0b59fb3acd7cb436156021f86
@@ -76,10 +76,12 @@ module Relaton
76
76
  # @return [Boolean] <description>
77
77
  #
78
78
  def check_format(index)
79
- cehck_basic_format(index) && check_id_format(index)
79
+ check_basic_format(index) && check_id_format(index)
80
80
  end
81
81
 
82
- def cehck_basic_format(index)
82
+ def check_basic_format(index)
83
+ return false unless index.is_a? Array
84
+
83
85
  keys = %i[file id]
84
86
  index.all? { |item| item.respond_to?(:keys) && item.keys.sort == keys }
85
87
  end
@@ -104,7 +106,20 @@ module Relaton
104
106
 
105
107
  index = YAML.safe_load yaml, permitted_classes: [Symbol]
106
108
  return index if check_format index
109
+
110
+ warn_local_index_error "Wrong structure of the"
107
111
  rescue Psych::SyntaxError
112
+ warn_local_index_error "YAML parsing error when reading"
113
+ end
114
+
115
+ def warn_local_index_error(reason)
116
+ warn "[relaton] #{reason} file #{file}"
117
+ if url.is_a? String
118
+ warn "[relaton] Considering #{file} file corrupt, re-downloading from #{url}"
119
+ else
120
+ warn "[relaton] Considering #{file} file corrupt, removing it."
121
+ remove
122
+ end
108
123
  end
109
124
 
110
125
  #
@@ -118,7 +133,18 @@ module Relaton
118
133
  entry = zip.get_next_entry
119
134
  index = YAML.safe_load(entry.get_input_stream.read, permitted_classes: [Symbol])
120
135
  save index
121
- index
136
+ warn "[relaton] Downloaded index from #{url}"
137
+ return index if check_format index
138
+
139
+ warn_remote_index_error "Wrong structure of"
140
+ rescue Psych::SyntaxError
141
+ warn_remote_index_error "YAML parsing error when reading"
142
+ end
143
+
144
+ def warn_remote_index_error(reason)
145
+ warn "[relaton] #{reason} newly downloaded file " \
146
+ "at #{file} #{url}, the remote index seems to be invalid." \
147
+ "Please report this issue at https://github.com/relaton/relaton-cli."
122
148
  end
123
149
 
124
150
  #
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Relaton
4
4
  module Index
5
- VERSION = "0.2.4"
5
+ VERSION = "0.2.6"
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.4
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-14 00:00:00.000000000 Z
11
+ date: 2023-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip