Sha256: 65cec81c66e7add2fd5b39d5efbd64cebf42e6d2e417b71ffd887e475f3ffcd9

Contents?: true

Size: 1.04 KB

Versions: 12

Compression:

Stored size: 1.04 KB

Contents

require 'bcrypt'

namespace :textcaptcha do

  desc "Creates a template config file in config/textcaptcha.yml"
  task :config do
    src  = File.join(File.dirname(__FILE__), '../..', 'config', 'textcaptcha.yml')
    dest = File.join(Rails.root, 'config', 'textcaptcha.yml')
    if File.exist?(dest)
      puts "\nOoops, a textcaptcha config file at #{dest} already exists ... aborting.\n\n"
    else
      config = ''
      salt   = BCrypt::Engine.generate_salt
      f = File.open(src, 'r')
      f.each_line { |line| config += line }
      config.gsub!(/RAKE_GENERATED_SALT_PLACEHOLDER/, salt)
      config.gsub!(/  api_key:(.*)# for gem test purposes only$/, "  api_key: PASTE_YOUR_TEXTCAPCHA_API_KEY_HERE")
      config.gsub!(/  bcrypt_salt:(.*)# for gem test purposes only$/, "  bcrypt_salt: #{salt}")

      f = File.new(dest, 'w')
      f.write(config)
      f.close
      puts "\ntextcaptcha.yml generated at #{dest} (with a new BCrypt salt)\nNOTE: edit this file and add your textcaptcha api key, grab one from http://textcaptcha.com/api\n\n"
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
acts_as_textcaptcha-3.0.11 lib/tasks/textcaptcha.rake
acts_as_textcaptcha-3.0.10 lib/tasks/textcaptcha.rake
acts_as_textcaptcha-3.0.9 lib/tasks/textcaptcha.rake
acts_as_textcaptcha-3.0.8 lib/tasks/textcaptcha.rake
acts_as_textcaptcha-3.0.7 lib/tasks/textcaptcha.rake
acts_as_textcaptcha-3.0.6 lib/tasks/textcaptcha.rake
acts_as_textcaptcha-3.0.5 lib/tasks/textcaptcha.rake
acts_as_textcaptcha-3.0.4 lib/tasks/textcaptcha.rake
acts_as_textcaptcha-3.0.3 lib/tasks/textcaptcha.rake
acts_as_textcaptcha-3.0.2 lib/tasks/textcaptcha.rake
acts_as_textcaptcha-3.0.1 lib/tasks/textcaptcha.rake
acts_as_textcaptcha-3.0.0 lib/tasks/textcaptcha.rake