relaton-index 0.2.2 → 0.2.4

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: bc21a3161ae2d23d6b2178a5947d07c83dd1758f6db4e093340b90f525968edd
4
- data.tar.gz: 8bf654f9260aff06bb3be34e6b14a35adf1280e5d90085a57fc3c608db976b94
3
+ metadata.gz: 8f5ff0818b55748f6a7f41bc1d905055a2226a54f1fdf8e7bdee8f00abda5db1
4
+ data.tar.gz: 76e77fe86f641f9f8f97a7e972562f576583766940d5fd763e784caf4143ef80
5
5
  SHA512:
6
- metadata.gz: faf0f893ec70ae6c5186e6fa2afe5619d9ab4757d6fef73f1637163690a1a371df999e4d85a5af896e8ae2bae479d690891bedc704f5227aa55d52a02f582217
7
- data.tar.gz: b9cf08da7a80849861da0c999d0d603d0b8c1466b93ed0e898d1bdb670bb5e49eb82ce592ba75d0d276d28d0309c3e85cccf5d317263791b16784132b55da8cf
6
+ metadata.gz: 7a6b728ad113d6e994a04ad5058224dfd9084bc8345272f5c71882629cce416f56993e01c909012a8a79e281b44f6f4683b687c1aa2db3744c64d0108bb95820
7
+ data.tar.gz: 28371d4298c344861d2934aa20b7d82f434abecc24913cc284e8231a86d0b9d48a6669336a1a9fb7ffb2c6d769b445dc014ace31efe97bac1ec0524746e2b2bd
@@ -75,15 +75,22 @@ module Relaton
75
75
  #
76
76
  # @return [Boolean] <description>
77
77
  #
78
- def check_format(index) # rubocop:disable Metrics/AbcSize
79
- keys = index.reduce(Set.new) do |acc, item|
80
- if item[:id].is_a?(Hash) && @id_keys.any?
81
- acc + item.keys + item[:id].keys
82
- else
83
- acc + item.keys
84
- end
78
+ def check_format(index)
79
+ cehck_basic_format(index) && check_id_format(index)
80
+ end
81
+
82
+ def cehck_basic_format(index)
83
+ keys = %i[file id]
84
+ index.all? { |item| item.respond_to?(:keys) && item.keys.sort == keys }
85
+ end
86
+
87
+ def check_id_format(index)
88
+ return true if @id_keys.empty?
89
+
90
+ keys = index.each_with_object(Set.new) do |item, acc|
91
+ acc.merge item[:id].keys if item[:id].is_a?(Hash)
85
92
  end
86
- keys == [:id, :file, *@id_keys].to_set
93
+ keys == @id_keys.to_set
87
94
  end
88
95
 
89
96
  #
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Relaton
4
4
  module Index
5
- VERSION = "0.2.2"
5
+ VERSION = "0.2.4"
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.2
4
+ version: 0.2.4
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