Sha256: 876d1d007715f6abd8aa37006def33039b39dab40b14505e2f1cb1e9d07b1aad

Contents?: true

Size: 1.72 KB

Versions: 16

Compression:

Stored size: 1.72 KB

Contents

require "uri"
require "net/http"

namespace :translation_center do

  def send_exception(exception)
    puts "An error has ocurred while performing this rake, would you like to send the exception to us so we may fix this problem ? press [Y/n]"
    confirm = $stdin.gets.chomp
    
    if confirm.blank? || confirm == 'y' || confirm == 'yes'
      puts 'Sending ...'
      params = {message: "#{exception.message} #{exception.backtrace.join("\n")}"}
      Net::HTTP.post_form(URI.parse('http://translation-center.herokuapp.com/translation_center_feedbacks/create_rake'), params)
      puts 'We have received your feedback. Thanks!'
    end

    # show the exception message
    puts exception.message
    puts exception.backtrace.join("\n")
  end

  desc "Insert yaml translations in db"
  task :yaml2db, [:locale ] => :environment do |t, args|
    begin
      TranslationCenter.yaml2db(args[:locale])
    rescue Exception => e
      send_exception(e)
    end
  end

  desc "Export translations from db to yaml"
  task :db2yaml, [:locale ] => :environment do |t, args|
    begin
      TranslationCenter.db2yaml(args[:locale])
    rescue Exception => e
      send_exception(e)
    end
  end

  desc "Calls yaml2db then db2yaml"
  task :synch, [:locale ] => :environment do |t, args|
    begin
      if TranslationCenter::Category.any?
        puts "WARNING: You already have translations stored in the db, do you want to destroy them? press [Y|n]"
        confirm = $stdin.gets.chomp
    
        TranslationCenter::Category.destroy_all if confirm.blank? || confirm == 'y' || confirm == 'yes'
      end
      TranslationCenter.yaml2db(args[:locale])
      TranslationCenter.db2yaml(args[:locale])
    rescue Exception => e
      send_exception(e)
    end  
  end

end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
translation_center-2.0.2 lib/tasks/translation_center.rake
translation_center-2.0.1 lib/tasks/translation_center.rake
translation_center-1.7.2 lib/tasks/translation_center.rake
afalkear_translation_center-1.8.4 lib/tasks/translation_center.rake
afalkear_translation_center-1.8.3 lib/tasks/translation_center.rake
afalkear_translation_center-1.8.2 lib/tasks/translation_center.rake
afalkear_translation_center-1.8.1 lib/tasks/translation_center.rake
afalkear_translation_center-1.8.0 lib/tasks/translation_center.rake
afalkear_translation_center-1.7.9 lib/tasks/translation_center.rake
afalkear_translation_center-1.7.8 lib/tasks/translation_center.rake
afalkear_translation_center-0.0.0 lib/tasks/translation_center.rake
afalkear_translation_center-1.7.7 lib/tasks/translation_center.rake
translation_center-1.7.1 lib/tasks/translation_center.rake
translation_center-1.7.0 lib/tasks/translation_center.rake
translation_center-1.6.10 lib/tasks/translation_center.rake
translation_center-1.6.9 lib/tasks/translation_center.rake