actionmessage 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/lib/action_message/adapters.rb +18 -7
- data/lib/action_message/message.rb +4 -1
- data/lib/action_message/railtie.rb +23 -0
- data/lib/action_message/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 195c072ea0df8b8382477070273029b215d4cb43
|
4
|
+
data.tar.gz: d58b267cd8d77e3c1135b4ef1225f1dc2f65cbf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8310e5bb7a9e40aa423377fc94620b796701268a408e47cf0b0614d67e9a5d6f23e984564bababf37a85eb09a5a8e0371ac2443aad805e64bb287ccd38a344cf
|
7
|
+
data.tar.gz: a95b89cdcfa0c46d589287dec9275378bc8eccaa3365297524eb2315b7b92e98dd5c7cb0499900fec2e7ce0339e6544b29664b40a9c8ca2300cf7220769a08a0
|
data/README.md
CHANGED
@@ -20,7 +20,9 @@ require 'action_message'
|
|
20
20
|
|
21
21
|
If you're using Rails, place this on your environment file or application.rb
|
22
22
|
```ruby
|
23
|
-
|
23
|
+
require 'action_message/railtie'
|
24
|
+
|
25
|
+
config.action_message = {
|
24
26
|
from: "number to send from in international format, e.g.: +11231231234",
|
25
27
|
adapter: {
|
26
28
|
name: :twilio,
|
@@ -42,7 +44,7 @@ class MerchantMessage < ActionMessage::Base
|
|
42
44
|
end
|
43
45
|
```
|
44
46
|
|
45
|
-
Define your views under app/views/merchant_message/send_welcome_sms.text.erb
|
47
|
+
Define your views under your view path, such as: app/views/merchant_message/send_welcome_sms.text.erb
|
46
48
|
```html
|
47
49
|
Welcome, <%= @name %>!!!
|
48
50
|
```
|
@@ -53,7 +55,6 @@ TODO:
|
|
53
55
|
- Add background processing (deliver_later);
|
54
56
|
- Log instrumentation with ActiveSupport;
|
55
57
|
- Add generators;
|
56
|
-
- Add a Railtie;
|
57
58
|
- Add delivery methods;
|
58
59
|
- Add test helpers;
|
59
60
|
- Add more adapters;
|
@@ -4,11 +4,22 @@ require 'action_message/adapters/twilio'
|
|
4
4
|
|
5
5
|
module ActionMessage
|
6
6
|
module Adapters
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
class << self
|
8
|
+
def adapter_klass
|
9
|
+
@@adapter_klass ||= adapter_params[:name].to_s.capitalize
|
10
|
+
end
|
11
|
+
|
12
|
+
def adapter_params
|
13
|
+
@@adapter_params ||= ActionMessage::Base.default_params[:adapter]
|
14
|
+
end
|
15
|
+
|
16
|
+
def adapter_credentials
|
17
|
+
@@adapter_credentials ||= adapter_params[:credentials]
|
18
|
+
end
|
19
|
+
|
20
|
+
def adapter
|
21
|
+
@@adapter ||= const_get(adapter_klass).new(adapter_credentials)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
14
25
|
end
|
@@ -1,6 +1,9 @@
|
|
1
1
|
module ActionMessage
|
2
|
+
include ActionMessage::Adapters
|
3
|
+
|
2
4
|
class Message
|
3
5
|
attr_accessor :headers, :action, :args, :body, :to, :debug
|
6
|
+
attr_reader :adapter
|
4
7
|
|
5
8
|
def initialize
|
6
9
|
@adapter = Adapters.adapter
|
@@ -12,7 +15,7 @@ module ActionMessage
|
|
12
15
|
|
13
16
|
def deliver
|
14
17
|
puts "Sending message \"#{body}\" to number #{to}" # TODO: Switch to a decent logger
|
15
|
-
|
18
|
+
adapter.send_message(body, to: to) # unless debug?
|
16
19
|
end
|
17
20
|
end
|
18
21
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "action_message"
|
2
|
+
require "rails"
|
3
|
+
|
4
|
+
module ActionMessage
|
5
|
+
class Railtie < Rails::Railtie # :nodoc:
|
6
|
+
config.action_message = ActiveSupport::OrderedOptions.new
|
7
|
+
config.eager_load_namespaces << ActionMessage
|
8
|
+
|
9
|
+
initializer "action_message.set_configs" do |app|
|
10
|
+
paths = app.config.paths
|
11
|
+
options = app.config.action_message
|
12
|
+
|
13
|
+
ActiveSupport.on_load(:action_message) do
|
14
|
+
options.each { |k,v| send("#{k}=", v) }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
config.after_initialize do |app|
|
19
|
+
ActionMessage::Base.default_options = app.config.action_message
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionmessage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Diego Ballona
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- lib/action_message/base.rb
|
122
122
|
- lib/action_message/message.rb
|
123
123
|
- lib/action_message/message_delivery.rb
|
124
|
+
- lib/action_message/railtie.rb
|
124
125
|
- lib/action_message/version.rb
|
125
126
|
homepage: http://github.com/dballona/actionmessage
|
126
127
|
licenses:
|