sms_gateway 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +11 -10
- data/Rakefile +1 -1
- data/lib/sms_gateway/adapters/better_opener.rb +23 -0
- data/lib/sms_gateway/adapters/test.rb +16 -1
- data/lib/sms_gateway/version.rb +1 -1
- data/sms_gateway.gemspec +2 -1
- data/test/test_adapter_test.rb +28 -0
- data/test/test_helper.rb +1 -0
- metadata +79 -73
data/README.rdoc
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
The SMS Gateway gem provides a simple and extensible interface for
|
4
4
|
various SMS Gateways. It is loosely oriented on Action Mailer. The
|
5
|
-
gem allows you to create
|
6
|
-
asynchronously. So far it
|
5
|
+
gem allows you to create an SMS and deliver it synchronously or
|
6
|
+
asynchronously. So far it ships with the following adapters:
|
7
7
|
|
8
8
|
* smsglobal.com
|
9
|
-
*
|
9
|
+
* smstrade.de
|
10
10
|
|
11
11
|
|
12
12
|
= Installation
|
@@ -21,22 +21,22 @@ gem's generator:
|
|
21
21
|
|
22
22
|
rails g sms_gateway:install
|
23
23
|
|
24
|
-
|
25
|
-
to configure before sending
|
24
|
+
which installs an initializer and a yml file that you will need
|
25
|
+
to configure before sending out an SMS.
|
26
26
|
|
27
27
|
|
28
28
|
== Resque and Redis
|
29
29
|
|
30
|
-
To deliver SMS asynchronously this gem makes use of resque, a
|
31
|
-
|
32
|
-
to have a working resque and redis setup if you want to use
|
33
|
-
|
30
|
+
To deliver SMS asynchronously this gem makes use of resque, a popular
|
31
|
+
queing system basd on the key-value data store redis. You need
|
32
|
+
to have a working resque and redis setup if you want to use the
|
33
|
+
aynchronous sending feature. For more information on resque visit
|
34
34
|
https://github.com/defunkt/resque .
|
35
35
|
|
36
36
|
|
37
37
|
= Usage
|
38
38
|
|
39
|
-
Similar to action mailer you create
|
39
|
+
Similar to action mailer you create a message object first:
|
40
40
|
|
41
41
|
m = SmsGateway::Sms.new(:from => '493088888888, :to => '49309999999',
|
42
42
|
:text => 'my sms must not be longer than 160 characters.')
|
@@ -67,6 +67,7 @@ So far the gem is pretty limited. Ideas for following version are:
|
|
67
67
|
* more and better unit tests
|
68
68
|
* more sms gateway apis
|
69
69
|
* decoupling of resque
|
70
|
+
* error handling
|
70
71
|
|
71
72
|
|
72
73
|
= License
|
data/Rakefile
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
module SmsGateway
|
2
|
+
|
3
|
+
module Adapters
|
4
|
+
|
5
|
+
class BetterOpener
|
6
|
+
|
7
|
+
def initialize(config={})
|
8
|
+
@config = {:from => SmsGateway::Base.from}
|
9
|
+
@config.merge!(config)
|
10
|
+
end
|
11
|
+
|
12
|
+
def send_sms(sms)
|
13
|
+
options = @config.merge({:to => sms.to, :message => sms.text})
|
14
|
+
BetterOpener.add_notification("sms", sms.text, sms.text)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
|
@@ -1,14 +1,29 @@
|
|
1
1
|
|
2
2
|
module SmsGateway
|
3
|
+
|
4
|
+
class Base
|
5
|
+
|
6
|
+
class << self
|
7
|
+
attr_reader :deliveries
|
8
|
+
end
|
9
|
+
|
10
|
+
@deliveries = []
|
11
|
+
end
|
12
|
+
|
13
|
+
|
3
14
|
module Adapters
|
4
15
|
|
5
16
|
class Test
|
17
|
+
|
18
|
+
attr_accessor :deliveries
|
19
|
+
|
6
20
|
def initialize(config={})
|
7
21
|
@logger = Logger.new(STDOUT)
|
8
22
|
end
|
9
23
|
|
10
24
|
def send_sms(sms)
|
11
|
-
|
25
|
+
#@logger.info "would be sending sms: #{sms.to_s}"
|
26
|
+
SmsGateway::Base.deliveries << sms
|
12
27
|
end
|
13
28
|
|
14
29
|
end
|
data/lib/sms_gateway/version.rb
CHANGED
data/sms_gateway.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.email = ["kai@doxter.de"]
|
11
11
|
s.homepage = ""
|
12
12
|
s.summary = %q{Simple and flexible interface to SMS Gateways}
|
13
|
-
s.description = %q{Provides an interface to SMS Gateways. So far it supports smsglobal.com.}
|
13
|
+
s.description = %q{Provides an interface to SMS Gateways. So far it supports smsglobal.com and smstrade.de}
|
14
14
|
|
15
15
|
s.rubyforge_project = "sms_gateway"
|
16
16
|
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_dependency('resque')
|
24
24
|
|
25
25
|
s.add_development_dependency('webmock')
|
26
|
+
s.add_development_dependency('debugger')
|
26
27
|
|
27
28
|
end
|
28
29
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SmsGateway::Adapters::SmsGatewayTest < Test::Unit::TestCase
|
4
|
+
include SmsGateway
|
5
|
+
|
6
|
+
def test_test_adapter
|
7
|
+
|
8
|
+
SmsGateway::Base.config = {
|
9
|
+
:from => '493011111111',
|
10
|
+
:user => 'userid',
|
11
|
+
:password => 'secret',
|
12
|
+
:adapter => 'test'
|
13
|
+
}
|
14
|
+
|
15
|
+
sms = Sms.new(:to => '493088888888', :text => "hello")
|
16
|
+
|
17
|
+
assert_equal 0, SmsGateway::Base.deliveries.size
|
18
|
+
sms.deliver
|
19
|
+
assert_equal 1, SmsGateway::Base.deliveries.size
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,79 +1,94 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: sms_gateway
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 0
|
10
|
-
version: 0.1.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Kai Rubarth
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-01-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: httparty
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
32
22
|
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: resque
|
36
23
|
prerelease: false
|
37
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: resque
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
38
33
|
none: false
|
39
|
-
requirements:
|
40
|
-
- -
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
|
43
|
-
segments:
|
44
|
-
- 0
|
45
|
-
version: "0"
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
46
38
|
type: :runtime
|
47
|
-
|
48
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
49
47
|
name: webmock
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
50
55
|
prerelease: false
|
51
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: debugger
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
52
65
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
57
|
-
segments:
|
58
|
-
- 0
|
59
|
-
version: "0"
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
60
70
|
type: :development
|
61
|
-
|
62
|
-
|
63
|
-
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: Provides an interface to SMS Gateways. So far it supports smsglobal.com
|
79
|
+
and smstrade.de
|
80
|
+
email:
|
64
81
|
- kai@doxter.de
|
65
82
|
executables: []
|
66
|
-
|
67
83
|
extensions: []
|
68
|
-
|
69
84
|
extra_rdoc_files: []
|
70
|
-
|
71
|
-
files:
|
85
|
+
files:
|
72
86
|
- .gitignore
|
73
87
|
- Gemfile
|
74
88
|
- README.rdoc
|
75
89
|
- Rakefile
|
76
90
|
- lib/sms_gateway.rb
|
91
|
+
- lib/sms_gateway/adapters/better_opener.rb
|
77
92
|
- lib/sms_gateway/adapters/sms_global.rb
|
78
93
|
- lib/sms_gateway/adapters/sms_trade.rb
|
79
94
|
- lib/sms_gateway/adapters/test.rb
|
@@ -87,39 +102,30 @@ files:
|
|
87
102
|
- sms_gateway.gemspec
|
88
103
|
- test/configuration_test.rb
|
89
104
|
- test/sms_gateway_test.rb
|
105
|
+
- test/test_adapter_test.rb
|
90
106
|
- test/test_helper.rb
|
91
|
-
homepage:
|
107
|
+
homepage: ''
|
92
108
|
licenses: []
|
93
|
-
|
94
109
|
post_install_message:
|
95
110
|
rdoc_options: []
|
96
|
-
|
97
|
-
require_paths:
|
111
|
+
require_paths:
|
98
112
|
- lib
|
99
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
114
|
none: false
|
101
|
-
requirements:
|
102
|
-
- -
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
|
105
|
-
|
106
|
-
- 0
|
107
|
-
version: "0"
|
108
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
120
|
none: false
|
110
|
-
requirements:
|
111
|
-
- -
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
|
114
|
-
segments:
|
115
|
-
- 0
|
116
|
-
version: "0"
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
117
125
|
requirements: []
|
118
|
-
|
119
126
|
rubyforge_project: sms_gateway
|
120
|
-
rubygems_version: 1.8.
|
127
|
+
rubygems_version: 1.8.23
|
121
128
|
signing_key:
|
122
129
|
specification_version: 3
|
123
130
|
summary: Simple and flexible interface to SMS Gateways
|
124
131
|
test_files: []
|
125
|
-
|