Sha256: e1a4ded134eb69319f96eab9286f2fe6e37d7372843a7260044088edddc187ea

Contents?: true

Size: 1008 Bytes

Versions: 5

Compression:

Stored size: 1008 Bytes

Contents

namespace :secret_service do
  desc 'Store a desired secret in the database'
  task :store => :environment do
    store = SecretService::Store.new

    puts "Enter source secret (as given in your source code; leave blank to auto-generate):"
    source_secret = STDIN.gets.chomp

    if source_secret == ''
      source_secret = store.generate_secret
    end

    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

5 entries across 5 versions & 1 rubygems

Version Path
secret_service-0.1.5 lib/secret_service/rake_tasks.rb
secret_service-0.1.4 lib/secret_service/rake_tasks.rb
secret_service-0.1.3 lib/secret_service/rake_tasks.rb
secret_service-0.1.2 lib/secret_service/rake_tasks.rb
secret_service-0.1.1 lib/secret_service/rake_tasks.rb