secret
Created

reading a file from inside a rake task

  • Download Gist
Rails.root-db-data.yml
YAML
1 2 3 4 5 6 7 8
---
stuff: this is some stuff
and:
- this
- is
- some
- nonesense
ooerr: Hi, Mate!
output.txt
1 2
$ be rake read_file
"---\nstuff: this is some stuff\n and:\n - this\n - is\n - some\n - nonesense\nooerr: Hi, Mate!\n"
read_file.rake
Ruby
1 2 3 4 5
desc "read a file inside rake"
task :read_file do |t|
path = File.join(Rails.root,"db","data.yml")
puts File.open(path).read.inspect
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.