relaton-index 0.2.0 → 0.2.1

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: 0eaf31518d3ecfb78041891165d24d8f0e9673d2aebcfa02608694ec9f562843
4
- data.tar.gz: 206c0f5fcf0b5336ff186f35da3efc79fda86cf25c93f1c499dd525cccdd6128
3
+ metadata.gz: 39ea35c85bb825679fc73792345d3c11217e80972f2eb32c1a4cc5b31b1a41de
4
+ data.tar.gz: eedc5afbe9b1fcbd76763d26b628b510e29a9f0a9c74d1a2bb4ab554b0ffb0f0
5
5
  SHA512:
6
- metadata.gz: 3426d0303d776d0c7ecaeb17bf957a20228858ae859f85aec02d52dc833d643ead02cd14c522d6fcecc72b9f920e2efbc3667f31c86e6dcd363ebc4ef9eae516
7
- data.tar.gz: 0e8809f80cc34c92100a081917ce561ccaeb287e9002171f558d62e0c6148ac68a5b4b72f96e8720815f4d3be9390cda026fe39b08c3ba0895706c15a74e8865
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, filename: "index.yaml"
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 id: "B-4 2.19.0", file: "data/b-4_2_19_0.xml"
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 git repository URL to fetch index from
16
- # (if not exists, or older than 24 hours) or nil if index is used to
17
- # index files
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, remove index from storage.
30
- # If url is nil, read index from file.
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 [] unless yaml
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
  #
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Relaton
4
4
  module Index
5
- VERSION = "0.2.0"
5
+ VERSION = "0.2.1"
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.0
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-05-14 00:00:00.000000000 Z
11
+ date: 2023-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip