Sha256: e92578b19ea26b191bebf0e13dafa42ddb32463e953e6f6cfb0661f7e30e0d52

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 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.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
  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
      TranslationCenter.yaml2db(args[:locale])
      TranslationCenter.db2yaml(args[:locale])
    rescue Exception => e
      send_exception(e)
    end  
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
translation_center-1.5.1 lib/tasks/translation_center.rake
translation_center-1.5.0 lib/tasks/translation_center.rake
translation_center-1.4.1 lib/tasks/translation_center.rake
translation_center-1.4.0 lib/tasks/translation_center.rake