eac_fs 0.16.0 → 0.17.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: 1a300257ce1a101a3b02f89dc5a949eb61f37e6ed235074f911bbe039bae1e65
4
- data.tar.gz: 2c8bb21e251b09eaa07c2cbf9123d4848bb20d94c671a756428458e50078a6dc
3
+ metadata.gz: 813163bfcc7db2f7f3de31f90f748af9dbd8053a6e67ed6391bf159116c7e7a4
4
+ data.tar.gz: 558e7d9585c101d922338cb80801847e68d57e1f3b3baa29f813467d28be973c
5
5
  SHA512:
6
- metadata.gz: 2f57dd6a77ed650bfa10977eb78e168648b0ad5b56472732979dc11cc84ca40a2b5c2d59087ca09996d7d3148efa71c4f1219932668844929a8239deb4c58609
7
- data.tar.gz: b0f1828e81c88fea66ed0630e1a70cc543ba3eda00bd143dabb25620e0a389d2e351a862032fc54dccca1e069e3a0246b29493cb10a2aa0f5ac90b4d6ff0de40
6
+ metadata.gz: 974627dabc22b66cadb53fe873a89d4723965c530c3dfba5a053b1cff1c4a4636996b6cd8f250c3b9be231fda87156d3e3a32ed796725981c9ce225a72b99eb5
7
+ data.tar.gz: b3779bc6aeabcc1e4c496bcc0e4100959659e8c79c018d63a3de3493e5336d82f0a02f5c675648f780f5b5fa8174f19ebfee9c07567f7d4b82bb33c1b8b089d5
@@ -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,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
- 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 [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
@@ -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.17.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.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: 2022-11-22 00:00:00.000000000 Z
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.107'
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.107'
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.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
  - - ">="