Sha256: 97d7e844a28e39fd4e895ff48b6be43612da38c0afa170c3c8df067f3477da17

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

require 'bundler/gem_tasks'

# 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['**/ec2_name*']
  begin
    from = dir.pop
    if from
      to = from.split('/')
      to[-1].gsub!('ec2_name', name)
      FileUtils.mv(from, to.join('/'))
    end
  end while dir.length > 0
  Dir["**/*"].each do |path|
    if File.file?(path)
      `sed -i '' 's/ec2_name/#{name}/g' #{path}`
      `sed -i '' 's/Ec2Name/#{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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ec2_name-0.1.0 Rakefile