mobilove 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
1
  require 'rest_client'
2
+ require 'iconv'
2
3
 
3
4
  require 'mobilove/text'
4
5
  require 'mobilove/exceptions'
@@ -4,11 +4,11 @@ module Mobilove
4
4
 
5
5
  class Text
6
6
  def initialize(key, route, from)
7
- @key, @route, @from = key, route, from
7
+ @key, @route, @from = key, route, CGI.escape(Iconv.conv('ISO-8859-1', 'utf-8', from))
8
8
  end
9
9
 
10
10
  def send(to, message, debug_mode = false)
11
- url = send_url(to, message, debug_mode)
11
+ url = send_url(to, CGI.escape(Iconv.conv('ISO-8859-1', 'utf-8', message)), debug_mode)
12
12
  response = RestClient.get(url)
13
13
  respond(response)
14
14
  end
@@ -16,13 +16,15 @@ module Mobilove
16
16
  private
17
17
 
18
18
  def send_url(to, message, debug_mode)
19
- "http://gw.mobilant.net/?key=#{@key}&to=#{to}&message=#{URI.escape(message)}&route=#{@route}&from=#{URI.escape(@from)}&debug=#{debug_mode ? '1' : '0'}"
19
+ "http://gw.mobilant.net/?key=#{@key}&to=#{to}&message=#{message}&route=#{@route}&from=#{@from}&debug=#{debug_mode ? '1' : '0'}"
20
20
  end
21
21
 
22
22
  def respond(response)
23
23
  case response.code.to_i
24
24
  when 100
25
25
  true
26
+ when 200
27
+ true
26
28
  when 10
27
29
  raise InvalidNumber.new(response.body)
28
30
  when 20
@@ -1,3 +1,3 @@
1
1
  module Mobilove
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobilove
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Red Davis
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-04-19 00:00:00 +02:00
19
+ date: 2011-04-21 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies: []
22
22