geny 2.1.3 → 2.1.4
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/geny/actions/find.rb +10 -14
- data/lib/geny/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7804461eee63b3bde29b4cb845b48495beb971a
|
4
|
+
data.tar.gz: 112ed6a31d7e95fa182146ec49fd6894fcad4997
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e08c3295f7d454a2addee666f1cbbc2830434adacb9a82e9b9aea6b973e2eaf799ea9a3afe462f513968ba6ca6166d72c7a02a74d79b217f965e8766f1e8bd7
|
7
|
+
data.tar.gz: 4f92d295a6b7fd5d64c5bb87acf52cd40e9985a57f6ddc13f4b2c9385e735da946df578cb49fbb1a5e9001892215d1c16e43e300e4add286434df1c49a03ffff
|
data/lib/geny/actions/find.rb
CHANGED
@@ -23,7 +23,7 @@ module Geny
|
|
23
23
|
next if path == root
|
24
24
|
|
25
25
|
# Don't look any further into this directory
|
26
|
-
::Find.prune if excluding &&
|
26
|
+
::Find.prune if excluding && path.match?(excluding)
|
27
27
|
|
28
28
|
# We don't care about directories
|
29
29
|
next if File.directory?(path)
|
@@ -51,31 +51,27 @@ module Geny
|
|
51
51
|
# @example
|
52
52
|
# find.rename("src", "Boilerplate", "YourProject")
|
53
53
|
def rename(root, pattern, replacement, force: false, excluding: nil)
|
54
|
-
|
55
|
-
options = {force: force, excluding: nil}
|
54
|
+
options = {force: force, excluding: excluding}
|
56
55
|
|
57
56
|
::Find.find(root) do |path|
|
58
57
|
# The first emitted path will be the root directory
|
59
58
|
next if path == root
|
60
59
|
|
61
60
|
# Don't look any further into this directory
|
62
|
-
::Find.prune if excluding &&
|
61
|
+
::Find.prune if excluding && path.match?(excluding)
|
63
62
|
|
64
63
|
# The path doesn't match, keep searching
|
65
64
|
next unless path.match?(pattern)
|
66
65
|
|
67
|
-
#
|
68
|
-
|
66
|
+
# The path matches, so rename it
|
67
|
+
dest = path.sub(pattern, replacement)
|
68
|
+
FileUtils.mv(path, dest, force: force)
|
69
69
|
|
70
|
-
#
|
71
|
-
# be renamed. We'll have re-run against the renamed path
|
72
|
-
::Find.prune
|
73
|
-
end
|
74
|
-
|
75
|
-
matches.each do |source|
|
76
|
-
dest = source.sub(pattern, replacement)
|
77
|
-
FileUtils.mv(source, dest, force: force)
|
70
|
+
# Find and rename the children of the path
|
78
71
|
rename(dest, pattern, replacement, options) if File.directory?(dest)
|
72
|
+
|
73
|
+
# We already searched the directory's children, so we should stop
|
74
|
+
::Find.prune
|
79
75
|
end
|
80
76
|
end
|
81
77
|
end
|
data/lib/geny/version.rb
CHANGED