Skip to content

Commit

Permalink
Merge pull request brianmario#429 from BanzaiMan/no_sed
Browse files Browse the repository at this point in the history
Eschew use of `sed`
  • Loading branch information
brianmario committed Oct 9, 2013
2 parents 71a0058 + 24391e6 commit 3bac270
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tasks/rspec.rake
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,26 @@ file 'spec/configuration.yml' => 'spec/configuration.yml.example' do |task|
CLEAN.exclude task.name
src_path = File.expand_path("../../#{task.prerequisites.first}", __FILE__)
dst_path = File.expand_path("../../#{task.name}", __FILE__)
cp src_path, dst_path
sh "sed -i 's/LOCALUSERNAME/#{ENV['USER']}/' #{dst_path}"

dst_file = File.open(dst_path, 'w')
File.open(src_path) do |f|
f.each_line do |line|
dst_file.write line.gsub(/LOCALUSERNAME/, ENV['USER'])
end
end
end

file 'spec/my.cnf' => 'spec/my.cnf.example' do |task|
CLEAN.exclude task.name
src_path = File.expand_path("../../#{task.prerequisites.first}", __FILE__)
dst_path = File.expand_path("../../#{task.name}", __FILE__)
cp src_path, dst_path
sh "sed -i 's/LOCALUSERNAME/#{ENV['USER']}/' #{dst_path}"

dst_file = File.open(dst_path, 'w')
File.open(src_path) do |f|
f.each_line do |line|
dst_file.write line.gsub(/LOCALUSERNAME/, ENV['USER'])
end
end
end

Rake::Task[:spec].prerequisites << :'spec/configuration.yml'
Expand Down

0 comments on commit 3bac270

Please sign in to comment.