namespace :d4_pagamento do

task :install do
    initializer_path = Rails.root.join('config', 'initializers', 'd4_pagamento.rb')
    routes_content = "mount D4Pagamento::Engine => '/pagamento'"

    initializer_content = %{

############################################### # # # Modulo de pagamento da dev4web # # Modulos suportados: MOIP / IUGU # # # # Descomentar as chaves que for utilizar # # # ################################################

# MOIP # D4_MOIP_TOKEN = 'TOKEN MOIP' # D4_MOIP_PUBLIC_KEY = 'CHAVE PUBLICA DO MOIP'

# IUGU # D4_IUGU_TOKEN = 'TOKEN MOIP' # D4_IUGU_PUBLIC_KEY = 'CHAVE PUBLICA DO MOIP' }

    begin
        initializer_file = File.open(initializer_path, 'w')
        initializer_file << initializer_content
        initializer_file.close

        puts '[*] Instalação do modulo D4Pagamento finalizada.'
        puts '[*] Configure as chaves no initializer chamado d4_pagamento'
        puts '[*] Adicione o código abaixo em seu arquivo de rotas: '
        puts "[*] #{routes_content}"

    rescue exception
        puts "[*] Erro: #{exception.message}"
        puts "[*] Finalizado com erros." 
    end

end

end