summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrendan G. Lim2009-02-18 20:12:33 -0500
committerBrendan G. Lim2009-02-18 20:12:33 -0500
commit4c1b777458b90de5d7c01cf7d14ef0be2fdcc4e6 (patch)
tree768549d808321dccce5fc24d02570c3189f5b6a4
parent0d804bdd6e48aa3eae548665c4740b2e2d4e3b86 (diff)
downloadsms-fu-4c1b777458b90de5d7c01cf7d14ef0be2fdcc4e6.tar.bz2
Adding in some view helpers for mobile carrier select boxes and updating README
-rw-r--r--README.rdoc20
-rw-r--r--init.rb4
-rw-r--r--lib/sms_fu.rb2
-rw-r--r--lib/sms_fu_helper.rb15
-rw-r--r--lib/sms_notifier.rb1
-rw-r--r--templates/sms_fu.yml1
6 files changed, 37 insertions, 6 deletions
diff --git a/README.rdoc b/README.rdoc
index 08680cd..5355cbc 100644
--- a/README.rdoc
+++ b/README.rdoc
@@ -7,9 +7,10 @@ of the supported carriers.
== Supported Carriers (US & International):
Alltel, Ameritech, AT&T, BellSouth Mobility, BlueSkyFrog, Boost Mobile, Cellular South,
-E-Plus, Fido, kajeet, Metro PCS, Powertel, PSC Wireless, Qwest, Southern Link, Sprint,
-Suncom, T-Mobile (US/UK/Germany), Telefonica, Virgin Mobile, Verizon Wireless,
-Vodafone (UK,Italy,Japan, Spain)
+Du, E-Plus, Etisalat, Fido, kajeet, Mobinil, Mobitel, Movistar, Metro PCS, Powertel,
+PSC Wireless, Qwest, Rogers, Southern Link, Sprint, Suncom, T-Mobile (US/UK/Germany),
+Telefonica, Virgin Mobile, Verizon Wireless, Vodafone (UK, Egypt, Italy, Japan, Spain),
+and many more ...
== Setup Instructions
@@ -60,5 +61,18 @@ That's it! Now you're good to go.
get_sms_address("5558675309","at&t") # => "5558675309@txt.att.net"
+== View Helpers
+
+* Retrieve a collection of all carriers
+
+ <%= carrier_collection %>
+
+* Display a select box with mobile carriers
+
+ <%= carrier_select %>
+
+* Display a custom select box with mobile carriers
+
+ <%= carrier_select('user[carrier_name]', "Please choose a carrier") %>
Copyright (c) 2008 Brendan G. Lim, Intridea, Inc., released under the MIT license
diff --git a/init.rb b/init.rb
index c6df249..b6cf0d9 100644
--- a/init.rb
+++ b/init.rb
@@ -1,3 +1,5 @@
require "action_mailer"
require File.dirname(__FILE__) + '/lib/sms_fu'
-ActionView::Base.send(:include, SMSFu) \ No newline at end of file
+require File.dirname(__FILE__) + '/lib/sms_fu_helper.rb'
+ActionView::Base.send(:include, SMSFu)
+ActionView::Base.send(:include, SMSFuHelper) \ No newline at end of file
diff --git a/lib/sms_fu.rb b/lib/sms_fu.rb
index 2aa2dea..6e22079 100644
--- a/lib/sms_fu.rb
+++ b/lib/sms_fu.rb
@@ -58,7 +58,7 @@ module SMSFu
end
def is_valid?(number)
- return (number.length >= 10 && number[/^.\d+$/]) ? true : false
+ number.length >= 10 && number[/^.\d+$/]
end
def determine_sms_email(phone_number, carrier)
diff --git a/lib/sms_fu_helper.rb b/lib/sms_fu_helper.rb
new file mode 100644
index 0000000..fdc67c1
--- /dev/null
+++ b/lib/sms_fu_helper.rb
@@ -0,0 +1,15 @@
+module SMSFuHelper
+ # Returns a collection of carriers to be used in your own select tag
+ # e.g., <%= f.select :mobile_carrier, carrier_collection %>
+ def carrier_collection
+ SMSFu.carriers.sort.collect{ |carrier| [carrier[0].titleize, carrier[0]] }
+ end
+
+ # Returns a formatted select box filled with carriers
+ # e.g., <%= carrier_select %>
+ # - name => name of the method in which you want to store the carrier name
+ # - phrase => default selected blank option in select box
+ def carrier_select(name = :mobile_carrier, phrase = "Select a Carrier")
+ select_tag name, options_for_select([phrase,nil]+carrier_collection, phrase)
+ end
+end \ No newline at end of file
diff --git a/lib/sms_notifier.rb b/lib/sms_notifier.rb
index 5d960c6..644408a 100644
--- a/lib/sms_notifier.rb
+++ b/lib/sms_notifier.rb
@@ -27,7 +27,6 @@ class SmsNotifier < ActionMailer::Base
content_type "text/plain"
recipients recipient
from sender_email
-
body['message'] = message
end
diff --git a/templates/sms_fu.yml b/templates/sms_fu.yml
index bb8ab42..9a3b1d1 100644
--- a/templates/sms_fu.yml
+++ b/templates/sms_fu.yml
@@ -28,6 +28,7 @@ carriers:
etisalat-arab-emirates: @email2sms.ae
fido-canada: @fido.ca
mobinil-egypt: @mobinil.net
+ mobitel: @sms.mobitel.lk
movistar-spain: @correo.movistar.net
o2-germany: @o2online.de
o2-uk: @mmail.co.uk