eac_fs 0.9.0 → 0.10.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e852c4bca2367df238571d8d843e2440fe0c7e91f564dab685f4ea1e5188d7a2
|
4
|
+
data.tar.gz: aa31fa42eedb2bb8ed49642dadd57d2c548fca7c484e9d0e766bf3c8712f1f44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2f4aabd8d31321f475f67545db56fa49fdc54bf46fcb007478589e1d365fb45050dc0f988536c7e3232b8839d9b3a72a1c2ce612bfcc1ddd4a0481cc000610a
|
7
|
+
data.tar.gz: c89c848cb937e1bb100584d7974180a7dd8725d8b233837ee04ae12f649fd424966a7b82e29dd2fdb1f64886e3a9f18b844a46e42cfbdd191a9197336f180860
|
@@ -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
|
@@ -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
30
|
def read_or_cache
|
33
|
-
write(yield) unless
|
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.10.0
|
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-01-24 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
|