blythedunham-sms_on_rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/Manifest +101 -0
  3. data/README +163 -0
  4. data/README.rdoc +211 -0
  5. data/Rakefile +76 -0
  6. data/app/controllers/admin/sms_on_rails/base_controller.rb +11 -0
  7. data/app/controllers/admin/sms_on_rails/drafts_controller.rb +75 -0
  8. data/app/controllers/admin/sms_on_rails/outbounds_controller.rb +117 -0
  9. data/app/controllers/admin/sms_on_rails/phone_carriers_controller.rb +85 -0
  10. data/app/controllers/admin/sms_on_rails/phone_numbers_controller.rb +101 -0
  11. data/app/controllers/sms_on_rails/creation_support.rb +99 -0
  12. data/app/controllers/sms_on_rails_controller.rb +14 -0
  13. data/app/helpers/admin/sms_on_rails/drafts_helper.rb +2 -0
  14. data/app/helpers/admin/sms_on_rails/phone_carriers_helper.rb +2 -0
  15. data/app/helpers/sms_on_rails/phone_numbers_helper.rb +9 -0
  16. data/app/helpers/sms_on_rails/sms_helper.rb +44 -0
  17. data/app/models/sms_on_rails/draft.rb +9 -0
  18. data/app/models/sms_on_rails/outbound.rb +17 -0
  19. data/app/models/sms_on_rails/phone_carrier.rb +14 -0
  20. data/app/models/sms_on_rails/phone_number.rb +8 -0
  21. data/app/views/admin/sms_on_rails/base/index.html.erb +5 -0
  22. data/app/views/admin/sms_on_rails/drafts/_show.html.erb +34 -0
  23. data/app/views/admin/sms_on_rails/drafts/edit.html.erb +36 -0
  24. data/app/views/admin/sms_on_rails/drafts/index.html.erb +32 -0
  25. data/app/views/admin/sms_on_rails/drafts/new.html.erb +34 -0
  26. data/app/views/admin/sms_on_rails/drafts/send_sms.html.erb +3 -0
  27. data/app/views/admin/sms_on_rails/drafts/show.html.erb +4 -0
  28. data/app/views/admin/sms_on_rails/outbounds/edit.html.erb +68 -0
  29. data/app/views/admin/sms_on_rails/outbounds/index.html.erb +37 -0
  30. data/app/views/admin/sms_on_rails/outbounds/new.html.erb +54 -0
  31. data/app/views/admin/sms_on_rails/outbounds/show.html.erb +69 -0
  32. data/app/views/admin/sms_on_rails/phone_carriers/edit.html.erb +24 -0
  33. data/app/views/admin/sms_on_rails/phone_carriers/index.html.erb +24 -0
  34. data/app/views/admin/sms_on_rails/phone_carriers/new.html.erb +22 -0
  35. data/app/views/admin/sms_on_rails/phone_carriers/show.html.erb +24 -0
  36. data/app/views/admin/sms_on_rails/phone_numbers/edit.html.erb +33 -0
  37. data/app/views/admin/sms_on_rails/phone_numbers/index.html.erb +28 -0
  38. data/app/views/admin/sms_on_rails/phone_numbers/new.html.erb +31 -0
  39. data/app/views/admin/sms_on_rails/phone_numbers/show.html.erb +32 -0
  40. data/app/views/layouts/sms_on_rails/basic.html.erb +26 -0
  41. data/app/views/sms_on_rails/_phone_carrier_form_item.html.erb +6 -0
  42. data/app/views/sms_on_rails/_send_sms.html.erb +33 -0
  43. data/app/views/sms_on_rails/index.html.erb +8 -0
  44. data/app/views/sms_on_rails/send_sms.html.erb +3 -0
  45. data/app/views/sms_on_rails/show.html.erb +29 -0
  46. data/config/routes.rb +19 -0
  47. data/db/data/fixtures/sms_phone_carriers.yml +110 -0
  48. data/db/migrate/sms_on_rails_carrier_tables.rb +9 -0
  49. data/db/migrate/sms_on_rails_model_tables.rb +48 -0
  50. data/db/migrate/sms_on_rails_phone_number_tables.rb +11 -0
  51. data/db/seed_data.rb +16 -0
  52. data/generators/sms_on_rails/USAGE +31 -0
  53. data/generators/sms_on_rails/commands/inserts.rb +63 -0
  54. data/generators/sms_on_rails/commands/timestamps.rb +33 -0
  55. data/generators/sms_on_rails/runners/add_all_models.rb +6 -0
  56. data/generators/sms_on_rails/runners/dependencies.rb +1 -0
  57. data/generators/sms_on_rails/runners/remove_all_models.rb +5 -0
  58. data/generators/sms_on_rails/runners/sms_on_rails_routes.rb +14 -0
  59. data/generators/sms_on_rails/sms_on_rails_generator.rb +255 -0
  60. data/generators/sms_on_rails/templates/configuration/clickatell.rb +6 -0
  61. data/generators/sms_on_rails/templates/configuration/email_gateway.rb +7 -0
  62. data/generators/sms_on_rails/templates/migrate/schema_migration.rb +15 -0
  63. data/generators/sms_on_rails/templates/migrate/sms_on_rails_update_phone_numbers.rb +40 -0
  64. data/generators/sms_on_rails/templates/phone_number_collision.rb +2 -0
  65. data/init.rb +3 -0
  66. data/install.rb +1 -0
  67. data/lib/sms_on_rails.rb +8 -0
  68. data/lib/sms_on_rails/activerecord_extensions/acts_as_deliverable.rb +92 -0
  69. data/lib/sms_on_rails/activerecord_extensions/acts_as_substitutable.rb +80 -0
  70. data/lib/sms_on_rails/activerecord_extensions/has_a_sms_service_provider.rb +101 -0
  71. data/lib/sms_on_rails/activerecord_extensions/lockable_record.rb +186 -0
  72. data/lib/sms_on_rails/all_models.rb +3 -0
  73. data/lib/sms_on_rails/model_support/draft.rb +178 -0
  74. data/lib/sms_on_rails/model_support/outbound.rb +136 -0
  75. data/lib/sms_on_rails/model_support/phone_carrier.rb +77 -0
  76. data/lib/sms_on_rails/model_support/phone_number.rb +248 -0
  77. data/lib/sms_on_rails/model_support/phone_number_associations.rb +13 -0
  78. data/lib/sms_on_rails/schema_helper.rb +51 -0
  79. data/lib/sms_on_rails/service_providers/base.rb +222 -0
  80. data/lib/sms_on_rails/service_providers/clickatell.rb +52 -0
  81. data/lib/sms_on_rails/service_providers/dummy.rb +19 -0
  82. data/lib/sms_on_rails/service_providers/email_gateway.rb +68 -0
  83. data/lib/sms_on_rails/service_providers/email_gateway_support/errors.rb +20 -0
  84. data/lib/sms_on_rails/service_providers/email_gateway_support/sms_mailer.rb +21 -0
  85. data/lib/sms_on_rails/service_providers/email_gateway_support/sms_mailer/sms_through_gateway.erb +6 -0
  86. data/lib/sms_on_rails/util/sms_error.rb +12 -0
  87. data/lib/smsonrails.rb +1 -0
  88. data/public/images/sms_on_rails/railsYoDawg.jpg +0 -0
  89. data/public/stylesheets/sms_on_rails.css +137 -0
  90. data/sms_on_rails.gemspec +32 -0
  91. data/tasks/sms_on_rails_tasks.rake +67 -0
  92. data/test/active_record_extensions/delivery_and_locking_test.rb +84 -0
  93. data/test/models/draft_test.rb +72 -0
  94. data/test/models/outbound_test.rb +89 -0
  95. data/test/models/phone_number_test.rb +131 -0
  96. data/test/run.rb +18 -0
  97. data/test/service_providers/abstract_test_support.rb +104 -0
  98. data/test/service_providers/clickatell_test.rb +39 -0
  99. data/test/service_providers/email_gateway_test.rb +30 -0
  100. data/test/test_helper.rb +24 -0
  101. data/uninstall.rb +1 -0
  102. metadata +187 -0
