smsified 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -31,7 +31,7 @@ Find a subscription:
31
31
  Documentation
32
32
  -------------
33
33
 
34
- May be found at http://tropo.github.com/smsified & http://smsified.com.
34
+ May be found at http://smsified.github.com/smsified-ruby & http://smsified.com.
35
35
 
36
36
  License
37
37
  -------
@@ -23,6 +23,7 @@ module Smsified
23
23
  # @example
24
24
  # one_api = OneAPI.new :username => 'user', :password => '123'
25
25
  def initialize(options)
26
+ raise ArgumentError, 'an options Hash is required' if !options.instance_of?(Hash)
26
27
  raise ArgumentError, ':username required' if options[:username].nil?
27
28
  raise ArgumentError, ':password required' if options[:password].nil?
28
29
 
@@ -53,6 +54,7 @@ module Smsified
53
54
  # one_api.send_sms :address => '14155551212', :message => 'Hi there!', :sender_address => '13035551212'
54
55
  # one_api.send_sms :address => ['14155551212', '13035551212'], :message => 'Hi there!', :sender_address => '13035551212'
55
56
  def send_sms(options)
57
+ raise ArgumentError, 'an options Hash is required' if !options.instance_of?(Hash)
56
58
  raise ArgumentError, ':sender_address is required' if options[:sender_address].nil? && @sender_address.nil?
57
59
  raise ArgumentError, ':address is required' if options[:address].nil?
58
60
  raise ArgumentError, ':message is required' if options[:message].nil?
@@ -92,10 +94,18 @@ module Smsified
92
94
  # Builds the necessary query string
93
95
  def build_query_string(options)
94
96
  query = ''
95
-
97
+
96
98
  options.each do |k,v|
97
99
  if k == :address
98
- v.each { |address| query += "#{ '&' if query != '' }address=#{CGI.escape address}" }
100
+ if RUBY_VERSION.to_f == 1.9
101
+ if v.instance_of?(String)
102
+ v.each_line { |address| query += "#{ '&' if query != '' }address=#{CGI.escape address}" }
103
+ else
104
+ v.each { |address| query += "#{ '&' if query != '' }address=#{CGI.escape address}" }
105
+ end
106
+ else
107
+ v.each { |address| query += "#{ '&' if query != '' }address=#{CGI.escape address}" }
108
+ end
99
109
  else
100
110
  query += "#{ '&' if query != '' }#{k.to_s}=#{CGI.escape v}"
101
111
  end
@@ -104,4 +114,4 @@ module Smsified
104
114
  query
105
115
  end
106
116
  end
107
- end
117
+ end
@@ -16,6 +16,7 @@ module Smsified
16
16
  # @example
17
17
  # subscription = Subscription.new :username => 'user', :password => '123'
18
18
  def initialize(options)
19
+ raise ArgumentError, 'an options Hash is required' if !options.instance_of?(Hash)
19
20
  raise ArgumentError, ':username required' if options[:username].nil?
20
21
  raise ArgumentError, ':password required' if options[:password].nil?
21
22
 
@@ -38,6 +39,7 @@ module Smsified
38
39
  # @example
39
40
  # one_api.delivery_status :request_id => 'f359193765f6a3149ca76a4508e21234', :sender_address => '14155551212'
40
41
  def delivery_status(options)
42
+ raise ArgumentError, 'an options Hash is required' if !options.instance_of?(Hash)
41
43
  raise ArgumentError, ':sender_address is required' if options[:sender_address].nil? && @sender_address.nil?
42
44
 
43
45
  options[:sender_address] = options[:sender_address] || @sender_address
@@ -18,6 +18,7 @@ module Smsified
18
18
  # @example
19
19
  # subscription = Subscription.new :username => 'user', :password => '123'
20
20
  def initialize(options)
21
+ raise ArgumentError, 'an options Hash is required' if !options.instance_of?(Hash)
21
22
  raise ArgumentError, ':username required' if options[:username].nil?
22
23
  raise ArgumentError, ':password required' if options[:password].nil?
23
24
 
@@ -26,10 +26,16 @@ describe "Smsified" do
26
26
  it "Should get errors if instantiating without all of the right parameters" do
27
27
  begin
28
28
  Smsified::OneAPI.new 'foobar'
29
+ rescue => e
30
+ e.to_s.should eql 'an options Hash is required'
31
+ end
32
+
33
+ begin
34
+ Smsified::OneAPI.new(:password => nil)
29
35
  rescue => e
30
36
  e.to_s.should eql ':username required'
31
37
  end
32
-
38
+
33
39
  begin
34
40
  Smsified::OneAPI.new(:username => @username)
35
41
  rescue => e
@@ -40,6 +46,12 @@ describe "Smsified" do
40
46
  it "Should raise an error if no :sender_address specified" do
41
47
  begin
42
48
  @one_api.send_sms('foobar')
49
+ rescue => e
50
+ e.to_s.should eql 'an options Hash is required'
51
+ end
52
+
53
+ begin
54
+ @one_api.send_sms({})
43
55
  rescue => e
44
56
  e.to_s.should eql ':sender_address is required'
45
57
  end
@@ -104,6 +116,12 @@ describe "Smsified" do
104
116
  it "Should get errors if instantiating without all of the right parameters" do
105
117
  begin
106
118
  Smsified::Subscriptions.new 'foobar'
119
+ rescue => e
120
+ e.to_s.should eql 'an options Hash is required'
121
+ end
122
+
123
+ begin
124
+ Smsified::Subscriptions.new({})
107
125
  rescue => e
