rip_hashrocket 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rip_hashrocket/version.rb +1 -1
- data/lib/rip_hashrocket.rb +7 -4
- metadata +3 -3
data/lib/rip_hashrocket.rb
CHANGED
@@ -6,7 +6,8 @@ module RipHashrocket
|
|
6
6
|
directory = options[0] || Dir.pwd
|
7
7
|
backup = options[1] || false
|
8
8
|
|
9
|
-
|
9
|
+
filecount = 0
|
10
|
+
linecount = 0
|
10
11
|
rbfiles = File.join(directory ,"**", "*.rb")
|
11
12
|
Dir.glob(rbfiles).each do |filename|
|
12
13
|
file = File.new(filename, "r+")
|
@@ -21,12 +22,13 @@ module RipHashrocket
|
|
21
22
|
#puts "newline: #{newline}"
|
22
23
|
lines[i] = newline
|
23
24
|
made_changes = true
|
24
|
-
|
25
|
+
linecount += 1
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
29
|
file.close
|
29
30
|
if made_changes
|
31
|
+
filecount += 1
|
30
32
|
if backup
|
31
33
|
File.rename(filename, filename + ".bak")
|
32
34
|
else
|
@@ -38,14 +40,15 @@ module RipHashrocket
|
|
38
40
|
file.close
|
39
41
|
end
|
40
42
|
end
|
41
|
-
p "Hash Rockets has upgraded hash syntax in #{
|
43
|
+
p "Hash Rockets has upgraded hash syntax on #{linecount} lines in #{filecount} out of #{Dir.glob(rbfiles).count} source files tested"
|
42
44
|
end
|
43
45
|
|
44
46
|
end
|
45
47
|
|
46
48
|
class String
|
47
49
|
def replace_rockets(s)
|
48
|
-
s.gsub(/:([a-
|
50
|
+
s.gsub(/:([a-z_\-.]*)(\s{0,})=>(\s{0,})/) do |n|
|
51
|
+
#puts "n: #{n}"
|
49
52
|
n.include?('-') ? n : "#{$1}: "
|
50
53
|
end
|
51
54
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rip_hashrocket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 7
|
10
|
+
version: 0.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ben Pellow
|