smsonrails 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/MIT-LICENSE +20 -0
- data/Manifest +101 -0
- data/README.rdoc +211 -0
- data/Rakefile +109 -0
- data/app/controllers/admin/sms_on_rails/base_controller.rb +11 -0
- data/app/controllers/admin/sms_on_rails/drafts_controller.rb +75 -0
- data/app/controllers/admin/sms_on_rails/outbounds_controller.rb +117 -0
- data/app/controllers/admin/sms_on_rails/phone_carriers_controller.rb +85 -0
- data/app/controllers/admin/sms_on_rails/phone_numbers_controller.rb +101 -0
- data/app/controllers/sms_on_rails/creation_support.rb +99 -0
- data/app/controllers/sms_on_rails_controller.rb +14 -0
- data/app/helpers/admin/sms_on_rails/drafts_helper.rb +2 -0
- data/app/helpers/admin/sms_on_rails/phone_carriers_helper.rb +2 -0
- data/app/helpers/sms_on_rails/phone_numbers_helper.rb +9 -0
- data/app/helpers/sms_on_rails/sms_helper.rb +44 -0
- data/app/models/sms_on_rails/draft.rb +9 -0
- data/app/models/sms_on_rails/outbound.rb +17 -0
- data/app/models/sms_on_rails/phone_carrier.rb +14 -0
- data/app/models/sms_on_rails/phone_number.rb +8 -0
- data/app/views/admin/sms_on_rails/base/index.html.erb +5 -0
- data/app/views/admin/sms_on_rails/drafts/_show.html.erb +34 -0
- data/app/views/admin/sms_on_rails/drafts/edit.html.erb +36 -0
- data/app/views/admin/sms_on_rails/drafts/index.html.erb +32 -0
- data/app/views/admin/sms_on_rails/drafts/new.html.erb +34 -0
- data/app/views/admin/sms_on_rails/drafts/send_sms.html.erb +3 -0
- data/app/views/admin/sms_on_rails/drafts/show.html.erb +4 -0
- data/app/views/admin/sms_on_rails/outbounds/edit.html.erb +68 -0
- data/app/views/admin/sms_on_rails/outbounds/index.html.erb +37 -0
- data/app/views/admin/sms_on_rails/outbounds/new.html.erb +54 -0
- data/app/views/admin/sms_on_rails/outbounds/show.html.erb +69 -0
- data/app/views/admin/sms_on_rails/phone_carriers/edit.html.erb +24 -0
- data/app/views/admin/sms_on_rails/phone_carriers/index.html.erb +24 -0
- data/app/views/admin/sms_on_rails/phone_carriers/new.html.erb +22 -0
- data/app/views/admin/sms_on_rails/phone_carriers/show.html.erb +24 -0
- data/app/views/admin/sms_on_rails/phone_numbers/edit.html.erb +33 -0
- data/app/views/admin/sms_on_rails/phone_numbers/index.html.erb +28 -0
- data/app/views/admin/sms_on_rails/phone_numbers/new.html.erb +31 -0
- data/app/views/admin/sms_on_rails/phone_numbers/show.html.erb +32 -0
- data/app/views/layouts/sms_on_rails/basic.html.erb +26 -0
- data/app/views/sms_on_rails/_phone_carrier_form_item.html.erb +6 -0
- data/app/views/sms_on_rails/_send_sms.html.erb +33 -0
- data/app/views/sms_on_rails/index.html.erb +8 -0
- data/app/views/sms_on_rails/send_sms.html.erb +3 -0
- data/app/views/sms_on_rails/show.html.erb +29 -0
- data/config/routes.rb +19 -0
- data/db/data/fixtures/sms_phone_carriers.yml +110 -0
- data/db/migrate/sms_on_rails_carrier_tables.rb +9 -0
- data/db/migrate/sms_on_rails_model_tables.rb +48 -0
- data/db/migrate/sms_on_rails_phone_number_tables.rb +11 -0
- data/db/seed_data.rb +16 -0
- data/generators/sms_on_rails/USAGE +31 -0
- data/generators/sms_on_rails/commands/inserts.rb +63 -0
- data/generators/sms_on_rails/commands/timestamps.rb +33 -0
- data/generators/sms_on_rails/runners/add_all_models.rb +6 -0
- data/generators/sms_on_rails/runners/dependencies.rb +1 -0
- data/generators/sms_on_rails/runners/remove_all_models.rb +5 -0
- data/generators/sms_on_rails/runners/sms_on_rails_routes.rb +14 -0
- data/generators/sms_on_rails/sms_on_rails_generator.rb +255 -0
- data/generators/sms_on_rails/templates/configuration/clickatell.rb +6 -0
- data/generators/sms_on_rails/templates/configuration/email_gateway.rb +7 -0
- data/generators/sms_on_rails/templates/migrate/schema_migration.rb +15 -0
- data/generators/sms_on_rails/templates/migrate/sms_on_rails_update_phone_numbers.rb +40 -0
- data/generators/sms_on_rails/templates/phone_number_collision.rb +2 -0
- data/init.rb +3 -0
- data/install.rb +1 -0
- data/lib/sms_on_rails.rb +10 -0
- data/lib/sms_on_rails/activerecord_extensions/acts_as_deliverable.rb +92 -0
- data/lib/sms_on_rails/activerecord_extensions/acts_as_substitutable.rb +80 -0
- data/lib/sms_on_rails/activerecord_extensions/has_a_sms_service_provider.rb +101 -0
- data/lib/sms_on_rails/activerecord_extensions/lockable_record.rb +186 -0
- data/lib/sms_on_rails/all_models.rb +3 -0
- data/lib/sms_on_rails/model_support/draft.rb +178 -0
- data/lib/sms_on_rails/model_support/outbound.rb +136 -0
- data/lib/sms_on_rails/model_support/phone_carrier.rb +77 -0
- data/lib/sms_on_rails/model_support/phone_number.rb +248 -0
- data/lib/sms_on_rails/model_support/phone_number_associations.rb +13 -0
- data/lib/sms_on_rails/schema_helper.rb +51 -0
- data/lib/sms_on_rails/service_providers/base.rb +222 -0
- data/lib/sms_on_rails/service_providers/clickatell.rb +52 -0
- data/lib/sms_on_rails/service_providers/dummy.rb +19 -0
- data/lib/sms_on_rails/service_providers/email_gateway.rb +68 -0
- data/lib/sms_on_rails/service_providers/email_gateway_support/errors.rb +20 -0
- data/lib/sms_on_rails/service_providers/email_gateway_support/sms_mailer.rb +21 -0
- data/lib/sms_on_rails/service_providers/email_gateway_support/sms_mailer/sms_through_gateway.erb +6 -0
- data/lib/sms_on_rails/util/sms_error.rb +12 -0
- data/lib/smsonrails.rb +1 -0
- data/public/images/sms_on_rails/railsYoDawg.jpg +0 -0
- data/public/stylesheets/sms_on_rails.css +137 -0
- data/tasks/sms_on_rails_tasks.rake +67 -0
- data/test/active_record_extensions/delivery_and_locking_test.rb +84 -0
- data/test/models/draft_test.rb +72 -0
- data/test/models/outbound_test.rb +89 -0
- data/test/models/phone_number_test.rb +131 -0
- data/test/run.rb +19 -0
- data/test/service_providers/abstract_test_support.rb +104 -0
- data/test/service_providers/clickatell_test.rb +37 -0
- data/test/service_providers/email_gateway_test.rb +30 -0
- data/test/test_helper.rb +24 -0
- data/uninstall.rb +1 -0
- metadata +201 -0
data/.gitignore
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Blythe Dunham
|
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/Manifest
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
app/controllers/admin/sms_on_rails/base_controller.rb
|
2
|
+
app/controllers/admin/sms_on_rails/drafts_controller.rb
|
3
|
+
app/controllers/admin/sms_on_rails/outbounds_controller.rb
|
4
|
+
app/controllers/admin/sms_on_rails/phone_carriers_controller.rb
|
5
|
+
app/controllers/admin/sms_on_rails/phone_numbers_controller.rb
|
6
|
+
app/controllers/sms_on_rails/creation_support.rb
|
7
|
+
app/controllers/sms_on_rails_controller.rb
|
8
|
+
app/helpers/admin/sms_on_rails/drafts_helper.rb
|
9
|
+
app/helpers/admin/sms_on_rails/phone_carriers_helper.rb
|
10
|
+
app/helpers/sms_on_rails/phone_numbers_helper.rb
|
11
|
+
app/helpers/sms_on_rails/sms_helper.rb
|
12
|
+
app/models/sms_on_rails/draft.rb
|
13
|
+
app/models/sms_on_rails/outbound.rb
|
14
|
+
app/models/sms_on_rails/phone_carrier.rb
|
15
|
+
app/models/sms_on_rails/phone_number.rb
|
16
|
+
app/views/admin/sms_on_rails/base/index.html.erb
|
17
|
+
app/views/admin/sms_on_rails/drafts/_show.html.erb
|
18
|
+
app/views/admin/sms_on_rails/drafts/edit.html.erb
|
19
|
+
app/views/admin/sms_on_rails/drafts/index.html.erb
|
20
|
+
app/views/admin/sms_on_rails/drafts/new.html.erb
|
21
|
+
app/views/admin/sms_on_rails/drafts/send_sms.html.erb
|
22
|
+
app/views/admin/sms_on_rails/drafts/show.html.erb
|
23
|
+
app/views/admin/sms_on_rails/outbounds/edit.html.erb
|
24
|
+
app/views/admin/sms_on_rails/outbounds/index.html.erb
|
25
|
+
app/views/admin/sms_on_rails/outbounds/new.html.erb
|
26
|
+
app/views/admin/sms_on_rails/outbounds/show.html.erb
|
27
|
+
app/views/admin/sms_on_rails/phone_carriers/edit.html.erb
|
28
|
+
app/views/admin/sms_on_rails/phone_carriers/index.html.erb
|
29
|
+
app/views/admin/sms_on_rails/phone_carriers/new.html.erb
|
30
|
+
app/views/admin/sms_on_rails/phone_carriers/show.html.erb
|
31
|
+
app/views/admin/sms_on_rails/phone_numbers/edit.html.erb
|
32
|
+
app/views/admin/sms_on_rails/phone_numbers/index.html.erb
|
33
|
+
app/views/admin/sms_on_rails/phone_numbers/new.html.erb
|
34
|
+
app/views/admin/sms_on_rails/phone_numbers/show.html.erb
|
35
|
+
app/views/layouts/sms_on_rails/basic.html.erb
|
36
|
+
app/views/sms_on_rails/_phone_carrier_form_item.html.erb
|
37
|
+
app/views/sms_on_rails/_send_sms.html.erb
|
38
|
+
app/views/sms_on_rails/index.html.erb
|
39
|
+
app/views/sms_on_rails/send_sms.html.erb
|
40
|
+
app/views/sms_on_rails/show.html.erb
|
41
|
+
config/routes.rb
|
42
|
+
db/data/fixtures/sms_phone_carriers.yml
|
43
|
+
db/migrate/sms_on_rails_carrier_tables.rb
|
44
|
+
db/migrate/sms_on_rails_model_tables.rb
|
45
|
+
db/migrate/sms_on_rails_phone_number_tables.rb
|
46
|
+
db/seed_data.rb
|
47
|
+
generators/sms_on_rails/commands/inserts.rb
|
48
|
+
generators/sms_on_rails/commands/timestamps.rb
|
49
|
+
generators/sms_on_rails/runners/add_all_models.rb
|
50
|
+
generators/sms_on_rails/runners/dependencies.rb
|
51
|
+
generators/sms_on_rails/runners/remove_all_models.rb
|
52
|
+
generators/sms_on_rails/runners/sms_on_rails_routes.rb
|
53
|
+
generators/sms_on_rails/sms_on_rails_generator.rb
|
54
|
+
generators/sms_on_rails/templates/configuration/clickatell.rb
|
55
|
+
generators/sms_on_rails/templates/configuration/email_gateway.rb
|
56
|
+
generators/sms_on_rails/templates/migrate/schema_migration.rb
|
57
|
+
generators/sms_on_rails/templates/migrate/sms_on_rails_update_phone_numbers.rb
|
58
|
+
generators/sms_on_rails/templates/phone_number_collision.rb
|
59
|
+
generators/sms_on_rails/USAGE
|
60
|
+
init.rb
|
61
|
+
install.rb
|
62
|
+
lib/sms_on_rails/activerecord_extensions/acts_as_deliverable.rb
|
63
|
+
lib/sms_on_rails/activerecord_extensions/acts_as_substitutable.rb
|
64
|
+
lib/sms_on_rails/activerecord_extensions/has_a_sms_service_provider.rb
|
65
|
+
lib/sms_on_rails/activerecord_extensions/lockable_record.rb
|
66
|
+
lib/sms_on_rails/all_models.rb
|
67
|
+
lib/sms_on_rails/model_support/draft.rb
|
68
|
+
lib/sms_on_rails/model_support/outbound.rb
|
69
|
+
lib/sms_on_rails/model_support/phone_carrier.rb
|
70
|
+
lib/sms_on_rails/model_support/phone_number.rb
|
71
|
+
lib/sms_on_rails/model_support/phone_number_associations.rb
|
72
|
+
lib/sms_on_rails/schema_helper.rb
|
73
|
+
lib/sms_on_rails/service_providers/base.rb
|
74
|
+
lib/sms_on_rails/service_providers/clickatell.rb
|
75
|
+
lib/sms_on_rails/service_providers/dummy.rb
|
76
|
+
lib/sms_on_rails/service_providers/email_gateway.rb
|
77
|
+
lib/sms_on_rails/service_providers/email_gateway_support/errors.rb
|
78
|
+
lib/sms_on_rails/service_providers/email_gateway_support/sms_mailer/sms_through_gateway.erb
|
79
|
+
lib/sms_on_rails/service_providers/email_gateway_support/sms_mailer.rb
|
80
|
+
lib/sms_on_rails/util/sms_error.rb
|
81
|
+
lib/sms_on_rails.rb
|
82
|
+
lib/smsonrails.rb
|
83
|
+
Manifest
|
84
|
+
MIT-LICENSE
|
85
|
+
public/images/sms_on_rails/railsYoDawg.jpg
|
86
|
+
public/stylesheets/sms_on_rails.css
|
87
|
+
Rakefile
|
88
|
+
README
|
89
|
+
README.rdoc
|
90
|
+
sms_on_rails.gemspec
|
91
|
+
tasks/sms_on_rails_tasks.rake
|
92
|
+
test/active_record_extensions/delivery_and_locking_test.rb
|
93
|
+
test/models/draft_test.rb
|
94
|
+
test/models/outbound_test.rb
|
95
|
+
test/models/phone_number_test.rb
|
96
|
+
test/run.rb
|
97
|
+
test/service_providers/abstract_test_support.rb
|
98
|
+
test/service_providers/clickatell_test.rb
|
99
|
+
test/service_providers/email_gateway_test.rb
|
100
|
+
test/test_helper.rb
|
101
|
+
uninstall.rb
|
data/README.rdoc
ADDED
@@ -0,0 +1,211 @@
|
|
1
|
+
= SmsOnRails
|
2
|
+
|
3
|
+
Sms on Rails provides an interface and ORM framework for sending and storing SMS messages through Email Gateway or with Clickatell HTTPS
|
4
|
+
|
5
|
+
The models and underlying architecture extend and include a ton of modules
|
6
|
+
and are designed to be configured if necessary. If you do not wish to run the
|
7
|
+
vanilla configuration, copy the <tt>vendor/plugins/sms_on_rails/lib/models</tt> to your
|
8
|
+
local models directory or copy <tt>vendor/plugins/sms_on_rails/lib/service_providers</tt> to <tt>lib/service_providers</tt>.
|
9
|
+
|
10
|
+
A lot of care has gone into the locking mechanism to prevent double sends. This
|
11
|
+
is a precursor to mass Smsing machine. Further detailed configuration is necessary. Contact
|
12
|
+
blythe@snowgiraffe.com if you love grapes.
|
13
|
+
|
14
|
+
== Install
|
15
|
+
|
16
|
+
=== Install Gem
|
17
|
+
<b>Add to environment.rb </b>
|
18
|
+
config.gem 'blythedunham-sms_on_rails', :lib => 'sms_on_rails', :source => 'http://gems.github.com'
|
19
|
+
config.gem 'clickatell' #If using Clickatell
|
20
|
+
|
21
|
+
Vendor the Gem
|
22
|
+
rake gems:install
|
23
|
+
rake gems:unpack
|
24
|
+
|
25
|
+
=== Quick Setup (after Install)
|
26
|
+
|
27
|
+
script/generate sms_on_rails setup --default-service-provider=[provider]
|
28
|
+
|
29
|
+
rake gems:install or rake gems:unpack (if using Clickatell)
|
30
|
+
|
31
|
+
rake db:migrate
|
32
|
+
|
33
|
+
=== Alternate Install
|
34
|
+
<b>Directly Install Gem</b>
|
35
|
+
gem sources -a http://gems.github.com
|
36
|
+
sudo gem install blythedunham-sms_on_rails
|
37
|
+
|
38
|
+
<b>Plugin</b>
|
39
|
+
script/plugin install git://github.com/blythedunham/smsonrails.git
|
40
|
+
|
41
|
+
Edit SMS configuration details in <tt>config/environment.rb</tt>. Sign up for clickatell at http://clickatell.com and/or update your mail settings for use with the email gateways.
|
42
|
+
|
43
|
+
=== Example Setup
|
44
|
+
The following creates a new rails project +dog+ and adds the Sms On Rails plugin. As seen at RailsConf2009
|
45
|
+
|
46
|
+
rails dog --database=mysql
|
47
|
+
mysqladmin -uroot create dog_development
|
48
|
+
cd dog
|
49
|
+
script/plugin install git://github.com/blythedunham/smsonrails
|
50
|
+
script/generate sms_on_rails setup --default-service-provider=clickatell
|
51
|
+
rake db:migrate
|
52
|
+
mate config/environment.rb
|
53
|
+
|
54
|
+
|
55
|
+
=== Run Setup Generator
|
56
|
+
script/generate sms_on_rails setup --default-service-provider=[provider]
|
57
|
+
|
58
|
+
Running the generator performs several setup steps:
|
59
|
+
|
60
|
+
* copy image and stylesheet assets to your public directory
|
61
|
+
* generates 3 database migrations (the 2nd and 3rd have a 2 and 3 appended)
|
62
|
+
* installs clickatell gem and static_record_cache plugin (for email carriers caching)
|
63
|
+
* insert configuration skeleton into environment.rb
|
64
|
+
|
65
|
+
=== Migrate
|
66
|
+
Three files are created with different timestamps in <tt>db/migrate</tt>
|
67
|
+
* Email Carrier information (email addresses for each carrier like txt.att.net)
|
68
|
+
* Phone Number setup.
|
69
|
+
* Draft and Outbound tables
|
70
|
+
|
71
|
+
Check them out and then run:
|
72
|
+
rake db:migrate
|
73
|
+
|
74
|
+
=== Configure settings
|
75
|
+
After running the generator, open up <tt>config/environment.rb</tt> in your rails application. Update the configuration hash maps, added by the generator, with your settings.
|
76
|
+
|
77
|
+
* email gateways - <tt>SmsOnRails::ServiceProviders::EmailGateway.config</tt>. Standard +ActionMailer+ configuration is required for the Email Gateway.
|
78
|
+
|
79
|
+
* clickatell http - <tt>SmsOnRails::ServiceProviders::Clickatell.config</tt>. Sign up for an account at http://clickatell.com
|
80
|
+
|
81
|
+
Ensure that the correct default provider is selected. Should be <tt>:email_gateway</tt> or <tt>:clickatell</tt>
|
82
|
+
SmsOnRails::ServiceProviders::Base.set_default_service_provider :clickatell
|
83
|
+
|
84
|
+
Also make sure that the correct default provider is selected.
|
85
|
+
|
86
|
+
<b> Added to environment.rb</b>
|
87
|
+
|
88
|
+
SmsOnRails::ServiceProviders::Clickatell.config = {
|
89
|
+
:api_id => 'api_key',
|
90
|
+
:user_name => 'user_name',
|
91
|
+
:password => 'password'
|
92
|
+
}
|
93
|
+
|
94
|
+
SmsOnRails::ServiceProviders::EmailGateway.config = {
|
95
|
+
:sender => 'youremail address',
|
96
|
+
:subject => 'Default Subject Text'
|
97
|
+
#:bcc => nil,
|
98
|
+
#:mailer_klass => nil,
|
99
|
+
}
|
100
|
+
|
101
|
+
SmsOnRails::ServiceProviders::Base.set_default_service_provider = :email_gateway
|
102
|
+
|
103
|
+
== Avoiding Collisions with existing PhoneNumber class
|
104
|
+
If you already have a <tt>PhoneNumber ActiveRecord</tt> class and +phone_number+ database table, you might experience a collision with the SMSOnRails engine. To avoid this, the generator will take the following measures.
|
105
|
+
|
106
|
+
=== PhoneNumber Migration
|
107
|
+
Instead of creating a new table, the phone number migration created by the generator will add only the columns needed by +SMSOnRails+. Please make sure to check out the migration for errors.
|
108
|
+
|
109
|
+
=== PhoneNumber ActiveRecord Class Changes
|
110
|
+
The generator will update <tt>PhoneNumber</tt> and add <tt>SmsOnRails::PhoneNumber</tt>
|
111
|
+
|
112
|
+
<b>PhoneNumber app/models/sms_on_rails/phone_number.rb</b>
|
113
|
+
This file is added and used to point <tt>SmsOnRails::PhoneNumber</tt> point to +PhoneNumber+
|
114
|
+
|
115
|
+
|
116
|
+
<b>PhoneNumber app/models/phone_number.rb</b>
|
117
|
+
The following two modules are included on your +PhoneNumber+ class:
|
118
|
+
* <tt>SmsOnRails::ModelSupport::PhoneNumber</tt> - basic functionality
|
119
|
+
* <tt>SmsOnRails::ModelSupport::PhoneNumberAssociations</tt> - associations for +PhoneNumber+
|
120
|
+
|
121
|
+
These modules are defined in:
|
122
|
+
vendor/plugins/smsonrails/lib/sms_on_rails/model_support
|
123
|
+
|
124
|
+
Please manually modify your +PhoneNumber+ class to change the associations if you must.
|
125
|
+
|
126
|
+
== ActionMailer
|
127
|
+
|
128
|
+
You will need to configure ActionMailer in environment.rb if you wish to use the
|
129
|
+
Email Gateway. Refer to the Troubleshooting section for more information.
|
130
|
+
|
131
|
+
By default, SmsMailer inherits the ActionMailer settings. If your SMS Mailer settings
|
132
|
+
differ from the default ActionMailer settings, you can define the new settings in enviroment.rb with:
|
133
|
+
SmsOnRails::ServiceProviders::EmailGatewaySupport::SmsMailer.smtp_settings ={}
|
134
|
+
|
135
|
+
|
136
|
+
== Default SMS Routes
|
137
|
+
|
138
|
+
Default Links in Your Application
|
139
|
+
* Send SMS: http://localhost:3000/sms/new
|
140
|
+
* Admin: http://localhost:3000/admin/sms
|
141
|
+
* Draft History: http://localhost:3000/admin/sms/draft
|
142
|
+
* Phone Numbers: http://localhost:3000/admin/sms/phone_numbers
|
143
|
+
* Phone Carriers: http://localhost:3000/admin/sms/phone_carriers
|
144
|
+
|
145
|
+
|
146
|
+
== Send Messages
|
147
|
+
|
148
|
+
=== Access Service Providers Directly
|
149
|
+
All service providers are singletons and can be accessed by their instance
|
150
|
+
|
151
|
+
To send a message without validation use +send_message+
|
152
|
+
SmsOnRails::ServiceProviders::<Provider>.instance.send_message '12065551234', 'my message', options
|
153
|
+
|
154
|
+
To send a message with validation use +send_to_phone_number+ with a string or SmsOnRails::PhoneNumber instance
|
155
|
+
SmsOnRails::ServiceProviders<Provider>.instance.send_to_phone_number(number, message, options)
|
156
|
+
|
157
|
+
To send an sms (+Outbound+) (with validation)
|
158
|
+
SmsOnRails::ServiceProviders<Provider>.instance.send_sms(sms, options)
|
159
|
+
However, it is preferred to use the locking mechanism to prevent double messages from being sent
|
160
|
+
sms.deliver!
|
161
|
+
|
162
|
+
=== ORM examples:
|
163
|
+
Clickatell does not need a carrier
|
164
|
+
SmsOnRails::Outbound.create_sms '12065551234', 'Send this test message', :send_immediately => true
|
165
|
+
|
166
|
+
Email gateway needs a carrier specified
|
167
|
+
sms = SmsOnRails::Outbound.create_sms '12065551234', 'Send this test message', :carrier => :att
|
168
|
+
sms.deliver!
|
169
|
+
|
170
|
+
|
171
|
+
== Troubleshooting
|
172
|
+
|
173
|
+
=== Clickatell
|
174
|
+
|
175
|
+
<b> Install Clickatell gem </b>
|
176
|
+
If you are using clickatell, please install the clickatell gem with either command:
|
177
|
+
sudo rake gems:unpack
|
178
|
+
sudo rake gems:install
|
179
|
+
sudo gem install clickatell
|
180
|
+
|
181
|
+
Possible Error messages:
|
182
|
+
* Missing these required gems: clickatell
|
183
|
+
* Cannot set default provider to clickatell. Check that support for clickatell exists.
|
184
|
+
|
185
|
+
=== Email Gateway
|
186
|
+
<b> ActionMailer</b>
|
187
|
+
If you are using the email gateways, make sure that your +ActionMailer+ settings are
|
188
|
+
configured properly in <tt>environment.rb</tt>. A good test is to send a normal email.
|
189
|
+
|
190
|
+
You can also test your settings by adding the line below to your environment.rb file.
|
191
|
+
|
192
|
+
ActionMailer::Base.delivery_method = :test
|
193
|
+
|
194
|
+
The message should be print to the log file <tt>log/development.rb</tt> like below:
|
195
|
+
To: 2035553215@vtext.com
|
196
|
+
Subject: Default Subject Text
|
197
|
+
Mime-Version: 1.0
|
198
|
+
Content-Type: text/plain; charset=utf-8
|
199
|
+
|
200
|
+
This is my test message
|
201
|
+
|
202
|
+
== Developers
|
203
|
+
* Blythe Dunham http://snowgiraffe.com
|
204
|
+
|
205
|
+
== Homepage
|
206
|
+
* Project Site: http://github.com/blythedunham/smsonrails
|
207
|
+
|
208
|
+
== License
|
209
|
+
This is MartiniWare. Buy yourself a martini if you like this software! If you like any software that uses this plugin you should also buy yourself a martini. Manhattans are ok too.
|
210
|
+
|
211
|
+
Copyright (c) 2009 Blythe Dunham, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |gem|
|
9
|
+
gem.name = "smsonrails"
|
10
|
+
gem.summary = %Q{Sms on Rails provides your app with instant SMS integration}
|
11
|
+
gem.description = %Q{Sms on Rails provides your app with instant SMS integration}
|
12
|
+
gem.email = "blythe@snowgiraffe.com"
|
13
|
+
gem.homepage = "http://github.com/blythedunham/smsonrails"
|
14
|
+
gem.authors = ["Blythe Dunham"]
|
15
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
16
|
+
gem.add_development_dependency "clickatell", ">= 0"
|
17
|
+
gem.add_dependency 'activesupport', ">=2.0.0"
|
18
|
+
gem.add_dependency 'static_record_cache'
|
19
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
20
|
+
end
|
21
|
+
Jeweler::GemcutterTasks.new
|
22
|
+
rescue LoadError
|
23
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'rake/testtask'
|
27
|
+
Rake::TestTask.new(:test) do |test|
|
28
|
+
test.libs << 'lib' << 'test'
|
29
|
+
test.pattern = 'test/**/test_*.rb'
|
30
|
+
test.verbose = true
|
31
|
+
end
|
32
|
+
|
33
|
+
begin
|
34
|
+
require 'rcov/rcovtask'
|
35
|
+
Rcov::RcovTask.new do |test|
|
36
|
+
test.libs << 'test'
|
37
|
+
test.pattern = 'test/**/test_*.rb'
|
38
|
+
test.verbose = true
|
39
|
+
end
|
40
|
+
rescue LoadError
|
41
|
+
task :rcov do
|
42
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
task :test => :check_dependencies
|
47
|
+
|
48
|
+
desc 'Default: run unit tests.'
|
49
|
+
task :default => :test
|
50
|
+
|
51
|
+
desc "Create test database. Run with root permissions. (sudo)"
|
52
|
+
task :create_test_database do
|
53
|
+
system "mysqladmin create sms_on_rails_test"
|
54
|
+
end
|
55
|
+
|
56
|
+
desc "Prepares the test database"
|
57
|
+
task :prepare_test do
|
58
|
+
require File.dirname(__FILE__) + '/test/run'
|
59
|
+
|
60
|
+
migration_dir = File.dirname(__FILE__), ""
|
61
|
+
#ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
|
62
|
+
|
63
|
+
require File.dirname(__FILE__) + '/lib/sms_on_rails/schema_helper'
|
64
|
+
puts SmsOnRails::SchemaHelper.schema(:create, 'sms_on_rails_carrier_tables', 'sms_on_rails_phone_number_tables', 'sms_on_rails_model_tables' )
|
65
|
+
instance_eval SmsOnRails::SchemaHelper.schema(:create, 'sms_on_rails_carrier_tables', 'sms_on_rails_phone_number_tables', 'sms_on_rails_model_tables' )
|
66
|
+
puts "Seeding SMS tables..."
|
67
|
+
require File.dirname(__FILE__) + '/test/test_helper.rb'
|
68
|
+
load File.dirname(__FILE__) + '/db/seed_data.rb'
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
desc 'Test the sms_on_rails plugin.'
|
73
|
+
task :test => [:prepare_test, :test_without_setup]
|
74
|
+
|
75
|
+
|
76
|
+
desc 'Test the sms_on_rails plugin without setup'
|
77
|
+
Rake::TestTask.new(:test_without_setup) do |t|
|
78
|
+
t.libs << 'lib'
|
79
|
+
t.pattern = 'test/**/*_test.rb'
|
80
|
+
t.verbose = true
|
81
|
+
end
|
82
|
+
|
83
|
+
desc 'Generate documentation for the sms_on_rails plugin.'
|
84
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
85
|
+
rdoc.rdoc_dir = 'rdoc'
|
86
|
+
rdoc.title = 'SmsOnRails'
|
87
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
88
|
+
rdoc.rdoc_files.include('README')
|
89
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
desc 'Copy templates from application files'
|
94
|
+
task :create_templates do
|
95
|
+
dest_dir = File.dirname(__FILE__) + '/generators/sms_on_rails/templates'
|
96
|
+
src_dir = File.dirname(__FILE__) + '/../../../app'
|
97
|
+
|
98
|
+
folders = %w( helpers/sms_on_rails helpers/admin/sms_on_rails controllers/admin/sms_on_rails views/layouts/admin/sms_on_rails views/admin/sms_on_rails )
|
99
|
+
folders.each do |f|
|
100
|
+
puts "Create: #{f}"
|
101
|
+
system("rm -r #{dest_dir}/#{f}")
|
102
|
+
FileUtils.mkdir_p File.dirname("#{dest_dir}/#{f}")
|
103
|
+
system("cp -r #{src_dir}/#{f} #{dest_dir}/#{f}")
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
108
|
+
|
109
|
+
|