ehbrs_ruby_utils 0.10.0 → 0.11.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: e525be69cfe63696e72dc2184618e53ab5d092cb330ea999a0cc7c1593b59a09
4
- data.tar.gz: 3bc91b8b5660eef3fd427f3795f4c7191b4bc1f253cd6cbad4d84b59686997d0
3
+ metadata.gz: 230878af735547a11e32b70f8c142dcc5adb581ea9b00ced816b7944b16ca532
4
+ data.tar.gz: e28ef687a67b61e17066721e725cfdb6fe8daa62f886e513f1750f4a013a4835
5
5
  SHA512:
6
- metadata.gz: 8dba5f9914093130cc606c99ed44e5dc88967dc7423cd8843d89111636ccd70d7a2570adfa087d5c6148347ffd03dfbc9efda4b107c88e7b1dac0fde2485f96b
7
- data.tar.gz: 0dbfef1d8c97cc3179789d9fcc3c1dffcaad87154e697d5a04d514c2cdb737bbb4350702e3f9846cb8057f18238bf7907acfd073c1372097d77b63e04ab4507d
6
+ metadata.gz: 9663bc98612d1f83e1654a3f518c6319d12395528c01392049360fc2eca89c727e7c5e8d4acfec04ba8062bf6601cbebc45576203ac78adf3f15b3826c303d67
7
+ data.tar.gz: '0805245a0e679bfdeeb3be0d621acd8daa5765042e697922d6e75c69f9d58c8fed91e7722ea4903cf3f97106a10b737a950f5f02210c3d6d2c2d5aff2dbba752'
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/files/info'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module EhbrsRubyUtils
7
+ module Fs
8
+ class CompressedPackage < ::Avm::Files::Info
9
+ MIME_TYPES = {
10
+ 'application/zip' => :zip,
11
+ 'application/x-7z-compressed' => :sevenzip,
12
+ 'application/x-rar' => :rar,
13
+ 'application/x-tar' => :tar
14
+ }.freeze
15
+
16
+ def extract_to(target)
17
+ target = target.to_pathname
18
+ target.mkpath
19
+ sub_extract_to(target)
20
+ end
21
+
22
+ private
23
+
24
+ def sub_extract_to(target)
25
+ MIME_TYPES[content_type.mime_type].if_present do |v|
26
+ return send("#{v}_extract_command", target).execute!
27
+ end
28
+ raise "Unknown how to extract \"#{path}\" (#{content_type})"
29
+ end
30
+
31
+ def sevenzip_extract_command(target_dir)
32
+ ::Ehbrs::Executables.sevenzip.command('x', path, '-o', target_dir)
33
+ end
34
+
35
+ def tar_extract_command(target_dir)
36
+ ::Ehbrs::Executables.tar.command('-xf', path, '-C', target_dir)
37
+ end
38
+
39
+ def rar_extract_command(target_dir)
40
+ ::Ehbrs::Executables.rar.command('x', path.expand_path).chdir(target_dir)
41
+ end
42
+
43
+ def zip_extract_command(target_dir)
44
+ ::Ehbrs::Executables.unzip.command(path, '-d', target_dir)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'ehbrs_ruby_utils/fs/selected/build_file'
5
+
6
+ module EhbrsRubyUtils
7
+ module Fs
8
+ class Selected
9
+ class Build
10
+ DEFAULT_TARGET_BASENAME_PROC = ::Proc.new { |basename| basename }
11
+
12
+ attr_reader :selected, :target_dir, :target_basename_proc
13
+
14
+ def initialize(selected, target_dir, &target_basename_proc)
15
+ @selected = selected
16
+ @target_dir = target_dir.to_pathname
17
+ @target_basename_proc = target_basename_proc.presence || DEFAULT_TARGET_BASENAME_PROC
18
+ end
19
+
20
+ def perform
21
+ clear_target_dir
22
+ link_selected_found
23
+ end
24
+
25
+ private
26
+
27
+ def clear_target_dir
28
+ target_dir.children.each do |c|
29
+ c.unlink if c.symlink? && c.directory?
30
+ end
31
+ end
32
+
33
+ def link_selected_found
34
+ selected.found.each do |found|
35
+ ::EhbrsRubyUtils::Fs::Selected::BuildFile.new(self, found).perform
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EhbrsRubyUtils
6
+ module Fs
7
+ class Selected
8
+ class BuildFile
9
+ common_constructor :build, :path do
10
+ self.path = path.to_pathname
11
+ end
12
+
13
+ def perform
14
+ target_path.make_symlink(path)
15
+ end
16
+
17
+ def target_path
18
+ build.target_dir.join(target_basename)
19
+ end
20
+
21
+ def target_basename
22
+ build.target_basename_proc.call(path.basename.to_path)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EhbrsRubyUtils
6
+ module Fs
7
+ class Selected
8
+ require_sub __FILE__
9
+ DEFAULT_FILENAME = '.selected'
10
+
11
+ enable_listable
12
+ enable_simple_cache
13
+ lists.add_symbol :option, :filename, :target_name_builder
14
+ common_constructor :root_path, :options, default: [{}] do
15
+ self.root_path = root_path.to_pathname
16
+ self.options = self.class.lists.option.hash_keys_validate!(options)
17
+ end
18
+
19
+ def build(target_dir)
20
+ ::EhbrsRubyUtils::Fs::Selected::Build.new(self, target_dir)
21
+ end
22
+
23
+ def filename
24
+ options[OPTION_FILENAME].if_present(DEFAULT_FILENAME)
25
+ end
26
+
27
+ private
28
+
29
+ # @return [Pathname]
30
+ def found_uncached
31
+ root_path.glob("**/#{filename}").map(&:parent).sort
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EhbrsRubyUtils
6
+ # Filesystem utilities.
7
+ module Fs
8
+ require_sub __FILE__
9
+ end
10
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EhbrsRubyUtils
4
- VERSION = '0.10.0'
4
+ VERSION = '0.11.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ehbrs_ruby_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo H. Bogoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-21 00:00:00.000000000 Z
11
+ date: 2021-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -30,6 +30,26 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 0.8.5
33
+ - !ruby/object:Gem::Dependency
34
+ name: avm
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.3'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.3.2
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '0.3'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.3.2
33
53
  - !ruby/object:Gem::Dependency
34
54
  name: eac_ruby_utils
35
55
  requirement: !ruby/object:Gem::Requirement
@@ -131,6 +151,11 @@ files:
131
151
  - lib/ehbrs_ruby_utils.rb
132
152
  - lib/ehbrs_ruby_utils/executables.rb
133
153
  - lib/ehbrs_ruby_utils/finances/bb_browser/docker_image.rb
154
+ - lib/ehbrs_ruby_utils/fs.rb
155
+ - lib/ehbrs_ruby_utils/fs/compressed_package.rb
156
+ - lib/ehbrs_ruby_utils/fs/selected.rb
157
+ - lib/ehbrs_ruby_utils/fs/selected/build.rb
158
+ - lib/ehbrs_ruby_utils/fs/selected/build_file.rb
134
159
  - lib/ehbrs_ruby_utils/music.rb
135
160
  - lib/ehbrs_ruby_utils/patches/object/template.rb
136
161
  - lib/ehbrs_ruby_utils/version.rb