text_message_rails 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +99 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/text_message_rails.rb +14 -0
- data/lib/text_message_rails/controller.rb +87 -0
- data/lib/text_message_rails/delivery.rb +41 -0
- data/lib/text_message_rails/delivery_job.rb +17 -0
- data/lib/text_message_rails/delivery_methods.rb +28 -0
- data/lib/text_message_rails/providers.rb +38 -0
- data/lib/text_message_rails/providers/text_magic.rb +33 -0
- data/lib/text_message_rails/railtie.rb +19 -0
- data/lib/text_message_rails/rendering.rb +50 -0
- data/lib/text_message_rails/version.rb +3 -0
- data/text_message_rails.gemspec +29 -0
- metadata +122 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 26a5894e66db8b6c2e44ed920d7acf88ceb77531
|
4
|
+
data.tar.gz: 8ebc8940b11eb126ea840c227b0f121fbd675230
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ef033256a2d69cf276bc05a7efedde046a4854750f1035924fd84ebc48c722594c43c60f18cfb07447bc6982c7e520df9b73801878263c3d8655ad9f31536949
|
7
|
+
data.tar.gz: 53f212e246d673a905f3e06b309e7a6b321a173f3718557a17c1727b45730945f75d6b47f8dc7a78c43507b0c7b54c86927c267da566268823334f4428e2c257
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at aurelien.noce@imagine-app.fr. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Aurélien Noce
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# text_message_rails
|
2
|
+
|
3
|
+
A simple gem to send text messages from rails
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'text_message_rails'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install text_message_rails
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
In your application config, define the provider you want ot use (for now on,
|
24
|
+
only TextMagic is supported):
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
config.text_message.provider = :text_magic
|
28
|
+
```
|
29
|
+
|
30
|
+
Then create instances of the `TextMessage::Controller`:
|
31
|
+
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
class ClientTextMessages < TextMessage::Controller
|
35
|
+
|
36
|
+
def confirm_order(order)
|
37
|
+
@order = order
|
38
|
+
@user = @order.user
|
39
|
+
|
40
|
+
# ...
|
41
|
+
|
42
|
+
phone_number = user.phone_number
|
43
|
+
send_to phone_number
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
And associated view(s):
|
50
|
+
|
51
|
+
```erb
|
52
|
+
<%# in app/views/client_text_messages/confirm_order.text.erb %>
|
53
|
+
Dear <%= user.name %> your order <%= order.id %> is confirmed !
|
54
|
+
```
|
55
|
+
|
56
|
+
Then from a different class, call:
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
ClientTextMessages.confirm_order(order).deliver_now!
|
60
|
+
# or
|
61
|
+
ClientTextMessages.confirm_order(order).deliver_later!
|
62
|
+
```
|
63
|
+
|
64
|
+
## Provider
|
65
|
+
|
66
|
+
For the time being, only the `TextMagic` provider is supported.
|
67
|
+
|
68
|
+
To use it, include it in you `Gemfile`:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
# include the API gem
|
72
|
+
gem "text_magic"
|
73
|
+
|
74
|
+
# (optional but recommanded) include Phony Rails so the provider will reformat
|
75
|
+
# the phone number in TextMagic-friendly way:
|
76
|
+
gem "phony_rails"
|
77
|
+
```
|
78
|
+
|
79
|
+
And enable its use in the configuration:
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
config.text_message.provider = :text_magic
|
83
|
+
```
|
84
|
+
|
85
|
+
## Development
|
86
|
+
|
87
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
88
|
+
|
89
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
90
|
+
|
91
|
+
## Contributing
|
92
|
+
|
93
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/text_message_rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
94
|
+
|
95
|
+
|
96
|
+
## License
|
97
|
+
|
98
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
99
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "text/messages/rails"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
module TextMessage
|
2
|
+
|
3
|
+
autoload :VERSION, "text_message_rails/version"
|
4
|
+
|
5
|
+
autoload :Controller, "text_message_rails/controller"
|
6
|
+
autoload :Delivery, "text_message_rails/delivery"
|
7
|
+
autoload :DeliveryJob, "text_message_rails/delivery_job"
|
8
|
+
autoload :DeliveryMethods, "text_message_rails/delivery_methods"
|
9
|
+
autoload :Rendering, "text_message_rails/rendering"
|
10
|
+
autoload :Providers, "text_message_rails/providers"
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
require "text_message_rails/railtie" if defined?(::Rails::Railtie)
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require "abstract_controller"
|
2
|
+
|
3
|
+
module TextMessage
|
4
|
+
|
5
|
+
# = TextMessage controller base class
|
6
|
+
# This class acts as a controller, similar to +ActionMailer::Controller+ subclasses.
|
7
|
+
# To use it:
|
8
|
+
#
|
9
|
+
# - implement action methods as in a "usual" controller
|
10
|
+
#
|
11
|
+
# class TextMessageTest < TextMessage::Controller
|
12
|
+
#
|
13
|
+
# # Will render app/views/sms_test/toto.(...), passing it the instance variables
|
14
|
+
# def toto
|
15
|
+
# @tutu = 4
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# end
|
19
|
+
class Controller < AbstractController::Base
|
20
|
+
|
21
|
+
# Load tons of AbstractController plugins
|
22
|
+
include AbstractController::Rendering
|
23
|
+
include AbstractController::Logger
|
24
|
+
include AbstractController::Helpers
|
25
|
+
include AbstractController::Callbacks
|
26
|
+
|
27
|
+
# Defines #render_to_body, needed by #render.
|
28
|
+
include ::TextMessage::Rendering
|
29
|
+
|
30
|
+
# Instanciate a new TextMessage object.
|
31
|
+
#
|
32
|
+
# Then calls +method_name+ with the given +args+.
|
33
|
+
def initialize(method_name, *args)
|
34
|
+
@recipients = []
|
35
|
+
super()
|
36
|
+
process(method_name, *args)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Basic Recipients handling
|
40
|
+
attr_reader :recipients
|
41
|
+
def send_to(*recipients)
|
42
|
+
@recipients = recipients || []
|
43
|
+
end
|
44
|
+
|
45
|
+
class << self
|
46
|
+
|
47
|
+
def default_url_options=(options)
|
48
|
+
@@default_url_options = options
|
49
|
+
end
|
50
|
+
# Reuses ActionMailer url options by default
|
51
|
+
def default_url_options
|
52
|
+
@@default_url_options || ActionMailer::Base.default_url_options
|
53
|
+
end
|
54
|
+
|
55
|
+
def provider=(p)
|
56
|
+
@@provider = p
|
57
|
+
end
|
58
|
+
# Defaults provider to the Base (empty) provider: will raise !
|
59
|
+
def provider
|
60
|
+
@@provider || TextMessage::Providers::Base
|
61
|
+
end
|
62
|
+
|
63
|
+
# Respond to the action methods directly on the class
|
64
|
+
#
|
65
|
+
# for example calling `TextMessageDemo.toto` (with TextMessageDemo a subclass of +TextMessage::Controller+)
|
66
|
+
# will create a +TextMessage::Delivery+ instance tied to the `TextMessageDemo` class,
|
67
|
+
# method `:toto` with no argument.
|
68
|
+
|
69
|
+
def respond_to?(method, include_private = false) #:nodoc:
|
70
|
+
super || action_methods.include?(method.to_s)
|
71
|
+
end
|
72
|
+
|
73
|
+
def method_missing(method_name, *args) #:nodoc:
|
74
|
+
if action_methods.include?(method_name.to_s)
|
75
|
+
TextMessage::Delivery.new(self, method_name, *args)
|
76
|
+
else
|
77
|
+
super
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def deliver_text_message(delivery)
|
82
|
+
provider.deliver_text_message(delivery)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module TextMessage
|
2
|
+
|
3
|
+
# = TextMessage Delivery Proxy
|
4
|
+
# The +Delivery+ class is the class returned by the +TextMessage::Base+ actions.
|
5
|
+
# It is used to enable lazy processing of the actions.
|
6
|
+
class Delivery < Delegator
|
7
|
+
|
8
|
+
include ::TextMessage::DeliveryMethods
|
9
|
+
|
10
|
+
# Creates a new +Delivery+ proxy.
|
11
|
+
# By providing a +TextMessage::Base+ subclass +text_message_class+, a method name to call
|
12
|
+
# +text_message_method+ and a set of arguments to this method +args+, we allow
|
13
|
+
# for lazy processing of the text_message action.
|
14
|
+
def initialize(text_message_class, text_message_method, *args)
|
15
|
+
@text_message_class = text_message_class.kind_of?(Class) ? text_message_class : text_message_class.constantize
|
16
|
+
@text_message_method = text_message_method
|
17
|
+
@args = args
|
18
|
+
end
|
19
|
+
|
20
|
+
# Needed by Decorator superclass
|
21
|
+
def __getobj__ #:nodoc:
|
22
|
+
@obj ||= @text_message_class.send(:new, @text_message_method, *@args)
|
23
|
+
end
|
24
|
+
|
25
|
+
# computes the body of the TextMessage
|
26
|
+
def body
|
27
|
+
renderer.render(view_context, template: "#{templates_dir}/#{@text_message_method}")
|
28
|
+
end
|
29
|
+
|
30
|
+
# The name of the templates which holds the templates.
|
31
|
+
# Usually it is the name of the class with underscores, something like:
|
32
|
+
#
|
33
|
+
# TextMessageDemo.new.templates_dir => "text_message demo"
|
34
|
+
# # so for exemple TextMessageDemo#toto will lookup for text_message_demo/toto{.text.erb}
|
35
|
+
def templates_dir
|
36
|
+
@text_message_class.to_s.underscore
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module TextMessage
|
2
|
+
|
3
|
+
# = TextMessage Deblivery Job
|
4
|
+
# The +TextMessage::DeliveryJob+ class is used to defer text_message delivery through ActiveJob.
|
5
|
+
class DeliveryJob < ActiveJob::Base #:nodoc:
|
6
|
+
|
7
|
+
queue_as :text_messages
|
8
|
+
|
9
|
+
# calls +deliver_now!+ on the text_message class
|
10
|
+
def perform(text_message_class, text_message_method, delivery_method, *args)
|
11
|
+
delivery = ::TextMessage::Delivery.new(text_message_class, text_message_method, *args)
|
12
|
+
delivery.send(delivery_method)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module TextMessage
|
2
|
+
|
3
|
+
# = TextMessage Delivery Methods
|
4
|
+
module DeliveryMethods
|
5
|
+
|
6
|
+
# Defivers a TextMessage
|
7
|
+
def deliver_now!
|
8
|
+
@text_message_class.deliver_text_message(self)
|
9
|
+
end
|
10
|
+
|
11
|
+
# Posts a ActionJob job to call +deliver_now!+ later
|
12
|
+
def deliver_later!(options={})
|
13
|
+
enqueue_delivery :deliver_now!, options
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
# Enqueues a delivery
|
19
|
+
# +options+ are passed to ActiveJob.
|
20
|
+
# +delivery_method+ (usually +deliver_now!+ is called with the saved +@args+ on time.
|
21
|
+
def enqueue_delivery(delivery_method, options={})
|
22
|
+
args = @text_message_class.name, @text_message_method.to_s, delivery_method.to_s, *@args
|
23
|
+
::TextMessage::DeliveryJob.set(options).perform_later(*args)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module TextMessage
|
2
|
+
module Providers
|
3
|
+
class Error < StandardError; end
|
4
|
+
|
5
|
+
def self.find(name)
|
6
|
+
"TextMessage::Providers::#{name.to_s.camelize}".constantize
|
7
|
+
end
|
8
|
+
|
9
|
+
class Base
|
10
|
+
attr_reader :delivery
|
11
|
+
attr_reader :options
|
12
|
+
|
13
|
+
def self.deliver_text_message(delivery, options={})
|
14
|
+
new(delivery, options).deliver_text_message
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(delivery, options={})
|
18
|
+
@delivery = delivery
|
19
|
+
@options = options
|
20
|
+
end
|
21
|
+
|
22
|
+
def deliver_text_message
|
23
|
+
raise Error.new("no provider configured")
|
24
|
+
end
|
25
|
+
|
26
|
+
def message
|
27
|
+
delivery.body.to_str
|
28
|
+
end
|
29
|
+
|
30
|
+
def recipients
|
31
|
+
delivery.recipients.map(&:to_str)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Known providers
|
36
|
+
autoload :TextMagic, "text_message_rails/providers/text_magic" if defined?(::TextMagic)
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module TextMessage
|
2
|
+
module Providers
|
3
|
+
|
4
|
+
class TextMagic < Base
|
5
|
+
def deliver_text_message
|
6
|
+
client.send(message, *escaped_recipients, options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def escaped_recipients
|
10
|
+
return recipients unless defined?(PhonyRails)
|
11
|
+
|
12
|
+
Array(recipients).map { |recipient|
|
13
|
+
PhonyRails.normalize_number(recipient, format: :international_relative, spaces: '', add_plus: false)
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def client
|
18
|
+
@client ||= ::TextMagic::API.new(username, password)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def username
|
24
|
+
options[:username] || ENV["TEXTMAGIC_USERNAME"]
|
25
|
+
end
|
26
|
+
|
27
|
+
def password
|
28
|
+
options[:password] || ENV["TEXTMAGIC_PASSWORD"]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "rails"
|
2
|
+
|
3
|
+
module TextMessage
|
4
|
+
class Railtie < Rails::Railtie
|
5
|
+
config.text_message = ActiveSupport::OrderedOptions.new
|
6
|
+
|
7
|
+
initializer "text_message.configure" do |app|
|
8
|
+
app_options = app.config.text_message
|
9
|
+
|
10
|
+
if default_url_options = app_options.default_url_options
|
11
|
+
TextMessage::Controller.default_url_options = default_url_options
|
12
|
+
end
|
13
|
+
|
14
|
+
if provider_key = app_options.provider
|
15
|
+
TextMessage::Controller.provider = TextMessage::Providers.find(provider_key)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "rails"
|
2
|
+
|
3
|
+
module TextMessage
|
4
|
+
|
5
|
+
# = TextMessage Rendering methods
|
6
|
+
module Rendering
|
7
|
+
|
8
|
+
def self.included(klass) #:nodoc:
|
9
|
+
# setup the view path: will lookup templates in view_paths/template_name
|
10
|
+
klass.view_paths = "app/views"
|
11
|
+
end
|
12
|
+
|
13
|
+
# Called internally by #render
|
14
|
+
def render_to_body(options={}) #:nodoc:
|
15
|
+
renderer.render(view_context, options)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Use custom rendeing class with helpers loaded
|
19
|
+
def view_context # :nodoc:
|
20
|
+
@view_context ||= TemplateContext.new(renderer, view_assigns, self)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Simple out-of-the box ActionView::Renderer
|
24
|
+
def renderer #:nodoc:
|
25
|
+
@renderer ||= ActionView::Renderer.new(lookup_context)
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
#
|
30
|
+
# Private class to render provide rendering context with helpers
|
31
|
+
#
|
32
|
+
|
33
|
+
class TemplateContext < ActionView::Base #:nodoc:
|
34
|
+
# Load route helpers
|
35
|
+
include Rails.application.routes.url_helpers
|
36
|
+
# load tag helpers (link_to ...)
|
37
|
+
include ActionView::Helpers::TagHelper
|
38
|
+
|
39
|
+
# Default options for urls
|
40
|
+
def default_url_options
|
41
|
+
TextMessage::Controller.default_url_options.merge({
|
42
|
+
#action: action_name,
|
43
|
+
#controller: controller.class.name.underscore
|
44
|
+
})
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'text_message_rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "text_message_rails"
|
8
|
+
spec.version = TextMessage::VERSION
|
9
|
+
spec.authors = ["Aurélien Noce"]
|
10
|
+
spec.email = ["aurelien.noce@imagine-app.fr"]
|
11
|
+
|
12
|
+
spec.summary = %q{Easy text messaging from Rails.}
|
13
|
+
spec.description = %q{
|
14
|
+
Simple ActionMail-like Text Message controllers for Rails 3+.
|
15
|
+
(this is a *very* early version !)
|
16
|
+
}
|
17
|
+
spec.homepage = "http://github.com/ushu/text_message_rails"
|
18
|
+
spec.license = "MIT"
|
19
|
+
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
28
|
+
spec.add_runtime_dependency "rails", "> 3.0"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: text_message_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aurélien Noce
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: "\n Simple ActionMail-like Text Message controllers for Rails 3+.\n
|
70
|
+
\ (this is a *very* early version !)\n "
|
71
|
+
email:
|
72
|
+
- aurelien.noce@imagine-app.fr
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".travis.yml"
|
80
|
+
- CODE_OF_CONDUCT.md
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
87
|
+
- lib/text_message_rails.rb
|
88
|
+
- lib/text_message_rails/controller.rb
|
89
|
+
- lib/text_message_rails/delivery.rb
|
90
|
+
- lib/text_message_rails/delivery_job.rb
|
91
|
+
- lib/text_message_rails/delivery_methods.rb
|
92
|
+
- lib/text_message_rails/providers.rb
|
93
|
+
- lib/text_message_rails/providers/text_magic.rb
|
94
|
+
- lib/text_message_rails/railtie.rb
|
95
|
+
- lib/text_message_rails/rendering.rb
|
96
|
+
- lib/text_message_rails/version.rb
|
97
|
+
- text_message_rails.gemspec
|
98
|
+
homepage: http://github.com/ushu/text_message_rails
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
metadata: {}
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options: []
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements: []
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 2.5.1
|
119
|
+
signing_key:
|
120
|
+
specification_version: 4
|
121
|
+
summary: Easy text messaging from Rails.
|
122
|
+
test_files: []
|