rumeme 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YzVhMzE2MWM3MzFjYzY5N2U5Y2MxNmEwZGU4MTEyMjdjMDBmZjY3YQ==
5
+ data.tar.gz: !binary |-
6
+ YTE5MDZjYzAyMWVkMGFjMTAxN2U3YzljZDAyMWZlMzZiODhkOGEyYQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NjQ3MDZiYjFkN2IzOWYwZWFlYzg0NTcxN2M5MWY5Yzg5YjEwODUxYjk0OTI4
10
+ NjJkYWZmYTNmZWMxMjUxY2JlN2RiN2U5NDkwNjU1ZThhM2Y4YmY0NWM3NDI4
11
+ YjdiY2Q0N2U2M2EzNjA2YzI3OWI4YTJmMTg1YTk5ZWQ0MmY0MDc=
12
+ data.tar.gz: !binary |-
13
+ MTRmZjliZGU1Mzg2NGNlZTc1MjZlYTc5MjliNWZhMWFjZWZlZjBmNzdiMmIy
14
+ ZDAwMGIwMmVlZDU5OGM4OTJkNWI5YzZhNDJjMGExOTNmZmM0ZGQzZjk1OTdi
15
+ MGJkYTQwYmQ2YmViN2IwYTQ0NWQ3YzgxYjY5MWExMDNlMmQ0N2E=
data/.gitignore CHANGED
@@ -1,3 +1,2 @@
1
- .idea
2
- run_simple_test.rb
3
- pkg
1
+ pkg
2
+ Gemfile.lock
data/CHANGELOG CHANGED
@@ -1,13 +1,36 @@
1
+ Version 0.4.1 - 2013-05-09
2
+ ===============================================================================
3
+
4
+ Anatoliy Plastinin (11):
5
+ Merge pull request #4 from rafaelmagu/master
6
+ remove commented logging
7
+ update readme
8
+ Merge PR #5 into master
9
+ clenaup
10
+ update gitignore
11
+ small code readability changes
12
+ other small fixes
13
+
14
+ Rafael Fonseca (1):
15
+ Commented out some debugging output. Fixed return value order in strip_invalid.
16
+
17
+ Stan Carver (15):
18
+ corrected strip_invalid method-logic test for nil was backwards.
19
+ simplified unescape method for readibility.
20
+ corrected changed resp variable name to response. corrected pass by reference change to data variable. removed unneeded print statements.
21
+ added more test coverage.
22
+
23
+
1
24
  Version 0.4.0 - 2012-10-30
2
25
  ===============================================================================
3
26
 
4
27
  Stan Carver II (6):
5
28
  changed send_messages to return true or false instead of raising an error
6
- added send_messages! to raise an error
7
- change inverted if not conditionals to unless
8
- refactored message_id_sign out of create_login_string
9
- consolidated self references with a << self block
10
- added my name to the credits as a contributor
29
+ added send_messages! to raise an error
30
+ change inverted if not conditionals to unless
31
+ refactored message_id_sign out of create_login_string
32
+ consolidated self references with a << self block
33
+ added my name to the credits as a contributor
11
34
 
12
35
 
13
36
  Version 0.3.0 - 2012-02-17
@@ -87,14 +110,3 @@ antlypls (5):
87
110
  update gitignore
88
111
  add maintaince tasks to rake
89
112
 
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in requeues-next.gemspec
4
3
  gemspec
