Sha256: 57d0e772b8d7c7e6ef37985cfed0fca0b1692deabd48f8d87cfb96d1f934bbd0

Contents?: true

Size: 847 Bytes

Versions: 10

Compression:

Stored size: 847 Bytes

Contents

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

10 entries across 10 versions & 1 rubygems

Version Path
thor_template-1.0.1 lib/starter_project/Rakefile
thor_template-1.0.0 lib/starter_project/Rakefile
thor_template-0.0.8 lib/starter_project/Rakefile
thor_template-0.0.7 lib/starter_project/Rakefile
thor_template-0.0.6 lib/starter_project/Rakefile
thor_template-0.0.5 lib/starter_project/Rakefile
thor_template-0.0.4 lib/starter_project/Rakefile
thor_template-0.0.3 lib/starter_project/Rakefile
thor_template-0.0.2 lib/starter_project/Rakefile
thor_template-0.0.1 lib/starter_project/Rakefile