Revision
14605
Author
diegoviola
Date
2009-08-23 17:38:11 -0500 (Sun, 23 Aug 2009)

Log Message

added script to parse/load rates

Added Paths

Diff

Added: freeswitch/trunk/contrib/diegoviola/ruby/callcard/load_rates.rb (0 => 14605)


--- freeswitch/trunk/contrib/diegoviola/ruby/callcard/load_rates.rb	                        (rev 0)
+++ freeswitch/trunk/contrib/diegoviola/ruby/callcard/load_rates.rb	2009-08-23 22:38:11 UTC (rev 14605)
@@ -0,0 +1,22 @@
+#!/usr/bin/ruby
+
+require 'rubygems'
+require 'fastercsv'
+require 'activerecord'
+
+ActiveRecord::Base.establish_connection(
+  :adapter  => "mysql",
+  :host     => "localhost",
+  :username => "root",
+  :password => "",
+  :database => "callcard_development"
+)
+
+class Destination < ActiveRecord::Base
+end
+
+FasterCSV.foreach(ARGV.to_s) do |row|
+  destination = Destination.new(:country => row[0], :prefix => row[1], :rate => row[4])
+  destination.save
+end
+