diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sms_fu.rb | 11 | ||||
| -rw-r--r-- | lib/sms_notifier.rb | 2 |
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) |
