eac_fs 0.8.1 → 0.11.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/lib/eac_fs/cached_download.rb +3 -3
- data/lib/eac_fs/contexts.rb +21 -0
- data/lib/eac_fs/logs/file.rb +4 -0
- data/lib/eac_fs/logs.rb +5 -0
- data/lib/eac_fs/patches/module/fs_cache.rb +9 -4
- data/lib/eac_fs/patches/object/fs_cache.rb +16 -6
- data/lib/eac_fs/{cache.rb → storage_tree.rb} +6 -8
- data/lib/eac_fs/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8851f1408994cf816ba9352954d7ef9a8858e8581434f5d14e917f7b9d3dd6bb
|
4
|
+
data.tar.gz: b31e40c894d8cb96cc5d1eae42789e980c4bfe849f47e9c2d0aac8d870b919ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37c02d3e22a2bfd5ffb77014bcca94555e1a41bec612a01d3c306fda460cc29468627ed0b38c508aaae8585d1c7e6e8ec8223c6058bab77008d5f2185c029cf3
|
7
|
+
data.tar.gz: 89405f8115a4479a59953cef8c3df475c052bd40927941b1e6d527c7619e96c90c857dc85931022b0a422b18629feccd14c6e76f76f1dc9d2141c03098038178
|
@@ -3,17 +3,17 @@
|
|
3
3
|
require 'eac_fs/patches'
|
4
4
|
require 'eac_ruby_utils/fs/temp'
|
5
5
|
|
6
|
-
module
|
6
|
+
module EacFs
|
7
7
|
class CachedDownload
|
8
8
|
attr_reader :url, :fs_cache
|
9
9
|
|
10
10
|
def initialize(url, parent_fs_cache = nil)
|
11
11
|
@url = url
|
12
|
-
@fs_cache = (parent_fs_cache || fs_cache).child(url.parameterize)
|
12
|
+
@fs_cache = (parent_fs_cache || fs_cache).child(url.to_s.parameterize)
|
13
13
|
end
|
14
14
|
|
15
15
|
def assert
|
16
|
-
download unless fs_cache.
|
16
|
+
download unless fs_cache.stored?
|
17
17
|
end
|
18
18
|
|
19
19
|
def download
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/context'
|
5
|
+
|
6
|
+
module EacFs
|
7
|
+
class Contexts
|
8
|
+
TYPES = %i[cache config data].freeze
|
9
|
+
|
10
|
+
class << self
|
11
|
+
TYPES.each do |type|
|
12
|
+
class_eval <<~CODE, __FILE__, __LINE__ + 1
|
13
|
+
# @return [EacRubyUtils::Context<EacFs::StorageTree>]
|
14
|
+
def #{type}
|
15
|
+
@#{type} ||= ::EacRubyUtils::Context.new
|
16
|
+
end
|
17
|
+
CODE
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/eac_fs/logs/file.rb
CHANGED
data/lib/eac_fs/logs.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'eac_fs/
|
3
|
+
require 'eac_fs/contexts'
|
4
4
|
|
5
5
|
class Module
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
::EacFs::Contexts::TYPES.each do |type|
|
7
|
+
method_name = "fs_#{type}"
|
8
|
+
class_eval <<~CODE, __FILE__, __LINE__ + 1
|
9
|
+
# @return [EacFs::StorageTree]
|
10
|
+
def #{method_name}
|
11
|
+
::EacFs::Contexts.#{type}.current.child('#{method_name}', *name.split('::'))
|
12
|
+
end
|
13
|
+
CODE
|
9
14
|
end
|
10
15
|
end
|
@@ -1,17 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'eac_fs/contexts'
|
3
4
|
require 'eac_fs/patches/module/fs_cache'
|
4
5
|
|
5
6
|
class Object
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
::EacFs::Contexts::TYPES.each do |type|
|
8
|
+
class_eval <<~CODE, __FILE__, __LINE__ + 1
|
9
|
+
# @return [EacFs::StorageTree]
|
10
|
+
def fs_#{type}
|
11
|
+
oid = fs_object_id_by_type(:'#{type}')
|
12
|
+
oid = [oid.to_s] unless oid.is_a?(::Enumerable)
|
13
|
+
oid.inject(self.class.fs_#{type}) { |a, e| a.child(e.to_s) }
|
14
|
+
end
|
15
|
+
CODE
|
11
16
|
end
|
12
17
|
|
13
18
|
# @return [String, Array<String>]
|
14
|
-
def
|
19
|
+
def fs_object_id
|
15
20
|
raise 'Abstract method hit'
|
16
21
|
end
|
22
|
+
|
23
|
+
def fs_object_id_by_type(type)
|
24
|
+
method = "fs_#{type}_object_id"
|
25
|
+
respond_to?(method) ? send(method) : fs_object_id
|
26
|
+
end
|
17
27
|
end
|
@@ -4,9 +4,7 @@ require 'eac_ruby_utils/core_ext'
|
|
4
4
|
require 'fileutils'
|
5
5
|
|
6
6
|
module EacFs
|
7
|
-
class
|
8
|
-
enable_context
|
9
|
-
|
7
|
+
class StorageTree
|
10
8
|
CONTENT_FILE_NAME = '__content__'
|
11
9
|
|
12
10
|
attr_reader :path
|
@@ -18,19 +16,19 @@ module EacFs
|
|
18
16
|
end
|
19
17
|
|
20
18
|
def clear
|
21
|
-
return unless
|
19
|
+
return unless stored?
|
22
20
|
|
23
21
|
::File.unlink(content_path)
|
24
22
|
end
|
25
23
|
|
26
24
|
def read
|
27
|
-
return nil unless
|
25
|
+
return nil unless stored?
|
28
26
|
|
29
27
|
::File.read(content_path)
|
30
28
|
end
|
31
29
|
|
32
|
-
def
|
33
|
-
write(yield) unless
|
30
|
+
def read_or_store
|
31
|
+
write(yield) unless stored?
|
34
32
|
|
35
33
|
read
|
36
34
|
end
|
@@ -45,7 +43,7 @@ module EacFs
|
|
45
43
|
self.class.new(path, *child_path_parts)
|
46
44
|
end
|
47
45
|
|
48
|
-
def
|
46
|
+
def stored?
|
49
47
|
::File.exist?(content_path)
|
50
48
|
end
|
51
49
|
|
data/lib/eac_fs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eac_fs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Put here the authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: content-type
|
@@ -73,8 +73,8 @@ extensions: []
|
|
73
73
|
extra_rdoc_files: []
|
74
74
|
files:
|
75
75
|
- lib/eac_fs.rb
|
76
|
-
- lib/eac_fs/cache.rb
|
77
76
|
- lib/eac_fs/cached_download.rb
|
77
|
+
- lib/eac_fs/contexts.rb
|
78
78
|
- lib/eac_fs/file_info.rb
|
79
79
|
- lib/eac_fs/logs.rb
|
80
80
|
- lib/eac_fs/logs/file.rb
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- lib/eac_fs/patches/object/fs_cache.rb
|
86
86
|
- lib/eac_fs/patches/pathname.rb
|
87
87
|
- lib/eac_fs/patches/pathname/info.rb
|
88
|
+
- lib/eac_fs/storage_tree.rb
|
88
89
|
- lib/eac_fs/traversable.rb
|
89
90
|
- lib/eac_fs/traverser.rb
|
90
91
|
- lib/eac_fs/version.rb
|