sms_gateway 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/lib/sms_gateway/adapters/sms_trade.rb +1 -0
- data/lib/sms_gateway/base.rb +2 -2
- data/lib/sms_gateway/sms.rb +3 -8
- data/lib/sms_gateway/version.rb +1 -1
- data/sms_gateway.gemspec +2 -1
- data/test/adapters/sms_global_test.rb +31 -0
- data/test/adapters/sms_trade_test.rb +43 -0
- data/test/{test_adapter_test.rb → adapters/test_adapter_test.rb} +4 -5
- data/test/configuration_test.rb +2 -20
- data/test/test_helper.rb +5 -10
- metadata +35 -19
- data/test/sms_gateway_test.rb +0 -60
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5da65ee20b61e04afa2d252edb032ef0595a3a2d
|
4
|
+
data.tar.gz: 2457d1ec22f250b82a3a6568532b5ab2136dff12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7062407b54906de2506b5a18f430a72c10f0d94bfd7e3fa02386889a9c02124bdd9b8823842e54f3f0379cf4b06dc74acb56df78fad730c5bf77e7ea7a9372c9
|
7
|
+
data.tar.gz: dad6fc449ea60413b949394217be9b9c7599042dfa8d36c46e32a3600a4e043da4ede7bd0bf299d22f470e129b195ae45a424158b38c484cd7c98ccdb15a0919
|
data/.travis.yml
ADDED
data/lib/sms_gateway/base.rb
CHANGED
data/lib/sms_gateway/sms.rb
CHANGED
@@ -1,21 +1,16 @@
|
|
1
|
-
|
2
1
|
## The SMS-Object
|
3
2
|
module SmsGateway
|
4
|
-
class Sms < Struct.new(:from, :to, :text)
|
3
|
+
class Sms < Struct.new(:from, :to, :text, :route)
|
5
4
|
|
6
5
|
def initialize(params)
|
7
|
-
#self.from = params[:from]||SmsGateway::Base.config[:from]
|
8
6
|
self.from = params[:from]||SmsGateway::Base.from
|
9
7
|
self.to = params[:to]
|
10
8
|
self.text = params[:text]
|
9
|
+
self.route = params[:route]
|
11
10
|
end
|
12
11
|
|
13
12
|
def deliver
|
14
|
-
SmsGateway::Base.deliver(
|
15
|
-
end
|
16
|
-
|
17
|
-
def deliver_later
|
18
|
-
Resque.enqueue(SmsGateway::SmsJob, :to=>self.to, :from=>self.from, :text=>self.text)
|
13
|
+
SmsGateway::Base.deliver(self)
|
19
14
|
end
|
20
15
|
|
21
16
|
def to_s
|
data/lib/sms_gateway/version.rb
CHANGED
data/sms_gateway.gemspec
CHANGED
@@ -20,9 +20,10 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
22
|
s.add_dependency('httparty')
|
23
|
-
s.add_dependency('resque')
|
24
23
|
|
25
24
|
s.add_development_dependency('rake')
|
25
|
+
s.add_development_dependency('minitest')
|
26
|
+
s.add_development_dependency('pry')
|
26
27
|
s.add_development_dependency('webmock')
|
27
28
|
|
28
29
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe SmsGateway::Adapters do
|
4
|
+
|
5
|
+
before do
|
6
|
+
SmsGateway::Base.config = {
|
7
|
+
:from => '493011111111',
|
8
|
+
:user => 'userid',
|
9
|
+
:password => 'secret',
|
10
|
+
:adapter => 'sms_global'
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'works with sms global' do
|
15
|
+
|
16
|
+
stub_request(:post, "http://www.smsglobal.com/http-api.php?action=sendsms&from=4930123456&password=secret&text=hello&to=493088888888&user=userid").
|
17
|
+
to_return(:status => 200, :body => "OK: 0;", :headers => {})
|
18
|
+
|
19
|
+
sms = SmsGateway::Sms.new(:from => '4930123456', :to => '493088888888',
|
20
|
+
:text => "hello")
|
21
|
+
|
22
|
+
sms.deliver
|
23
|
+
|
24
|
+
assert_requested(:post, "http://www.smsglobal.com/http-api.php?action=sendsms&from=4930123456&password=secret&text=hello&to=493088888888&user=userid")
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe SmsGateway::Adapters::SmsGlobal do
|
4
|
+
|
5
|
+
before do
|
6
|
+
SmsGateway::Base.config = {
|
7
|
+
:adapter => 'sms_trade',
|
8
|
+
:route => 'direct',
|
9
|
+
:key => 'KEY',
|
10
|
+
:from => 'SMSTRADE'
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'works with smstrade' do
|
15
|
+
|
16
|
+
sms = SmsGateway::Sms.new(:to => '491701234567', :text => "Hallö Ümläut.", :from => 'SENDER')
|
17
|
+
|
18
|
+
stub_request(:get, "http://gateway.smstrade.de/?charset=UTF-8&from=SENDER&key=KEY&message=#{URI.encode(sms.text)}&route=direct&to=491701234567").
|
19
|
+
to_return(:status => 200, :body => "", :headers => {})
|
20
|
+
|
21
|
+
sms.deliver
|
22
|
+
|
23
|
+
assert_requested(:get, "http://gateway.smstrade.de/?key=KEY&to=491701234567&message=#{URI.encode(sms.text)}&route=direct&from=SENDER&charset=UTF-8")
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'allows changing the route on the fly' do
|
27
|
+
|
28
|
+
sms = SmsGateway::Sms.new(:to => '491701234567', :text => "SMSTEXT", :from => 'SENDER', :route => 'basic')
|
29
|
+
|
30
|
+
stub_request(:get, "http://gateway.smstrade.de/?charset=UTF-8&from=SENDER&key=KEY&message=#{URI.encode(sms.text)}&route=basic&to=491701234567").
|
31
|
+
to_return(:status => 200, :body => "", :headers => {})
|
32
|
+
|
33
|
+
sms.deliver
|
34
|
+
|
35
|
+
assert_requested(:get, "http://gateway.smstrade.de/?key=KEY&to=491701234567&message=#{URI.encode(sms.text)}&route=basic&from=SENDER&charset=UTF-8")
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
include SmsGateway
|
3
|
+
describe SmsGateway::Adapters::Test do
|
5
4
|
|
6
|
-
|
5
|
+
it 'works with the test adapter' do
|
7
6
|
|
8
7
|
SmsGateway::Base.config = {
|
9
8
|
:from => '493011111111',
|
@@ -12,7 +11,7 @@ class SmsGateway::Adapters::SmsGatewayTest < Test::Unit::TestCase
|
|
12
11
|
:adapter => 'test'
|
13
12
|
}
|
14
13
|
|
15
|
-
sms = Sms.new(:to => '493088888888', :text => "hello")
|
14
|
+
sms = SmsGateway::Sms.new(:to => '493088888888', :text => "hello")
|
16
15
|
|
17
16
|
assert_equal 0, SmsGateway::Base.deliveries.size
|
18
17
|
sms.deliver
|
@@ -20,7 +19,7 @@ class SmsGateway::Adapters::SmsGatewayTest < Test::Unit::TestCase
|
|
20
19
|
|
21
20
|
SmsGateway::Base.deliveries = []
|
22
21
|
assert_equal [], SmsGateway::Base.deliveries
|
23
|
-
|
22
|
+
|
24
23
|
end
|
25
24
|
|
26
25
|
|
data/test/configuration_test.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
|
2
1
|
require 'test_helper'
|
3
2
|
|
4
|
-
|
3
|
+
describe SmsGateway::Base do
|
5
4
|
|
6
|
-
|
5
|
+
before do
|
7
6
|
SmsGateway::Base.configure do |config|
|
8
7
|
config.from = '123456789'
|
9
8
|
config.user = 'some_user'
|
@@ -25,23 +24,6 @@ class SmsGateway::ConfigurationTest < Test::Unit::TestCase
|
|
25
24
|
assert_equal '123456789', sms.from
|
26
25
|
end
|
27
26
|
|
28
|
-
# def test_parse_adapter
|
29
|
-
# assert_equal SmsGateway::Adapters::Test, SmsGateway::Base.adapter
|
30
|
-
# end
|
31
|
-
#
|
32
|
-
# def test_work_config_hash
|
33
|
-
# SmsGateway::Base.config = {
|
34
|
-
# :from => 'new_from',
|
35
|
-
# :user => 'new_user',
|
36
|
-
# :password => 'new_password',
|
37
|
-
# :adapter => 'sms_global'}
|
38
|
-
#
|
39
|
-
# assert_equal 'new_from', SmsGateway::Base.from
|
40
|
-
# assert_equal 'new_user', SmsGateway::Base.user
|
41
|
-
# assert_equal 'new_password', SmsGateway::Base.password
|
42
|
-
# assert_equal SmsGateway::Adapters::SmsGlobal, SmsGateway::Base.adapter
|
43
|
-
# end
|
44
|
-
|
45
27
|
end
|
46
28
|
|
47
29
|
|
data/test/test_helper.rb
CHANGED
@@ -1,12 +1,7 @@
|
|
1
|
-
|
2
|
-
require 'rubygems'
|
3
|
-
require 'test/unit'
|
4
|
-
require 'webmock/test_unit'
|
5
|
-
require 'debugger'
|
6
|
-
|
7
1
|
require 'sms_gateway'
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
2
|
+
require 'sms_gateway/adapters/sms_global'
|
3
|
+
require 'sms_gateway/adapters/sms_trade'
|
4
|
+
require 'minitest/autorun'
|
5
|
+
require 'webmock/minitest'
|
6
|
+
require 'pry'
|
12
7
|
|
metadata
CHANGED
@@ -1,69 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sms_gateway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kai Rubarth
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
|
-
type: :
|
34
|
+
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: webmock
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
73
|
+
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: '0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
description: Provides an interface to SMS Gateways. So far it supports smsglobal.com
|
@@ -74,7 +88,8 @@ executables: []
|
|
74
88
|
extensions: []
|
75
89
|
extra_rdoc_files: []
|
76
90
|
files:
|
77
|
-
- .gitignore
|
91
|
+
- ".gitignore"
|
92
|
+
- ".travis.yml"
|
78
93
|
- Gemfile
|
79
94
|
- README.rdoc
|
80
95
|
- Rakefile
|
@@ -91,9 +106,10 @@ files:
|
|
91
106
|
- lib/sms_gateway/sms.rb
|
92
107
|
- lib/sms_gateway/version.rb
|
93
108
|
- sms_gateway.gemspec
|
109
|
+
- test/adapters/sms_global_test.rb
|
110
|
+
- test/adapters/sms_trade_test.rb
|
111
|
+
- test/adapters/test_adapter_test.rb
|
94
112
|
- test/configuration_test.rb
|
95
|
-
- test/sms_gateway_test.rb
|
96
|
-
- test/test_adapter_test.rb
|
97
113
|
- test/test_helper.rb
|
98
114
|
homepage: ''
|
99
115
|
licenses: []
|
@@ -104,17 +120,17 @@ require_paths:
|
|
104
120
|
- lib
|
105
121
|
required_ruby_version: !ruby/object:Gem::Requirement
|
106
122
|
requirements:
|
107
|
-
- -
|
123
|
+
- - ">="
|
108
124
|
- !ruby/object:Gem::Version
|
109
125
|
version: '0'
|
110
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
127
|
requirements:
|
112
|
-
- -
|
128
|
+
- - ">="
|
113
129
|
- !ruby/object:Gem::Version
|
114
130
|
version: '0'
|
115
131
|
requirements: []
|
116
132
|
rubyforge_project: sms_gateway
|
117
|
-
rubygems_version: 2.
|
133
|
+
rubygems_version: 2.2.2
|
118
134
|
signing_key:
|
119
135
|
specification_version: 4
|
120
136
|
summary: Simple and flexible interface to SMS Gateways
|
data/test/sms_gateway_test.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class SmsGateway::Adapters::SmsGatewayTest < Test::Unit::TestCase
|
6
|
-
include SmsGateway
|
7
|
-
|
8
|
-
def setup
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_sms_gateway
|
12
|
-
|
13
|
-
SmsGateway::Base.config = {
|
14
|
-
:from => '493011111111',
|
15
|
-
:user => 'userid',
|
16
|
-
:password => 'secret',
|
17
|
-
:adapter => 'sms_global'
|
18
|
-
}
|
19
|
-
|
20
|
-
stub_request(:post, "http://www.smsglobal.com/http-api.php?action=sendsms&from=4930123456&password=secret&text=hello&to=493088888888&user=userid").
|
21
|
-
to_return(:status => 200, :body => "OK: 0;", :headers => {})
|
22
|
-
|
23
|
-
sms = Sms.new(:from => '4930123456', :to => '493088888888',
|
24
|
-
:text => "hello")
|
25
|
-
|
26
|
-
sms.deliver
|
27
|
-
|
28
|
-
assert_requested(:post, "http://www.smsglobal.com/http-api.php?action=sendsms&from=4930123456&password=secret&text=hello&to=493088888888&user=userid")
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
def test_sms_trade
|
36
|
-
|
37
|
-
SmsGateway::Base.config = {
|
38
|
-
:adapter => 'sms_trade',
|
39
|
-
:route => 'direct',
|
40
|
-
:key => 'KEY',
|
41
|
-
:from => 'SMSTRADE'
|
42
|
-
}
|
43
|
-
|
44
|
-
sms = Sms.new(:to => '491701234567', :text => "Hallö Ümläut.", :from => 'SENDER')
|
45
|
-
|
46
|
-
stub_request(:get, "http://gateway.smstrade.de/?charset=UTF-8&from=SENDER&key=KEY&message=#{URI.encode(sms.text)}&route=direct&to=491701234567").
|
47
|
-
to_return(:status => 200, :body => "", :headers => {})
|
48
|
-
|
49
|
-
sms.deliver
|
50
|
-
|
51
|
-
assert_requested(:get, "http://gateway.smstrade.de/?key=KEY&to=491701234567&message=#{URI.encode(sms.text)}&route=direct&from=SENDER&charset=UTF-8")
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|