@@ -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.
@@ -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 ADDED
@@ -0,0 +1,163 @@
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 vendor/plugins/sms_on_rails/lib/models to your
8
+ local models directory.
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
+
15
+
16
+ == Install
17
+ script/plugin install git://github.com/blythedunham/smsonrails.git
18
+
19
+ === Quick Install
20
+ script/plugin install git://github.com/blythedunham/smsonrails.git
21
+
22
+ script/generate sms_on_rails setup --default-service-provider=[provider]
23
+
24
+ rake db:migrate
25
+
26
+ 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.
27
+
28
+ === Example Setup
29
+ The following creates a new rails project +dog+ and adds the Sms On Rails plugin. As seen at RailsConf2009
30
+
31
+ rails dog --database=mysql
32
+ mysqladmin -uroot create dog_development
33
+ cd dog
34
+ script/plugin install git://github.com/blythedunham/smsonrails
35
+ script/generate sms_on_rails setup --default-service-provider=clickatell
36
+ rake db:migrate
37
+ mate config/environment.rb
38
+
39
+
40
+ === Run Setup Generator
41
+ script/generate sms_on_rails setup --default-service-provider=[provider]
42
+
43
+ Running the generator performs several setup steps:
44
+
45
+ * copy image and stylesheet assets to your public directory
46
+ * generates 3 database migrations (the 2nd and 3rd have a 2 and 3 appended)
47
+ * installs clickatell gem and static_record_cache plugin (for email carriers caching)
48
+ * insert configuration skeleton into environment.rb
49
+
50
+ === Migrate
51
+ Three files are created with different timestamps in <tt>db/migrate</tt>
52
+ * Email Carrier information (email addresses for each carrier like txt.att.net)
53
+ * Phone Number setup.
54
+ * Draft and Outbound tables
55
+
56
+ Check them out and then run:
57
+ rake db:migrate
58
+
59
+ === Configure settings
60
+ 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.
61
+
62
+ * email gateways - <tt>SmsOnRails::ServiceProviders::EmailGateway.config</tt>. Standard +ActionMailer+ configuration is required for the Email Gateway.
63
+
64
+ * clickatell http - <tt>SmsOnRails::ServiceProviders::Clickatell.config</tt>. Sign up for an account at http://clickatell.com
65
+
66
+ Ensure that the correct default provider is selected.
67
+ SmsOnRails::ServiceProviders::Base.default_service_provider=
68
+
69
+ Also make sure that the correct default provider is selected.
70
+
71
+ <b> Added to environment.rb</b>
72
+
73
+ SmsOnRails::ServiceProviders::Clickatell.config = {
74
+ :api_id => 'api_key',
75
+ :user_name => 'user_name',
76
+ :password => 'password'
77
+ }
78
+
79
+ SmsOnRails::ServiceProviders::EmailGateway.config = {
80
+ :sender => 'youremail address',
81
+ :subject => 'Default Subject Text'
82
+ #:bcc => nil,
83
+ #:mailer_klass => nil,
84
+ }
85
+
86
+ #Default inherits from ActionMailer
87
+ #SmsOnRails::ServiceProviders::EmailGatewaySupport::SmsMailer.smtp_settings ={}
88
+
89
+
90
+ #Uncomment out your default SMS sender
91
+ SmsOnRails::ServiceProviders::Base.default_service_provider = SmsOnRails::ServiceProviders::Clickatell.instance
92
+ #SmsOnRails::ServiceProviders::Base.default_service_provider = SmsOnRails::ServiceProviders::EmailGateway.instance
93
+
94
+
95
+ == Avoiding Collisions with existing PhoneNumber class
96
+ 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.
97
+
98
+ === PhoneNumber Migration
99
+ 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.
100
+
101
+ === PhoneNumber ActiveRecord Class Changes
102
+ The generator will update <tt>PhoneNumber</tt> and add <tt>SmsOnRails::PhoneNumber</tt>
103
+
104
+ <b>PhoneNumber app/models/sms_on_rails/phone_number.rb</b>
105
+ This file is added and used to point <tt>SmsOnRails::PhoneNumber</tt> point to +PhoneNumber+
106
+
107
+
108
+ <b>PhoneNumber app/models/phone_number.rb</b>
109
+ The following two modules are included on your +PhoneNumber+ class:
110
+ * <tt>SmsOnRails::ModelSupport::PhoneNumber</tt> - basic functionality
111
+ * <tt>SmsOnRails::ModelSupport::PhoneNumberAssociations</tt> - associations for +PhoneNumber+
112
+
113
+ These modules are defined in:
114
+ vendor/plugins/smsonrails/lib/sms_on_rails/model_support
115
+
116
+ Please manually modify your +PhoneNumber+ class to change the associations if you must.
117
+
118
+
119
+
120
+ == Default SMS Routes
121
+
122
+ Default Links in Your Application
123
+ * Send SMS: http://localhost:3000/sms/new
124
+ * Admin: http://localhost:3000/admin/sms
125
+ * Draft History: http://localhost:3000/admin/sms/draft
126
+ * Phone Numbers: http://localhost:3000/admin/sms/phone_numbers
127
+ * Phone Carriers: http://localhost:3000/admin/sms/phone_carriers
128
+
129
+
130
+ == Send Messages
131
+
132
+ === Access Service Providers Directly
133
+ All service providers are singletons and can be accessed by their instance
134
+
135
+ To send a message without validation use +send_message+
136
+ SmsOnRails::ServiceProviders::<Provider>.instance.send_message '12065551234', 'my message', options
137
+
138
+ To send a message with validation use +send_to_phone_number+ with a string or SmsOnRails::PhoneNumber instance
139
+ SmsOnRails::ServiceProviders<Provider>.instance.send_to_phone_number(number, message, options)
140
+
141
+ To send an sms (+Outbound+) (with validation)
142
+ SmsOnRails::ServiceProviders<Provider>.instance.send_sms(sms, options)
143
+ However, it is preferred to use the locking mechanism to prevent double messages from being sent
144
+ sms.deliver!
145
+
146
+ === ORM examples:
147
+ Clickatell does not need a carrier
148
+ SmsOnRails::Outbound.create_sms '12065551234', 'Send this test message', :send_immediately => true
149
+
150
+ Email gateway needs a carrier specified
151
+ sms = SmsOnRails::Outbound.create_sms '12065551234', 'Send this test message', :carrier => :att
152
+ sms.deliver!
153
+
154
+
155
+
156
+ == License
157
+
158
+ This is MartiniWare. Buy yourself a martini if you like this software.
159
+
160
+ blythe at snowgiraffe dot com
161
+ http://snowgiraffe.com
162
+
163
+ Copyright (c) 2009 Blythe Dunham, released under the MIT license
@@ -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-smsonrails', :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-smsonrails
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