bulksms 0.5.1 → 0.5.2
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.
- data/CHANGELOG +6 -0
- data/README.rdoc +5 -0
- data/lib/bulksms/account.rb +23 -1
- data/lib/bulksms/version.rb +1 -1
- data/spec/account_spec.rb +14 -3
- metadata +13 -7
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
@@ -53,6 +53,11 @@ If you prefer more control, the <tt>Service</tt> and <tt>Message</tt> objects ar
|
|
53
53
|
m.want_report = 1
|
54
54
|
s.deliver(m)
|
55
55
|
|
56
|
+
== Encoding
|
57
|
+
|
58
|
+
All messages will be converted to ISO-8859-15 before being sent to the Bulksms servers. Some special characters, including the euro symbol, will be converted and prepended with a special escape character, suitable for GSM-7, so that they will be received correctly. For more details on character encoding, checkout the Bulksms API:
|
59
|
+
|
60
|
+
http://www.bulksms.com/int/docs/eapi/submission/character_encoding/
|
56
61
|
|
57
62
|
== Checking your account balance
|
58
63
|
|
data/lib/bulksms/account.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
|
2
3
|
require 'cgi'
|
4
|
+
require 'iconv'
|
3
5
|
|
4
6
|
module Bulksms
|
5
7
|
|
6
8
|
class AccountError < Exception; end
|
7
9
|
|
10
|
+
|
8
11
|
class Account
|
9
12
|
|
10
13
|
attr_reader :username, :password, :host, :port
|
@@ -54,9 +57,28 @@ module Bulksms
|
|
54
57
|
end
|
55
58
|
|
56
59
|
def params_to_query_string(params)
|
57
|
-
params.collect{|k,v| "#{k}=#{
|
60
|
+
params.collect{|k,v| "#{k}=#{encode_cgi_string(v.to_s)}"}.join('&')
|
58
61
|
end
|
59
62
|
|
63
|
+
def encode_cgi_string(string)
|
64
|
+
CGI.escape(Iconv.iconv('ISO-8859-15//ignore', 'UTF-8', string)[0]).gsub(/%[0-9A-F]{2}/) do |match|
|
65
|
+
code = GSM0338_EXTENDED_MAP[match]
|
66
|
+
code ? "%BB%#{code}" : match
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
GSM0338_EXTENDED_MAP = {
|
71
|
+
'%5E' => '14', # ^
|
72
|
+
'%7B' => '28', # {
|
73
|
+
'%7D' => '29', # }
|
74
|
+
'%5C' => '2F', # \
|
75
|
+
'%5B' => '3C', # [
|
76
|
+
'%7E' => '3D', # ~
|
77
|
+
'%5D' => '3E', # ]
|
78
|
+
'%7C' => '40', # |
|
79
|
+
'%A4' => '65', # EURO
|
80
|
+
}
|
81
|
+
|
60
82
|
end
|
61
83
|
|
62
84
|
end
|
data/lib/bulksms/version.rb
CHANGED
data/spec/account_spec.rb
CHANGED
@@ -83,12 +83,23 @@ describe Bulksms::Account do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
describe "#params_to_query_string" do
|
86
|
-
it "converts params to string" do
|
87
|
-
txt = @account.send(:params_to_query_string, :msg => "Random
|
88
|
-
txt.should include("Random
|
86
|
+
it "converts normal params to string" do
|
87
|
+
txt = @account.send(:params_to_query_string, :msg => "Random cháráctérs -and- symbols +34123123123", :some => :symbol)
|
88
|
+
txt.should include("Random+ch%E1r%E1ct%E9")
|
89
89
|
txt.should include("%2B34123")
|
90
90
|
txt.should include("some=symbol")
|
91
91
|
end
|
92
|
+
|
93
|
+
it "converts special characters in params to string" do
|
94
|
+
txt = @account.send(:params_to_query_string, :msg => "[special] {characters} tilde~ pipe| hat^ euro€")
|
95
|
+
txt.should include("%BB%3Cspecial%BB%3E")
|
96
|
+
txt.should include("%BB%28characters%BB%29")
|
97
|
+
txt.should include("tilde%BB%3D")
|
98
|
+
txt.should include("pipe%BB%40")
|
99
|
+
txt.should include("hat%BB%14")
|
100
|
+
txt.should include("euro%BB%65")
|
101
|
+
end
|
102
|
+
|
92
103
|
end
|
93
104
|
|
94
105
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bulksms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,11 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2012-02-01 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec
|
18
|
-
requirement: &
|
18
|
+
requirement: &2164746900 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ! '>='
|
@@ -23,10 +23,10 @@ dependencies:
|
|
23
23
|
version: '0'
|
24
24
|
type: :development
|
25
25
|
prerelease: false
|
26
|
-
version_requirements: *
|
26
|
+
version_requirements: *2164746900
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: fakeweb
|
29
|
-
requirement: &
|
29
|
+
requirement: &2164745660 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
32
|
- - ! '>='
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
|
-
version_requirements: *
|
37
|
+
version_requirements: *2164745660
|
38
38
|
description: Send SMS text messages via the BulkSMS API.
|
39
39
|
email:
|
40
40
|
- me@samlown.com
|
@@ -88,4 +88,10 @@ rubygems_version: 1.8.10
|
|
88
88
|
signing_key:
|
89
89
|
specification_version: 3
|
90
90
|
summary: Simple BulkSMS API
|
91
|
-
test_files:
|
91
|
+
test_files:
|
92
|
+
- spec/account_spec.rb
|
93
|
+
- spec/bulksms_spec.rb
|
94
|
+
- spec/configuration_spec.rb
|
95
|
+
- spec/message_spec.rb
|
96
|
+
- spec/service_spec.rb
|
97
|
+
- spec/spec_helper.rb
|