relaton-index 0.2.0 → 0.2.1
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 +4 -4
- data/README.adoc +2 -2
- data/lib/relaton/index/file_io.rb +11 -8
- data/lib/relaton/index/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39ea35c85bb825679fc73792345d3c11217e80972f2eb32c1a4cc5b31b1a41de
|
4
|
+
data.tar.gz: eedc5afbe9b1fcbd76763d26b628b510e29a9f0a9c74d1a2bb4ab554b0ffb0f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e420ccb8c3d7eaa8834d02c901b0ff495ec6f16552fb614b81905d15758228553eb399234b2575a6bf905931dc96c11491f90082355c28f5be8ba3fa2a0edb44
|
7
|
+
data.tar.gz: 63971b59580a47e70782a0e6a1b98acb270953b415ed451f2b634a5baebafbc46ea7ca08b83a5a76f5110e95d96af27ba64ab8a63fbc6feb850118553b4b6611
|
data/README.adoc
CHANGED
@@ -33,7 +33,7 @@ Relaton::Index.find_or_create :IHO, url: "https://raw.githubusercontent.com/rela
|
|
33
33
|
Relaton::Index.find_or_create :IHO
|
34
34
|
|
35
35
|
# If the URL or filename is specified and has a new value (different from what it was before), the index object will be recreated.
|
36
|
-
Relaton::Index.find_or_create :IHO, url: nil,
|
36
|
+
Relaton::Index.find_or_create :IHO, url: nil, file: "index.yaml"
|
37
37
|
|
38
38
|
# Remove the index from the pool.
|
39
39
|
Relaton::Index.close :IHO
|
@@ -53,7 +53,7 @@ In this case, the Relaton library creates an index object and adds documents' fi
|
|
53
53
|
index = Relaton::Index.find_or_create :IHO
|
54
54
|
|
55
55
|
# Add a document to the index or update it if it already exists.
|
56
|
-
index.add_or_update
|
56
|
+
index.add_or_update "B-4 2.19.0", "data/b-4_2_19_0.xml"
|
57
57
|
|
58
58
|
# Save the index to the `index.yaml` file in the current directory.
|
59
59
|
index.save
|
@@ -11,10 +11,12 @@ module Relaton
|
|
11
11
|
#
|
12
12
|
# Initialize FileIO
|
13
13
|
#
|
14
|
-
# @param [String] dir local directory in ~/.relaton to store index
|
15
|
-
# @param [String, Boolean, nil] url
|
16
|
-
#
|
17
|
-
#
|
14
|
+
# @param [String] dir falvor specific local directory in ~/.relaton to store index
|
15
|
+
# @param [String, Boolean, nil] url
|
16
|
+
# if String then the URL is used to fetch an index from a Git repository
|
17
|
+
# and save it to the storage (if not exists, or older than 24 hours)
|
18
|
+
# if true then the index is read from the storage (used to remove index file)
|
19
|
+
# if nil then the fiename is used to read and write file (used to create indes in GH actions)
|
18
20
|
#
|
19
21
|
def initialize(dir, url, filename)
|
20
22
|
@dir = dir
|
@@ -26,8 +28,8 @@ module Relaton
|
|
26
28
|
# If url is String, check if index file exists and is not older than 24
|
27
29
|
# hours. If not, fetch index from external repository and save it to
|
28
30
|
# storage.
|
29
|
-
# If url is true,
|
30
|
-
# If url is nil, read index from
|
31
|
+
# If url is true, read index from path to local file.
|
32
|
+
# If url is nil, read index from filename.
|
31
33
|
#
|
32
34
|
# @return [Array<Hash>] index
|
33
35
|
#
|
@@ -36,7 +38,7 @@ module Relaton
|
|
36
38
|
when String
|
37
39
|
check_file || fetch_and_save
|
38
40
|
else
|
39
|
-
read_file
|
41
|
+
read_file || []
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
@@ -72,9 +74,10 @@ module Relaton
|
|
72
74
|
#
|
73
75
|
def read_file
|
74
76
|
yaml = Index.config.storage.read(file)
|
75
|
-
return
|
77
|
+
return unless yaml
|
76
78
|
|
77
79
|
YAML.safe_load yaml, permitted_classes: [Symbol]
|
80
|
+
rescue Psych::SyntaxError
|
78
81
|
end
|
79
82
|
|
80
83
|
#
|
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
|
+
version: 0.2.1
|
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-
|
11
|
+
date: 2023-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|