eac_fs 0.16.0 → 0.17.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 +4 -4
- data/lib/eac_fs/comparator/build.rb +2 -2
- data/lib/eac_fs/contexts.rb +3 -3
- data/lib/eac_fs/executables.rb +24 -0
- data/lib/eac_fs/file_info.rb +18 -3
- data/lib/eac_fs/logs.rb +1 -1
- data/lib/eac_fs/patches/module/fs_cache.rb +3 -6
- data/lib/eac_fs/patches/module.rb +1 -1
- data/lib/eac_fs/patches/object/fs_cache.rb +8 -12
- data/lib/eac_fs/patches/object.rb +1 -1
- data/lib/eac_fs/patches/pathname.rb +1 -1
- data/lib/eac_fs/patches.rb +1 -1
- data/lib/eac_fs/storage_tree.rb +1 -1
- data/lib/eac_fs/version.rb +1 -1
- metadata +8 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 813163bfcc7db2f7f3de31f90f748af9dbd8053a6e67ed6391bf159116c7e7a4
|
4
|
+
data.tar.gz: 558e7d9585c101d922338cb80801847e68d57e1f3b3baa29f813467d28be973c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 974627dabc22b66cadb53fe873a89d4723965c530c3dfba5a053b1cff1c4a4636996b6cd8f250c3b9be231fda87156d3e3a32ed796725981c9ce225a72b99eb5
|
7
|
+
data.tar.gz: b3779bc6aeabcc1e4c496bcc0e4100959659e8c79c018d63a3de3493e5336d82f0a02f5c675648f780f5b5fa8174f19ebfee9c07567f7d4b82bb33c1b8b089d5
|
data/lib/eac_fs/contexts.rb
CHANGED
@@ -11,9 +11,9 @@ module EacFs
|
|
11
11
|
TYPES.each do |type|
|
12
12
|
class_eval <<~CODE, __FILE__, __LINE__ + 1
|
13
13
|
# @return [EacRubyUtils::Context<EacFs::StorageTree>]
|
14
|
-
def #{type}
|
15
|
-
@#{type} ||= ::EacRubyUtils::Context.new
|
16
|
-
end
|
14
|
+
def #{type} # def cache
|
15
|
+
@#{type} ||= ::EacRubyUtils::Context.new # @cache ||= ::EacRubyUtils::Context.new
|
16
|
+
end # end
|
17
17
|
CODE
|
18
18
|
end
|
19
19
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/envs'
|
5
|
+
|
6
|
+
module EacFs
|
7
|
+
module Executables
|
8
|
+
class << self
|
9
|
+
enable_simple_cache
|
10
|
+
|
11
|
+
# @return [EacRubyUtils::Envs::Local]
|
12
|
+
def env
|
13
|
+
::EacRubyUtils::Envs.local
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
# @return [EacRubyUtils::Envs::Executable]
|
19
|
+
def lsof_uncached
|
20
|
+
env.executable('lsof', '-v')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/eac_fs/file_info.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'eac_fs/executables'
|
3
4
|
require 'eac_ruby_utils/core_ext'
|
4
5
|
require 'content-type'
|
5
6
|
require 'filemagic'
|
@@ -10,14 +11,23 @@ module EacFs
|
|
10
11
|
UNKNOWN_CONTENT_TYPE = ::ContentType.parse(UNKNOWN_CONTENT_TYPE_STRING)
|
11
12
|
|
12
13
|
enable_simple_cache
|
13
|
-
attr_reader :magic_string
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
# @!attribute [r] path
|
16
|
+
# @return [Pathname]
|
17
|
+
|
18
|
+
# @!method initialize(path)
|
19
|
+
# @param path [Pathname]
|
20
|
+
common_constructor :path do
|
21
|
+
self.path = path.to_pathname
|
17
22
|
end
|
18
23
|
|
19
24
|
delegate :charset, :mime_type, :subtype, :type, to: :content_type
|
20
25
|
|
26
|
+
# @return [Boolean]
|
27
|
+
def open?
|
28
|
+
::EacFs::Executables.lsof.command(path).execute.fetch(:exit_code).zero?
|
29
|
+
end
|
30
|
+
|
21
31
|
private
|
22
32
|
|
23
33
|
def content_type_uncached
|
@@ -25,5 +35,10 @@ module EacFs
|
|
25
35
|
rescue ::Parslet::ParseFailed
|
26
36
|
UNKNOWN_CONTENT_TYPE
|
27
37
|
end
|
38
|
+
|
39
|
+
# @return [String]
|
40
|
+
def magic_string_uncached
|
41
|
+
::FileMagic.new(FileMagic::MAGIC_MIME).file(path.to_path)
|
42
|
+
end
|
28
43
|
end
|
29
44
|
end
|
data/lib/eac_fs/logs.rb
CHANGED
@@ -5,11 +5,8 @@ require 'eac_fs/contexts'
|
|
5
5
|
class Module
|
6
6
|
::EacFs::Contexts::TYPES.each do |type|
|
7
7
|
method_name = "fs_#{type}"
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
::EacFs::Contexts.#{type}.current.child('#{method_name}', *name.split('::'))
|
12
|
-
end
|
13
|
-
CODE
|
8
|
+
define_method method_name do
|
9
|
+
::EacFs::Contexts.send(type).current.child(method_name, *name.split('::'))
|
10
|
+
end
|
14
11
|
end
|
15
12
|
end
|
@@ -5,19 +5,15 @@ require 'eac_fs/patches/module/fs_cache'
|
|
5
5
|
|
6
6
|
class Object
|
7
7
|
::EacFs::Contexts::TYPES.each do |type|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
oid.inject(fs_#{type}_parent) { |a, e| a.child(e.to_s) }
|
14
|
-
end
|
8
|
+
define_method "fs_#{type}" do
|
9
|
+
oid = fs_object_id_by_type(:"\#{type}")
|
10
|
+
oid = [oid.to_s] unless oid.is_a?(::Enumerable)
|
11
|
+
oid.inject(send("fs_#{type}_parent")) { |a, e| a.child(e.to_s) }
|
12
|
+
end
|
15
13
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
CODE
|
14
|
+
define_method "fs_#{type}_parent" do
|
15
|
+
self.class.send("fs_#{type}")
|
16
|
+
end
|
21
17
|
end
|
22
18
|
|
23
19
|
# @return [String, Array<String>]
|
data/lib/eac_fs/patches.rb
CHANGED
data/lib/eac_fs/storage_tree.rb
CHANGED
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.17.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: 2023-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: content-type
|
@@ -36,20 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '0.
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: 0.107.1
|
39
|
+
version: '0.120'
|
43
40
|
type: :runtime
|
44
41
|
prerelease: false
|
45
42
|
version_requirements: !ruby/object:Gem::Requirement
|
46
43
|
requirements:
|
47
44
|
- - "~>"
|
48
45
|
- !ruby/object:Gem::Version
|
49
|
-
version: '0.
|
50
|
-
- - ">="
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: 0.107.1
|
46
|
+
version: '0.120'
|
53
47
|
- !ruby/object:Gem::Dependency
|
54
48
|
name: ruby-filemagic
|
55
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,14 +70,14 @@ dependencies:
|
|
76
70
|
requirements:
|
77
71
|
- - "~>"
|
78
72
|
- !ruby/object:Gem::Version
|
79
|
-
version: 0.
|
73
|
+
version: '0.9'
|
80
74
|
type: :development
|
81
75
|
prerelease: false
|
82
76
|
version_requirements: !ruby/object:Gem::Requirement
|
83
77
|
requirements:
|
84
78
|
- - "~>"
|
85
79
|
- !ruby/object:Gem::Version
|
86
|
-
version: 0.
|
80
|
+
version: '0.9'
|
87
81
|
description:
|
88
82
|
email:
|
89
83
|
executables: []
|
@@ -97,6 +91,7 @@ files:
|
|
97
91
|
- lib/eac_fs/comparator/rename_file.rb
|
98
92
|
- lib/eac_fs/contexts.rb
|
99
93
|
- lib/eac_fs/core_ext.rb
|
94
|
+
- lib/eac_fs/executables.rb
|
100
95
|
- lib/eac_fs/file_info.rb
|
101
96
|
- lib/eac_fs/logs.rb
|
102
97
|
- lib/eac_fs/logs/file.rb
|
@@ -124,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
119
|
requirements:
|
125
120
|
- - ">="
|
126
121
|
- !ruby/object:Gem::Version
|
127
|
-
version: '
|
122
|
+
version: '2.7'
|
128
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
124
|
requirements:
|
130
125
|
- - ">="
|