relaton-index 0.2.3 → 0.2.5

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: 21befc44c8bd8f0d88e60fe51d5aa5be78e12b8a5857a27ce618bd561ee1aa88
4
- data.tar.gz: c527ce0b9894779d32ccb355f435c8d22b0c7d34355bd8f65bffce58c9512859
3
+ metadata.gz: 505b5d0118ee9844e1486dff3fbd57c1ceec35d609ca022dcb5ba4f121e3c7db
4
+ data.tar.gz: d9c7dd287a036fd2d939cf5d9a5ec6193408fc2c1de24aaa465aa38e2d8ed876
5
5
  SHA512:
6
- metadata.gz: c6984ef1228e1ac5c862c0ed68ba6a8e8c841b9c758fc37d0b32178d8c63bfee6423f169b12c2f80bdb438bbc33596559c980fb8267887aa4f7ccab6d1e87357
7
- data.tar.gz: cda24cb6adef4dab6a51f16b78ed54d239cc76daa41e8ae76a4d2f442b0ec5d430be5da4fd0e8141f21860126f0ebce630d5e828c768b46320e7eb621885a98d
6
+ metadata.gz: fb4cd48d2db8361dbcd8414ce8512e3dc1fe618d16e1d82ac1da53b05b3a505980d691a5a0f0f8cc09856ab38029256bd5e0ca413f7d26f7a8897ca89b9aba17
7
+ data.tar.gz: 9155e1925e674e35a7ee889bb8467c5cb21dcbf7394ba87650ed70f856725431784b6ad90e2433b8250cc61362c742acae9d5523b40d99865a7a3af5f771ed76
@@ -81,13 +81,15 @@ module Relaton
81
81
 
82
82
  def cehck_basic_format(index)
83
83
  keys = %i[file id]
84
- index.none? { |item| item.keys.sort != keys }
84
+ index.all? { |item| item.respond_to?(:keys) && item.keys.sort == keys }
85
85
  end
86
86
 
87
87
  def check_id_format(index)
88
88
  return true if @id_keys.empty?
89
89
 
90
- keys = index.reduce(Set.new) { |acc, item| acc + item[:id].keys }
90
+ keys = index.each_with_object(Set.new) do |item, acc|
91
+ acc.merge item[:id].keys if item[:id].is_a?(Hash)
92
+ end
91
93
  keys == @id_keys.to_set
92
94
  end
93
95
 
@@ -102,7 +104,20 @@ module Relaton
102
104
 
103
105
  index = YAML.safe_load yaml, permitted_classes: [Symbol]
104
106
  return index if check_format index
107
+
108
+ warn_local_index_error "Wrong structure of the"
105
109
  rescue Psych::SyntaxError
110
+ warn_local_index_error "YAML parsing error when reading"
111
+ end
112
+
113
+ def warn_local_index_error(reason)
114
+ warn "[relaton] #{reason} file #{file}"
115
+ if url.is_a? String
116
+ warn "[relaton] Considering #{file} file corrupt, re-downloading from #{url}"
117
+ else
118
+ warn "[relaton] Considering #{file} file corrupt, removing it."
119
+ remove
120
+ end
106
121
  end
107
122
 
108
123
  #
@@ -116,7 +131,18 @@ module Relaton
116
131
  entry = zip.get_next_entry
117
132
  index = YAML.safe_load(entry.get_input_stream.read, permitted_classes: [Symbol])
118
133
  save index
119
- index
134
+ warn "[relaton] Downloaded index from #{url}"
135
+ return index if check_format index
136
+
137
+ warn_remote_index_error "Wrong structure of"
138
+ rescue Psych::SyntaxError
139
+ warn_remote_index_error "YAML parsing error when reading"
140
+ end
141
+
142
+ def warn_remote_index_error(reason)
143
+ warn "[relaton] #{reason} newly downloaded file " \
144
+ "at #{file} #{url}, the remote index seems to be invalid." \
145
+ "Please report this issue at https://github.com/relaton/relaton-cli."
120
146
  end
121
147
 
122
148
  #
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Relaton
4
4
  module Index
5
- VERSION = "0.2.3"
5
+ VERSION = "0.2.5"
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.3
4
+ version: 0.2.5
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-13 00:00:00.000000000 Z
11
+ date: 2023-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip