relaton-index 0.1.9 → 0.2.0

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: 116ce97493b2532df6617749a9b8b29c815222450a9a8195850c25f3326fcce1
4
- data.tar.gz: 6ee22048d4b694b6055d5e5d866afb4ea8c69343bc9b9804fe42f9de9ad066c2
3
+ metadata.gz: 0eaf31518d3ecfb78041891165d24d8f0e9673d2aebcfa02608694ec9f562843
4
+ data.tar.gz: 206c0f5fcf0b5336ff186f35da3efc79fda86cf25c93f1c499dd525cccdd6128
5
5
  SHA512:
6
- metadata.gz: b497db789344edc0376b295ae27551c2240062bc882f71164f52e82cac453b724dc17c3ca2f12152d34967ad30f4afea481875f28bed4913f57923e84b327fc3
7
- data.tar.gz: 3e8f5f10253631234ed6645785382537318265de9f12eb956cb4eb056bf893bc13147bc1c1c9566e43a4065ad7335d1a6928c206418ad8f2138a50de60181e68
6
+ metadata.gz: 3426d0303d776d0c7ecaeb17bf957a20228858ae859f85aec02d52dc833d643ead02cd14c522d6fcecc72b9f920e2efbc3667f31c86e6dcd363ebc4ef9eae516
7
+ data.tar.gz: 0e8809f80cc34c92100a081917ce561ccaeb287e9002171f558d62e0c6148ac68a5b4b72f96e8720815f4d3be9390cda026fe39b08c3ba0895706c15a74e8865
@@ -34,17 +34,16 @@ module Relaton
34
34
  def read
35
35
  case url
36
36
  when String
37
- @file ||= path_to_local_file
38
37
  check_file || fetch_and_save
39
- when true
40
- @file ||= path_to_local_file
41
- read_file
42
38
  else
43
- @file ||= @filename
44
39
  read_file
45
40
  end
46
41
  end
47
42
 
43
+ def file
44
+ @file ||= url ? path_to_local_file : @filename
45
+ end
46
+
48
47
  #
49
48
  # Create path to local file
50
49
  #
@@ -60,7 +59,7 @@ module Relaton
60
59
  # @return [Array<Hash>, nil] index or nil
61
60
  #
62
61
  def check_file
63
- ctime = Index.config.storage.ctime(@file)
62
+ ctime = Index.config.storage.ctime(file)
64
63
  return unless ctime && ctime > Time.now - 86400
65
64
 
66
65
  read_file
@@ -72,7 +71,7 @@ module Relaton
72
71
  # @return [Array<Hash>] index
73
72
  #
74
73
  def read_file
75
- yaml = Index.config.storage.read(@file)
74
+ yaml = Index.config.storage.read(file)
76
75
  return [] unless yaml
77
76
 
78
77
  YAML.safe_load yaml, permitted_classes: [Symbol]
@@ -100,7 +99,7 @@ module Relaton
100
99
  # @return [void]
101
100
  #
102
101
  def save(index)
103
- Index.config.storage.write @file, index.to_yaml
102
+ Index.config.storage.write file, index.to_yaml
104
103
  end
105
104
 
106
105
  #
@@ -109,7 +108,7 @@ module Relaton
109
108
  # @return [Array]
110
109
  #
111
110
  def remove
112
- Index.config.storage.remove @filename
111
+ Index.config.storage.remove file
113
112
  []
114
113
  end
115
114
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Relaton
4
4
  module Index
5
- VERSION = "0.1.9"
5
+ VERSION = "0.2.0"
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.1.9
4
+ version: 0.2.0
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-13 00:00:00.000000000 Z
11
+ date: 2023-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip