eac_fs 0.16.0 → 0.18.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: 1a300257ce1a101a3b02f89dc5a949eb61f37e6ed235074f911bbe039bae1e65
4
- data.tar.gz: 2c8bb21e251b09eaa07c2cbf9123d4848bb20d94c671a756428458e50078a6dc
3
+ metadata.gz: 5f25c50876ad513b809f7b854f771d54fe659690f0d582b7e70f7c33368d0ac7
4
+ data.tar.gz: 2a16ba681913960960b37b2573684dbeddfd949ee2e161d38927beeeeb8efcd0
5
5
  SHA512:
6
- metadata.gz: 2f57dd6a77ed650bfa10977eb78e168648b0ad5b56472732979dc11cc84ca40a2b5c2d59087ca09996d7d3148efa71c4f1219932668844929a8239deb4c58609
7
- data.tar.gz: b0f1828e81c88fea66ed0630e1a70cc543ba3eda00bd143dabb25620e0a389d2e351a862032fc54dccca1e069e3a0246b29493cb10a2aa0f5ac90b4d6ff0de40
6
+ metadata.gz: 82445c024c62ce7b242a7ac88747a3d00d4bae8c88fe6cb7815ad89166f5f143fb0e73a2e9fe2e7867de6fda46b557bc90abccf57a6b8165c9d2e1c2105f1d24
7
+ data.tar.gz: e3248f5b51b855ec447cc9eb1c80b1f954ee92ffce06b93a37cfe712d9a3f853beb862a1c714cfa1abbf15817115a05e778006462727b6a92bf761f2153dc256
@@ -31,9 +31,9 @@ module EacFs
31
31
  # @param dir [Pathname]
32
32
  # @return [Hash]
33
33
  def build_directory(dir)
34
- dir.children.map do |child|
34
+ dir.children.to_h do |child|
35
35
  [fs_object_basename(child), build(child)]
36
- end.to_h
36
+ end
37
37
  end
38
38
 
39
39
  # @param file [Pathname]
@@ -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
@@ -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,20 +11,44 @@ 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
- def initialize(path)
16
- @magic_string = ::FileMagic.new(FileMagic::MAGIC_MIME).file(path.to_pathname.to_path)
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 [String]
27
+ def description
28
+ magic
29
+ end
30
+
31
+ # @return [Boolean]
32
+ def open?
33
+ ::EacFs::Executables.lsof.command(path).execute.fetch(:exit_code).zero?
34
+ end
35
+
36
+ # @return [String]
37
+ def magic(*flags)
38
+ ::FileMagic.new(*flags).file(path.to_path)
39
+ end
40
+
21
41
  private
22
42
 
23
43
  def content_type_uncached
24
- ::ContentType.parse(magic_string)
44
+ ::ContentType.parse(mime_string)
25
45
  rescue ::Parslet::ParseFailed
26
46
  UNKNOWN_CONTENT_TYPE
27
47
  end
48
+
49
+ # @return [String]
50
+ def mime_string_uncached
51
+ magic(::FileMagic::MAGIC_MIME)
52
+ end
28
53
  end
29
54
  end
data/lib/eac_fs/logs.rb CHANGED
@@ -25,7 +25,7 @@ module EacFs
25
25
 
26
26
  # @return [EacFs::Logs]
27
27
  def clean_all
28
- log_set.values.each(&:clean)
28
+ log_set.each_value(&:clean)
29
29
  end
30
30
 
31
31
  # @return [EacFs::Logs]
@@ -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
- 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
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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_ruby_utils/require_sub'
4
- ::EacRubyUtils.require_sub(__FILE__)
4
+ EacRubyUtils.require_sub(__FILE__)
@@ -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
- 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(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
- # @return [EacFs::StorageTree]
17
- def fs_#{type}_parent
18
- self.class.fs_#{type}
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>]
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_ruby_utils/require_sub'
4
- ::EacRubyUtils.require_sub(__FILE__)
4
+ EacRubyUtils.require_sub(__FILE__)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_ruby_utils/require_sub'
4
- ::EacRubyUtils.require_sub(__FILE__)
4
+ EacRubyUtils.require_sub(__FILE__)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_ruby_utils/require_sub'
4
- ::EacRubyUtils.require_sub(__FILE__)
4
+ EacRubyUtils.require_sub(__FILE__)
@@ -35,7 +35,7 @@ module EacFs
35
35
  end
36
36
 
37
37
  # @return [Object]
38
- def read_or_store_yaml(use_cache = true)
38
+ def read_or_store_yaml(use_cache = true) # rubocop:disable Style/OptionalBooleanParameter
39
39
  write_yaml(yield) unless stored? && use_cache
40
40
 
41
41
  read_yaml
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacFs
4
- VERSION = '0.16.0'
4
+ VERSION = '0.18.0'
5
5
  end
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.16.0
4
+ version: 0.18.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: 2022-11-22 00:00:00.000000000 Z
11
+ date: 2024-07-05 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.107'
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: 0.107.1
39
+ version: '0.122'
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.107'
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: 0.107.1
46
+ version: '0.122'
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.5.1
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.5.1
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: '0'
122
+ version: '2.7'
128
123
  required_rubygems_version: !ruby/object:Gem::Requirement
129
124
  requirements:
130
125
  - - ">="