@@ -0,0 +1,71 @@
1
+ RuMeMe
2
+ ======
3
+
4
+ Ruby SDK for Message Media SMS Gateway API.
5
+ Since Message Media doesn't provide any ruby projects support, we decided to port it from available SDKs (mainly from PHP SDK; and some .NET usage).
6
+ For more information checkout [Message Media SMS APIs](http://www.message-media.com/sms-gateway.html).
7
+
8
+ Help
9
+ ====
10
+
11
+ Installation
12
+ ------------
13
+
14
+ Just execute
15
+
16
+ gem install rumeme
17
+
18
+ Usage
19
+ -----
20
+
21
+ First, add Rumeme initialization
22
+
23
+ ```ruby
24
+ Rumeme.configure do |config|
25
+ config.username = 'xxx'
26
+ config.password = 'yyy'
27
+ config.use_message_id = true
28
+ config.secure = true
29
+ config.allow_splitting = false
30
+ config.allow_long_messages = true
31
+ end
32
+ ```
33
+
34
+ Where xxx and yyy is your username and password consequently.
35
+ Then you can use SmsInterface class to add and send messages.
36
+
37
+ ```ruby
38
+ si = SmsInterface.new
39
+
40
+ si.add_message :phone_number => 'xxxxxxxxxxx', :message => 'Message text 1'
41
+ si.add_message :phone_number => 'xxxxxxxxxxx', :message => 'Message text 2'
42
+ si.add_message :phone_number => 'xxxxxxxxxxx', :message => 'Message text 3'
43
+ si.add_message :phone_number => 'xxxxxxxxxxx', :message => 'Message text 4'
44
+ si.add_message :phone_number => 'xxxxxxxxxxx', :message => 'Message text 5'
45
+
46
+ si.send_messages
47
+ ```
48
+
49
+ Where xxxxxxxxxxx is phone number.
50
+
51
+ To Do
52
+ =====
53
+
54
+ * Refactoring to make api more rubyish,
55
+ * Add unit tests,
56
+
57
+ Credits
58
+ =======
59
+
60
+ RuMeMe is maintained by Anatoliy Plastinin, and is funded by [Cloud Castle, LLC](http://cloudcastlegroup.com/).
61
+
62
+ Contributors
63
+ ============
64
+
65
+ * Stan Carver II
66
+ * Rafael Fonseca
67
+
68
+ License
69
+ =======
70
+
71
+ Still looking for license. But the software is provided "as is", without warranty of any kind.
data/Rakefile CHANGED
@@ -2,6 +2,8 @@ require 'rake'
2
2
  require 'rake/testtask'
3
3
  require 'bundler/gem_tasks'
4
4
 
5
+ require 'date'
6
+
5
7
  desc 'Test the rumeme gem'
6
8
  Rake::TestTask.new(:test) do |t|
7
9
  t.libs << 'lib'
@@ -9,9 +11,11 @@ Rake::TestTask.new(:test) do |t|
9
11
  t.verbose = true
10
12
  end
11
13
 
14
+ task :default => [:test]
15
+
12
16
  desc "Bumps the version by a minor or patch version, depending on what was passed in."
13
17
  task :bump, :part do |t, args|
14
- if Rumeme::VERSION =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/
18
+ if Rumeme::VERSION =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/
15
19
  major = $1.to_i
16
20
  minor = $2.to_i
17
21
  patch = $3.to_i
@@ -59,7 +63,7 @@ Version #{version} - #{Date.today}
59
63
  EOF
60
64
  end
61
65
 
62
- editor = ENV["EDITOR"] || 'mvim'
66
+ editor = ENV["EDITOR"] || 'vim'
63
67
 
64
68
  system ["#{editor} #{file}",
65
69
  "git commit -aqm '#{message}'",
@@ -12,8 +12,8 @@ module Rumeme
12
12
  def configure
13
13
  @configuration ||= Configuration.new
14
14
  yield @configuration
15
-
15
+
16
16
  raise 'unknown long_messages_strategy' unless [:split, :send, :cut].include?(@configuration.long_messages_strategy)
17
17
  end
18
18
  end
19
- end
19
+ end
@@ -11,7 +11,7 @@ module Rumeme
11
11
  # possible values
12
12
  # :send - sends messages as is without any modification
13
13
  # :split - splits messages into small (less than 160 ch) messages
14
- # :cut - sends only first 160 symbols
14
+ # :cut - sends only first 160 symbols
15
15
  attr_accessor :long_messages_strategy
16
16
 
17
17
  def initialize
@@ -6,4 +6,4 @@ module Rumeme
6
6
  DELIVERED = 2
7
7
  FAILED = 3
8
8
  end
9
- end
9
+ end
@@ -64,7 +64,7 @@ module Rumeme
64
64
  def open_server_connection server
65
65
  port, use_ssl = @secure ? [443, true] : [80, false]
66
66
 
67
- http_connection = Net::HTTP.new(server, port)
67
+ http_connection = Net::HTTP.new(server, port)
68
68
  http_connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
69
69
  http_connection.use_ssl = use_ssl
70
70
  http_connection
@@ -132,7 +132,7 @@ module Rumeme
132
132
  end
133
133
 
134
134
  def split_message_internal message
135
- list =[]
135
+ list = []
136
136
  sizes = Enumerator.new {|yielder| yielder << 152; yielder << 155 while true}
137
137
 
138
138
  until message.nil? do
@@ -152,10 +152,10 @@ module Rumeme
152
152
 
153
153
  # Strip invalid characters from the phone number.
154
154
  def strip_invalid phone
155
- phone.nil? ? "+#{phone.gsub(/[^0-9]/, '')}" : nil
155
+ "+#{phone.gsub(/[^0-9]/, '')}" if phone
156
156
  end
157
157
  end
158
-
158
+
159
159
  def process_long_message message
160
160
  return [message] if message.length <= 160
161
161
  @long_messages_processor.call(message)
@@ -164,28 +164,23 @@ module Rumeme
164
164
  def message_id_sign
165
165
  @use_message_id ? '#' : ''
166
166
  end
167
-
167
+
168
168
  def create_login_string # can be calculate once at initialization
169
169
  "m4u\r\nUSER=#{@username}#{message_id_sign}\r\nPASSWORD=#{@password}\r\nVER=PHP1.0\r\n"
170
170
  end
171
171
 
172
172
  def post_data_to_server data
173
- puts 'post_data_to_server'
174
-
175
173
  http_connection = open_server_connection(@server_list[0])
176
174
  text_buffer = create_login_string + data
177
175
 
178
- puts "buffer: #{text_buffer}"
179
176
  headers = {'Content-Length' => text_buffer.length.to_s}
180
177
 
181
178
  path = '/'
182
179
 
183
180
  resp = http_connection.post(path, text_buffer, headers)
184
181
  data = resp.body
185
- p resp
186
- p data
187
-
188
- raise BadServerResponse.new('http response code != 200') unless response.code.to_i == 200
182
+
183
+ raise BadServerResponse.new('http response code != 200') unless resp.code.to_i == 200
189
184
 
190
185
  if data =~ /^.+<TITLE>(.+)<\/TITLE>.+<BODY>(.+)<\/BODY>.+/m
191
186
  parsed_title, parsed_body = $1, $2
@@ -197,13 +192,10 @@ module Rumeme
197
192
 
198
193
  response_message = parsed_body.strip
199
194
 
200
- response_message.match /^(\d+)\s+/
195
+ response_message.match(/^(\d+)\s+/)
201
196
  response_code = $1.to_i
202
197
 
203
- puts "latest response code: #{response_code}"
204
- puts "response: #{response_message }"
205
-
206
198
  [response_message, response_code]
207
199
  end
208
200
  end
209
- end
201
+ end
@@ -15,9 +15,9 @@ module Rumeme
15
15
 
16
16
  @message = @message.gsub("\n",'\n').gsub("\r",'\r').gsub("\\",'\\\\')
17
17
  end
18
-
18
+
19
19
  def post_string
20
20
  "#{@message_id} #{@phone_number} #{@delay} #{@validity_period} #{@delivery_report ? 1 : 0} #{@message}\r\n"
21
21
  end
22
22
  end
23
- end
23
+ end
@@ -11,7 +11,7 @@ module Rumeme
11
11
  class << self
12
12
  # Unescape any escaped characters in the string.
13
13
  def unescape line
14
- line.nil? ? nil : line.gsub('\n', "\n").gsub('\r', "\r").gsub('\\\\', "\\")
14
+ line.gsub('\n', "\n").gsub('\r', "\r").gsub('\\\\', "\\") if line
15
15
  end
16
16
 
17
17
  # Parse a reply from a string.
@@ -20,7 +20,7 @@ module Rumeme
20
20
  # Or if delivery receipt: messageID messageStatus when /(\d+)\s(\d)\s(\d+)/
21
21
  # current implementation ignores use_message_id setting (as original code)
22
22
  def parse line
23
- p "parsing line: #{line}"
23
+ # p "parsing line: #{line}"
24
24
 
25
25
  message_id, status, message, phone, when_ = case line
26
26
  when /^(\d+)\s(\d)\s(\d+)/
@@ -44,4 +44,4 @@ module Rumeme
44
44
  @status != MessageStatus::NONE
45
45
  end
46
46
  end
47
- end
47
+ end
@@ -11,4 +11,4 @@ module Rumeme
11
11
  ONE_WEEK = 173
12
12
  MAXIMUM = 255
13
13
  end
14
- end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module Rumeme
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -16,14 +16,11 @@ Gem::Specification.new do |s|
16
16
  s.summary = "Ruby SDK for Message Media SMS Gateway API"
17
17
  s.description = "Ruby SDK for Message Media SMS Gateway API"
18
18
 
19
-
20
19
  s.add_development_dependency 'shoulda'
21
20
 
22
-
23
21
  s.files = `git ls-files`.split("\n")
24
22
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
25
23
  s.require_paths = %W(lib)
26
- s.extra_rdoc_files = ["README.rdoc"]
27
- s.rdoc_options = ["--line-numbers", "--main", "README.rdoc"]
28
-
24
+ s.extra_rdoc_files = ["README.md"]
25
+ s.rdoc_options = ["--line-numbers", "--main", "README.md"]
29
26
  end
@@ -0,0 +1,39 @@
1
+ $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
2
+ require 'test/unit'
3
+ require "rubygems"
4
+ require 'shoulda'
5
+ require "rumeme"
6
+
7
+ include Rumeme
8
+
9
+ class ConfigurationTest < Test::Unit::TestCase
10
+ context "has attributes" do
11
+ setup do
12
+ @rumeme_configuration = Configuration.new
13
+ end
14
+
15
+ should "have username attribute" do
16
+ assert_respond_to @rumeme_configuration, :username
17
+ end
18
+
19
+ should "have password attribute" do
20
+ assert_respond_to @rumeme_configuration, :password
21
+ end
22
+
23
+ should "have use_message_id attribute" do
24
+ assert_respond_to @rumeme_configuration, :use_message_id
25
+ end
26
+
27
+ should "have secure attribute" do
28
+ assert_respond_to @rumeme_configuration, :secure
29
+ end
30
+
31
+ should "have replies_auto_confirm attribute" do
32
+ assert_respond_to @rumeme_configuration, :replies_auto_confirm
33
+ end
34
+
35
+ should "have long_messages_strategy attribute" do
36
+ assert_respond_to @rumeme_configuration, :long_messages_strategy
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,14 @@
1
+ $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
2
+ require 'test/unit'
3
+ require "rubygems"
4
+ require 'shoulda'
5
+ require "rumeme"
6
+
7
+ class MessageStatusTest < Test::Unit::TestCase
8
+ should "correctly assign MessageStatus constants" do
9
+ assert_equal Rumeme::MessageStatus::NONE, 0
10
+ assert_equal Rumeme::MessageStatus::PENDING, 1
11
+ assert_equal Rumeme::MessageStatus::DELIVERED, 2
12
+ assert_equal Rumeme::MessageStatus::FAILED, 3
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
2
+ require 'test/unit'
3
+ require "rubygems"
4
+ require 'shoulda'
5
+ require "rumeme"
6
+
7
+ include Rumeme
8
+
9
+ class SmsInterfaceTest < Test::Unit::TestCase
10
+
11
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
2
+ require 'test/unit'
3
+ require "rubygems"
4
+ require 'shoulda'
5
+ require "rumeme"
6
+ require "rumeme/version"
7
+
8
+ class VersionTest < Test::Unit::TestCase
9
+ should "have Version constant" do
10
+ assert Rumeme.const_defined? :VERSION
11
+ end
12
+ end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rumeme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
5
- prerelease:
4
+ version: 0.4.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Anatoliy Plastinin, Cloud Castle LLC
@@ -10,12 +9,11 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2012-11-01 00:00:00.000000000 Z
12
+ date: 2013-05-09 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: shoulda
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
18
  - - ! '>='
21
19
  - !ruby/object:Gem::Version
@@ -23,7 +21,6 @@ dependencies:
23
21
  type: :development
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
25
  - - ! '>='
29
26
  - !ruby/object:Gem::Version
@@ -35,13 +32,12 @@ email:
35
32
  executables: []
36
33
  extensions: []
37
34
  extra_rdoc_files:
38
- - README.rdoc
35
+ - README.md
39
36
  files:
40
37
  - .gitignore
41
38
  - CHANGELOG
42
39
  - Gemfile
43
- - Gemfile.lock
44
- - README.rdoc
40
+ - README.md
45
41
  - Rakefile
46
42
  - lib/rumeme.rb
47
43
  - lib/rumeme/configuration.rb
@@ -52,35 +48,42 @@ files:
52
48
  - lib/rumeme/validity_period.rb
53
49
  - lib/rumeme/version.rb
54
50
  - rumeme.gemspec
51
+ - test/configuration_test.rb
52
+ - test/message_status_test.rb
53
+ - test/sms_interface_test.rb
55
54
  - test/sms_message_test.rb
56
55
  - test/sms_reply_test.rb
56
+ - test/version_test.rb
57
57
  homepage: http://github.com/programmable/rumeme
58
58
  licenses: []
59
+ metadata: {}
59
60
  post_install_message:
60
61
  rdoc_options:
61
62
  - --line-numbers
62
63
  - --main
63
- - README.rdoc
64
+ - README.md
64
65
  require_paths:
65
66
  - lib
66
67
  required_ruby_version: !ruby/object:Gem::Requirement
67
- none: false
68
68
  requirements:
69
69
  - - ! '>='
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  required_rubygems_version: !ruby/object:Gem::Requirement
73
- none: false
74
73
  requirements:
75
74
  - - ! '>='
76
75
  - !ruby/object:Gem::Version
77
76
  version: '0'
78
77
  requirements: []
79
78
  rubyforge_project:
80
- rubygems_version: 1.8.23
79
+ rubygems_version: 2.0.3
81
80
  signing_key:
82
- specification_version: 3
81
+ specification_version: 4
83
82
  summary: Ruby SDK for Message Media SMS Gateway API
84
83
  test_files:
84
+ - test/configuration_test.rb
85
+ - test/message_status_test.rb
86
+ - test/sms_interface_test.rb
85
87
  - test/sms_message_test.rb
86
88
  - test/sms_reply_test.rb
89
+ - test/version_test.rb
@@ -1,7 +0,0 @@
1
- GEM
2
- specs:
3
-
4
- PLATFORMS
5
- ruby
6
-
7
- DEPENDENCIES
@@ -1,49 +0,0 @@
1
- = RuMeMe
2
- Ruby SDK for Message Media SMS Gateway API.
3
- Since Message Media doesn't provide any ruby projects support, we decided to port it from available SDKs (mainly from PHP SDK; and some .NET usage).
4
- For more information checkout {Message Media SMS APIs}[http://www.message-media.com/sms-gateway.html].
5
-
6
- = Help
7
- == Installation
8
- Just execute
9
- gem install rumeme
10
-
11
- == Usage
12
- First, add Rumeme initialization
13
-
14
- Rumeme.configure do |config|
15
- config.username = 'xxx'
16
- config.password = 'yyy'
17
- config.use_message_id = true
18
- config.secure = true
19
- config.allow_splitting = false
20
- config.allow_long_messages = true
21
- end
22
-
23
- Where xxx and yyy is your username and password consequently.
24
- Then you can use SmsInterface class to add and send messages.
25
-
26
- si = SmsInterface.new
27
-
28
- si.add_message :phone_number => 'xxxxxxxxxxx', :message => 'Message text 1'
29
- si.add_message :phone_number => 'xxxxxxxxxxx', :message => 'Message text 2'
30
- si.add_message :phone_number => 'xxxxxxxxxxx', :message => 'Message text 3'
31
- si.add_message :phone_number => 'xxxxxxxxxxx', :message => 'Message text 4'
32
- si.add_message :phone_number => 'xxxxxxxxxxx', :message => 'Message text 5'
33
-
34
- si.send_messages
35
-
36
- Where xxxxxxxxxxx is phone number.
37
-
38
- = To Do
39
- * Refactoring to make api more rubyish,
40
- * Add unit tests,
41
-
42
- = Credits
43
- RuMeMe is maintained by Anatoliy Plastinin, and is funded by {Cloud Castle, LLC}[http://cloudcastlegroup.com/].
44
-
45
- = Contributors
46
- Stan Carver II
47
-
48
- = License
49
- Still looking for license. But the software is provided "as is", without warranty of any kind.