clickatell 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.5.0
2
+ * Added support for mobile originated flag (courtesy Dan Weinand)
3
+ * Added support for WAP push (experimental, courtesy Zhao Lu)
4
+ * Updated specs to use Mocha instead of the built-in RSpec mocking
5
+ * Improved specs in general
6
+
1
7
  == 0.4.1
2
8
  * Custom alphanumeric sender would not always be supported by default unless it was explicitly enabled using the req_feat parameter.
3
9
 
data/Manifest.txt CHANGED
@@ -2,6 +2,7 @@ History.txt
2
2
  License.txt
3
3
  Manifest.txt
4
4
  README.txt
5
+ README.textile
5
6
  Rakefile
6
7
  bin/sms
7
8
  lib/clickatell.rb
data/README.textile ADDED
@@ -0,0 +1,33 @@
1
+ h1. Clickatell SMS Library
2
+
3
+ To use this gem, you will need sign up for an account at www.clickatell.com. Once you are registered and logged into your account centre, you should add an HTTP API connection to your account. This will give you your API_ID.
4
+
5
+ h2. Basic Usage
6
+
7
+ You will need your API_ID as well as your account username and password.
8
+
9
+ require 'rubygems'
10
+ require 'clickatell'
11
+
12
+ api = Clickatell::API.authenticate('your_api_id', 'your_username', 'your_password')
13
+ api.send_message('447771234567', 'Hello from clickatell')
14
+
15
+
16
+ h2. Command-line SMS Utility
17
+
18
+ The Clickatell gem also comes with a command-line utility that will allow you to send an SMS directly from the command-line.
19
+
20
+ You will need to create a YAML configuration file in your home directory, in a file called .clickatell that resembles the following:
21
+
22
+ # ~/.clickatell
23
+ api_key: your_api_id
24
+ username: your_username
25
+ password: your_password
26
+
27
+ You can then use the sms utility to send a message to a single recipient:
28
+
29
+ sms 447771234567 'Hello from clickatell'
30
+
31
+ Alternatively, you can specify the username and password as a command line option. Run +sms+ without any arguments for a full list of options.
32
+
33
+ See http://clickatell.rubyforge.org for further instructions.
data/README.txt CHANGED
@@ -1,11 +1,10 @@
1
- == Basic Usage
1
+ = Clickatell SMS Library
2
+
3
+ To use this gem, you will need sign up for an account at www.clickatell.com. Once you are registered and logged into your account centre, you should add an HTTP API connection to your account. This will give you your API_ID.
2
4
 
3
- To use this gem, you will need sign up for an account at www.clickatell.com.
4
- Once you are registered and logged into your account centre, you should add
5
- an HTTP API connection to your account. This will give you your API_ID.
5
+ == Basic Usage
6
6
 
7
- You can now use the library directly. You will need your API_ID as well as your
8
- account username and password.
7
+ You will need your API_ID as well as your account username and password.
9
8
 
10
9
  require 'rubygems'
11
10
  require 'clickatell'
@@ -16,11 +15,9 @@ account username and password.
16
15
 
17
16
  == Command-line SMS Utility
18
17
 
19
- The Clickatell gem also comes with a command-line utility that will allow you
20
- to send an SMS directly from the command-line.
18
+ The Clickatell gem also comes with a command-line utility that will allow you to send an SMS directly from the command-line.
21
19
 
22
- You will need to create a YAML configuration file in your home directory, in a
23
- file called .clickatell that resembles the following:
20
+ You will need to create a YAML configuration file in your home directory, in a file called .clickatell that resembles the following:
24
21
 
25
22
  # ~/.clickatell
26
23
  api_key: your_api_id
@@ -31,11 +28,6 @@ You can then use the sms utility to send a message to a single recipient:
31
28
 
32
29
  sms 447771234567 'Hello from clickatell'
33
30
 
34
- Run +sms+ without any arguments for a full list of options.
31
+ Alternatively, you can specify the username and password as a command line option. Run +sms+ without any arguments for a full list of options.
35
32
 
36
33
  See http://clickatell.rubyforge.org for further instructions.
37
-
38
-
39
-
40
-
41
-
data/Rakefile CHANGED
@@ -48,14 +48,12 @@ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
48
48
 
49
49
  NAME = "clickatell"
50
50
  REV = nil
51
- # UNCOMMENT IF REQUIRED:
52
- # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
53
51
  VERS = Clickatell::VERSION::STRING + (REV ? ".#{REV}" : "")
54
52
  CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
55
53
  RDOC_OPTS = ['--quiet', '--title', 'clickatell documentation',
56
54
  "--opname", "index.html",
57
55
  "--line-numbers",
58
- "--main", "README",
56
+ "--main", "README.txt",
59
57
  "--inline-source"]
60
58
 
61
59
  class Hoe
@@ -129,7 +127,7 @@ task :check_version do
129
127
  end
130
128
 
131
129
  Rake::RDocTask.new('docs') do |rd|
132
- rd.main = 'README.txt'
130
+ rd.main = 'README.textile'
133
131
  rd.rdoc_files.include('README.txt', 'History.txt', 'License.txt', 'lib/**/*.rb')
134
132
  rd.rdoc_dir = 'doc'
135
133
  rd.options << '--style=http://clickatell.rubyforge.org/stylesheets/rdoc.css'
@@ -153,8 +151,8 @@ namespace :spec do
153
151
 
154
152
  desc "Run the specs in HTML format"
155
153
  Spec::Rake::SpecTask.new('html') do |t|
