jcnetdev-sms-fu 1.0.20080704

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG ADDED
@@ -0,0 +1,77 @@
1
+ commit f1026d0aca169caf57dd44e57661177bd66e2e37
2
+ Author: Brendan G. Lim <brendan@intridea.com>
3
+ Date: Thu Jun 19 02:17:08 2008 -0400
4
+
5
+ Updating to be compatibile with Rails 2.1
6
+
7
+ commit de241d15bfa878f600a462f49b4fd3c92285c3ab
8
+ Author: Brendan G. Lim <brendan@intridea.com>
9
+ Date: Sat May 31 10:05:16 2008 -0700
10
+
11
+ Merging in changes from gcnovus for fixing warnings and redundant YAML parsing when requiring sms_fu more than once.
12
+
13
+ commit d23d86216ffc5a6b44db5b354934f40178e9dfc0
14
+ Author: Brendan G. Lim <brendan@intridea.com>
15
+ Date: Sat Apr 19 01:23:45 2008 -0500
16
+
17
+ Another update to README
18
+
19
+ commit e8386f3b75f5f4794d5f280025772a34e79542ba
20
+ Author: Brendan G. Lim <brendan@intridea.com>
21
+ Date: Sat Apr 19 01:23:17 2008 -0500
22
+
23
+ Another update to README
24
+
25
+ commit d16925d6f60669d492005b419df212d26b3d21bd
26
+ Author: Brendan G. Lim <brendan@intridea.com>
27
+ Date: Sat Apr 19 01:17:51 2008 -0500
28
+
29
+ Adding in kajeet to carrier list and updated README
30
+
31
+ commit 9cf4ef9db332418dd167bd942f29ed34d11f20f9
32
+ Author: Jannis Leidel <jannis@leidel.info>
33
+ Date: Sat Apr 12 13:40:30 2008 +0200
34
+
35
+ added some international carriers
36
+
37
+ commit 364997b52bdb1c7ae8b3382b4742b5fbd52fb20c
38
+ Author: Brendan G. Lim <brendan@intridea.com>
39
+ Date: Mon Mar 31 18:23:53 2008 -0400
40
+
41
+ Fixed indentation of README and minor tweak
42
+
43
+ commit 5ecbaaee4d38543a66767b02d5b41ef9e885f2d5
44
+ Author: Brendan G. Lim <brendan@intridea.com>
45
+ Date: Mon Mar 31 18:18:40 2008 -0400
46
+
47
+ Fixed some of the tests
48
+
49
+ commit cb0138f5f1f637bcd5065e548b0dac04d413acd8
50
+ Author: Brendan G. Lim <brendan@intridea.com>
51
+ Date: Mon Mar 31 17:58:07 2008 -0400
52
+
53
+ Quick fix for international numbers
54
+
55
+ commit fc874c849ed5fb4f7b1e35b3e6b0e1496b95cf4f
56
+ Author: Brendan G. Lim <brendan@intridea.com>
57
+ Date: Mon Mar 31 17:45:09 2008 -0400
58
+
59
+ Updating README with International carrier information
60
+
61
+ commit 7813e59c8535f6180852a534fd0bfd7ba6085ace
62
+ Author: Brendan G. Lim <brendan@intridea.com>
63
+ Date: Mon Mar 31 17:37:02 2008 -0400
64
+
65
+ Adding in international support and externalizing carrier list into sms_fu.yml
66
+
67
+ commit 5393cc834ce85da8856ed8869e7b5e66b004239f
68
+ Author: Brendan G. Lim <brendan@intridea.com>
69
+ Date: Sun Mar 30 19:01:20 2008 -0400
70
+
71
+ Made some readme changes
72
+
73
+ commit aba05f07d765306b5bd5f6c403a318092a437c0b
74
+ Author: Brendan G. Lim <brendan@intridea.com>
75
+ Date: Sun Mar 30 16:10:05 2008 -0400
76
+
77
+ Initial import
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Brendan G. Lim
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,59 @@
1
+ = SMS Fu
2
+
3
+ Want to send an SMS from your Rails application? SMS Fu allows you to do just that.
4
+ It allows you to send a text-message in the form of an e-mail to a cell phone on any
5
+ of the supported carriers.
6
+
7
+ == Supported Carriers (US & International):
8
+
9
+ Alltel, Ameritech, AT&T, BellSouth Mobility, BlueSkyFrog, Boost Mobile, Cellular South,
10
+ E-Plus, Fido, kajeet, Metro PCS, Powertel, PSC Wireless, Qwest, Southern Link, Sprint,
11
+ Suncom, T-Mobile (US/UK/Germany), Telefonica, Virgin Mobile, Verizon Wireless,
12
+ Vodafone (UK,Italy,Japan, Spain)
13
+
14
+ == Setup Instructions
15
+
16
+ Add this this one line to the controller you want to be able to use SMS Fu in.
17
+
18
+ class ExampleController < ApplicationController
19
+ include SMSFu
20
+ end
21
+
22
+ Modify sms_fu.yml in your config folder with your reply-to e-mail address.
23
+
24
+ That's it! Now you're good to go.
25
+
26
+ == Example Usage
27
+
28
+ * You have to send in the phone number, without any non-numeric characters. The
29
+ phone numbers must be 10 digits in length.
30
+ * The two required parameters are the phone number and the phone carrier.
31
+ * Here are some of the default carrier values:
32
+
33
+ Alltel Wireless => "alltel"
34
+ AT&T/Cingular => "at&t"
35
+ Boost Mobile => "boost"
36
+ Sprint Wireless => "sprint"
37
+ T-Mobile US => "t-mobile"
38
+ T-Mobile UK => "t-mobile-uk"
39
+ Virgin Mobile => "virgin"
40
+ Verizon Wireless => "verizon"
41
+ Vodafone Tokyo => "vodafone-jp-tokyo"
42
+
43
+ * <b>Check sms_fu.yml for a complete list of supported carriers, including international
44
+ carriers as well.</b>
45
+
46
+ deliver_sms("5558675309","at&t","your message here")
47
+
48
+ * You can set the maximum length of the SMS message, which is not set by
49
+ default. Most phones can only accept 128 characters. To do this just
50
+ specify the limit option.
51
+
52
+ deliver_sms("5558675309","at&t","your message here", :limit => 128)
53
+
54
+ * You can retrieve just the formatted address to use in your own mailer.
55
+
56
+ get_sms_address("5558675309","at&t") # => "5558675309@txt.att.net"
57
+
58
+
59
+ Copyright (c) 2008 Brendan G. Lim, Intridea, Inc., released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the sms_fu plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.pattern = 'test/**/*_test.rb'
12
+ t.verbose = true
13
+ end
14
+
15
+ desc 'Generate documentation for the sms_fu plugin.'
16
+ Rake::RDocTask.new(:rdoc) do |rdoc|
17
+ rdoc.rdoc_dir = 'rdoc'
18
+ rdoc.title = 'SmsFu'
19
+ rdoc.options << '--line-numbers' << '--inline-source'
20
+ rdoc.rdoc_files.include('README')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
+ end
data/lib/sms_fu.rb ADDED
@@ -0,0 +1,73 @@
1
+ require 'yaml'
2
+ require 'sms_notifier'
3
+ # Copyright (c) 2008 Brendan G. Lim (brendangl@gmail.com)
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining
6
+ # a copy of this software and associated documentation files (the
7
+ # "Software"), to deal in the Software without restriction, including
8
+ # without limitation the rights to use, copy, modify, merge, publish,
9
+ # distribute, sublicense, and/or sell copies of the Software, and to
10
+ # permit persons to whom the Software is furnished to do so, subject to
11
+ # the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ module SMSFu
25
+ RAILS_CONFIG_ROOT = defined?(RAILS_ROOT) ? "#{RAILS_ROOT}/config" : "#{File.dirname(__FILE__)}/../templates" unless defined?(RAILS_CONFIG_ROOT)
26
+ @config ||= YAML::load(File.open("#{RAILS_CONFIG_ROOT}/sms_fu.yml"))
27
+ @@carriers ||= @config['carriers']
28
+
29
+ def self.carriers
30
+ @@carriers.dup
31
+ end
32
+
33
+ def deliver_sms(number,carrier,message,options={})
34
+ number = format_number(number)
35
+ raise SMSFuException.new("Cannot deliver an empty message to #{number}") if message.nil? or message.empty?
36
+
37
+ options[:limit] ||= message.length
38
+ message = message[0..options[:limit]-1]
39
+ sms_email = determine_sms_email(format_number(number),carrier)
40
+
41
+ SmsNotifier.deliver_sms_message(sms_email,message)
42
+ rescue SMSFuException => exception
43
+ raise exception
44
+ end
45
+
46
+ def get_sms_address(number,carrier)
47
+ number = format_number(number)
48
+ determine_sms_email(number,carrier)
49
+ end
50
+
51
+ private
52
+
53
+ def format_number(number)
54
+ pre_formatted = number.gsub("-","").strip
55
+ formatted = (pre_formatted.length == 11 && pre_formatted[0,1] == "1") ? pre_formatted[1..pre_formatted.length] : pre_formatted
56
+
57
+ return is_valid?(formatted) ? formatted : (raise SMSFuException.new("Phone number (#{number}) is not formatted correctly"))
58
+ end
59
+
60
+ def is_valid?(number)
61
+ return (number.length >= 10 && number[/^.\d+$/]) ? true : false
62
+ end
63
+
64
+ def determine_sms_email(phone_number, carrier)
65
+ if @@carriers.has_key?(carrier.downcase)
66
+ "#{phone_number}#{@@carriers[carrier.downcase]}"
67
+ else
68
+ raise SMSFuException.new("Specified carrier, #{carrier} is not supported.")
69
+ end
70
+ end
71
+
72
+ class SMSFuException < StandardError; end
73
+ end
@@ -0,0 +1,45 @@
1
+ require 'yaml'
2
+ # Copyright (c) 2008 Brendan G. Lim (brendangl@gmail.com)
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ class SmsNotifier < ActionMailer::Base
24
+ @config = YAML::load(File.open("#{RAILS_ROOT}/config/sms_fu.yml"))
25
+ @@from_address = @config['config']['from_address']
26
+ cattr_accessor :from_address
27
+
28
+ def sms_message(recipient, message)
29
+ content_type "text/plain"
30
+ recipients recipient
31
+ from from_address
32
+
33
+ body['message'] = message
34
+ end
35
+
36
+ view_path = File.join(File.dirname(__FILE__), '..', 'views')
37
+ if public_methods.include?('append_view_path')
38
+ self.append_view_path view_path
39
+ elsif public_methods.include?("view_paths")
40
+ self.view_paths << view_path
41
+ else
42
+ self.template_root = view_path
43
+ end
44
+
45
+ end
data/rails/init.rb ADDED
@@ -0,0 +1,3 @@
1
+ require "action_mailer"
2
+ require File.dirname(__FILE__) + '/lib/sms_fu'
3
+ ActionView::Base.send(:include, SMSFu)
data/sms-fu.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'sms-fu'
3
+ s.version = '1.0.20080704'
4
+ s.date = '2008-07-04'
5
+
6
+ s.summary = "Easily send SMS messages from Rails"
7
+ s.description = "Want to send an SMS from your Rails application? SMS Fu allows you to do just that. It allows you to send a text-message in the form of an e-mail to a cell phone on any of the supported carriers."
8
+
9
+ s.authors = ['Brendan G. Lim']
10
+ s.email = 'brendan@intridea.com'
11
+ s.homepage = 'http://github.com/brendanlim/sms-fu'
12
+
13
+ s.has_rdoc = true
14
+ s.rdoc_options = ["--main", "README"]
15
+ s.extra_rdoc_files = ["README.rdoc"]
16
+
17
+ s.add_dependency 'rails', ['>= 2.1']
18
+
19
+ s.files = ["CHANGELOG",
20
+ "MIT-LICENSE",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "lib/sms_fu.rb",
24
+ "lib/sms_notifier.rb",
25
+ "rails/init.rb",
26
+ "sms-fu.gemspec",
27
+ "templates/sms_fu.yml",
28
+ "views/sms_notifier/sms_message.html.erb"]
29
+
30
+
31
+ s.test_files = ["test/sms_fu_test.rb"]
32
+
33
+ end
@@ -0,0 +1,52 @@
1
+ config:
2
+ from_address: noreply@domain.com
3
+
4
+ carriers:
5
+ # US Carriers
6
+ alltell: @message.alltell.com
7
+ ameritech: @paging.acswireless.com
8
+ at&t: @txt.att.net
9
+ bellsouthmobility: @blsdcs.net
10
+ blueskyfrog: @blueskyfrog.com
11
+ boost: @myboostmobile.com
12
+ cellularsouth: @csouth1.com
13
+ kajeet: @mobile.kajeet.net
14
+ metropcs: @mymetropcs.com
15
+ powertel: @ptel.net
16
+ pscwireless: @sms.pscel.com
17
+ qwest: @qwestmp.com
18
+ southernlink: @page.southernlinc.com
19
+ sprint: @messaging.sprintpcs.com
20
+ suncom: @tms.suncom.com
21
+ t-mobile: @tmomail.net
22
+ virgin: @vmobl.net
23
+ verizon: @vtext.com
24
+ # International Carriers
25
+ e-plus-germany: @smsmail.eplus.de
26
+ fido-canada: @fido.ca
27
+ o2-germany: @o2online.de
28
+ o2-uk: @mmail.co.uk
29
+ orange-netherlands: @sms.orange.nl
30
+ orange-uk: @orange.net
31
+ t-mobile-austria: @sms.t-mobile.at
32
+ t-mobile-germany: @t-d1-sms.de
33
+ t-mobile-uk: @t-mobile.uk.net
34
+ telefonica-spain: @movistar.net
35
+ vodafone-germany: @vodafone-sms.de
36
+ vodafone-uk: @sms.vodafone.net
37
+ vodafone-italy: @sms.vodafone.it
38
+ vodafone-jp-chuugoku: @n.vodafone.ne.jp
39
+ vodafone-jp-hokkaido: @d.vodafone.ne.jp
40
+ vodafone-jp-hokuriko: @r.vodafone.ne.jp
41
+ vodafone-jp-kansai: @k.vodafone.ne.jp
42
+ vodafone-jp-osaka: @k.vodafone.ne.jp
43
+ vodafone-jp-kanto: @k.vodafone.ne.jp
44
+ vodafone-jp-koushin: @k.vodafone.ne.jp
45
+ vodafone-jp-tokyo: @k.vodafone.ne.jp
46
+ vodafone-jp-kyuushu: @q.vodafone.ne.jp
47
+ vodafone-jp-okinawa: @q.vodafone.ne.jp
48
+ vodafone-jp-shikoku: @s.vodafone.ne.jp
49
+ vodafone-jp-touhoku: @h.vodafone.ne.jp
50
+ vodafone-jp-niigata: @h.vodafone.ne.jp
51
+ vodafone-jp-toukai: @h.vodafone.ne.jp
52
+ vodafone-spain: @vodafone.es
@@ -0,0 +1,23 @@
1
+ require 'test/unit'
2
+ require 'sms_fu'
3
+
4
+ class SmsFuTest < Test::Unit::TestCase
5
+ include SMSFu
6
+
7
+ def test_validity_of_number
8
+ assert_raise(SMSFuException) { deliver_sms("456789011","AT&T","Message") }
9
+ assert_equal("5555555555@txt.att.net", get_sms_address("1-555-555-5555","AT&T"))
10
+ end
11
+
12
+ def test_international_number
13
+ assert_equal("+445555555555@txt.att.net", get_sms_address("+44-555-555-5555","AT&T"))
14
+ end
15
+
16
+ def test_handling_of_blank_message
17
+ assert_raise(SMSFuException) { deliver_sms("1234567890","AT&T","") }
18
+ end
19
+
20
+ def test_get_sms_address
21
+ assert_equal("1234567890@txt.att.net", get_sms_address("1234567890","AT&T"))
22
+ end
23
+ end
@@ -0,0 +1 @@
1
+ <%= @message %>
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jcnetdev-sms-fu
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.20080704
5
+ platform: ruby
6
+ authors:
7
+ - Brendan G. Lim
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-07-04 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "2.1"
23
+ version:
24
+ description: Want to send an SMS from your Rails application? SMS Fu allows you to do just that. It allows you to send a text-message in the form of an e-mail to a cell phone on any of the supported carriers.
25
+ email: brendan@intridea.com
26
+ executables: []
27
+
28
+ extensions: []
29
+
30
+ extra_rdoc_files:
31
+ - README.rdoc
32
+ files:
33
+ - CHANGELOG
34
+ - MIT-LICENSE
35
+ - README.rdoc
36
+ - Rakefile
37
+ - lib/sms_fu.rb
38
+ - lib/sms_notifier.rb
39
+ - rails/init.rb
40
+ - sms-fu.gemspec
41
+ - templates/sms_fu.yml
42
+ - views/sms_notifier/sms_message.html.erb
43
+ has_rdoc: true
44
+ homepage: http://github.com/brendanlim/sms-fu
45
+ post_install_message:
46
+ rdoc_options:
47
+ - --main
48
+ - README
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
63
+ requirements: []
64
+
65
+ rubyforge_project:
66
+ rubygems_version: 1.2.0
67
+ signing_key:
68
+ specification_version: 2
69
+ summary: Easily send SMS messages from Rails
70
+ test_files:
71
+ - test/sms_fu_test.rb