Skip to content

Commit

Permalink
Adding rake decrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisquintel committed Dec 13, 2013
1 parent 83052af commit 3a0e439
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ gqueries/sandbox
coverage/
.rbenv-version
energy_balance.csv
.password
25 changes: 25 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,28 @@ task :console do
cd '../atlas'
exec "bundle exec rake 'console[#{ directory }]'"
end

desc <<-DESC
Decrypts the energy balance for every area.
DESC

task :decrypt do
if File.exists?('.password')
password = File.read('.password').strip
else
puts "File .password not found in root."
puts "Please Enter Passphrase to decrypt files:"
password = $stdin.gets.strip
end

puts "Start Decrypting..."
Dir.glob('datasets/*').each do |area|
if File.exists?("#{ area }/energy_balance.gpg")
puts "* #{ area }"
cmd = "gpg -d --passphrase #{ password } #{ area }/energy_balance.gpg > #{ area }/energy_balance.csv"
puts `#{ cmd }`
end
end

puts "Done!"
end

0 comments on commit 3a0e439

Please sign in to comment.