156
- t.spec_opts = ['--format', "html"]
157
154
  t.spec_files = FileList['spec/*_spec.rb']
155
+ t.spec_opts = ['--format', "html:website/specs.html"]
158
156
  end
159
157
  end
160
158
 
data/bin/sms CHANGED
File without changes
@@ -36,7 +36,7 @@ module Clickatell
36
36
  # a session_id if successful which can be used in subsequent
37
37
  # API calls.
38
38
  def authenticate(api_id, username, password)
39
- response = execute_command('auth',
39
+ response = execute_command('auth', 'http',
40
40
  :api_id => api_id,
41
41
  :user => username,
42
42
  :password => password
@@ -47,7 +47,7 @@ module Clickatell
47
47
  # Pings the service with the specified session_id to keep the
48
48
  # session alive.
49
49
  def ping(session_id)
50
- execute_command('ping', :session_id => session_id)
50
+ execute_command('ping', 'http', :session_id => session_id)
51
51
  end
52
52
 
53
53
  # Sends a message +message_text+ to +recipient+. Recipient
@@ -57,33 +57,44 @@ module Clickatell
57
57
  #
58
58
  # Additional options:
59
59
  # :from - the from number/name
60
+ # :set_mobile_originated - mobile originated flag
60
61
  #
61
62
  # Returns a new message ID if successful.
62
63
  def send_message(recipient, message_text, opts={})
63
- valid_options = opts.only(:from)
64
+ valid_options = opts.only(:from, :mo)
64
65
  valid_options.merge!(:req_feat => '48') if valid_options[:from]
65
- response = execute_command('sendmsg',
66
+ valid_options.merge!(:mo => '1') if opts[:set_mobile_originated]
67
+ response = execute_command('sendmsg', 'http',
66
68
  {:to => recipient, :text => message_text}.merge(valid_options)
67
69
  )
68
70
  parse_response(response)['ID']
69
71
  end
72
+
73
+ def send_wap_push(recipient, media_url, notification_text='', opts={})
74
+ valid_options = opts.only(:from)
75
+ valid_options.merge!(:req_feat => '48') if valid_options[:from]
76
+ response = execute_command('si_push', 'mms',
77
+ {:to => recipient, :si_url => media_url, :si_text => notification_text, :si_id => 'foo'}.merge(valid_options)
78
+ )
79
+ parse_response(response)['ID']
80
+ end
70
81
 
71
82
  # Returns the status of a message. Use message ID returned
72
83
  # from original send_message call.
73
84
  def message_status(message_id)
74
- response = execute_command('querymsg', :apimsgid => message_id)
85
+ response = execute_command('querymsg', 'http', :apimsgid => message_id)
75
86
  parse_response(response)['Status']
76
87
  end
77
88
 
78
89
  # Returns the number of credits remaining as a float.
79
90
  def account_balance
80
- response = execute_command('getbalance')
91
+ response = execute_command('getbalance', 'http')
81
92
  parse_response(response)['Credit'].to_f
82
93
  end
83
94
 
84
95
  protected
85
- def execute_command(command_name, parameters={}) #:nodoc:
86
- CommandExecutor.new(auth_hash, self.class.secure_mode, self.class.debug_mode).execute(command_name, parameters)
96
+ def execute_command(command_name, service, parameters={}) #:nodoc:
97
+ CommandExecutor.new(auth_hash, self.class.secure_mode, self.class.debug_mode).execute(command_name, service, parameters)
87
98
  end
88
99
 
89
100
  def parse_response(raw_response) #:nodoc:
@@ -6,8 +6,9 @@ module Clickatell
6
6
  class Command
7
7
  API_SERVICE_HOST = 'api.clickatell.com'
8
8
 
9
- def initialize(command_name, opts={})
9
+ def initialize(command_name, service = 'http', opts={})
10
10
  @command_name = command_name
11
+ @service = service
11
12
  @options = { :secure => false }.merge(opts)
12
13
  end
13
14
 
@@ -21,7 +22,7 @@ module Clickatell
21
22
  def api_service_uri
22
23
  protocol = @options[:secure] ? 'https' : 'http'
23
24
  port = @options[:secure] ? 443 : 80
24
- return "#{protocol}://#{API_SERVICE_HOST}:#{port}/http/"
25
+ return "#{protocol}://#{API_SERVICE_HOST}:#{port}/#{@service}/"
25
26
  end
26
27
  end
27
28
 
@@ -15,15 +15,15 @@ module Clickatell
15
15
  # Builds a command object and sends it using HTTP GET.
16
16
  # Will output URLs as they are requested to stdout when
17
17
  # debugging is enabled.
18
- def execute(command_name, parameters={})
19
- request_uri = command(command_name, parameters)
18
+ def execute(command_name, service, parameters={})
19
+ request_uri = command(command_name, service, parameters)
20
20
  puts "[debug] Sending request to #{request_uri}" if @debug
21
21
  get_response(request_uri).first
22
22
  end
23
23
 
24
24
  protected
25
- def command(command_name, parameters) #:nodoc:
26
- Command.new(command_name, :secure => @secure).with_params(
25
+ def command(command_name, service, parameters) #:nodoc:
26
+ Command.new(command_name, service, :secure => @secure).with_params(
27
27
  parameters.merge(@authentication_hash)
28
28
  )
29
29
  end
@@ -1,8 +1,8 @@
1
1
  module Clickatell #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 4
5
- TINY = 1
4
+ MINOR = 5
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
 
data/spec/api_spec.rb CHANGED
@@ -1,6 +1,12 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
  require File.dirname(__FILE__) + '/../lib/clickatell'
3
3
 
4
+ class FakeHttp
5
+ def start(&block)
6
+ yield self
7
+ end
8
+ end
9
+
4
10
  module Clickatell
5
11
 
6
12
  describe "API Command" do
@@ -21,7 +27,7 @@ module Clickatell
21
27
 
22
28
  describe "Secure API Command" do
23
29
  before do
24
- @command = API::Command.new('cmdname', :secure => true)
30
+ @command = API::Command.new('cmdname', 'http', :secure => true)
25
31
  end
26
32
 
27
33
  it "should use HTTPS" do
@@ -31,28 +37,30 @@ module Clickatell
31
37
  end
32
38
 
33
39
  describe "Command executor" do
34
- it "should create an API command with auth params and send it via HTTP get, returning the raw http response" do
40
+ it "should create an API command with the given params" do
41
+ executor = API::CommandExecutor.new(:session_id => '12345')
42
+ executor.stubs(:get_response).returns([])
43
+ API::Command.expects(:new).with('cmdname', 'http', :secure => false).returns(command = stub('Command'))
44
+ command.expects(:with_params).with(:param_one => 'foo', :session_id => '12345').returns(stub_everything('URI'))
45
+ executor.execute('cmdname', 'http', :param_one => 'foo')
46
+ end
47
+
48
+ it "should send the URI generated by the created command via HTTP get and return the response" do
35
49
  executor = API::CommandExecutor.new(:session_id => '12345')
36
- API::Command.should_receive(:new).with('cmdname', :secure => false).and_return(cmd=mock('command'))
37
- uri = stub('uri', :host => 'example.com', :port => 80, :scheme => 'http', :path => '/foo/bar', :query => 'a=b')
38
- cmd.should_receive(:with_params).with(:param_one => 'foo', :session_id => '12345').and_return(uri)
39
- Net::HTTP.should_receive(:new).with('example.com', 80).and_return(transport=mock('http'))
40
- transport.should_receive(:use_ssl=).with(false)
41
- transport.should_receive(:start).and_yield(yielded_transport=mock('http'))
42
- yielded_transport.should_receive(:get).with('/foo/bar?a=b').and_return(raw_response=mock('http response'))
43
- executor.execute('cmdname', :param_one => 'foo').should == raw_response
50
+ command_uri = URI.parse('http://clickatell.com:8080/path?foo=bar')
51
+ API::Command.stubs(:new).returns(command = stub('Command', :with_params => command_uri))
52
+ Net::HTTP.stubs(:new).with(command_uri.host, command_uri.port).returns(http = FakeHttp.new)
53
+ http.stubs(:use_ssl=)
54
+ http.stubs(:get).with('/path?foo=bar').returns([response = stub('HTTP Response'), 'response body'])
55
+ executor.execute('cmdname', 'http').should == response
44
56
  end
45
57
 
46
- it "should create a secure API command and send command using HTTPS if secure is true" do
47
- executor = API::CommandExecutor.new({:session_id => '12345'}, secure=true)
48
- API::Command.should_receive(:new).with('cmdname', :secure => true).and_return(cmd=mock('command'))
49
- uri = stub('uri', :host => 'example.com', :port => 443, :scheme => 'https', :path => '/foo/bar', :query => 'a=b')
50
- cmd.should_receive(:with_params).with(:param_one => 'foo', :session_id => '12345').and_return(uri)
51
- Net::HTTP.should_receive(:new).with('example.com', 443).and_return(transport=mock('http'))
52
- transport.should_receive(:use_ssl=).with(true)
53
- transport.should_receive(:start).and_yield(yielded_transport=mock('http'))
54
- yielded_transport.should_receive(:get).with('/foo/bar?a=b').and_return(raw_response=mock('http response'))
55
- executor.execute('cmdname', :param_one => 'foo').should == raw_response
58
+ it "should send the command over a secure HTTPS connection if :secure option is set to true" do
59
+ executor = API::CommandExecutor.new({:session_id => '12345'}, secure = true)
60
+ Net::HTTP.stubs(:new).returns(http = mock('HTTP'))
61
+ http.expects(:use_ssl=).with(true)
62
+ http.stubs(:start).returns([])
63
+ executor.execute('cmdname', 'http')
56
64
  end
57
65
  end
58
66
 
@@ -60,82 +68,77 @@ module Clickatell
60
68
  before do
61
69
  API.debug_mode = false
62
70
  API.secure_mode = false
63
- API::CommandExecutor.should_receive(:new).with({:session_id => '1234'}, false, false).and_return(@executor = mock('command executor'))
71
+ @executor = mock('command executor')
64
72
  @api = API.new(:session_id => '1234')
73
+ API::CommandExecutor.stubs(:new).with({:session_id => '1234'}, false, false).returns(@executor)
65
74
  end
66
75
 
67
- it "should return session_id for successful authentication" do
68
- @executor.should_receive(:execute).with('auth',
76
+ it "should use the api_id, username and password to authenticate and return the new session id" do
77
+ @executor.expects(:execute).with('auth', 'http',
69
78
  :api_id => '1234',
70
79
  :user => 'joebloggs',
71
80
  :password => 'superpass'
72
- ).and_return(response=mock('response'))
73
- Response.should_receive(:parse).with(response).and_return('OK' => 'new_session_id')
81
+ ).returns(response = stub('response'))
82
+ Response.stubs(:parse).with(response).returns('OK' => 'new_session_id')
74
83
  @api.authenticate('1234', 'joebloggs', 'superpass').should == 'new_session_id'
75
84
  end
76
85
 
77
- it "should support ping" do
78
- @executor.should_receive(:execute).with('ping', :session_id => 'abcdefg').and_return(response=mock('response'))
86
+ it "should support ping, using the current session_id" do
87
+ @executor.expects(:execute).with('ping', 'http', :session_id => 'abcdefg').returns(response = stub('response'))
79
88
  @api.ping('abcdefg').should == response
80
89
  end
81
90
 
82
- it "should support sending messages, returning the message id" do
83
- @executor.should_receive(:execute).with('sendmsg',
91
+ it "should support sending messages to a specified number, returning the message id" do
92
+ @executor.expects(:execute).with('sendmsg', 'http',
84
93
  :to => '4477791234567',
85
94
  :text => 'hello world'
86
- ).and_return(response=mock('response'))
87
- Response.should_receive(:parse).with(response).and_return('ID' => 'message_id')
95
+ ).returns(response = stub('response'))
96
+ Response.stubs(:parse).with(response).returns('ID' => 'message_id')
88
97
  @api.send_message('4477791234567', 'hello world').should == 'message_id'
89
98
  end
90
99
 
91
- it "should support sending messages with custom sender, passing the appropriate feature mask, returning the message id" do
92
- @executor.should_receive(:execute).with('sendmsg',
93
- :to => '4477791234567',
94
- :text => 'hello world',
95
- :from => 'LUKE',
96
- :req_feat => '48'
97
- ).and_return(response=mock('response'))
98
- Response.should_receive(:parse).with(response).and_return('ID' => 'message_id')
100
+ it "should set the :from parameter and set the :req_feat to 48 when using a custom from string when sending a message" do
101
+ @executor.expects(:execute).with('sendmsg', 'http', has_entries(:from => 'LUKE', :req_feat => '48')).returns(response = stub('response'))
102
+ Response.stubs(:parse).with(response).returns('ID' => 'message_id')
99
103
  @api.send_message('4477791234567', 'hello world', :from => 'LUKE')
100
104
  end
101
105
 
102
- it "should ignore any invalid parameters when sending message" do
103
- @executor.should_receive(:execute).with('sendmsg',
104
- :to => '4477791234567',
105
- :text => 'hello world',
106
- :from => 'LUKE',
107
- :req_feat => '48'
108
- ).and_return(response=mock('response'))
109
- Response.stub!(:parse).and_return('ID' => 'foo')
106
+ it "should set the :mo flag to 1 when :set_mobile_originated is true when sending a message" do
107
+ @executor.expects(:execute).with('sendmsg', 'http', has_entry(:mo => '1')).returns(response=mock('response'))
108
+ Response.stubs(:parse).with(response).returns('ID' => 'message_id')
109
+ @api.send_message('4477791234567', 'hello world', :set_mobile_originated => true)
110
+ end
111
+
112
+ it "should ignore any invalid parameters when sending a message" do
113
+ @executor.expects(:execute).with('sendmsg', 'http', Not(has_key(:any_old_param))).returns(response = stub('response'))
114
+ Response.stubs(:parse).returns('ID' => 'foo')
110
115
  @api.send_message('4477791234567', 'hello world', :from => 'LUKE', :any_old_param => 'test')
111
116
  end
112
117
 
113
- it "should support message status query, returning message status" do
114
- @executor.should_receive(:execute).with('querymsg',
115
- :apimsgid => 'messageid'
116
- ).and_return(response=mock('response'))
117
- Response.should_receive(:parse).with(response).and_return('ID' => 'message_id', 'Status' => 'message_status')
118
+ it "should support message status query for a given message id, returning the message status" do
119
+ @executor.expects(:execute).with('querymsg', 'http', :apimsgid => 'messageid').returns(response = stub('response'))
120
+ Response.expects(:parse).with(response).returns('ID' => 'message_id', 'Status' => 'message_status')
118
121
  @api.message_status('messageid').should == 'message_status'
119
122
  end
120
123
 
121
124
  it "should support balance query, returning number of credits as a float" do
122
- @executor.should_receive(:execute).with('getbalance', {}).and_return(response=mock('response'))
123
- Response.should_receive(:parse).with(response).and_return('Credit' => '10.0')
125
+ @executor.expects(:execute).with('getbalance', 'http', {}).returns(response=mock('response'))
126
+ Response.stubs(:parse).with(response).returns('Credit' => '10.0')
124
127
  @api.account_balance.should == 10.0
125
128
  end
126
129
 
127
130
  it "should raise an API::Error if the response parser raises" do
128
- @executor.stub!(:execute)
129
- Response.stub!(:parse).and_raise(Clickatell::API::Error.new('', ''))
131
+ @executor.stubs(:execute)
132
+ Response.stubs(:parse).raises(Clickatell::API::Error.new('', ''))
130
133
  proc { @api.account_balance }.should raise_error(Clickatell::API::Error)
131
134
  end
132
135
  end
133
136
 
134
137
  describe API, ' when authenticating' do
135
138
  it "should authenticate to retrieve a session_id and return a new API instance using that session id" do
136
- API.stub!(:new).and_return(api=mock('api'))
137
- api.should_receive(:authenticate).with('my_api_key', 'joebloggs', 'mypassword').and_return('new_session_id')
138
- api.should_receive(:auth_options=).with(:session_id => 'new_session_id')
139
+ API.stubs(:new).returns(api = mock('api'))
140
+ api.stubs(:authenticate).with('my_api_key', 'joebloggs', 'mypassword').returns('new_session_id')
141
+ api.expects(:auth_options=).with(:session_id => 'new_session_id')
139
142
  API.authenticate('my_api_key', 'joebloggs', 'mypassword')
140
143
  end
141
144
  end
@@ -145,8 +148,8 @@ module Clickatell
145
148
  API.debug_mode = false
146
149
  API.secure_mode = false
147
150
  api = API.new
148
- API::CommandExecutor.should_receive(:new).with({}, false, false).and_return(executor=mock('command executor'))
149
- executor.stub!(:execute)
151
+ API::CommandExecutor.stubs(:new).with({}, false, false).returns(executor = stub('command executor'))
152
+ executor.stubs(:execute)
150
153
  api.ping('1234')
151
154
  end
152
155
  end
@@ -156,8 +159,8 @@ module Clickatell
156
159
  API.debug_mode = false
157
160
  API.secure_mode = true
158
161
  api = API.new
159
- API::CommandExecutor.should_receive(:new).with({}, true, false).and_return(executor=mock('command executor'))
160
- executor.stub!(:execute)
162
+ API::CommandExecutor.expects(:new).with({}, true, false).returns(executor = stub('command executor'))
163
+ executor.stubs(:execute)
161
164
  api.ping('1234')
162
165
  end
163
166
  end
@@ -5,18 +5,15 @@ module Clickatell
5
5
 
6
6
  describe "Response parser" do
7
7
  before do
8
- @raw_response = stub('response')
9
- Clickatell::API::Error.stub!(:parse).and_return(Clickatell::API::Error.new('', ''))
8
+ Clickatell::API::Error.stubs(:parse).returns(Clickatell::API::Error.new('', ''))
10
9
  end
11
10
 
12
11
  it "should return hash for one-line success response" do
13
- @raw_response.stub!(:body).and_return('k1: foo k2: bar')
14
- Response.parse(@raw_response).should == {'k1' => 'foo', 'k2' => 'bar'}
12
+ Response.parse(stub('response', :body => 'k1: foo k2: bar')).should == {'k1' => 'foo', 'k2' => 'bar'}
15
13
  end
16
14
 
17
15
  it "should raise API::Error if response contains an error message" do
18
- @raw_response.stub!(:body).and_return('ERR: 001, Authentication failed')
19
- proc { Response.parse(@raw_response) }.should raise_error(Clickatell::API::Error)
16
+ proc { Response.parse(stub('response', :body => 'ERR: 001, Authentication failed')) }.should raise_error(Clickatell::API::Error)
20
17
  end
21
18
  end
22
19
 
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'spec'
3
+ require 'mocha'
4
+
5
+ Spec::Runner.configure do |config|
6
+ config.mock_with :mocha
7
+ end
data/website/index.html CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  <div id="header">
18
18
 
19
- <h1>Clickatell Ruby API <span class="version">0.4.1</span>
19
+ <h1>Clickatell Ruby API <span class="version">0.5.0</span>
20
20
  <span class="tagline">gem install clickatell</span></h1>
21
21
 
22
22
  </div>
@@ -37,7 +37,15 @@
37
37
 
38
38
  <pre><code>$ sudo gem install clickatell</code></pre>
39
39
 
40
- <p>Getting the latest version from Subversion:</p>
40
+ <h4>Clickatell on GitHub</h4>
41
+
42
+
43
+ <p>The source repository for clickatell has been <a href="http://github.com/lukeredpath/clickatell/">moved to GitHub</a>.</p>
44
+
45
+
46
+ <pre><code>git clone git://github.com/lukeredpath/clickatell.git</code></pre>
47
+
48
+ <p>You can still access the old subversion repository although this is unlikely to be updated:</p>
41
49
 
42
50
 
43
51
  <pre><code>$ svn co svn://lukeredpath.co.uk/var/svn/opensource/clickatell/trunk clickatell-trunk</code></pre>
@@ -113,7 +121,7 @@ $ sms -u your_username -p your_password -k your_api_key 447771234567 'Hello from
113
121
  <p>These values will take presedence over any values in your ~/.clickatell file.</p>
114
122
 
115
123
 
116
- <p>You can also specify the name or number that will appear in the &#8220;From&#8221; label on the recipients phone. You can either add a &#8220;from&#8221; key to your .clickatell file or manually using the&#8212;from option:</p>
124
+ <p>You can also specify a custom Sender ID &#8211; the name or number that will appear in the &#8220;From&#8221; label on the recipients phone. You can either add a &#8220;from&#8221; key to your .clickatell file or manually using the&#8212;from option:</p>
117
125
 
118
126
 
119
127
  <pre><code>
@@ -123,6 +131,12 @@ $ sms --from 'Luke Redpath' 447771234567 'Hello from clickatell'
123
131
  <p>The &#8220;from&#8221; option can either be a 16 digit number or an 11 character alpha-numeric string.</p>
124
132
 
125
133
 
134
+ <p><strong>Important note about custom sender IDs:</strong> Since November 2007, Clickatell have implemented a policy whereby all Sender IDs must be registered in your account centre before they can be used (the mobile number that you signed up with will have automatically been registered). If you try to specify a custom sender ID that has not been registered, the <span class="caps">SMS</span> will not be delivered.</p>
135
+
136
+
137
+ <p>In addition, if you do not specify a sender ID, a default Clickatell number will be used instead. If you are using the sms utility to send messages from your own number, make sure you have added the &#8216;from&#8217; field to your .clickatell file otherwise you will need to specify it every time you send a message.</p>
138
+
139
+
126
140
  <p>You can also use the <ins>sms</ins> utility to check your Clickatell account balance:</p>
127
141
 
128
142
 
@@ -161,7 +175,7 @@ $ sms --status 30b7d15bffb38695ba26e77c9c20f4ec
161
175
  <div id="footer">
162
176
  <p class="copyright">
163
177
  <a href="http://rubyforge.org/projects/clickatell">Rubyforge Project Page</a> |
164
- <a href="http://rubyforge.org/frs/?group_id=4295&amp;release_id=13922">Download latest version (0.4.1)</a> |
178
+ <a href="http://rubyforge.org/frs/?group_id=4295&amp;release_id=13922">Download latest version (0.5.0)</a> |
165
179
  <a href="rdoc/">RDoc</a>
166
180
  </p>
167
181
  </div>
data/website/index.txt CHANGED
@@ -12,7 +12,13 @@ h3. Installing
12
12
 
13
13
  <pre><code>$ sudo gem install clickatell</code></pre>
14
14
 
15
- Getting the latest version from Subversion:
15
+ h4. Clickatell on GitHub
16
+
17
+ The source repository for clickatell has been <a href="http://github.com/lukeredpath/clickatell/">moved to GitHub</a>.
18
+
19
+ <pre><code>git clone git://github.com/lukeredpath/clickatell.git</code></pre>
20
+
21
+ You can still access the old subversion repository although this is unlikely to be updated:
16
22
 
17
23
  <pre><code>$ svn co svn://lukeredpath.co.uk/var/svn/opensource/clickatell/trunk clickatell-trunk</code></pre>
18
24
 
@@ -74,7 +80,7 @@ $ sms -u your_username -p your_password -k your_api_key 447771234567 'Hello from
74
80
 
75
81
  These values will take presedence over any values in your ~/.clickatell file.
76
82
 
77
- You can also specify the name or number that will appear in the "From" label on the recipients phone. You can either add a "from" key to your .clickatell file or manually using the --from option:
83
+ You can also specify a custom Sender ID - the name or number that will appear in the "From" label on the recipients phone. You can either add a "from" key to your .clickatell file or manually using the --from option:
78
84
 
79
85
  <pre><code>
80
86
  $ sms --from 'Luke Redpath' 447771234567 'Hello from clickatell'
@@ -82,6 +88,10 @@ $ sms --from 'Luke Redpath' 447771234567 'Hello from clickatell'
82
88
 
83
89
  The "from" option can either be a 16 digit number or an 11 character alpha-numeric string.
84
90
 
91
+ <strong>Important note about custom sender IDs:</strong> Since November 2007, Clickatell have implemented a policy whereby all Sender IDs must be registered in your account centre before they can be used (the mobile number that you signed up with will have automatically been registered). If you try to specify a custom sender ID that has not been registered, the SMS will not be delivered.
92
+
93
+ In addition, if you do not specify a sender ID, a default Clickatell number will be used instead. If you are using the sms utility to send messages from your own number, make sure you have added the 'from' field to your .clickatell file otherwise you will need to specify it every time you send a message.
94
+
85
95
  You can also use the +sms+ utility to check your Clickatell account balance:
86
96
 
87
97
  <pre><code>
File without changes
data/website/specs.html CHANGED
@@ -1,12 +1,11 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
6
5
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
6
  <head>
8
7
  <title>RSpec results</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
8
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10
9
  <meta http-equiv="Expires" content="-1" />
11
10
  <meta http-equiv="Pragma" content="no-cache" />
12
11
  <style type="text/css">
@@ -74,7 +73,7 @@ function makeYellow(element_id) {
74
73
  font-size: 1.2em;
75
74
  }
76
75
 
77
- .behaviour {
76
+ .example_group {
78
77
  margin: 0 10px 5px;
79
78
  background: #fff;
80
79
  }
@@ -177,100 +176,104 @@ a {
177
176
  </div>
178
177
 
179
178
  <div class="results">
180
- <div class="behaviour">
179
+ <div class="example_group">
181
180
  <dl>
182
- <dt id="behaviour_1">API Command</dt>
183
- <script type="text/javascript">moveProgressBar('4.7');</script>
181
+ <dt id="example_group_1">API Command</dt>
182
+ <script type="text/javascript">moveProgressBar('4.3');</script>
184
183
  <dd class="spec passed"><span class="passed_spec_name">should return encoded URL for the specified command and parameters</span></dd>
185
- <script type="text/javascript">moveProgressBar('9.5');</script>
184
+ <script type="text/javascript">moveProgressBar('8.6');</script>
186
185
  <dd class="spec passed"><span class="passed_spec_name">should URL encode any special characters in parameters</span></dd>
187
186
  </dl>
188
187
  </div>
189
- <div class="behaviour">
188
+ <div class="example_group">
190
189
  <dl>
191
- <dt id="behaviour_2">Secure API Command</dt>
192
- <script type="text/javascript">moveProgressBar('14.2');</script>
190
+ <dt id="example_group_2">Secure API Command</dt>
191
+ <script type="text/javascript">moveProgressBar('13.0');</script>
193
192
  <dd class="spec passed"><span class="passed_spec_name">should use HTTPS</span></dd>
194
193
  </dl>
195
194
  </div>
196
- <div class="behaviour">
195
+ <div class="example_group">
197
196
  <dl>
198
- <dt id="behaviour_3">Command executor</dt>
199
- <script type="text/javascript">moveProgressBar('19.0');</script>
200
- <dd class="spec passed"><span class="passed_spec_name">should create an API command with auth params and send it via HTTP get, returning the raw http response</span></dd>
201
- <script type="text/javascript">moveProgressBar('23.8');</script>
202
- <dd class="spec passed"><span class="passed_spec_name">should create a secure API command and send command using HTTPS if secure is true</span></dd>
197
+ <dt id="example_group_3">Command executor</dt>
198
+ <script type="text/javascript">moveProgressBar('17.3');</script>
199
+ <dd class="spec passed"><span class="passed_spec_name">should create an API command with the given params</span></dd>
200
+ <script type="text/javascript">moveProgressBar('21.7');</script>
201
+ <dd class="spec passed"><span class="passed_spec_name">should send the URI generated by the created command via HTTP get and return the response</span></dd>
202
+ <script type="text/javascript">moveProgressBar('26.0');</script>
203
+ <dd class="spec passed"><span class="passed_spec_name">should send the command over a secure HTTPS connection if :secure option is set to true</span></dd>
203
204
  </dl>
204
205
  </div>
205
- <div class="behaviour">
206
+ <div class="example_group">
206
207
  <dl>
207
- <dt id="behaviour_4">API</dt>
208
- <script type="text/javascript">moveProgressBar('28.5');</script>
209
- <dd class="spec passed"><span class="passed_spec_name">should return session_id for successful authentication</span></dd>
210
- <script type="text/javascript">moveProgressBar('33.3');</script>
211
- <dd class="spec passed"><span class="passed_spec_name">should support ping</span></dd>
212
- <script type="text/javascript">moveProgressBar('38.0');</script>
213
- <dd class="spec passed"><span class="passed_spec_name">should support sending messages, returning the message id</span></dd>
214
- <script type="text/javascript">moveProgressBar('42.8');</script>
215
- <dd class="spec passed"><span class="passed_spec_name">should support sending messages with custom sender, passing the appropriate feature mask, returning the message id</span></dd>
216
- <script type="text/javascript">moveProgressBar('47.6');</script>
217
- <dd class="spec passed"><span class="passed_spec_name">should ignore any invalid parameters when sending message</span></dd>
218
- <script type="text/javascript">moveProgressBar('52.3');</script>
219
- <dd class="spec passed"><span class="passed_spec_name">should support message status query, returning message status</span></dd>
220
- <script type="text/javascript">moveProgressBar('57.1');</script>
208
+ <dt id="example_group_4">API</dt>
209
+ <script type="text/javascript">moveProgressBar('30.4');</script>
210
+ <dd class="spec passed"><span class="passed_spec_name">should use the api_id, username and password to authenticate and return the new session id</span></dd>
211
+ <script type="text/javascript">moveProgressBar('34.7');</script>
212
+ <dd class="spec passed"><span class="passed_spec_name">should support ping, using the current session_id</span></dd>
213
+ <script type="text/javascript">moveProgressBar('39.1');</script>
214
+ <dd class="spec passed"><span class="passed_spec_name">should support sending messages to a specified number, returning the message id</span></dd>
215
+ <script type="text/javascript">moveProgressBar('43.4');</script>
216
+ <dd class="spec passed"><span class="passed_spec_name">should set the :from parameter and set the :req_feat to 48 when using a custom from string when sending a message</span></dd>
217
+ <script type="text/javascript">moveProgressBar('47.8');</script>
218
+ <dd class="spec passed"><span class="passed_spec_name">should set the :mo flag to 1 when :set_mobile_originated is true when sending a message</span></dd>
219
+ <script type="text/javascript">moveProgressBar('52.1');</script>
220
+ <dd class="spec passed"><span class="passed_spec_name">should ignore any invalid parameters when sending a message</span></dd>
221
+ <script type="text/javascript">moveProgressBar('56.5');</script>
222
+ <dd class="spec passed"><span class="passed_spec_name">should support message status query for a given message id, returning the message status</span></dd>
223
+ <script type="text/javascript">moveProgressBar('60.8');</script>
221
224
  <dd class="spec passed"><span class="passed_spec_name">should support balance query, returning number of credits as a float</span></dd>
222
- <script type="text/javascript">moveProgressBar('61.9');</script>
225
+ <script type="text/javascript">moveProgressBar('65.2');</script>
223
226
  <dd class="spec passed"><span class="passed_spec_name">should raise an API::Error if the response parser raises</span></dd>
224
227
  </dl>
225
228
  </div>
226
- <div class="behaviour">
229
+ <div class="example_group">
227
230
  <dl>
228
- <dt id="behaviour_5">Clickatell::API when authenticating</dt>
229
- <script type="text/javascript">moveProgressBar('66.6');</script>
231
+ <dt id="example_group_5">Clickatell::API when authenticating</dt>
232
+ <script type="text/javascript">moveProgressBar('69.5');</script>
230
233
  <dd class="spec passed"><span class="passed_spec_name">should authenticate to retrieve a session_id and return a new API instance using that session id</span></dd>
231
234
  </dl>
232
235
  </div>
233
- <div class="behaviour">
236
+ <div class="example_group">
234
237
  <dl>
235
- <dt id="behaviour_6">Clickatell::API with no authentication options set</dt>
236
- <script type="text/javascript">moveProgressBar('71.4');</script>
238
+ <dt id="example_group_6">Clickatell::API with no authentication options set</dt>
239
+ <script type="text/javascript">moveProgressBar('73.9');</script>
237
240
  <dd class="spec passed"><span class="passed_spec_name">should build commands with no authentication options</span></dd>
238
241
  </dl>
239
242
  </div>
240
- <div class="behaviour">
243
+ <div class="example_group">
241
244
  <dl>
242
- <dt id="behaviour_7">Clickatell::API in secure mode</dt>
243
- <script type="text/javascript">moveProgressBar('76.1');</script>
245
+ <dt id="example_group_7">Clickatell::API in secure mode</dt>
246
+ <script type="text/javascript">moveProgressBar('78.2');</script>
244
247
  <dd class="spec passed"><span class="passed_spec_name">should execute commands securely</span></dd>
245
248
  </dl>
246
249
  </div>
247
- <div class="behaviour">
250
+ <div class="example_group">
248
251
  <dl>
249
- <dt id="behaviour_8">API Error</dt>
250
- <script type="text/javascript">moveProgressBar('80.9');</script>
252
+ <dt id="example_group_8">API Error</dt>
253
+ <script type="text/javascript">moveProgressBar('82.6');</script>
251
254
  <dd class="spec passed"><span class="passed_spec_name">should parse http response string to create error</span></dd>
252
255
  </dl>
253
256
  </div>
254
- <div class="behaviour">
257
+ <div class="example_group">
255
258
  <dl>
256
- <dt id="behaviour_9">Hash</dt>
257
- <script type="text/javascript">moveProgressBar('85.7');</script>
259
+ <dt id="example_group_9">Hash</dt>
260
+ <script type="text/javascript">moveProgressBar('86.9');</script>
258
261
  <dd class="spec passed"><span class="passed_spec_name">should return only the keys specified</span></dd>
259
- <script type="text/javascript">moveProgressBar('90.4');</script>
262
+ <script type="text/javascript">moveProgressBar('91.3');</script>
260
263
  <dd class="spec passed"><span class="passed_spec_name">should return only the keys specified, ignoring keys that do not exist</span></dd>
261
264
  </dl>
262
265
  </div>
263
- <div class="behaviour">
266
+ <div class="example_group">
264
267
  <dl>
265
- <dt id="behaviour_10">Response parser</dt>
266
- <script type="text/javascript">moveProgressBar('95.2');</script>
268
+ <dt id="example_group_10">Response parser</dt>
269
+ <script type="text/javascript">moveProgressBar('95.6');</script>
267
270
  <dd class="spec passed"><span class="passed_spec_name">should return hash for one-line success response</span></dd>
268
271
  <script type="text/javascript">moveProgressBar('100.0');</script>
269
272
  <dd class="spec passed"><span class="passed_spec_name">should raise API::Error if response contains an error message</span></dd>
270
273
  </dl>
271
274
  </div>
272
- <script type="text/javascript">document.getElementById('duration').innerHTML = "Finished in <strong>0.02819 seconds</strong>";</script>
273
- <script type="text/javascript">document.getElementById('totals').innerHTML = "21 examples, 0 failures";</script>
275
+ <script type="text/javascript">document.getElementById('duration').innerHTML = "Finished in <strong>0.105423 seconds</strong>";</script>
276
+ <script type="text/javascript">document.getElementById('totals').innerHTML = "23 examples, 0 failures";</script>
274
277
  </div>
275
278
  </div>
276
279
  </body>
metadata CHANGED
@@ -1,38 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.2
3
- specification_version: 1
4
2
  name: clickatell
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.4.1
7
- date: 2007-11-26 00:00:00 +00:00
8
- summary: Ruby interface to the Clickatell SMS gateway service.
9
- require_paths:
10
- - lib
11
- email: contact[AT]lukeredpath.co.uk
12
- homepage: http://clickatell.rubyforge.org
13
- rubyforge_project: clickatell
14
- description: Ruby interface to the Clickatell SMS gateway service.
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 0.5.0
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Luke Redpath
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-08-19 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.7.0
24
+ version:
25
+ description: Ruby interface to the Clickatell SMS gateway service.
26
+ email: contact[AT]lukeredpath.co.uk
27
+ executables:
28
+ - sms
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - History.txt
33
+ - License.txt
34
+ - Manifest.txt
35
+ - README.txt
36
+ - website/index.txt
31
37
  files:
32
38
  - History.txt
33
39
  - License.txt
34
40
  - Manifest.txt
35
41
  - README.txt
42
+ - README.textile
36
43
  - Rakefile
37
44
  - bin/sms
38
45
  - lib/clickatell.rb
@@ -64,22 +71,32 @@ files:
64
71
  - website/stylesheets/rdoc.css
65
72
  - website/stylesheets/screen.css
66
73
  - website/template.rhtml
67
- test_files: []
68
-
74
+ has_rdoc: true
75
+ homepage: http://clickatell.rubyforge.org
76
+ post_install_message:
69
77
  rdoc_options:
70
78
  - --main
71
79
  - README.txt
72
- extra_rdoc_files:
73
- - History.txt
74
- - License.txt
75
- - Manifest.txt
76
- - README.txt
77
- - website/index.txt
78
- executables:
79
- - sms
80
- extensions: []
81
-
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: "0"
87
+ version:
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: "0"
93
+ version:
82
94
  requirements: []
83
95
 
84
- dependencies: []
96
+ rubyforge_project: clickatell
97
+ rubygems_version: 1.2.0
98
+ signing_key:
99
+ specification_version: 2
100
+ summary: Ruby interface to the Clickatell SMS gateway service.
101
+ test_files: []
85
102