effective_developer 0.2.6 → 0.2.7
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/effective_developer/version.rb +1 -1
- data/lib/tasks/rename_class.rake +15 -7
- 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: 74c38f7ee20c5522dcff4f6b2a6a1e58c8031f19
|
4
|
+
data.tar.gz: e9111fe494d48ed6d024bca15dbc435ff3d19e9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e65b13b9a3030f2853bec4aaecf5c2b0d21b8a0a349f59cb93e1051ce80ae4bc3ba7510284e79d2c13e548dd28549ae102f1d6abeff6562652e4fa01dbd6d60
|
7
|
+
data.tar.gz: f20cbb3501f214a4981eedf971cd4102537f89fd710493b8fabac95e1b2eb5556885102dc5f1515764b56812322199e91c0ebd3d39448df8e37ee5a0d6d36cb1
|
data/lib/tasks/rename_class.rake
CHANGED
@@ -11,7 +11,7 @@ task :rename_class, [:source, :target, :db] => :environment do |t, args|
|
|
11
11
|
|
12
12
|
puts "=== Renaming class '#{source.classify}' to '#{target.classify}'"
|
13
13
|
|
14
|
-
whitelist = ['app/', 'db/', 'lib/', 'test/'].compact
|
14
|
+
whitelist = ['app/', 'config/routes.rb', 'config/locales/', 'db/', 'lib/', 'test/'].compact
|
15
15
|
blacklist = ['db/schema.rb', ('db/migrate' if args.db == 'skipdb')].compact
|
16
16
|
|
17
17
|
# Rename any directories in the app
|
@@ -28,7 +28,7 @@ task :rename_class, [:source, :target, :db] => :environment do |t, args|
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
#
|
31
|
+
# Rename any files in the app
|
32
32
|
Dir.glob('**/*.*').each do |path|
|
33
33
|
next unless whitelist.any? { |ok| path.start_with?(ok) }
|
34
34
|
next if blacklist.any? { |nope| path.start_with?(nope) }
|
@@ -41,16 +41,24 @@ task :rename_class, [:source, :target, :db] => :environment do |t, args|
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
#
|
44
|
+
# Search and replace in all files
|
45
|
+
subs = {
|
46
|
+
source.classify.pluralize => target.classify.pluralize,
|
47
|
+
source.classify => target.classify,
|
48
|
+
source.pluralize => target.pluralize,
|
49
|
+
source => target
|
50
|
+
}
|
51
|
+
|
52
|
+
if source.include?('_')
|
53
|
+
subs[source.gsub('_', '-')] ||= target
|
54
|
+
end
|
55
|
+
|
45
56
|
Dir.glob('**/*.*').each do |path|
|
46
57
|
next unless whitelist.any? { |ok| path.start_with?(ok) }
|
47
58
|
next if blacklist.any? { |nope| path.start_with?(nope) }
|
48
59
|
|
49
60
|
writer = Effective::CodeWriter.new(path) do |w|
|
50
|
-
w.gsub!(
|
51
|
-
w.gsub!(source.classify, target.classify)
|
52
|
-
w.gsub!(source.pluralize, target.pluralize)
|
53
|
-
w.gsub!(source, target)
|
61
|
+
subs.each { |k, v| w.gsub!(k, v) }
|
54
62
|
end
|
55
63
|
|
56
64
|
puts "updated: #{path}" if writer.changed?
|