Skip to content

Commit

Permalink
Re-adding rake rename
Browse files Browse the repository at this point in the history
  • Loading branch information
winton committed Aug 30, 2011
1 parent db40128 commit 293d0b2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Rakefile
Expand Up @@ -91,4 +91,30 @@ end
desc "Validate the gemspec" desc "Validate the gemspec"
task :gemspec do task :gemspec do
gemspec.validate gemspec.validate
end

# DELETE AFTER USING
desc "Rename project"
task :rename do
name = ENV['NAME'] || File.basename(Dir.pwd)
camelize = lambda do |str|
str.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
end
dir = Dir['**/gem_template*']
begin
from = dir.pop
if from
to = from.split('/')
to[-1].gsub!('gem_template', name)
FileUtils.mv(from, to.join('/'))
end
end while dir.length > 0
Dir["**/*"].each do |path|
if File.file?(path)
`sed -i '' 's/gem_template/#{name}/g' #{path}`
`sed -i '' 's/GemTemplate/#{camelize.call(name)}/g' #{path}`
no_space = File.read(path).gsub(/\s+\z/, '')
File.open(path, 'w') { |f| f.write(no_space) }
end
end
end end

0 comments on commit 293d0b2

Please sign in to comment.