summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBrendan G. Lim2008-03-31 18:18:40 -0400
committerBrendan G. Lim2008-03-31 18:18:40 -0400
commit5ecbaaee4d38543a66767b02d5b41ef9e885f2d5 (patch)
tree6f571ca5e88dab97907f30e57e9cda6b31e6130f /lib
parentcb0138f5f1f637bcd5065e548b0dac04d413acd8 (diff)
downloadsms-fu-5ecbaaee4d38543a66767b02d5b41ef9e885f2d5.tar.bz2
Fixed some of the tests
Diffstat (limited to 'lib')
-rw-r--r--lib/sms_fu.rb11
-rw-r--r--lib/sms_notifier.rb2
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/sms_fu.rb b/lib/sms_fu.rb
index 9dd958b..5932d4a 100644
--- a/lib/sms_fu.rb
+++ b/lib/sms_fu.rb
@@ -21,7 +21,10 @@ require 'yaml'
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
module SMSFu
- @@config = YAML::load(File.open("#{RAILS_ROOT}/config/sms_fu.yml"))
+
+ RAILS_CONFIG_ROOT = defined?(RAILS_ROOT) ? "#{RAILS_ROOT}/config" : "#{File.dirname(__FILE__)}/../templates"
+ @config = YAML::load(File.open("#{RAILS_CONFIG_ROOT}/sms_fu.yml"))
+ @@carriers = @config['carriers']
def deliver_sms(number,carrier,message,options={})
number = format_number(number)
@@ -44,7 +47,7 @@ module SMSFu
def format_number(number)
pre_formatted = number.gsub("-","").strip
- formatted = (pre_formatted.length == 11) ? pre_formatted[1..pre_formatted.length] : pre_formatted
+ formatted = (pre_formatted.length == 11 && pre_formatted[0,1] == "1") ? pre_formatted[1..pre_formatted.length] : pre_formatted
return is_valid?(formatted) ? formatted : (raise SMSFuException.new("Phone number (#{number}) is not formatted correctly"))
end
@@ -54,8 +57,8 @@ module SMSFu
end
def determine_sms_email(phone_number, carrier)
- if @@config['carriers'].has_key?(carrier.downcase)
- "#{phone_number}#{@@config['carriers'][carrier.downcase]}"
+ if @@carriers.has_key?(carrier.downcase)
+ "#{phone_number}#{@@carriers[carrier.downcase]}"
else
raise SMSFuException.new("Specified carrier, #{carrier} is not supported.")
end
diff --git a/lib/sms_notifier.rb b/lib/sms_notifier.rb
index 127f35b..cf698c8 100644
--- a/lib/sms_notifier.rb
+++ b/lib/sms_notifier.rb
@@ -22,7 +22,7 @@ require 'yaml'
class SmsNotifier < ActionMailer::Base
@config = YAML::load(File.open("#{RAILS_ROOT}/config/sms_fu.yml"))
- @@from_address = @config['from_address']
+ @@from_address = @config['config']['from_address']
cattr_accessor :from_address
def sms_message(recipient, message)