108
126
  e.to_s.should eql ':username required'
109
127
  end
@@ -364,6 +382,12 @@ describe "Smsified" do
364
382
  it "Should get errors if instantiating without all of the right parameters" do
365
383
  begin
366
384
  Smsified::Reporting.new 'foobar'
385
+ rescue => e
386
+ e.to_s.should eql 'an options Hash is required'
387
+ end
388
+
389
+ begin
390
+ Smsified::Reporting.new({})
367
391
  rescue => e
368
392
  e.to_s.should eql ':username required'
369
393
  end
@@ -378,6 +402,12 @@ describe "Smsified" do
378
402
  it "Should raise an error if no :sender_address specified" do
379
403
  begin
380
404
  @reporting.delivery_status('foobar')
405
+ rescue => e
406
+ e.to_s.should eql 'an options Hash is required'
407
+ end
408
+
409
+ begin
410
+ @reporting.delivery_status({})
381
411
  rescue => e
382
412
  e.to_s.should eql ':sender_address is required'
383
413
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smsified
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason Goecke
@@ -15,10 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-20 00:00:00 -04:00
18
+ date: 2011-06-24 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
+ prerelease: false
22
23
  type: :development
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
24
25
  none: false
@@ -31,10 +32,10 @@ dependencies:
31
32
  - 3
32
33
  - 0
33
34
  version: 2.3.0
34
- name: rspec
35
35
  version_requirements: *id001
36
- prerelease: false
36
+ name: rspec
37
37
  - !ruby/object:Gem::Dependency
38
+ prerelease: false
38
39
  type: :development
39
40
  requirement: &id002 !ruby/object:Gem::Requirement
40
41
  none: false
@@ -47,10 +48,10 @@ dependencies:
47
48
  - 6
48
49
  - 0
49
50
  version: 0.6.0
50
- name: yard
51
51
  version_requirements: *id002
52
- prerelease: false
52
+ name: yard
53
53
  - !ruby/object:Gem::Dependency
54
+ prerelease: false
54
55
  type: :development
55
56
  requirement: &id003 !ruby/object:Gem::Requirement
56
57
  none: false
@@ -63,10 +64,10 @@ dependencies:
63
64
  - 0
64
65
  - 0
65
66
  version: 1.0.0
66
- name: bundler
67
67
  version_requirements: *id003
68
- prerelease: false
68
+ name: bundler
69
69
  - !ruby/object:Gem::Dependency
70
+ prerelease: false
70
71
  type: :development
71
72
  requirement: &id004 !ruby/object:Gem::Requirement
72
73
  none: false
@@ -79,10 +80,10 @@ dependencies:
79
80
  - 5
80
81
  - 2
81
82
  version: 1.5.2
82
- name: jeweler
83
83
  version_requirements: *id004
84
- prerelease: false
84
+ name: jeweler
85
85
  - !ruby/object:Gem::Dependency
86
+ prerelease: false
86
87
  type: :development
87
88
  requirement: &id005 !ruby/object:Gem::Requirement
88
89
  none: false
@@ -93,10 +94,10 @@ dependencies:
93
94
  segments:
94
95
  - 0
95
96
  version: "0"
96
- name: rcov
97
97
  version_requirements: *id005
98
- prerelease: false
98
+ name: rcov
99
99
  - !ruby/object:Gem::Dependency
100
+ prerelease: false
100
101
  type: :development
101
102
  requirement: &id006 !ruby/object:Gem::Requirement
102
103
  none: false
@@ -107,10 +108,10 @@ dependencies:
107
108
  segments:
108
109
  - 0
109
110
  version: "0"
110
- name: fakeweb
111
111
  version_requirements: *id006
112
- prerelease: false
112
+ name: fakeweb
113
113
  - !ruby/object:Gem::Dependency
114
+ prerelease: false
114
115
  type: :development
115
116
  requirement: &id007 !ruby/object:Gem::Requirement
116
117
  none: false
@@ -121,10 +122,10 @@ dependencies:
121
122
  segments:
122
123
  - 0
123
124
  version: "0"
124
- name: awesome_print
125
125
  version_requirements: *id007
126
- prerelease: false
126
+ name: awesome_print
127
127
  - !ruby/object:Gem::Dependency
128
+ prerelease: false
128
129
  type: :development
129
130
  requirement: &id008 !ruby/object:Gem::Requirement
130
131
  none: false
@@ -135,10 +136,10 @@ dependencies:
135
136
  segments:
136
137
  - 0
137
138
  version: "0"
138
- name: json
139
139
  version_requirements: *id008
140
- prerelease: false
140
+ name: json
141
141
  - !ruby/object:Gem::Dependency
142
+ prerelease: false
142
143
  type: :runtime
143
144
  requirement: &id009 !ruby/object:Gem::Requirement
144
145
  none: false
@@ -149,9 +150,8 @@ dependencies:
149
150
  segments:
150
151
  - 0
151
152
  version: "0"
152
- name: httparty
153
153
  version_requirements: *id009
154
- prerelease: false
154
+ name: httparty
155
155
  description: Gem for consuming the SMSified OneAPI
156
156
  email: jsgoecke@voxeo.com
157
157
  executables: []
@@ -203,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
203
  requirements: []
204
204
 
205
205
  rubyforge_project:
206
- rubygems_version: 1.5.2
206
+ rubygems_version: 1.5.0
207
207
  signing_key:
208
208
  specification_version: 3
209
209
  summary: Gem for consuming the SMSified OneAPI