brendanlim-sms-fu 1.0.0
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 +131 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +89 -0
- data/Rakefile +36 -0
- data/VERSION +1 -0
- data/init.rb +5 -0
- data/install.rb +4 -0
- data/lib/sms_fu.rb +81 -0
- data/lib/sms_fu_helper.rb +15 -0
- data/lib/sms_notifier.rb +42 -0
- data/sms-fu.gemspec +52 -0
- data/tasks/sms_fu_tasks.rake +0 -0
- data/templates/sms_fu.yml +207 -0
- data/test/sms_fu_test.rb +23 -0
- data/uninstall.rb +1 -0
- data/views/sms_notifier/sms_message.html.erb +1 -0
- metadata +68 -0
data/CHANGELOG
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
commit 8abc7168dd392b083fdfd3a9cb2ce1e7c1d068a0
|
2
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
3
|
+
Date: Wed Feb 18 20:25:05 2009 -0500
|
4
|
+
|
5
|
+
Some structural changes to SMS Fu
|
6
|
+
|
7
|
+
commit 4e5aa349ac9d4c12da5d53de08d1fd3281bcfa0d
|
8
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
9
|
+
Date: Wed Feb 18 20:12:55 2009 -0500
|
10
|
+
|
11
|
+
Updating CHANGELOG
|
12
|
+
|
13
|
+
commit 4c1b777458b90de5d7c01cf7d14ef0be2fdcc4e6
|
14
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
15
|
+
Date: Wed Feb 18 20:12:33 2009 -0500
|
16
|
+
|
17
|
+
Adding in some view helpers for mobile carrier select boxes and updating README
|
18
|
+
|
19
|
+
commit 0d804bdd6e48aa3eae548665c4740b2e2d4e3b86
|
20
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
21
|
+
Date: Mon Dec 15 14:17:16 2008 -0500
|
22
|
+
|
23
|
+
Adding Etisalat support and adding country designation to mobinil and movistar
|
24
|
+
|
25
|
+
commit 0d417e1f30f5b153e9658e5649144630b95c2ec1
|
26
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
27
|
+
Date: Thu Dec 11 19:09:20 2008 -0500
|
28
|
+
|
29
|
+
Adding Vodafone Egypt, Virgin Mobile Canada, and Mobitel Sri Lanka to supported SMS carriers
|
30
|
+
|
31
|
+
commit ec20bd73afe7c26583bcdb7037028161f65cc8a5
|
32
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
33
|
+
Date: Thu Dec 11 13:31:17 2008 -0500
|
34
|
+
|
35
|
+
Adding a good chunk of carriers into SMS Fu
|
36
|
+
|
37
|
+
commit 8d9a829177f6a249206892ccc7a13b8ae5467496
|
38
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
39
|
+
Date: Thu Jul 31 13:48:30 2008 -0400
|
40
|
+
|
41
|
+
Upating the CHANGELOG
|
42
|
+
|
43
|
+
commit 3912b0b91621ba1a827585f3b22c1426fc70c9e4
|
44
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
45
|
+
Date: Thu Jul 31 13:48:15 2008 -0400
|
46
|
+
|
47
|
+
Adding ability to specify custom from address per mailing
|
48
|
+
|
49
|
+
commit 09fc1fa3076082d98b61f7cdf0d10dd5abd30a1a
|
50
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
51
|
+
Date: Thu Jun 19 02:18:09 2008 -0400
|
52
|
+
|
53
|
+
Updating CHANGELOG
|
54
|
+
|
55
|
+
commit f1026d0aca169caf57dd44e57661177bd66e2e37
|
56
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
57
|
+
Date: Thu Jun 19 02:17:08 2008 -0400
|
58
|
+
|
59
|
+
Updating to be compatibile with Rails 2.1
|
60
|
+
|
61
|
+
commit de241d15bfa878f600a462f49b4fd3c92285c3ab
|
62
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
63
|
+
Date: Sat May 31 10:05:16 2008 -0700
|
64
|
+
|
65
|
+
Merging in changes from gcnovus for fixing warnings and redundant YAML parsing when requiring sms_fu more than once.
|
66
|
+
|
67
|
+
commit d23d86216ffc5a6b44db5b354934f40178e9dfc0
|
68
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
69
|
+
Date: Sat Apr 19 01:23:45 2008 -0500
|
70
|
+
|
71
|
+
Another update to README
|
72
|
+
|
73
|
+
commit e8386f3b75f5f4794d5f280025772a34e79542ba
|
74
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
75
|
+
Date: Sat Apr 19 01:23:17 2008 -0500
|
76
|
+
|
77
|
+
Another update to README
|
78
|
+
|
79
|
+
commit d16925d6f60669d492005b419df212d26b3d21bd
|
80
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
81
|
+
Date: Sat Apr 19 01:17:51 2008 -0500
|
82
|
+
|
83
|
+
Adding in kajeet to carrier list and updated README
|
84
|
+
|
85
|
+
commit 9cf4ef9db332418dd167bd942f29ed34d11f20f9
|
86
|
+
Author: Jannis Leidel <jannis@leidel.info>
|
87
|
+
Date: Sat Apr 12 13:40:30 2008 +0200
|
88
|
+
|
89
|
+
added some international carriers
|
90
|
+
|
91
|
+
commit 364997b52bdb1c7ae8b3382b4742b5fbd52fb20c
|
92
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
93
|
+
Date: Mon Mar 31 18:23:53 2008 -0400
|
94
|
+
|
95
|
+
Fixed indentation of README and minor tweak
|
96
|
+
|
97
|
+
commit 5ecbaaee4d38543a66767b02d5b41ef9e885f2d5
|
98
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
99
|
+
Date: Mon Mar 31 18:18:40 2008 -0400
|
100
|
+
|
101
|
+
Fixed some of the tests
|
102
|
+
|
103
|
+
commit cb0138f5f1f637bcd5065e548b0dac04d413acd8
|
104
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
105
|
+
Date: Mon Mar 31 17:58:07 2008 -0400
|
106
|
+
|
107
|
+
Quick fix for international numbers
|
108
|
+
|
109
|
+
commit fc874c849ed5fb4f7b1e35b3e6b0e1496b95cf4f
|
110
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
111
|
+
Date: Mon Mar 31 17:45:09 2008 -0400
|
112
|
+
|
113
|
+
Updating README with International carrier information
|
114
|
+
|
115
|
+
commit 7813e59c8535f6180852a534fd0bfd7ba6085ace
|
116
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
117
|
+
Date: Mon Mar 31 17:37:02 2008 -0400
|
118
|
+
|
119
|
+
Adding in international support and externalizing carrier list into sms_fu.yml
|
120
|
+
|
121
|
+
commit 5393cc834ce85da8856ed8869e7b5e66b004239f
|
122
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
123
|
+
Date: Sun Mar 30 19:01:20 2008 -0400
|
124
|
+
|
125
|
+
Made some readme changes
|
126
|
+
|
127
|
+
commit aba05f07d765306b5bd5f6c403a318092a437c0b
|
128
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
129
|
+
Date: Sun Mar 30 16:10:05 2008 -0400
|
130
|
+
|
131
|
+
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,89 @@
|
|
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, Bell Atlantic, BellSouth Mobility, Beeline(UA), BlueSkyFrog,
|
10
|
+
Boost Mobile, BPL Mobile, Cellular South, Claro (Brazil, Nicaragua), Comcast, Du,
|
11
|
+
E-Plus, Etisalat, Fido, kajeet, Mobinil, Mobitel, Movistar, Metro PCS, O2, Orange,
|
12
|
+
Powertel, PSC Wireless, Qwest, Rogers, Southern Link, Sprint, Suncom,
|
13
|
+
T-Mobile (US/UK/Germany), Telefonica, Tracfone, Virgin Mobile, Verizon Wireless,
|
14
|
+
Vodafone (UK, Egypt, Italy, Japan, Spain), and many more ...
|
15
|
+
|
16
|
+
== Opt-In Warning for Some International Carriers
|
17
|
+
|
18
|
+
Some International carriers require that their users subscribe to an Email to SMS
|
19
|
+
feature before they are able to receive SMS messages this way. If one your users
|
20
|
+
mentions that they are not receiving their messages, chances are it is due to this
|
21
|
+
limitation.
|
22
|
+
|
23
|
+
Some carriers that need this include, Mobitel, Etisalat, T-Mobile (Netherlands),
|
24
|
+
etc.
|
25
|
+
|
26
|
+
== Setup Instructions
|
27
|
+
|
28
|
+
Add this this one line to the controller you want to be able to use SMS Fu in.
|
29
|
+
|
30
|
+
class ExampleController < ApplicationController
|
31
|
+
has_sms_fu
|
32
|
+
end
|
33
|
+
|
34
|
+
Modify sms_fu.yml in your config folder with your reply-to e-mail address.
|
35
|
+
|
36
|
+
That's it! Now you're good to go.
|
37
|
+
|
38
|
+
== Example Usage
|
39
|
+
|
40
|
+
* You have to send in the phone number, without any non-numeric characters. The
|
41
|
+
phone numbers must be 10 digits in length.
|
42
|
+
* The two required parameters are the phone number and the phone carrier.
|
43
|
+
* Here are some of the default carrier values:
|
44
|
+
|
45
|
+
Alltel Wireless => "alltel"
|
46
|
+
AT&T/Cingular => "at&t"
|
47
|
+
Boost Mobile => "boost"
|
48
|
+
Sprint Wireless => "sprint"
|
49
|
+
T-Mobile US => "t-mobile"
|
50
|
+
T-Mobile UK => "t-mobile-uk"
|
51
|
+
Virgin Mobile => "virgin"
|
52
|
+
Verizon Wireless => "verizon"
|
53
|
+
Vodafone Tokyo => "vodafone-jp-tokyo"
|
54
|
+
|
55
|
+
* <b>Check sms_fu.yml for a complete list of supported carriers, including international
|
56
|
+
carriers as well.</b>
|
57
|
+
|
58
|
+
deliver_sms("5558675309","at&t","message")
|
59
|
+
|
60
|
+
* If you want to set a custom from e-mail per SMS message, you can do so
|
61
|
+
by doing the following.
|
62
|
+
|
63
|
+
deliver_sms("5558675309","at&t","message", :from => "bob@test.com")
|
64
|
+
|
65
|
+
* You can set the maximum length of the SMS message, which is not set by
|
66
|
+
default. Most phones can only accept 128 characters. To do this just
|
67
|
+
specify the limit option.
|
68
|
+
|
69
|
+
deliver_sms("5558675309","at&t","message", :limit => 128)
|
70
|
+
|
71
|
+
* You can retrieve just the formatted address to use in your own mailer.
|
72
|
+
|
73
|
+
get_sms_address("5558675309","at&t") # => "5558675309@txt.att.net"
|
74
|
+
|
75
|
+
== View Helpers
|
76
|
+
|
77
|
+
* Retrieve a collection of all carriers
|
78
|
+
|
79
|
+
<%= carrier_collection %>
|
80
|
+
|
81
|
+
* Display a select box with mobile carriers
|
82
|
+
|
83
|
+
<%= carrier_select %>
|
84
|
+
|
85
|
+
* Display a custom select box with mobile carriers
|
86
|
+
|
87
|
+
<%= carrier_select('user[carrier_name]', "Please choose a carrier") %>
|
88
|
+
|
89
|
+
Copyright (c) 2008 Brendan G. Lim, Intridea, Inc., released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
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
|
23
|
+
|
24
|
+
begin
|
25
|
+
require 'jeweler'
|
26
|
+
Jeweler::Tasks.new do |gemspec|
|
27
|
+
gemspec.name = "sms-fu"
|
28
|
+
gemspec.summary = "SMS Fu allows ou to send a text-message for free in the form of an e-mail to a mobile recipient."
|
29
|
+
gemspec.description = "SMS Fu allows ou to send a text-message for free in the form of an e-mail to a mobile recipient."
|
30
|
+
gemspec.email = "brendangl@gmail.com"
|
31
|
+
gemspec.homepage = "http://github.com/brendanlim/sms-fu"
|
32
|
+
gemspec.authors = ["Brendan G. Lim"]
|
33
|
+
end
|
34
|
+
rescue LoadError
|
35
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
36
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
data/init.rb
ADDED
data/install.rb
ADDED
data/lib/sms_fu.rb
ADDED
@@ -0,0 +1,81 @@
|
|
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
|
+
def self.included(base)
|
26
|
+
base.class_eval do
|
27
|
+
def self.has_sms_fu
|
28
|
+
include SMSFu
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
RAILS_CONFIG_ROOT = defined?(RAILS_ROOT) ? "#{RAILS_ROOT}/config" : "#{File.dirname(__FILE__)}/../templates" unless defined?(RAILS_CONFIG_ROOT)
|
34
|
+
@config ||= YAML::load(File.open("#{RAILS_CONFIG_ROOT}/sms_fu.yml"))
|
35
|
+
@@carriers ||= @config['carriers']
|
36
|
+
@@from_address = @config['config']['from_address']
|
37
|
+
|
38
|
+
def self.carriers
|
39
|
+
@@carriers.dup
|
40
|
+
end
|
41
|
+
|
42
|
+
def deliver_sms(number,carrier,message,options={})
|
43
|
+
raise SMSFuException.new("Cannot deliver an empty message to #{format_number(number)}") if message.nil? or message.empty?
|
44
|
+
|
45
|
+
options[:limit] ||= message.length
|
46
|
+
options[:from] ||= @@from_address
|
47
|
+
message = message[0..options[:limit]-1]
|
48
|
+
sms_email = determine_sms_email(format_number(number),carrier)
|
49
|
+
|
50
|
+
SmsNotifier.deliver_sms_message(sms_email,message,options[:from])
|
51
|
+
rescue SMSFuException => exception
|
52
|
+
raise exception
|
53
|
+
end
|
54
|
+
|
55
|
+
def get_sms_address(number,carrier)
|
56
|
+
number = format_number(number)
|
57
|
+
determine_sms_email(number,carrier)
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def format_number(number)
|
63
|
+
pre_formatted = number.gsub("-","").strip
|
64
|
+
formatted = (pre_formatted.length == 11 && pre_formatted[0,1] == "1") ? pre_formatted[1..pre_formatted.length] : pre_formatted
|
65
|
+
return is_valid?(formatted) ? formatted : (raise SMSFuException.new("Phone number (#{number}) is not formatted correctly"))
|
66
|
+
end
|
67
|
+
|
68
|
+
def is_valid?(number)
|
69
|
+
number.length >= 10 && number[/^.\d+$/]
|
70
|
+
end
|
71
|
+
|
72
|
+
def determine_sms_email(phone_number, carrier)
|
73
|
+
if @@carriers.has_key?(carrier.downcase)
|
74
|
+
"#{phone_number}#{@@carriers[carrier.downcase]['value']}"
|
75
|
+
else
|
76
|
+
raise SMSFuException.new("Specified carrier, #{carrier} is not supported.")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
class SMSFuException < StandardError; end
|
81
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module SMSFuHelper
|
2
|
+
# Returns a collection of carriers to be used in your own select tag
|
3
|
+
# e.g., <%= f.select :mobile_carrier, carrier_collection %>
|
4
|
+
def carrier_collection
|
5
|
+
SMSFu.carriers.sort.collect{ |carrier| [carrier[1]["name"], carrier[0]] }
|
6
|
+
end
|
7
|
+
|
8
|
+
# Returns a formatted select box filled with carriers
|
9
|
+
# e.g., <%= carrier_select %>
|
10
|
+
# - name => name of the method in which you want to store the carrier name
|
11
|
+
# - phrase => default selected blank option in select box
|
12
|
+
def carrier_select(name = :mobile_carrier, phrase = "Select a Carrier")
|
13
|
+
select_tag name, options_for_select([phrase,nil]+carrier_collection, phrase)
|
14
|
+
end
|
15
|
+
end
|
data/lib/sms_notifier.rb
ADDED
@@ -0,0 +1,42 @@
|
|
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
|
+
|
26
|
+
def sms_message(recipient, message, sender_email)
|
27
|
+
content_type "text/plain"
|
28
|
+
recipients recipient
|
29
|
+
from sender_email
|
30
|
+
body['message'] = message
|
31
|
+
end
|
32
|
+
|
33
|
+
view_path = File.join(File.dirname(__FILE__), '..', 'views')
|
34
|
+
if public_methods.include?('append_view_path')
|
35
|
+
self.append_view_path view_path
|
36
|
+
elsif public_methods.include?("view_paths")
|
37
|
+
self.view_paths << view_path
|
38
|
+
else
|
39
|
+
self.template_root = view_path
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
data/sms-fu.gemspec
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{sms-fu}
|
5
|
+
s.version = "1.0.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Brendan G. Lim"]
|
9
|
+
s.date = %q{2009-07-20}
|
10
|
+
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.}
|
11
|
+
s.email = %q{brendangl@gmail.com}
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"README.rdoc"
|
14
|
+
]
|
15
|
+
s.files = [
|
16
|
+
"CHANGELOG",
|
17
|
+
"MIT-LICENSE",
|
18
|
+
"README.rdoc",
|
19
|
+
"Rakefile",
|
20
|
+
"VERSION",
|
21
|
+
"init.rb",
|
22
|
+
"install.rb",
|
23
|
+
"lib/sms_fu.rb",
|
24
|
+
"lib/sms_fu_helper.rb",
|
25
|
+
"lib/sms_notifier.rb",
|
26
|
+
"sms-fu.gemspec",
|
27
|
+
"tasks/sms_fu_tasks.rake",
|
28
|
+
"templates/sms_fu.yml",
|
29
|
+
"test/sms_fu_test.rb",
|
30
|
+
"uninstall.rb",
|
31
|
+
"views/sms_notifier/sms_message.html.erb"
|
32
|
+
]
|
33
|
+
s.has_rdoc = true
|
34
|
+
s.homepage = %q{http://github.com/brendanlim/sms-fu}
|
35
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = %q{1.3.1}
|
38
|
+
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.}
|
39
|
+
s.test_files = [
|
40
|
+
"test/sms_fu_test.rb"
|
41
|
+
]
|
42
|
+
|
43
|
+
if s.respond_to? :specification_version then
|
44
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
45
|
+
s.specification_version = 2
|
46
|
+
|
47
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
48
|
+
else
|
49
|
+
end
|
50
|
+
else
|
51
|
+
end
|
52
|
+
end
|
File without changes
|
@@ -0,0 +1,207 @@
|
|
1
|
+
config:
|
2
|
+
from_address: noreply@domain.com
|
3
|
+
|
4
|
+
carriers:
|
5
|
+
# US Carriers
|
6
|
+
alltel:
|
7
|
+
name: Alltel
|
8
|
+
value: @message.alltel.com
|
9
|
+
ameritech:
|
10
|
+
name: Ameritech
|
11
|
+
value: @paging.acswireless.com
|
12
|
+
at&t:
|
13
|
+
name: AT&T
|
14
|
+
value: @txt.att.net
|
15
|
+
bell-atlantic:
|
16
|
+
name: Bell Atlantic
|
17
|
+
value: @message.bam.com
|
18
|
+
bellsouthmobility:
|
19
|
+
name: Bellsouth Mobility
|
20
|
+
value: @blsdcs.net
|
21
|
+
blueskyfrog:
|
22
|
+
name: BlueSkyFrog
|
23
|
+
valye: @blueskyfrog.com
|
24
|
+
boost:
|
25
|
+
name: Boost Mobile
|
26
|
+
value: @myboostmobile.com
|
27
|
+
cellularsouth:
|
28
|
+
name: Cellular South
|
29
|
+
value: @csouth1.com
|
30
|
+
comcast:
|
31
|
+
name: Comcast PCS
|
32
|
+
value: @comcastpcs.textmsg.com
|
33
|
+
cricket:
|
34
|
+
name: Cricket
|
35
|
+
value: @sms.mycricket.com
|
36
|
+
kajeet:
|
37
|
+
name: kajeet
|
38
|
+
value: @mobile.kajeet.net
|
39
|
+
metropcs:
|
40
|
+
name: Metro PCS
|
41
|
+
value: @mymetropcs.com
|
42
|
+
powertel:
|
43
|
+
name: Powertel
|
44
|
+
value: @ptel.net
|
45
|
+
pscwireless:
|
46
|
+
name: PSC Wireless
|
47
|
+
value: @sms.pscel.com
|
48
|
+
qwest:
|
49
|
+
name: Qwest
|
50
|
+
value: @qwestmp.com
|
51
|
+
southernlink:
|
52
|
+
name: Southern Link
|
53
|
+
value: @page.southernlinc.com
|
54
|
+
sprint:
|
55
|
+
name: Sprint PCS
|
56
|
+
value: @messaging.sprintpcs.com
|
57
|
+
suncom:
|
58
|
+
name: Suncom
|
59
|
+
value: @tms.suncom.com
|
60
|
+
t-mobile:
|
61
|
+
name: T-Mobile
|
62
|
+
value: @tmomail.net
|
63
|
+
tracfone:
|
64
|
+
name: Tracfone
|
65
|
+
value: @mmst5.tracfone.com
|
66
|
+
telus-mobility:
|
67
|
+
name: Telus Mobility
|
68
|
+
value: @msg.telus.com
|
69
|
+
virgin:
|
70
|
+
name: Virgin Mobile
|
71
|
+
value: @vmobl.net
|
72
|
+
verizon:
|
73
|
+
name: Verizon Wireless
|
74
|
+
value: @vtext.com
|
75
|
+
# International Carriers
|
76
|
+
beeline-ua:
|
77
|
+
name: Beeline
|
78
|
+
value: @sms.beeline.ua
|
79
|
+
bpl-mobile:
|
80
|
+
name: BPL Mobile
|
81
|
+
value: @bplmobile.com
|
82
|
+
claro-brazil:
|
83
|
+
name: Claro (Brazil)
|
84
|
+
value: @clarotorpedo.com.br
|
85
|
+
claro-nicaragua:
|
86
|
+
name: Claro (Nicaragua)
|
87
|
+
value: @ideasclaro-ca.com
|
88
|
+
du-arab-emirates:
|
89
|
+
name: Du
|
90
|
+
value: @email2sms.ae
|
91
|
+
e-plus-germany:
|
92
|
+
name: E-Plus
|
93
|
+
value: @smsmail.eplus.de
|
94
|
+
etisalat-arab-emirates:
|
95
|
+
name: Etisalat
|
96
|
+
value: @email2sms.ae
|
97
|
+
fido-canada:
|
98
|
+
name: Fido
|
99
|
+
value: @fido.ca
|
100
|
+
mobinil-egypt:
|
101
|
+
name: Mobinil
|
102
|
+
value: @mobinil.net
|
103
|
+
mobistar-belgium:
|
104
|
+
name: Mobistar (Belgium)
|
105
|
+
value: @mobistar.be
|
106
|
+
mobitel:
|
107
|
+
name: Mobitel
|
108
|
+
value: @sms.mobitel.lk
|
109
|
+
movistar-spain:
|
110
|
+
name: Movistar
|
111
|
+
value: @correo.movistar.net
|
112
|
+
o2-germany:
|
113
|
+
name: o2 (Germany)
|
114
|
+
value: @o2online.de
|
115
|
+
o2-uk:
|
116
|
+
name: o2 (UK)
|
117
|
+
value: @mmail.co.uk
|
118
|
+
orange-mumbai:
|
119
|
+
name: Orange (Mumbai)
|
120
|
+
value: @orangemail.co.in
|
121
|
+
orange-netherlands:
|
122
|
+
name: Orange (Netherlands)
|
123
|
+
value: @sms.orange.nl
|
124
|
+
orange-uk:
|
125
|
+
name: Orange (UK)
|
126
|
+
value: @orange.net
|
127
|
+
rogers-wireless:
|
128
|
+
name: Rogers Wireless
|
129
|
+
value: @pcs.rogers.com
|
130
|
+
sfr-france:
|
131
|
+
name: SFR (France)
|
132
|
+
value: @sfr.fr
|
133
|
+
t-mobile-austria:
|
134
|
+
name: T-Mobile (Austria)
|
135
|
+
value: @sms.t-mobile.at
|
136
|
+
t-mobile-germany:
|
137
|
+
name: T-Mobile (Germany)
|
138
|
+
value: @t-d1-sms.de
|
139
|
+
t-mobile-germany:
|
140
|
+
name: T-Mobile (Netherlands)
|
141
|
+
value: @gin.nl
|
142
|
+
t-mobile-uk:
|
143
|
+
name: T-Mobile (UK)
|
144
|
+
value: @t-mobile.uk.net
|
145
|
+
telefonica-spain:
|
146
|
+
name: Telefonica
|
147
|
+
value: @movistar.net
|
148
|
+
virgin-canada:
|
149
|
+
name: Virgin Canada
|
150
|
+
value: @vmobile.ca
|
151
|
+
vodafone-germany:
|
152
|
+
name: Vodafone (Germany)
|
153
|
+
value: @vodafone-sms.de
|
154
|
+
vodafone-egypt:
|
155
|
+
name: Vodafone (Egypt)
|
156
|
+
value: @vodafone.com.eg
|
157
|
+
vodafone-uk:
|
158
|
+
name: Vodafone (UK)
|
159
|
+
value: @sms.vodafone.net
|
160
|
+
vodafone-italy:
|
161
|
+
name: Vodafone (Italy)
|
162
|
+
value: @sms.vodafone.it
|
163
|
+
vodafone-jp-chuugoku:
|
164
|
+
name: Vodafone (Japan - Chuugoku)
|
165
|
+
value: @n.vodafone.ne.jp
|
166
|
+
vodafone-jp-hokkaido:
|
167
|
+
name: Vodafone (Japan - Hokkaido)
|
168
|
+
value: @d.vodafone.ne.jp
|
169
|
+
vodafone-jp-hokuriko:
|
170
|
+
name: Vodafone (Japan - Hokuriko)
|
171
|
+
value: @r.vodafone.ne.jp
|
172
|
+
vodafone-jp-kansai:
|
173
|
+
name: Vodafone (Japan - Kansai)
|
174
|
+
value: @k.vodafone.ne.jp
|
175
|
+
vodafone-jp-osaka:
|
176
|
+
name: Vodafone (Japan - Osaka)
|
177
|
+
value: @k.vodafone.ne.jp
|
178
|
+
vodafone-jp-kanto:
|
179
|
+
name: Vodafone (Japan - Kanto)
|
180
|
+
value: @k.vodafone.ne.jp
|
181
|
+
vodafone-jp-koushin:
|
182
|
+
name: Vodafone (Japan - Koushin)
|
183
|
+
value: @k.vodafone.ne.jp
|
184
|
+
vodafone-jp-tokyo:
|
185
|
+
name: Vodafone (Japan - Tokyo)
|
186
|
+
value: @k.vodafone.ne.jp
|
187
|
+
vodafone-jp-kyuushu:
|
188
|
+
name: Vodafone (Japan - Kyuushu)
|
189
|
+
value: @q.vodafone.ne.jp
|
190
|
+
vodafone-jp-okinawa:
|
191
|
+
name: Vodafone (Japan - Okinawa)
|
192
|
+
value: @q.vodafone.ne.jp
|
193
|
+
vodafone-jp-shikoku:
|
194
|
+
name: Vodafone (Japan - Shikoku)
|
195
|
+
value: @s.vodafone.ne.jp
|
196
|
+
vodafone-jp-touhoku:
|
197
|
+
name: Vodafone (Japan - Touhoku)
|
198
|
+
value: @h.vodafone.ne.jp
|
199
|
+
vodafone-jp-niigata:
|
200
|
+
name: Vodafone (Japan - Niigata)
|
201
|
+
value: @h.vodafone.ne.jp
|
202
|
+
vodafone-jp-toukai:
|
203
|
+
name: Vodafone (Japan - Toukai)
|
204
|
+
value: @h.vodafone.ne.jp
|
205
|
+
vodafone-spain:
|
206
|
+
name: Vodafone (Japan - Spain)
|
207
|
+
value: @vodafone.es
|
data/test/sms_fu_test.rb
ADDED
@@ -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
|
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @message %>
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: brendanlim-sms-fu
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brendan G. Lim
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-20 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: SMS Fu allows ou to send a text-message for free in the form of an e-mail to a mobile recipient.
|
17
|
+
email: brendangl@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.rdoc
|
24
|
+
files:
|
25
|
+
- CHANGELOG
|
26
|
+
- MIT-LICENSE
|
27
|
+
- README.rdoc
|
28
|
+
- Rakefile
|
29
|
+
- VERSION
|
30
|
+
- init.rb
|
31
|
+
- install.rb
|
32
|
+
- lib/sms_fu.rb
|
33
|
+
- lib/sms_fu_helper.rb
|
34
|
+
- lib/sms_notifier.rb
|
35
|
+
- sms-fu.gemspec
|
36
|
+
- tasks/sms_fu_tasks.rake
|
37
|
+
- templates/sms_fu.yml
|
38
|
+
- test/sms_fu_test.rb
|
39
|
+
- uninstall.rb
|
40
|
+
- views/sms_notifier/sms_message.html.erb
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: http://github.com/brendanlim/sms-fu
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options:
|
45
|
+
- --charset=UTF-8
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: "0"
|
53
|
+
version:
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
version:
|
60
|
+
requirements: []
|
61
|
+
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.2.0
|
64
|
+
signing_key:
|
65
|
+
specification_version: 2
|
66
|
+
summary: SMS Fu allows ou to send a text-message for free in the form of an e-mail to a mobile recipient.
|
67
|
+
test_files:
|
68
|
+
- test/sms_fu_test.rb
|