avm-files 0.6.2 → 0.7.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: 4599f3e55314cbcb23c4f09ae26f61e2ccd83daf14df7c7fd37637b3478b6fa2
4
- data.tar.gz: c8fe726f1184eac42b15d9a39f19bdbb780681ab3cfc73af322645ef05704e08
3
+ metadata.gz: a1be6222438f1634817d7dd940ecdd13176a121b118b0d7c2b8b381bf7c0e0da
4
+ data.tar.gz: eb94719a18444b4008a1774871a7154133a65a1e5839764340250e4f284b138a
5
5
  SHA512:
6
- metadata.gz: df549d9a43bc0f5f8a22354aa4884da9c19684a56254d8e03a93f6b658436b18d769d364eac4773c462db330afdb4686683784d515e315fe5b94ad93288eacdf
7
- data.tar.gz: e65a35c8cc5114412bf2336002e729b69a80d49f647480b4475b6b5d8763ea1500fd925c98d356332c9c14fbc6c19dc4374dfdf0fc8cb6903982fe014a24ca9d
6
+ metadata.gz: db17f17620d7924812c35bf65c01442eddad46569a37ed40bbece6f63671fc25ea3ee25faa9d6830a377dfce957d77319260f9b2f4558e0f0cad803590f18250
7
+ data.tar.gz: e0bf2f93667968428c926aae9ddcd665b9e48f68d311e0f00985b0bb2bf0cae835a567dbef253b0c34332c9e3bf38bb70a10313ad311d4f2f8530df654c81677
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+
5
+ module Avm
6
+ module Files
7
+ module RunnerWith
8
+ module FilesystemRenamer
9
+ common_concern do
10
+ runner_with :confirmation, :filesystem_traverser
11
+ prepend PrependMethods
12
+ end
13
+
14
+ class RenameFile
15
+ enable_speaker
16
+ common_constructor :runner, :file
17
+ delegate :path, :target_path, :valid?, to: :file
18
+
19
+ CONFIRM_MESSAGE = 'Rename?'
20
+
21
+ def show
22
+ if rename?
23
+ puts [target_path_to_s, '<='.green, path_to_s].join(' ')
24
+ else
25
+ puts path_to_s
26
+ end
27
+ end
28
+
29
+ def rename
30
+ return unless rename?
31
+
32
+ show
33
+ do_rename if runner.confirm?(CONFIRM_MESSAGE)
34
+ end
35
+
36
+ # @return [Boolean]
37
+ def rename?
38
+ path.to_pathname != target_path.to_pathname
39
+ end
40
+
41
+ private
42
+
43
+ def do_rename
44
+ ::FileUtils.mv(path, target_path)
45
+ end
46
+
47
+ # @return [String]
48
+ def path_to_s
49
+ path.basename.to_path.light_black
50
+ end
51
+
52
+ # @return [String]
53
+ def target_path_to_s
54
+ target_path.relative_path_from(path.dirname).to_path
55
+ end
56
+ end
57
+
58
+ module PrependMethods
59
+ # @param path [Pathname]
60
+ # @return [void]
61
+ def traverser_check_file(path)
62
+ file = RenameFile.new(self, file_class.new(path))
63
+ files << file if file.valid?
64
+ end
65
+ end
66
+
67
+ FILE_WRAPPER_CLASS_BASENAME = 'FileWrapper'
68
+
69
+ # @return [Class]
70
+ def file_class
71
+ self.class.const_get(FILE_WRAPPER_CLASS_BASENAME)
72
+ end
73
+
74
+ # @return [void]
75
+ def run_filesystem_renamer
76
+ self.files = []
77
+ run_filesystem_traverser
78
+ show_files
79
+ rename_files
80
+ success 'Done'
81
+ end
82
+
83
+ # @return [void]
84
+ def show_files
85
+ infov 'Files found', files.count
86
+ files.each(&:show)
87
+ end
88
+
89
+ # @return [void]
90
+ def rename_files
91
+ return if parsed.no? || files.none?(&:rename?)
92
+
93
+ infom 'Renaming files...'
94
+ files.each(&:rename)
95
+ end
96
+
97
+ private
98
+
99
+ attr_accessor :files
100
+ end
101
+ end
102
+ end
103
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Files
5
- VERSION = '0.6.2'
5
+ VERSION = '0.7.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-files
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.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: 2023-05-04 00:00:00.000000000 Z
11
+ date: 2024-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm
@@ -16,68 +16,62 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.67'
19
+ version: '0.84'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.67.1
22
+ version: 0.84.2
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: '0.67'
29
+ version: '0.84'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.67.1
32
+ version: 0.84.2
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: eac_cli
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.30'
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: 0.30.1
39
+ version: '0.40'
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.30'
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: 0.30.1
46
+ version: '0.40'
53
47
  - !ruby/object:Gem::Dependency
