broadcast 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +21 -1
- data/broadcast.gemspec +1 -0
- data/lib/broadcast/media/campfire.rb +1 -1
- data/lib/broadcast/media/email.rb +2 -2
- data/lib/broadcast/media/facebook.rb +1 -1
- data/lib/broadcast/media/irc.rb +1 -1
- data/lib/broadcast/media/jabber.rb +1 -1
- data/lib/broadcast/media/sms.rb +16 -0
- data/lib/broadcast/version.rb +1 -1
- data/spec/lib/broadcast/media/sms_spec.rb +38 -0
- data/spec/support/config.rb +8 -0
- metadata +21 -4
data/README.markdown
CHANGED
@@ -3,7 +3,7 @@ Broadcast [![Build Status](http://travis-ci.org/futuresimple/broadcast.png)](htt
|
|
3
3
|
|
4
4
|
A broadcasting microframework making publishing of messages to different services easy and DRY.
|
5
5
|
|
6
|
-
|
6
|
+
Current version is 0.2.1.
|
7
7
|
|
8
8
|
Use Cases
|
9
9
|
------------
|
@@ -226,6 +226,26 @@ It is based on the assumption that the user associated with the access token has
|
|
226
226
|
end
|
227
227
|
```
|
228
228
|
|
229
|
+
### SMS
|
230
|
+
|
231
|
+
Broadcast::Medium::SMS is based on the SMSified gem.
|
232
|
+
You must create an account on http://smsified.com before sending SMS text messages (developer accounts are free).
|
233
|
+
You will be given a phone number to use as your very own FROM sms number. This number, along with your username and password,
|
234
|
+
must be added to your config during setup. The To address is the address of the mobile number that you would like to send the SMS message to.
|
235
|
+
|
236
|
+
#### Example setup
|
237
|
+
|
238
|
+
```ruby
|
239
|
+
Broadcast.setup do |config|
|
240
|
+
config.sms { |sms|
|
241
|
+
sms.username = 'myaccount'
|
242
|
+
sms.password = 'mypass'
|
243
|
+
sms.from = '16025551212'
|
244
|
+
sms.to = '14801234567'
|
245
|
+
}
|
246
|
+
end
|
247
|
+
```
|
248
|
+
|
229
249
|
Copyright
|
230
250
|
---------
|
231
251
|
|
data/broadcast.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_dependency 'broach'
|
22
22
|
s.add_dependency 'shout-bot'
|
23
23
|
s.add_dependency 'koala'
|
24
|
+
s.add_dependency 'smsified'
|
24
25
|
|
25
26
|
s.files = `git ls-files`.split("\n")
|
26
27
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'mail'
|
2
2
|
|
3
|
-
class Broadcast::Medium::Email < Broadcast::Medium
|
3
|
+
class Broadcast::Medium::Email < Broadcast::Medium
|
4
4
|
|
5
5
|
def publish(message)
|
6
6
|
recipients = options.recipients.is_a?(Array) ? options.recipients : [options.recipients]
|
@@ -18,5 +18,5 @@ class Broadcast::Medium::Email < Broadcast::Medium::Oauth
|
|
18
18
|
mail.deliver
|
19
19
|
end
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
end
|
data/lib/broadcast/media/irc.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'smsified'
|
2
|
+
|
3
|
+
class Broadcast::Medium::Sms < Broadcast::Medium
|
4
|
+
|
5
|
+
def publish(message)
|
6
|
+
|
7
|
+
oneapi = Smsified::OneAPI.new :username => options.username,
|
8
|
+
:password => options.password
|
9
|
+
|
10
|
+
oneapi.send_sms :address => options.to,
|
11
|
+
:message => message.body,
|
12
|
+
:sender_address => options.from
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
data/lib/broadcast/version.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Broadcast::Medium::Sms do
|
4
|
+
|
5
|
+
describe '.new' do
|
6
|
+
|
7
|
+
it "should create a new instance with options provided in config" do
|
8
|
+
medium = Broadcast::Medium::Sms.new
|
9
|
+
medium.options.username.should == 'myaccount'
|
10
|
+
medium.options.password.should == 'mypass'
|
11
|
+
medium.options.to.should == '22222222222'
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should prioritize options argument over options provided in config" do
|
15
|
+
medium = Broadcast::Medium::Sms.new(:to => '33333333333')
|
16
|
+
medium.options.username.should == 'myaccount'
|
17
|
+
medium.options.password.should == 'mypass'
|
18
|
+
medium.options.to.should == '33333333333'
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#publish' do
|
24
|
+
|
25
|
+
before do
|
26
|
+
@mock_client = mock
|
27
|
+
Smsified::OneAPI.should_receive(:new).with(:username => 'myaccount', :password => 'mypass').and_return(@mock_client)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should send the sms" do
|
31
|
+
message = Broadcast::Message::SpecWithContent.new
|
32
|
+
@mock_client.should_receive(:send_sms).with({:message=>message.body, :sender_address=>"11111111111", :address=>"22222222222"})
|
33
|
+
Broadcast::Medium::Sms.new.publish(message)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/spec/support/config.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: broadcast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marcin Bunsch
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-06-
|
19
|
+
date: 2011-06-11 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: hashie
|
@@ -116,6 +116,20 @@ dependencies:
|
|
116
116
|
version: "0"
|
117
117
|
prerelease: false
|
118
118
|
requirement: *id007
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
name: smsified
|
121
|
+
type: :runtime
|
122
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
hash: 3
|
128
|
+
segments:
|
129
|
+
- 0
|
130
|
+
version: "0"
|
131
|
+
prerelease: false
|
132
|
+
requirement: *id008
|
119
133
|
description: A broadcasting microframework making publishing of messages to different services easy
|
120
134
|
email:
|
121
135
|
- marcin@futuresimple.com
|
@@ -142,6 +156,7 @@ files:
|
|
142
156
|
- lib/broadcast/media/jabber.rb
|
143
157
|
- lib/broadcast/media/log.rb
|
144
158
|
- lib/broadcast/media/oauth.rb
|
159
|
+
- lib/broadcast/media/sms.rb
|
145
160
|
- lib/broadcast/media/twitter.rb
|
146
161
|
- lib/broadcast/media/yammer.rb
|
147
162
|
- lib/broadcast/medium.rb
|
@@ -156,6 +171,7 @@ files:
|
|
156
171
|
- spec/lib/broadcast/media/jabber_spec.rb
|
157
172
|
- spec/lib/broadcast/media/log_spec.rb
|
158
173
|
- spec/lib/broadcast/media/oauth_spec.rb
|
174
|
+
- spec/lib/broadcast/media/sms_spec.rb
|
159
175
|
- spec/lib/broadcast/media/twitter_spec.rb
|
160
176
|
- spec/lib/broadcast/media/yammer_spec.rb
|
161
177
|
- spec/lib/broadcast/medium_spec.rb
|
@@ -205,6 +221,7 @@ test_files:
|
|
205
221
|
- spec/lib/broadcast/media/jabber_spec.rb
|
206
222
|
- spec/lib/broadcast/media/log_spec.rb
|
207
223
|
- spec/lib/broadcast/media/oauth_spec.rb
|
224
|
+
- spec/lib/broadcast/media/sms_spec.rb
|
208
225
|
- spec/lib/broadcast/media/twitter_spec.rb
|
209
226
|
- spec/lib/broadcast/media/yammer_spec.rb
|
210
227
|
- spec/lib/broadcast/medium_spec.rb
|