ehbrs_ruby_utils 0.7.0 → 0.8.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: d1db8f880cc352ae33c4c463b939ed297c85e2a3929e4772d2234ebe496a7fcd
4
- data.tar.gz: 38956ec13fb3d729584be1b37b7d2e7375e8ffb282ac0b30ef1394e06840e34b
3
+ metadata.gz: 61330d9b4828f3813d1430120407527b77f13c1525446441bac3e818b93134a0
4
+ data.tar.gz: ce61e87673cf8e01fa96df9aea63b45829004b9305d0e141f9a764252665edb1
5
5
  SHA512:
6
- metadata.gz: fdf2feaa8744a08c7fdbd5216435b84ce0c8d9332824db70d948b468b2725c818aae84f44875e6fbfdf35dd5e6a37947261567b334a3390cfd038c13682d35f7
7
- data.tar.gz: 8bd6c93afa5dc990675ea276f409411f11f8f99a329722f4d5cdb8371922d5bd99dcb7b0ee0e0243b4d2d44c2349e9dc489003e90adb1aa732c116ab63a1e71d
6
+ metadata.gz: 83fee97906fc1ed7dd110f4c59e4dea81a11efd1697b275691b31b0d34b8326c534f29b069b1647a5eda03d1ef5eebf8fe51ab130dbe97c3a8a83f2e73f7927f
7
+ data.tar.gz: fd6dc95bb3e4ed3b6c536d1f46b3b2e7d605d72e706890140a5cf7034599677d038bb08818889b7020df7899787949c2e3f0a88029b4d4677697775de3d924ab
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EhbrsRubyUtils
4
- VERSION = '0.7.0'
4
+ VERSION = '0.8.0'
5
5
  end
@@ -1,11 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'ostruct'
4
+ require 'eac_ruby_utils/core_ext'
4
5
 
5
6
  module EhbrsRubyUtils
6
7
  module WebUtils
7
8
  module Videos
8
9
  class File < ::SimpleDelegator
10
+ require_sub __FILE__
11
+
9
12
  def initialize(data)
10
13
  super(::OpenStruct.new(data))
11
14
  end
@@ -14,12 +17,15 @@ module EhbrsRubyUtils
14
17
  ::File.exist?(original_path)
15
18
  end
16
19
 
17
- def path_changed?
18
- original_path != new_path
20
+ def move(target_dir)
21
+ ::EhbrsRubyUtils::WebUtils::Videos::File::Rename.new(
22
+ self,
23
+ target_dir.to_pathname.join(original_path.to_pathname.relative_path_from(root_path))
24
+ ).perform
19
25
  end
20
26
 
21
- def can_rename?
22
- ::File.exist?(original_path) && !::File.exist?(new_path)
27
+ def path_changed?
28
+ original_path != new_path
23
29
  end
24
30
 
25
31
  def remove
@@ -29,10 +35,7 @@ module EhbrsRubyUtils
29
35
  end
30
36
 
31
37
  def rename
32
- return unless can_rename?
33
-
34
- ::FileUtils.mkdir_p(::File.dirname(new_path))
35
- ::FileUtils.mv(original_path, new_path)
38
+ ::EhbrsRubyUtils::WebUtils::Videos::File::Rename.new(self, new_path).perform
36
39
  end
37
40
  end
38
41
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EhbrsRubyUtils
6
+ module WebUtils
7
+ module Videos
8
+ class File < ::SimpleDelegator
9
+ class Rename
10
+ common_constructor :file, :target_path
11
+
12
+ delegate :original_path, to: :file
13
+
14
+ def can_rename?
15
+ ::File.exist?(original_path) && !::File.exist?(target_path)
16
+ end
17
+
18
+ def perform
19
+ return unless can_rename?
20
+
21
+ ::FileUtils.mkdir_p(::File.dirname(target_path))
22
+ ::FileUtils.mv(original_path, target_path)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ 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.7.0
4
+ version: 0.8.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-07-29 00:00:00.000000000 Z
11
+ date: 2021-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_ruby_utils
@@ -93,6 +93,7 @@ files:
93
93
  - lib/ehbrs_ruby_utils/web_utils/instance.rb
94
94
  - lib/ehbrs_ruby_utils/web_utils/videos.rb
95
95
  - lib/ehbrs_ruby_utils/web_utils/videos/file.rb
96
+ - lib/ehbrs_ruby_utils/web_utils/videos/file/rename.rb
96
97
  - lib/ehbrs_ruby_utils/web_utils/videos/files_list.rb
97
98
  homepage:
98
99
  licenses: []