diff options
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | CHANGELOG | 42 | ||||
| -rw-r--r-- | README.rdoc | 35 | ||||
| -rw-r--r-- | Rakefile | 14 | ||||
| -rw-r--r-- | VERSION | 1 | ||||
| -rw-r--r-- | init.rb | 4 | ||||
| -rw-r--r-- | lib/sms_fu.rb | 34 | ||||
| -rw-r--r-- | lib/sms_fu_helper.rb | 17 | ||||
| -rw-r--r-- | lib/sms_notifier.rb | 1 | ||||
| -rw-r--r-- | sms-fu.gemspec | 52 | ||||
| -rw-r--r-- | templates/sms_fu.yml | 281 | 
11 files changed, 408 insertions, 76 deletions
| diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f541d9a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea +.idea/* +.idea/**/* @@ -1,3 +1,45 @@ +commit 8abc7168dd392b083fdfd3a9cb2ce1e7c1d068a0 +Author: Brendan G. Lim <brendan@intridea.com> +Date:   Wed Feb 18 20:25:05 2009 -0500 + +    Some structural changes to SMS Fu + +commit 4e5aa349ac9d4c12da5d53de08d1fd3281bcfa0d +Author: Brendan G. Lim <brendan@intridea.com> +Date:   Wed Feb 18 20:12:55 2009 -0500 + +    Updating CHANGELOG + +commit 4c1b777458b90de5d7c01cf7d14ef0be2fdcc4e6 +Author: Brendan G. Lim <brendan@intridea.com> +Date:   Wed Feb 18 20:12:33 2009 -0500 + +    Adding in some view helpers for mobile carrier select boxes and updating README + +commit 0d804bdd6e48aa3eae548665c4740b2e2d4e3b86 +Author: Brendan G. Lim <brendan@intridea.com> +Date:   Mon Dec 15 14:17:16 2008 -0500 + +    Adding Etisalat support and adding country designation to mobinil and movistar + +commit 0d417e1f30f5b153e9658e5649144630b95c2ec1 +Author: Brendan G. Lim <brendan@intridea.com> +Date:   Thu Dec 11 19:09:20 2008 -0500 + +    Adding Vodafone Egypt, Virgin Mobile Canada, and Mobitel Sri Lanka to supported SMS carriers + +commit ec20bd73afe7c26583bcdb7037028161f65cc8a5 +Author: Brendan G. Lim <brendan@intridea.com> +Date:   Thu Dec 11 13:31:17 2008 -0500 + +    Adding a good chunk of carriers into SMS Fu + +commit 8d9a829177f6a249206892ccc7a13b8ae5467496 +Author: Brendan G. Lim <brendan@intridea.com> +Date:   Thu Jul 31 13:48:30 2008 -0400 + +    Upating the CHANGELOG +  commit 3912b0b91621ba1a827585f3b22c1426fc70c9e4  Author: Brendan G. Lim <brendan@intridea.com>  Date:   Thu Jul 31 13:48:15 2008 -0400 diff --git a/README.rdoc b/README.rdoc index 08680cd..ee40adc 100644 --- a/README.rdoc +++ b/README.rdoc @@ -6,17 +6,29 @@ 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) +Alltel, Ameritech, AT&T, Bell Atlantic, BellSouth Mobility, Beeline(UA), BlueSkyFrog,  +Boost Mobile, BPL Mobile, Cellular South, Claro (Brazil, Nicaragua), Comcast, Du,  +E-Plus, Etisalat, Fido, kajeet, Mobinil, Mobitel, Movistar, Metro PCS, O2, Orange,  +Powertel, PSC Wireless, Qwest, Rogers, Southern Link, Sprint, Suncom,  +T-Mobile (US/UK/Germany), Telefonica, Tracfone, Virgin Mobile, Verizon Wireless,  +Vodafone (UK, Egypt, Italy, Japan, Spain), and many more ... + +== Opt-In Warning for Some International Carriers + +Some International carriers require that their users subscribe to an Email to SMS +feature before they are able to receive SMS messages this way.  If one your users +mentions that they are not receiving their messages, chances are it is due to this +limitation. + +Some carriers that need this include, Mobitel, Etisalat, T-Mobile (Netherlands),  +etc.  == Setup Instructions  Add this this one line to the controller you want to be able to use SMS Fu in.      class ExampleController < ApplicationController -      include SMSFu +      has_sms_fu      end  Modify sms_fu.yml in your config folder with your reply-to e-mail address. @@ -60,5 +72,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 @@ -20,3 +20,17 @@ Rake::RDocTask.new(:rdoc) do |rdoc|    rdoc.rdoc_files.include('README')    rdoc.rdoc_files.include('lib/**/*.rb')  end + +begin +  require 'jeweler' +  Jeweler::Tasks.new do |gemspec| +    gemspec.name = "sms-fu" +    gemspec.summary = "SMS Fu allows ou to send a text-message for free in the form of an e-mail to a mobile recipient." +    gemspec.description = "SMS Fu allows ou to send a text-message for free in the form of an e-mail to a mobile recipient." +    gemspec.email = "brendangl@gmail.com" +    gemspec.homepage = "http://github.com/brendanlim/sms-fu" +    gemspec.authors = ["Brendan G. Lim"] +  end +rescue LoadError +  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com" +end @@ -0,0 +1 @@ +1.0.0 @@ -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' +ActionController::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..b8b56bd 100644 --- a/lib/sms_fu.rb +++ b/lib/sms_fu.rb @@ -22,52 +22,60 @@ require 'sms_notifier'  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  module SMSFu +  def self.included(base) +    base.class_eval do +      def self.has_sms_fu +        include SMSFu +      end +    end +  end +    RAILS_CONFIG_ROOT = defined?(RAILS_ROOT) ? "#{RAILS_ROOT}/config" : "#{File.dirname(__FILE__)}/../templates" unless defined?(RAILS_CONFIG_ROOT)    @config     ||= YAML::load(File.open("#{RAILS_CONFIG_ROOT}/sms_fu.yml"))    @@carriers  ||= @config['carriers']     @@from_address = @config['config']['from_address'] -   +    def self.carriers      @@carriers.dup    end -   +    def deliver_sms(number,carrier,message,options={})      raise SMSFuException.new("Cannot deliver an empty message to #{format_number(number)}") if message.nil? or message.empty? -     +      options[:limit] ||= message.length      options[:from]  ||= @@from_address      message = message[0..options[:limit]-1]      sms_email = determine_sms_email(format_number(number),carrier) -     +      SmsNotifier.deliver_sms_message(sms_email,message,options[:from])    rescue SMSFuException => exception      raise exception    end -   +    def get_sms_address(number,carrier)      number = format_number(number)      determine_sms_email(number,carrier)    end -   +    private -   +    def format_number(number)      pre_formatted = number.gsub("-","").strip      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 -   +    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)      if @@carriers.has_key?(carrier.downcase) -      "#{phone_number}#{@@carriers[carrier.downcase]}" +      "#{phone_number}#{@@carriers[carrier.downcase]['value']}"      else         raise SMSFuException.new("Specified carrier, #{carrier} is not supported.")      end    end  -        +       class SMSFuException < StandardError; end -end
\ No newline at end of file +end diff --git a/lib/sms_fu_helper.rb b/lib/sms_fu_helper.rb new file mode 100644 index 0000000..5730444 --- /dev/null +++ b/lib/sms_fu_helper.rb @@ -0,0 +1,17 @@ +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[1]["name"], 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  +  # - selected => carrier to pre-select +  def carrier_select(name = :mobile_carrier, phrase = "Select a Carrier", selected = nil) +    select_tag name, options_for_select([phrase,nil]+carrier_collection, selected || phrase) +  end + +end 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/sms-fu.gemspec b/sms-fu.gemspec new file mode 100644 index 0000000..31e59eb --- /dev/null +++ b/sms-fu.gemspec @@ -0,0 +1,52 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| +  s.name = %q{sms-fu} +  s.version = "1.0.0" + +  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= +  s.authors = ["Brendan G. Lim"] +  s.date = %q{2009-07-20} +  s.description = %q{SMS Fu allows ou to send a text-message for free in the form of an e-mail to a mobile recipient.} +  s.email = %q{brendangl@gmail.com} +  s.extra_rdoc_files = [ +    "README.rdoc" +  ] +  s.files = [ +    "CHANGELOG", +     "MIT-LICENSE", +     "README.rdoc", +     "Rakefile", +     "VERSION", +     "init.rb", +     "install.rb", +     "lib/sms_fu.rb", +     "lib/sms_fu_helper.rb", +     "lib/sms_notifier.rb", +     "sms-fu.gemspec", +     "tasks/sms_fu_tasks.rake", +     "templates/sms_fu.yml", +     "test/sms_fu_test.rb", +     "uninstall.rb", +     "views/sms_notifier/sms_message.html.erb" +  ] +  s.has_rdoc = true +  s.homepage = %q{http://github.com/brendanlim/sms-fu} +  s.rdoc_options = ["--charset=UTF-8"] +  s.require_paths = ["lib"] +  s.rubygems_version = %q{1.3.1} +  s.summary = %q{SMS Fu allows ou to send a text-message for free in the form of an e-mail to a mobile recipient.} +  s.test_files = [ +    "test/sms_fu_test.rb" +  ] + +  if s.respond_to? :specification_version then +    current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION +    s.specification_version = 2 + +    if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then +    else +    end +  else +  end +end diff --git a/templates/sms_fu.yml b/templates/sms_fu.yml index 63b395c..9b5b698 100644 --- a/templates/sms_fu.yml +++ b/templates/sms_fu.yml @@ -2,60 +2,229 @@ config:    from_address: noreply@domain.com  carriers: -  # US Carriers -  alltell: @message.alltell.com -  ameritech: @paging.acswireless.com   -  at&t: @txt.att.net -  bellsouthmobility: @blsdcs.net -  blueskyfrog: @blueskyfrog.com -  boost: @myboostmobile.com -  cellularsouth: @csouth1.com -  kajeet: @mobile.kajeet.net -  metropcs: @mymetropcs.com -  powertel: @ptel.net -  pscwireless: @sms.pscel.com -  qwest: @qwestmp.com -  southernlink: @page.southernlinc.com -  sprint: @messaging.sprintpcs.com -  suncom: @tms.suncom.com -  t-mobile: @tmomail.net -  virgin: @vmobl.net -  verizon: @vtext.com -  # Canadian Carriers -  aliant: @chat.wirefree.ca -  bellmobility: @txt.bell.ca -  fido-canada: @fido.ca -  manitobatelecom: @text.mtsmobility.com -  northerntel: @txt.northerntelmobility.com -  rogers: @pcs.rogers.ca -  sasktel: @sms.sasktel.ca -  telebec: @txt.telebecmobilite.com -  telus: @msg.telus.com +  alltel: +    name: Alltel +    value: @message.alltel.com +  ameritech: +    name: Ameritech +    value: @paging.acswireless.com +  at&t:  +    name: AT&T +    value: @txt.att.net +  bell-atlantic:  +    name: Bell Atlantic +    value: @message.bam.com +  bellsouthmobility: +    name: Bellsouth Mobility +    value: @blsdcs.net +  blueskyfrog:  +    name: BlueSkyFrog +    value: @blueskyfrog.com +  boost:  +    name: Boost Mobile +    value: @myboostmobile.com +  cellularsouth:  +    name: Cellular South +    value: @csouth1.com +  comcast:  +    name: Comcast PCS +    value: @comcastpcs.textmsg.com +  cricket:  +    name: Cricket +    value: @sms.mycricket.com +  kajeet:  +    name: kajeet +    value: @mobile.kajeet.net +  metropcs:  +    name: Metro PCS +    value: @mymetropcs.com +  powertel:  +    name: Powertel +    value: @ptel.net +  pscwireless:  +    name: PSC Wireless +    value: @sms.pscel.com +  qwest:  +    name: Qwest +    value: @qwestmp.com +  southernlink:  +    name: Southern Link +    value: @page.southernlinc.com +  sprint:  +    name: Sprint PCS +    value: @messaging.sprintpcs.com +  suncom:  +    name: Suncom +    value: @tms.suncom.com +  t-mobile:  +    name: T-Mobile +    value: @tmomail.net +  tracfone:  +    name: Tracfone +    value: @mmst5.tracfone.com +  telus-mobility:  +    name: Telus Mobility +    value: @msg.telus.com +  virgin:  +    name: Virgin Mobile +    value: @vmobl.net +  verizon:  +    name: Verizon Wireless +    value: @vtext.com    # International Carriers -  e-plus-germany: @smsmail.eplus.de -  o2-germany: @o2online.de -  o2-uk: @mmail.co.uk -  orange-netherlands: @sms.orange.nl -  orange-uk: @orange.net -  t-mobile-austria: @sms.t-mobile.at -  t-mobile-germany: @t-d1-sms.de -  t-mobile-uk: @t-mobile.uk.net -  telefonica-spain: @movistar.net -  vodafone-germany: @vodafone-sms.de -  vodafone-uk: @sms.vodafone.net -  vodafone-italy: @sms.vodafone.it -  vodafone-jp-chuugoku: @n.vodafone.ne.jp -  vodafone-jp-hokkaido: @d.vodafone.ne.jp -  vodafone-jp-hokuriko: @r.vodafone.ne.jp -  vodafone-jp-kansai: @k.vodafone.ne.jp -  vodafone-jp-osaka: @k.vodafone.ne.jp -  vodafone-jp-kanto: @k.vodafone.ne.jp -  vodafone-jp-koushin: @k.vodafone.ne.jp -  vodafone-jp-tokyo: @k.vodafone.ne.jp -  vodafone-jp-kyuushu: @q.vodafone.ne.jp -  vodafone-jp-okinawa: @q.vodafone.ne.jp -  vodafone-jp-shikoku: @s.vodafone.ne.jp -  vodafone-jp-touhoku: @h.vodafone.ne.jp -  vodafone-jp-niigata: @h.vodafone.ne.jp -  vodafone-jp-toukai: @h.vodafone.ne.jp -  vodafone-spain: @vodafone.es +  aliant-canada: +    name: Aliant (Canada) +    value: @chat.wirefree.ca +  beeline-ua:  +    name: Beeline +    value: @sms.beeline.ua +  bellmobility-canada: +    name: Bell Mobility (Canada) +    value: @txt.bell.ca +  bpl-mobile:  +    name: BPL Mobile +    value: @bplmobile.com +  claro-brazil: +    name: Claro (Brazil) +    value: @clarotorpedo.com.br +  claro-nicaragua:  +    name: Claro (Nicaragua) +    value: @ideasclaro-ca.com +  du-arab-emirates:  +    name: Du (UAE) +    value: @email2sms.ae +  e-plus-germany:  +    name: E-Plus (Germany) +    value: @smsmail.eplus.de +  etisalat-arab-emirates:  +    name: Etisalat (UAE) +    value: @email2sms.ae +  fido-canada:  +    name: Fido +    value: @fido.ca +  manitobatelecom-canada: +    name: Manitoba Telecom (Canada) +    value: @text.mtsmobility.com +  mobinil-egypt: +    name: Mobinil +    value: @mobinil.net +  mobistar-belgium:  +    name: Mobistar (Belgium) +    value: @mobistar.be +  mobitel:  +    name: Mobitel +    value: @sms.mobitel.lk +  movistar-spain:  +    name: Movistar (Spain) +    value: @correo.movistar.net +  northerntel-canada: +    name: NorthernTel (Canada) +    value: @txt.northerntelmobility.com +  o2-germany:  +    name: o2 (Germany) +    value: @o2online.de +  o2-uk:  +    name: o2 (UK) +    value: @mmail.co.uk +  orange-mumbai:  +    name: Orange (Mumbai) +    value: @orangemail.co.in +  orange-netherlands:  +    name: Orange (Netherlands) +    value: @sms.orange.nl +  orange-uk:  +    name: Orange (UK) +    value: @orange.net +  rogers-wireless:  +    name: Rogers Wireless +    value: @pcs.rogers.com +  rogers-canada: +    name: Rogers (Canada) +    value: @pcs.rogers.ca +  sasktel-canada: +    name: SaskTel (canada) +    value: @sms.sasktel.ca +  sfr-france:  +    name: SFR (France) +    value: @sfr.fr +  t-mobile-austria:  +    name: T-Mobile (Austria) +    value: @sms.t-mobile.at +  t-mobile-germany:  +    name: T-Mobile (Germany) +    value: @t-d1-sms.de +  t-mobile-germany:  +    name: T-Mobile (Netherlands) +    value: @gin.nl +  t-mobile-uk:  +    name: T-Mobile (UK) +    value: @t-mobile.uk.net +  telebec-canada: +    name: Telebec (Canada) +    value: @txt.telebecmobilite.com +  telefonica-spain:  +    name: Telefonica (Spain) +    value: @movistar.net +  telus-canada: +    name: Telus (Canada) +    value: @msg.telus.com +  virgin-canada: +    name: Virgin (Canada) +    value: @vmobile.ca  +  vodafone-germany:  +    name: Vodafone (Germany) +    value: @vodafone-sms.de +  vodafone-egypt:  +    name: Vodafone (Egypt) +    value: @vodafone.com.eg +  vodafone-uk:  +    name: Vodafone (UK) +    value: @sms.vodafone.net +  vodafone-italy:  +    name: Vodafone (Italy) +    value: @sms.vodafone.it +  vodafone-jp-chuugoku:  +    name: Vodafone (Japan - Chuugoku) +    value: @n.vodafone.ne.jp +  vodafone-jp-hokkaido:  +    name: Vodafone (Japan - Hokkaido) +    value: @d.vodafone.ne.jp +  vodafone-jp-hokuriko:  +    name: Vodafone (Japan - Hokuriko) +    value: @r.vodafone.ne.jp +  vodafone-jp-kansai:  +    name: Vodafone (Japan - Kansai) +    value: @k.vodafone.ne.jp +  vodafone-jp-osaka:  +    name: Vodafone (Japan - Osaka) +    value: @k.vodafone.ne.jp +  vodafone-jp-kanto:  +    name: Vodafone (Japan - Kanto) +    value: @k.vodafone.ne.jp +  vodafone-jp-koushin:  +    name: Vodafone (Japan - Koushin) +    value: @k.vodafone.ne.jp +  vodafone-jp-tokyo:  +    name: Vodafone (Japan - Tokyo) +    value: @k.vodafone.ne.jp +  vodafone-jp-kyuushu:  +    name: Vodafone (Japan - Kyuushu) +    value: @q.vodafone.ne.jp +  vodafone-jp-okinawa:  +    name: Vodafone (Japan - Okinawa) +    value: @q.vodafone.ne.jp +  vodafone-jp-shikoku:  +    name: Vodafone (Japan - Shikoku) +    value: @s.vodafone.ne.jp +  vodafone-jp-touhoku:  +    name: Vodafone (Japan - Touhoku) +    value: @h.vodafone.ne.jp +  vodafone-jp-niigata:  +    name: Vodafone (Japan - Niigata) +    value: @h.vodafone.ne.jp +  vodafone-jp-toukai:  +    name: Vodafone (Japan - Toukai) +    value: @h.vodafone.ne.jp +  vodafone-spain:  +    name: Vodafone (Japan - Spain) +    value: @vodafone.es | 
