Sha256: 1a4ef95c9deab174dce6a0fed2429542620e27d6219364ee446851832c359e7d

Contents?: true

Size: 863 Bytes

Versions: 1

Compression:

Stored size: 863 Bytes

Contents

namespace :secret_service do
  desc 'Store a desired secret in the database'
  task :store => :environment do
    store = SecretService::Store.new
    source_secret = ENV['SOURCE_SECRET'] || store.generate_secret

    puts "Enter secret:"
    final_secret = STDIN.gets.chomp

    store.set(source_secret, final_secret)

    puts "We're done!"
    puts
    puts "Retrieve this secret in your app using"
    puts "  SecretService.secret(#{source_secret.inspect})"
    puts
  end

  desc 'Show a previously stored secret'
  task :show => :environment do
    store = SecretService::Store.new
    puts "Enter source secret (as given in your source code):"
    source_secret = STDIN.gets.chomp

    secret = store.get(source_secret, :only_existing => true)
    if secret
      puts "Secret: ", secret
    else
      puts "Secret not stored"
    end
    puts
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
secret_service-0.1.0 lib/secret_service/rake_tasks.rb