-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathRakefile
32 lines (29 loc) · 836 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require "bundler/gem_tasks"
require "rspec/core/rake_task"
task :default => :spec
RSpec::Core::RakeTask.new
# 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['**/cli-template*']
begin
from = dir.pop
if from
to = from.split('/')
to[-1].gsub!('cli-template', name)
FileUtils.mv(from, to.join('/'))
end
end while dir.length > 0
Dir["**/*"].each do |path|
if File.file?(path)
`sed -i 's/cli-template/#{name}/g' #{path}`
`sed -i 's/CliTemplate/#{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