moonshado-sms 1.0.1 → 1.1.0.rc1

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.
@@ -1,5 +1,5 @@
1
1
  ---
2
- :patch: 1
3
- :build:
2
+ :patch: 0
3
+ :build: rc1
4
4
  :major: 1
5
- :minor: 0
5
+ :minor: 1
@@ -1,10 +1,11 @@
1
1
  module Moonshado
2
2
  class Configuration
3
3
 
4
- OPTIONS = [:api_key, :development_environments, :keywords,
5
- :sms_uri, :keyword_uri, :auto_register_keyword,
6
- :environment_name, :host, :http_open_timeout,
7
- :http_read_timeout, :port, :protocol, :secure].freeze
4
+ OPTIONS = [:api_key, :keywords, :sms_uri,
5
+ :keyword_uri, :auto_register_keyword,
6
+ :host, :http_open_timeout, :http_read_timeout,
7
+ :port, :protocol, :secure,
8
+ :production_environment].freeze
8
9
 
9
10
  attr_accessor :api_key
10
11
  attr_accessor :keywords
@@ -17,8 +18,11 @@ module Moonshado
17
18
  attr_accessor :auto_register_keywords
18
19
  attr_accessor :production_environment
19
20
  attr_accessor :port
21
+ attr_accessor :message_length_range
22
+ attr_accessor :message_length_check
20
23
 
21
24
  alias_method :secure?, :secure
25
+ alias_method :message_length_check?, :message_length_check
22
26
 
23
27
  def initialize
24
28
  @secure = false
@@ -30,6 +34,8 @@ module Moonshado
30
34
  @keywords_uri = '/keywords'
31
35
  @auto_register_keywords = false
32
36
  @port = default_port
37
+ @message_length_range = 3..115
38
+ @message_length_check = true
33
39
  end
34
40
 
35
41
  def api_key
@@ -31,19 +31,10 @@ module Moonshado
31
31
  @message = message
32
32
  end
33
33
 
34
- # def self.find(id)
35
- # if config[:test_env] == true
36
- # {:sms => {:id => id, :reports => '[{"update_date":"2010-01-03T22:56:45-08:00","status_info":"test"}]'}, :stat => "ok"}
37
- # else
38
- # response = RestClient.get("#{url}/#{id}")
39
- # JSON.parse(response.body)
40
- # end
41
- # end
42
-
43
34
  def deliver_sms
44
35
  raise MoonshadoSMSException.new("Invalid message") unless is_message_valid?(@message)
45
36
 
46
- data = {:sms => {:device_address => format_number(@number), :message => @message}}
37
+ data = {:sms => {:device_address => format_number(@number), :message => @message.to_s}}
47
38
 
48
39
  if production_environment?
49
40
  begin
@@ -70,7 +61,11 @@ module Moonshado
70
61
  end
71
62
 
72
63
  def is_message_valid?(message)
73
- message.size <= 115 && !message.nil? && message.is_a?(String) && !message.empty?
64
+ if message_length_check?
65
+ message_length_range.include?(message.to_s.size)
66
+ else
67
+ true
68
+ end
74
69
  end
75
70
 
76
71
  class MoonshadoSMSException < StandardError; end
@@ -95,5 +90,13 @@ module Moonshado
95
90
  {"stat"=>"fail", "error"=>"json parser error", "response"=>json.to_s}
96
91
  end
97
92
  end
93
+
94
+ def message_length_range
95
+ configuration.message_length_range
96
+ end
97
+
98
+ def message_length_check?
99
+ configuration.message_length_check?
100
+ end
98
101
  end
99
102
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{moonshado-sms}
8
- s.version = "1.0.1"
8
+ s.version = "1.1.0.rc1"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kevin Patel"]
12
- s.date = %q{2010-08-29}
12
+ s.date = %q{2010-08-30}
13
13
  s.email = %q{tech@moonshado.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -3,6 +3,7 @@ require 'helper'
3
3
  class Moonshado::SmsTest < Test::Unit::TestCase
4
4
  context Moonshado::Sms do
5
5
  setup do
6
+ Moonshado::Sms.configuration = nil
6
7
  Moonshado::Sms.configure do |config|
7
8
  config.api_key = '20lsdjf2'
8
9
  config.production_environment = false
@@ -59,10 +60,10 @@ class Moonshado::SmsTest < Test::Unit::TestCase
59
60
 
60
61
  context Moonshado::Sms do
61
62
  setup do
63
+ Moonshado::Sms.configuration = nil
62
64
  Moonshado::Sms.configure do |config|
63
65
  config.api_key = '20lsdjf2'
64
66
  config.host = 'notreal.moonshado.com'
65
- config.production_environment = true
66
67
  end
67
68
  end
68
69
 
@@ -70,4 +71,22 @@ class Moonshado::SmsTest < Test::Unit::TestCase
70
71
  assert_equal(Moonshado::Sms.new("1(555)555-6471", "test").deliver_sms["stat"], "fail")
71
72
  end
72
73
  end
74
+
75
+ context Moonshado::Sms do
76
+ setup do
77
+ Moonshado::Sms.configuration = nil
78
+ Moonshado::Sms.configure do |config|
79
+ config.api_key = '20lsdjf2'
80
+ config.production_environment = false
81
+ config.message_length_check = false
82
+ end
83
+ end
84
+
85
+ should "not enforce message length" do
86
+ assert_nothing_raised do
87
+ message = "Well, if you like burgers give 'em a try sometime. I can't usually get 'em myself because my girlfriend's a vegitarian which pretty much makes me a vegitarian. But I do love the taste of a good burger. Mm-mm-mm. You know what they call a Quarter Pounder with cheese in France?"
88
+ Moonshado::Sms.new("1(555)555-6471", message).deliver_sms
89
+ end
90
+ end
91
+ end
73
92
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moonshado-sms
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease: false
4
+ hash: 977940566
5
+ prerelease: true
6
6
  segments:
7
7
  - 1
8
- - 0
9
8
  - 1
10
- version: 1.0.1
9
+ - 0
10
+ - rc1
11
+ version: 1.1.0.rc1
11
12
  platform: ruby
12
13
  authors:
13
14
  - Kevin Patel
@@ -15,7 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-08-29 00:00:00 -04:00
19
+ date: 2010-08-30 00:00:00 -04:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
@@ -140,12 +141,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
140
141
  required_rubygems_version: !ruby/object:Gem::Requirement
141
142
  none: false
142
143
  requirements:
143
- - - ">="
144
+ - - ">"
144
145
  - !ruby/object:Gem::Version
145
- hash: 3
146
+ hash: 25
146
147
  segments:
147
- - 0
148
- version: "0"
148
+ - 1
149
+ - 3
150
+ - 1
151
+ version: 1.3.1
149
152
  requirements: []
150
153
 
151
154
  rubyforge_project: