relaton-index 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +3 -3
- data/lib/relaton/index/file_io.rb +24 -6
- data/lib/relaton/index/type.rb +1 -1
- 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: 116ce97493b2532df6617749a9b8b29c815222450a9a8195850c25f3326fcce1
|
4
|
+
data.tar.gz: 6ee22048d4b694b6055d5e5d866afb4ea8c69343bc9b9804fe42f9de9ad066c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b497db789344edc0376b295ae27551c2240062bc882f71164f52e82cac453b724dc17c3ca2f12152d34967ad30f4afea481875f28bed4913f57923e84b327fc3
|
7
|
+
data.tar.gz: 3e8f5f10253631234ed6645785382537318265de9f12eb956cb4eb056bf893bc13147bc1c1c9566e43a4065ad7335d1a6928c206418ad8f2138a50de60181e68
|
data/README.adoc
CHANGED
@@ -61,11 +61,11 @@ index.save
|
|
61
61
|
|
62
62
|
=== Searching
|
63
63
|
|
64
|
-
In this case, the Relaton library should create an index object and search for a document by reference. The gem looks for the `.relaton/[TYPE]/index.yaml` file in the user's home directory. The `[TYPE]` is one of downcased ISO, IEC, IHO, etc. If the file is not found or is older than 24 hours then it will be downloaded from the URL specified in the `find_or_create` method.
|
64
|
+
In this case, the Relaton library should create an index object and search for a document by reference. The gem looks for the `.relaton/[TYPE]/index.yaml` file in the user's home directory. The `[TYPE]` is one of downcased ISO, IEC, IHO, etc. If the file is not found or is older than 24 hours then it will be downloaded from the URL specified in the `find_or_create` method. The URL can be specified as `true` if the index should not be fetched from the URL.
|
65
65
|
|
66
66
|
[source,ruby]
|
67
67
|
----
|
68
|
-
# Create a new index object or fetch an existing one. URL should be specified. If the index file is not found or is older than 24 hours, it will be downloaded from the URL. By default, the index is saved as `index.yaml` file to the `/[HOME]/.relaton/iho/` folder.
|
68
|
+
# Create a new index object or fetch an existing one. URL should be specified. If the index file is not found or is older than 24 hours, it will be downloaded from the URL. By default, the index is saved as `index.yaml` file to the `/[HOME]/.relaton/iho/` folder. If the URL is specified as `true`, the index won't be fetched from the URL.
|
69
69
|
index = Relaton::Index.find_or_create :IHO, url: "https://raw.githubusercontent.com/relaton/relaton-data-iho/master/index.zip"
|
70
70
|
|
71
71
|
|
@@ -96,7 +96,7 @@ This method removes the index file. The index object is cleared and can be used
|
|
96
96
|
|
97
97
|
[source,ruby]
|
98
98
|
----
|
99
|
-
index.
|
99
|
+
index.remove_file
|
100
100
|
----
|
101
101
|
|
102
102
|
=== Configuration
|
@@ -12,7 +12,7 @@ module Relaton
|
|
12
12
|
# Initialize FileIO
|
13
13
|
#
|
14
14
|
# @param [String] dir local directory in ~/.relaton to store index
|
15
|
-
# @param [String, nil] url git repository URL to fetch index from
|
15
|
+
# @param [String, Boolean, nil] url git repository URL to fetch index from
|
16
16
|
# (if not exists, or older than 24 hours) or nil if index is used to
|
17
17
|
# index files
|
18
18
|
#
|
@@ -23,20 +23,37 @@ module Relaton
|
|
23
23
|
end
|
24
24
|
|
25
25
|
#
|
26
|
-
#
|
26
|
+
# If url is String, check if index file exists and is not older than 24
|
27
|
+
# hours. If not, fetch index from external repository and save it to
|
28
|
+
# storage.
|
29
|
+
# If url is true, remove index from storage.
|
30
|
+
# If url is nil, read index from file.
|
27
31
|
#
|
28
32
|
# @return [Array<Hash>] index
|
29
33
|
#
|
30
34
|
def read
|
31
|
-
|
32
|
-
|
35
|
+
case url
|
36
|
+
when String
|
37
|
+
@file ||= path_to_local_file
|
33
38
|
check_file || fetch_and_save
|
39
|
+
when true
|
40
|
+
@file ||= path_to_local_file
|
41
|
+
read_file
|
34
42
|
else
|
35
43
|
@file ||= @filename
|
36
44
|
read_file
|
37
45
|
end
|
38
46
|
end
|
39
47
|
|
48
|
+
#
|
49
|
+
# Create path to local file
|
50
|
+
#
|
51
|
+
# @return [<Type>] <description>
|
52
|
+
#
|
53
|
+
def path_to_local_file
|
54
|
+
File.join(Index.config.storage_dir, ".relaton", @dir, @filename)
|
55
|
+
end
|
56
|
+
|
40
57
|
#
|
41
58
|
# Check if index file exists and is not older than 24 hours
|
42
59
|
#
|
@@ -89,10 +106,11 @@ module Relaton
|
|
89
106
|
#
|
90
107
|
# Remove index file from storage
|
91
108
|
#
|
92
|
-
# @return [
|
109
|
+
# @return [Array]
|
93
110
|
#
|
94
111
|
def remove
|
95
|
-
Index.config.storage.remove @
|
112
|
+
Index.config.storage.remove @filename
|
113
|
+
[]
|
96
114
|
end
|
97
115
|
end
|
98
116
|
end
|
data/lib/relaton/index/type.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.9
|
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-
|
11
|
+
date: 2023-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|