54
48
  name: eac_fs
55
49
  requirement: !ruby/object:Gem::Requirement
56
50
  requirements:
57
51
  - - "~>"
58
52
  - !ruby/object:Gem::Version
59
- version: '0.16'
53
+ version: '0.17'
60
54
  type: :runtime
61
55
  prerelease: false
62
56
  version_requirements: !ruby/object:Gem::Requirement
63
57
  requirements:
64
58
  - - "~>"
65
59
  - !ruby/object:Gem::Version
66
- version: '0.16'
60
+ version: '0.17'
67
61
  - !ruby/object:Gem::Dependency
68
62
  name: eac_ruby_utils
69
63
  requirement: !ruby/object:Gem::Requirement
70
64
  requirements:
71
65
  - - "~>"
72
66
  - !ruby/object:Gem::Version
73
- version: '0.112'
67
+ version: '0.121'
74
68
  type: :runtime
75
69
  prerelease: false
76
70
  version_requirements: !ruby/object:Gem::Requirement
77
71
  requirements:
78
72
  - - "~>"
79
73
  - !ruby/object:Gem::Version
80
- version: '0.112'
74
+ version: '0.121'
81
75
  - !ruby/object:Gem::Dependency
82
76
  name: eac_templates
83
77
  requirement: !ruby/object:Gem::Requirement
@@ -85,6 +79,9 @@ dependencies:
85
79
  - - "~>"
86
80
  - !ruby/object:Gem::Version
87
81
  version: '0.5'
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 0.5.1
88
85
  type: :runtime
89
86
  prerelease: false
90
87
  version_requirements: !ruby/object:Gem::Requirement
@@ -92,20 +89,23 @@ dependencies:
92
89
  - - "~>"
93
90
  - !ruby/object:Gem::Version
94
91
  version: '0.5'
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 0.5.1
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: eac_ruby_gem_support
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - "~>"
100
100
  - !ruby/object:Gem::Version
101
- version: 0.5.1
101
+ version: '0.9'
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - "~>"
107
107
  - !ruby/object:Gem::Version
108
- version: 0.5.1
108
+ version: '0.9'
109
109
  description:
110
110
  email:
111
111
  executables: []
@@ -123,6 +123,7 @@ files:
123
123
  - lib/avm/files/deploy.rb
124
124
  - lib/avm/files/runner_with.rb
125
125
  - lib/avm/files/runner_with/file_replacer.rb
126
+ - lib/avm/files/runner_with/filesystem_renamer.rb
126
127
  - lib/avm/files/runner_with/filesystem_traverser.rb
127
128
  - lib/avm/files/text_replacer.rb
128
129
  - lib/avm/files/text_replacer/gsub.rb
@@ -138,7 +139,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
139
  requirements:
139
140
  - - ">="
140
141
  - !ruby/object:Gem::Version
141
- version: '0'
142
+ version: '2.7'
142
143
  required_rubygems_version: !ruby/object:Gem::Requirement
143
144
  requirements:
144
145
  - - ">="