rip_hashrocket 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
@@ -0,0 +1,9 @@
1
+ Ruby Gem for updating hash syntax from Ruby 1.8 to 1.9 syle, removing rockets "=>"
2
+
3
+
4
+ INSTALLATION:
5
+ gem install rip_hashrocket
6
+
7
+ USAGE:
8
+ rip_hashrocket
9
+
@@ -1,3 +1,3 @@
1
1
  module RipHashrocket
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -6,7 +6,7 @@ module RipHashrocket
6
6
  directory = options[0] || Dir.pwd
7
7
  backup = options[1] || false
8
8
 
9
- # TODO : add options for recursivity (and application of the script to a single file)
9
+ count = 0
10
10
  rbfiles = File.join(directory ,"**", "*.rb")
11
11
  Dir.glob(rbfiles).each do |filename|
12
12
  file = File.new(filename, "r+")
@@ -16,8 +16,13 @@ module RipHashrocket
16
16
 
17
17
  lines.each_with_index do |line, i|
18
18
  newline = line.replace_rockets(line)
19
- made_changes = true if lines[i] != newline
20
- lines[i] = newline
19
+ if newline != line
20
+ #puts "line: #{lines[i]}"
21
+ #puts "newline: #{newline}"
22
+ lines[i] = newline
23
+ made_changes = true
24
+ count += 1
25
+ end
21
26
  end
22
27
 
23
28
  file.close
@@ -29,21 +34,19 @@ module RipHashrocket
29
34
  end
30
35
 
31
36
  file = File.new(filename, "w+")
32
-
33
- file.rewind
34
37
  file.puts(lines.join)
35
38
  file.close
36
39
  end
37
40
  end
38
- p "Hash Rockets replaced for #{Dir.glob(rbfiles).count} source files"
41
+ p "Hash Rockets has upgraded hash syntax in #{count} out of #{Dir.glob(rbfiles).count} source files tested"
39
42
  end
40
43
 
41
44
  end
42
45
 
43
46
  class String
44
47
  def replace_rockets(s)
45
- s.gsub(/:([a-z.]*) => /) do |n|
46
- n.include?('-') ? n : "#{n[1..n.size-5]}: "
48
+ s.gsub(/:([a-z.]*)(\s{0,})=>(\s{0,})/) do |n|
49
+ n.include?('-') ? n : "#{$1}: "
47
50
  end
48
51
  end
49
52
  end
@@ -0,0 +1 @@
1
+ { :a => "a", :b => "b", :c =>"d", :e=>"e"}
metadata CHANGED
@@ -1,57 +1,77 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rip_hashrocket
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.5
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ hash: 19
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 6
10
+ version: 0.0.6
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Ben Pellow
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2011-06-12 00:00:00.000000000 -07:00
17
+
18
+ date: 2011-06-13 00:00:00 -07:00
13
19
  default_executable:
14
20
  dependencies: []
15
- description: R.I.P. Hash Rocket gem will transform Ruby 1.8 hashrocket syntax into
16
- Ruby 1.9 friendly syntax
17
- email:
21
+
22
+ description: R.I.P. Hash Rocket gem will transform Ruby 1.8 hashrocket syntax into Ruby 1.9 friendly syntax
23
+ email:
18
24
  - ben@campuscred.com
19
- executables:
25
+ executables:
20
26
  - rip_hashrocket
21
27
  extensions: []
28
+
22
29
  extra_rdoc_files: []
23
- files:
30
+
31
+ files:
24
32
  - .gitignore
25
33
  - Gemfile
34
+ - README
26
35
  - Rakefile
27
36
  - bin/rip_hashrocket
28
37
  - lib/rip_hashrocket.rb
29
38
  - lib/rip_hashrocket/version.rb
30
39
  - rip_hashrocket.gemspec
31
40
  - test_rb_files/test1.rb
41
+ - test_rb_files/test2.rb
32
42
  has_rdoc: true
33
43
  homepage: http://www.campuscred.com
34
44
  licenses: []
45
+
35
46
  post_install_message:
36
47
  rdoc_options: []
37
- require_paths:
48
+
49
+ require_paths:
38
50
  - lib
39
- required_ruby_version: !ruby/object:Gem::Requirement
51
+ required_ruby_version: !ruby/object:Gem::Requirement
40
52
  none: false
41
- requirements:
42
- - - ! '>='
43
- - !ruby/object:Gem::Version
44
- version: '0'
45
- required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
61
  none: false
47
- requirements:
48
- - - ! '>='
49
- - !ruby/object:Gem::Version
50
- version: '0'
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ hash: 3
66
+ segments:
67
+ - 0
68
+ version: "0"
51
69
  requirements: []
70
+
52
71
  rubyforge_project: rip_hashrocket
53
- rubygems_version: 1.6.2
72
+ rubygems_version: 1.3.7
54
73
  signing_key:
55
74
  specification_version: 3
56
75
  summary: R.I.P. Hash Rocket updates hash syntax for Ruby 1.9
57
76
  test_files: []
77
+