eac_fs 0.12.3 → 0.14.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 +57 -0
- data/lib/eac_fs/comparator/rename_file.rb +15 -0
- data/lib/eac_fs/comparator.rb +18 -0
- data/lib/eac_fs/version.rb +1 -1
- metadata +29 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 67ecee467e1090048cee39cf7ac2466c9c6b5cadd94dc15b8460d941cb7d053a
|
|
4
|
+
data.tar.gz: a980f7eb121bc6c28ca546228e044795a20fd90b224938ed3dfd01d1280cfb69
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bc41798978be925acce17cc05790230ac2f9655f9fc9b7ed86ef6335873d4f98ecf952a0a965acc0b139dfa44724dbbc5baf704adcf96909de6266b7371eb45d
|
|
7
|
+
data.tar.gz: ddb6da66ffe30077ddbcc0f01ed4e30177b2f23d82f2b7e9706697ddfa6258876ee2831839021cc7f1e4f5984c4be51417e3f1b555adb54bcaf1e4159f426cd9
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
|
4
|
+
|
|
5
|
+
module EacFs
|
|
6
|
+
class Comparator
|
|
7
|
+
class Build
|
|
8
|
+
TRUNCATE_FILE_CONTENT = "__TRUNCATED__\n"
|
|
9
|
+
|
|
10
|
+
enable_method_class
|
|
11
|
+
common_constructor :comparator, :root
|
|
12
|
+
delegate :rename_files, :truncate_files, to: :comparator
|
|
13
|
+
|
|
14
|
+
# @return [Hash]
|
|
15
|
+
def result
|
|
16
|
+
build(root)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def build(obj)
|
|
22
|
+
if obj.file?
|
|
23
|
+
build_file(obj)
|
|
24
|
+
elsif obj.directory?
|
|
25
|
+
build_directory(obj)
|
|
26
|
+
else
|
|
27
|
+
raise "Unknown filesystem object \"#{obj}\""
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# @param dir [Pathname]
|
|
32
|
+
# @return [Hash]
|
|
33
|
+
def build_directory(dir)
|
|
34
|
+
dir.children.map do |child|
|
|
35
|
+
[fs_object_basename(child), build(child)]
|
|
36
|
+
end.to_h
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# @param file [Pathname]
|
|
40
|
+
# @return [Hash]
|
|
41
|
+
def build_file(file)
|
|
42
|
+
truncate_file?(file) ? TRUNCATE_FILE_CONTENT : file.read
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# @return [String]
|
|
46
|
+
def fs_object_basename(obj)
|
|
47
|
+
rename_files.inject(obj.basename.to_path) { |a, e| e.apply(a) }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def truncate_file?(file)
|
|
51
|
+
truncate_files.any? do |pattern|
|
|
52
|
+
file.basename.fnmatch?(pattern)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
|
4
|
+
|
|
5
|
+
module EacFs
|
|
6
|
+
class Comparator
|
|
7
|
+
require_sub __FILE__, require_dependency: true
|
|
8
|
+
|
|
9
|
+
enable_immutable
|
|
10
|
+
immutable_accessor :rename_file, :truncate_file, type: :array
|
|
11
|
+
|
|
12
|
+
alias rename_file_push rename_file
|
|
13
|
+
|
|
14
|
+
def rename_file(from, to)
|
|
15
|
+
rename_file_push(::EacFs::Comparator::RenameFile.new(from, to))
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
data/lib/eac_fs/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,57 +1,75 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: eac_fs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.14.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
|
+
date: 2022-10-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: content-type
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.0'
|
|
17
20
|
- - ">="
|
|
18
21
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
22
|
+
version: 0.0.2
|
|
20
23
|
type: :runtime
|
|
21
24
|
prerelease: false
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
26
|
requirements:
|
|
27
|
+
- - "~>"
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '0.0'
|
|
24
30
|
- - ">="
|
|
25
31
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
32
|
+
version: 0.0.2
|
|
27
33
|
- !ruby/object:Gem::Dependency
|
|
28
34
|
name: eac_ruby_utils
|
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
|
30
36
|
requirements:
|
|
31
37
|
- - "~>"
|
|
32
38
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0.
|
|
39
|
+
version: '0.106'
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: 0.106.1
|
|
34
43
|
type: :runtime
|
|
35
44
|
prerelease: false
|
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
46
|
requirements:
|
|
38
47
|
- - "~>"
|
|
39
48
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '0.
|
|
49
|
+
version: '0.106'
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: 0.106.1
|
|
41
53
|
- !ruby/object:Gem::Dependency
|
|
42
54
|
name: ruby-filemagic
|
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
|
44
56
|
requirements:
|
|
57
|
+
- - "~>"
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: '0.7'
|
|
45
60
|
- - ">="
|
|
46
61
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
62
|
+
version: 0.7.3
|
|
48
63
|
type: :runtime
|
|
49
64
|
prerelease: false
|
|
50
65
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
66
|
requirements:
|
|
67
|
+
- - "~>"
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '0.7'
|
|
52
70
|
- - ">="
|
|
53
71
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
72
|
+
version: 0.7.3
|
|
55
73
|
- !ruby/object:Gem::Dependency
|
|
56
74
|
name: eac_ruby_gem_support
|
|
57
75
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -74,6 +92,9 @@ extra_rdoc_files: []
|
|
|
74
92
|
files:
|
|
75
93
|
- lib/eac_fs.rb
|
|
76
94
|
- lib/eac_fs/cached_download.rb
|
|
95
|
+
- lib/eac_fs/comparator.rb
|
|
96
|
+
- lib/eac_fs/comparator/build.rb
|
|
97
|
+
- lib/eac_fs/comparator/rename_file.rb
|
|
77
98
|
- lib/eac_fs/contexts.rb
|
|
78
99
|
- lib/eac_fs/file_info.rb
|
|
79
100
|
- lib/eac_fs/logs.rb
|