rip_hashrocket 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/bin/rip_hashrocket +8 -0
- data/lib/rip_hashrocket/version.rb +3 -0
- data/lib/rip_hashrocket.rb +49 -0
- data/rip_hashrocket.gemspec +20 -0
- data/test_rb_files/test1.rb +3 -0
- metadata +57 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/rip_hashrocket
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require "rip_hashrocket/version"
|
2
|
+
|
3
|
+
module RipHashrocket
|
4
|
+
def self.process(options)
|
5
|
+
|
6
|
+
directory = options[0] || Dir.pwd
|
7
|
+
backup = options[1] || false
|
8
|
+
|
9
|
+
# TODO : add options for recursivity (and application of the script to a single file)
|
10
|
+
rbfiles = File.join(directory ,"**", "*.rb")
|
11
|
+
Dir.glob(rbfiles).each do |filename|
|
12
|
+
file = File.new(filename, "r+")
|
13
|
+
|
14
|
+
made_changes = false
|
15
|
+
lines = file.readlines
|
16
|
+
|
17
|
+
lines.each_with_index do |line, i|
|
18
|
+
newline = line.replace_rockets(line)
|
19
|
+
made_changes = true if lines[i] != newline
|
20
|
+
lines[i] = newline
|
21
|
+
end
|
22
|
+
|
23
|
+
file.close
|
24
|
+
if made_changes
|
25
|
+
if backup
|
26
|
+
File.rename(filename, filename + ".bak")
|
27
|
+
else
|
28
|
+
File.delete(filename)
|
29
|
+
end
|
30
|
+
|
31
|
+
file = File.new(filename, "w+")
|
32
|
+
|
33
|
+
file.rewind
|
34
|
+
file.puts(lines.join)
|
35
|
+
file.close
|
36
|
+
end
|
37
|
+
end
|
38
|
+
p "Hash Rockets replaced for #{Dir.glob(rbfiles).count} source files"
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
class String
|
44
|
+
def replace_rockets(s)
|
45
|
+
s.gsub(/:([a-z.]*) => /) do |n|
|
46
|
+
n.include?('-') ? n : "#{n[1..n.size-5]}: "
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "rip_hashrocket/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "rip_hashrocket"
|
7
|
+
s.version = RipHashrocket::VERSION
|
8
|
+
s.authors = ["Ben Pellow"]
|
9
|
+
s.email = ["ben@campuscred.com"]
|
10
|
+
s.homepage = "http://www.campuscred.com"
|
11
|
+
s.summary = %q{R.I.P. Hash Rocket updates hash syntax for Ruby 1.9}
|
12
|
+
s.description = %q{R.I.P. Hash Rocket gem will transform Ruby 1.8 hashrocket syntax into Ruby 1.9 friendly syntax}
|
13
|
+
|
14
|
+
s.rubyforge_project = "rip_hashrocket"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rip_hashrocket
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ben Pellow
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-06-12 00:00:00.000000000 -07:00
|
13
|
+
default_executable:
|
14
|
+
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:
|
18
|
+
- ben@campuscred.com
|
19
|
+
executables:
|
20
|
+
- rip_hashrocket
|
21
|
+
extensions: []
|
22
|
+
extra_rdoc_files: []
|
23
|
+
files:
|
24
|
+
- .gitignore
|
25
|
+
- Gemfile
|
26
|
+
- Rakefile
|
27
|
+
- bin/rip_hashrocket
|
28
|
+
- lib/rip_hashrocket.rb
|
29
|
+
- lib/rip_hashrocket/version.rb
|
30
|
+
- rip_hashrocket.gemspec
|
31
|
+
- test_rb_files/test1.rb
|
32
|
+
has_rdoc: true
|
33
|
+
homepage: http://www.campuscred.com
|
34
|
+
licenses: []
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
requirements: []
|
52
|
+
rubyforge_project: rip_hashrocket
|
53
|
+
rubygems_version: 1.6.2
|
54
|
+
signing_key:
|
55
|
+
specification_version: 3
|
56
|
+
summary: R.I.P. Hash Rocket updates hash syntax for Ruby 1.9
|
57
|
+
test_files: []
|