geny 2.1.3 → 2.1.4

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
  SHA1:
3
- metadata.gz: d07d1a5700e58f2b989bd93d768549d94cb51dff
4
- data.tar.gz: 06e23fcb08d75d370accea16c1f431349567a2ec
3
+ metadata.gz: f7804461eee63b3bde29b4cb845b48495beb971a
4
+ data.tar.gz: 112ed6a31d7e95fa182146ec49fd6894fcad4997
5
5
  SHA512:
6
- metadata.gz: e4ba13c3b7d643ea21532242d2de50bbc60fd1d286ecaddc0b2c1ff206ec68500c6741aac7ba5ca0cd7a201f16c411b4611fcc3b75c9a94c99802561ab366022
7
- data.tar.gz: 369e5da4a210fd8db57f64f189575a96f51fdb98d46eee9362259af0a10628becef42cd402918223e7da05f8d807ca69c4820e9451079428be51aa60a940f3d0
6
+ metadata.gz: 4e08c3295f7d454a2addee666f1cbbc2830434adacb9a82e9b9aea6b973e2eaf799ea9a3afe462f513968ba6ca6166d72c7a02a74d79b217f965e8766f1e8bd7
7
+ data.tar.gz: 4f92d295a6b7fd5d64c5bb87acf52cd40e9985a57f6ddc13f4b2c9385e735da946df578cb49fbb1a5e9001892215d1c16e43e300e4add286434df1c49a03ffff
@@ -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 && excluding.match?(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
- matches = []
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 && excluding.match?(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
- # Record the match
68
- matches << path
66
+ # The path matches, so rename it
67
+ dest = path.sub(pattern, replacement)
68
+ FileUtils.mv(path, dest, force: force)
69
69
 
70
- # Don't search the children of the match, because it will
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
@@ -1,3 +1,3 @@
1
1
  module Geny
2
- VERSION = "2.1.3"
2
+ VERSION = "2.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geny
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 2.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ray Zane