textmagic 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -16
- data/.rubocop.yml +102 -0
- data/.rubocop_todo.yml +38 -0
- data/.ruby-version +1 -0
- data/Rakefile +1 -1
- data/bin/tm +28 -28
- data/gems.rb +8 -0
- data/lib/textmagic.rb +0 -2
- data/lib/textmagic/api.rb +11 -10
- data/lib/textmagic/charset.rb +11 -6
- data/lib/textmagic/error.rb +5 -1
- data/lib/textmagic/executor.rb +15 -8
- data/lib/textmagic/response.rb +15 -11
- data/lib/textmagic/validation.rb +5 -2
- data/lib/textmagic/version.rb +3 -1
- data/test/test_api.rb +39 -34
- data/test/test_charset.rb +0 -2
- data/test/test_executor.rb +20 -12
- data/test/test_helper.rb +13 -5
- data/test/test_response.rb +18 -13
- data/test/test_validation.rb +5 -4
- data/textmagic.gemspec +8 -9
- metadata +13 -31
- data/Gemfile +0 -9
- data/lib/textmagic/.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0465c4db491828640efa4ca882e0ab95884e4cde
|
4
|
+
data.tar.gz: 96c9846d3a600b35896843d67f778a60f2f97c3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6de90d2f47bab95032839e143a2ea945f7786a99afb34f51d07a76b63cf5008186a6488d4c49a5427a86ab9a9f7aa3f3a090ef6327e3b84efb112a6f3b8f8b9e
|
7
|
+
data.tar.gz: e6b8a540489968dc9c6c7e8b018a333d9fac8fde9b7335741d1630fb449d0ffecf2201dd660cf3f3910eabcf573dc6e02609ecec5bc7b339481ad030a4dd9cc8
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.0
|
5
|
+
|
6
|
+
Documentation:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Lint/EndAlignment:
|
10
|
+
EnforcedStyleAlignWith: variable
|
11
|
+
|
12
|
+
Lint/LiteralInInterpolation:
|
13
|
+
Enabled: true
|
14
|
+
|
15
|
+
Metrics/AbcSize:
|
16
|
+
Exclude:
|
17
|
+
- test/**/*
|
18
|
+
|
19
|
+
Metrics/ClassLength:
|
20
|
+
Exclude:
|
21
|
+
- test/**/*
|
22
|
+
|
23
|
+
Metrics/LineLength:
|
24
|
+
Max: 120
|
25
|
+
Exclude:
|
26
|
+
- test/**/*
|
27
|
+
|
28
|
+
Metrics/MethodLength:
|
29
|
+
Exclude:
|
30
|
+
- test/**/*
|
31
|
+
|
32
|
+
Layout/AlignParameters:
|
33
|
+
EnforcedStyle: with_fixed_indentation
|
34
|
+
|
35
|
+
Layout/CaseIndentation:
|
36
|
+
EnforcedStyle: end
|
37
|
+
|
38
|
+
Layout/DotPosition:
|
39
|
+
EnforcedStyle: trailing
|
40
|
+
|
41
|
+
Layout/EmptyLinesAroundBlockBody:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
Layout/EmptyLinesAroundClassBody:
|
45
|
+
EnforcedStyle: empty_lines
|
46
|
+
|
47
|
+
Layout/EmptyLinesAroundModuleBody:
|
48
|
+
EnforcedStyle: empty_lines
|
49
|
+
|
50
|
+
Layout/FirstParameterIndentation:
|
51
|
+
EnforcedStyle: special_for_inner_method_call
|
52
|
+
|
53
|
+
Layout/IndentArray:
|
54
|
+
EnforcedStyle: consistent
|
55
|
+
|
56
|
+
Layout/IndentHash:
|
57
|
+
EnforcedStyle: consistent
|
58
|
+
|
59
|
+
Layout/MultilineMethodCallIndentation:
|
60
|
+
EnforcedStyle: indented
|
61
|
+
IndentationWidth: 2
|
62
|
+
|
63
|
+
Layout/MultilineOperationIndentation:
|
64
|
+
EnforcedStyle: indented
|
65
|
+
IndentationWidth: 2
|
66
|
+
|
67
|
+
Style/AutoResourceCleanup:
|
68
|
+
Enabled: true
|
69
|
+
|
70
|
+
Style/DoubleNegation:
|
71
|
+
Enabled: false
|
72
|
+
|
73
|
+
Style/FrozenStringLiteralComment:
|
74
|
+
Enabled: false
|
75
|
+
|
76
|
+
Style/MethodCalledOnDoEndBlock:
|
77
|
+
Enabled: true
|
78
|
+
|
79
|
+
Style/MethodCalledOnDoEndBlock:
|
80
|
+
Exclude:
|
81
|
+
- test/**/*
|
82
|
+
|
83
|
+
Style/Send:
|
84
|
+
Enabled: true
|
85
|
+
|
86
|
+
Style/StringLiterals:
|
87
|
+
EnforcedStyle: double_quotes
|
88
|
+
|
89
|
+
Style/StringLiteralsInInterpolation:
|
90
|
+
EnforcedStyle: double_quotes
|
91
|
+
|
92
|
+
Style/StringMethods:
|
93
|
+
Enabled: true
|
94
|
+
|
95
|
+
Style/SymbolArray:
|
96
|
+
Enabled: true
|
97
|
+
|
98
|
+
Style/TrailingCommaInArguments:
|
99
|
+
EnforcedStyleForMultiline: comma
|
100
|
+
|
101
|
+
Style/TrailingCommaInLiteral:
|
102
|
+
EnforcedStyleForMultiline: comma
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2017-10-02 15:24:21 +0000 using RuboCop version 0.50.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 4
|
10
|
+
Metrics/AbcSize:
|
11
|
+
Max: 35
|
12
|
+
|
13
|
+
# Offense count: 16
|
14
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
15
|
+
Metrics/BlockLength:
|
16
|
+
Max: 265
|
17
|
+
|
18
|
+
# Offense count: 2
|
19
|
+
Metrics/CyclomaticComplexity:
|
20
|
+
Max: 13
|
21
|
+
|
22
|
+
# Offense count: 4
|
23
|
+
# Configuration parameters: CountComments.
|
24
|
+
Metrics/MethodLength:
|
25
|
+
Max: 17
|
26
|
+
|
27
|
+
# Offense count: 2
|
28
|
+
Metrics/PerceivedComplexity:
|
29
|
+
Max: 11
|
30
|
+
|
31
|
+
# Offense count: 27
|
32
|
+
Style/Send:
|
33
|
+
Exclude:
|
34
|
+
- 'bin/tm'
|
35
|
+
- 'lib/textmagic/api.rb'
|
36
|
+
- 'lib/textmagic/response.rb'
|
37
|
+
- 'test/test_api.rb'
|
38
|
+
- 'test/test_response.rb'
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.4.1
|
data/Rakefile
CHANGED
data/bin/tm
CHANGED
@@ -1,44 +1,44 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require
|
2
|
+
require "optparse"
|
3
3
|
|
4
|
-
lib = File.join(File.dirname(__FILE__),
|
4
|
+
lib = File.join(File.dirname(__FILE__), "..", "lib", "textmagic")
|
5
5
|
|
6
6
|
if File.exist?("#{lib}.rb")
|
7
7
|
require lib
|
8
8
|
else
|
9
|
-
require
|
10
|
-
require
|
9
|
+
require "rubygems"
|
10
|
+
require "textmagic"
|
11
11
|
end
|
12
12
|
|
13
|
-
filename = File.join(ENV[
|
13
|
+
filename = File.join(ENV["HOME"], ".textmagic")
|
14
14
|
options = YAML.load_file(filename) if File.exist?(filename)
|
15
15
|
options ||= {}
|
16
16
|
|
17
17
|
parser = OptionParser.new do |opts|
|
18
|
-
opts.banner =
|
18
|
+
opts.banner = "Usage:"
|
19
19
|
opts.separator " "
|
20
20
|
opts.separator [
|
21
21
|
"tm account",
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
"tm send PHONE[,PHONE2[,PHONE3 ...]] MESSAGE",
|
23
|
+
"tm status MESSAGE_ID",
|
24
|
+
"tm receive [LAST_RETREIVED_ID]",
|
25
|
+
"tm delete MESSAGE_ID [MESSAGE_ID2 [MESSAGE_ID3 ...]]",
|
26
26
|
]
|
27
27
|
|
28
28
|
opts.separator " "
|
29
29
|
opts.separator "Specific options:"
|
30
30
|
|
31
|
-
opts.on(
|
31
|
+
opts.on("-u", "--username USERNAME",
|
32
32
|
"Specify your TextMagic API username (overrides ~/.textmagic setting)") do |username|
|
33
|
-
options[
|
33
|
+
options["username"] = username
|
34
34
|
end
|
35
35
|
|
36
|
-
opts.on(
|
36
|
+
opts.on("-p", "--password PASSWORD",
|
37
37
|
"Specify your TextMagic API password (overrides ~/.textmagic setting)") do |password|
|
38
|
-
options[
|
38
|
+
options["password"] = password
|
39
39
|
end
|
40
40
|
|
41
|
-
opts.on_tail(
|
41
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
42
42
|
puts opts
|
43
43
|
exit
|
44
44
|
end
|
@@ -53,38 +53,38 @@ end
|
|
53
53
|
|
54
54
|
command = ARGV.shift
|
55
55
|
|
56
|
-
unless options[
|
56
|
+
unless options["username"]
|
57
57
|
puts "Username not specified. Use --help option to find out details"
|
58
58
|
exit 1
|
59
59
|
end
|
60
60
|
|
61
|
-
unless options[
|
61
|
+
unless options["password"]
|
62
62
|
puts "Password not specified. Use --help option to find out details"
|
63
63
|
exit 1
|
64
64
|
end
|
65
65
|
|
66
|
-
api = TextMagic::API.new(options[
|
66
|
+
api = TextMagic::API.new(options["username"], options["password"])
|
67
67
|
|
68
68
|
begin
|
69
69
|
case command
|
70
|
-
when
|
70
|
+
when "account"
|
71
71
|
puts "Your account's balance: #{api.account.balance} credits"
|
72
|
-
when
|
73
|
-
unless phones = ARGV.shift
|
72
|
+
when "send"
|
73
|
+
unless (phones = ARGV.shift)
|
74
74
|
puts "Phone number(s) and message not specified. Use --help option to find out details"
|
75
75
|
exit 1
|
76
76
|
end
|
77
|
-
if (text = ARGV.join(
|
77
|
+
if (text = ARGV.join(" ")).empty?
|
78
78
|
puts "Message not specified. Use --help option to find out details"
|
79
79
|
exit 1
|
80
80
|
end
|
81
|
-
response = api.send(text, phones.split(
|
81
|
+
response = api.send(text, phones.split(","))
|
82
82
|
puts "Sent text: #{response.sent_text}"
|
83
83
|
puts "Parts: #{response.parts_count}"
|
84
84
|
response.each do |phone, message_id|
|
85
85
|
puts "Message id (#{phone}): #{message_id}"
|
86
86
|
end
|
87
|
-
when
|
87
|
+
when "status"
|
88
88
|
if ARGV.empty?
|
89
89
|
puts "Message id(s) not specified. Use --help option to find out details"
|
90
90
|
exit 1
|
@@ -92,15 +92,15 @@ begin
|
|
92
92
|
api.status(ARGV).each do |message_id, status|
|
93
93
|
puts "Status (#{message_id}): #{status}"
|
94
94
|
end
|
95
|
-
when
|
95
|
+
when "receive"
|
96
96
|
response = api.receive(ARGV.first)
|
97
97
|
response.each do |message|
|
98
98
|
puts "#{message} [#{message.message_id}, #{message.timestamp}]"
|
99
99
|
end
|
100
|
-
puts
|
101
|
-
when
|
100
|
+
puts "No new messages" if response.empty?
|
101
|
+
when "delete"
|
102
102
|
api.delete(ARGV)
|
103
|
-
puts
|
103
|
+
puts "Message(s) deleted"
|
104
104
|
else
|
105
105
|
puts "Unknown command #{command}. Use --help option to find out details"
|
106
106
|
exit 1
|
data/gems.rb
ADDED
data/lib/textmagic.rb
CHANGED
data/lib/textmagic/api.rb
CHANGED
@@ -88,13 +88,13 @@ module TextMagic
|
|
88
88
|
when nil then unicode ? 1 : 0
|
89
89
|
else raise Error.new(10, "Wrong parameter value #{options[:unicode]} for parameter unicode")
|
90
90
|
end
|
91
|
-
raise Error.new(6, "Message contains invalid characters") if unicode && options[:unicode]
|
91
|
+
raise Error.new(6, "Message contains invalid characters") if unicode && options[:unicode].zero?
|
92
92
|
raise Error.new(7, "Message too long") unless API.validate_text_length(text, unicode)
|
93
93
|
single = args.size == 1 && args.first.is_a?(String)
|
94
94
|
phones = args.flatten
|
95
95
|
raise Error.new(9, "Invalid phone number format") unless API.validate_phones(phones)
|
96
96
|
options[:send_time] = options[:send_time].to_i if options[:send_time]
|
97
|
-
hash = Executor.execute("send", @username, @password, options.merge(:
|
97
|
+
hash = Executor.execute("send", @username, @password, options.merge(text: text, phone: phones.join(",")))
|
98
98
|
TextMagic::API::Response.send(hash, single)
|
99
99
|
end
|
100
100
|
|
@@ -141,10 +141,10 @@ module TextMagic
|
|
141
141
|
single = ids.size == 1 && ids.first.is_a?(String)
|
142
142
|
ids.flatten!
|
143
143
|
raise TextMagic::API::Error.new(4, "Insufficient parameters") if ids.empty?
|
144
|
-
hash = Executor.execute("message_status", @username, @password, :
|
144
|
+
hash = Executor.execute("message_status", @username, @password, ids: ids.join(","))
|
145
145
|
TextMagic::API::Response.message_status(hash, single)
|
146
146
|
end
|
147
|
-
alias
|
147
|
+
alias status message_status
|
148
148
|
|
149
149
|
# Executes a receive command by sending a request to the TextMagic's
|
150
150
|
# SMS gateway.
|
@@ -175,7 +175,7 @@ module TextMagic
|
|
175
175
|
# <b>It is strongly encouraged to setup callbacks to receive replies instead of
|
176
176
|
# using this method.</b>
|
177
177
|
def receive(last_retrieved_id = nil)
|
178
|
-
hash = Executor.execute("receive", @username, @password, :
|
178
|
+
hash = Executor.execute("receive", @username, @password, last_retrieved_id: last_retrieved_id)
|
179
179
|
TextMagic::API::Response.receive(hash)
|
180
180
|
end
|
181
181
|
|
@@ -192,13 +192,12 @@ module TextMagic
|
|
192
192
|
# api.delete_reply("173205", "223606")
|
193
193
|
# api.delete_reply(["244948", "264575"])
|
194
194
|
def delete_reply(*ids)
|
195
|
-
single = ids.size == 1 && ids.first.is_a?(String)
|
196
195
|
ids.flatten!
|
197
196
|
raise TextMagic::API::Error.new(4, "Insufficient parameters") if ids.empty?
|
198
|
-
Executor.execute("delete_reply", @username, @password, :
|
197
|
+
Executor.execute("delete_reply", @username, @password, ids: ids.join(","))
|
199
198
|
true
|
200
199
|
end
|
201
|
-
alias
|
200
|
+
alias delete delete_reply
|
202
201
|
|
203
202
|
# Executes a check_number command by sending a request to the TextMagic's
|
204
203
|
# SMS gateway.
|
@@ -239,9 +238,11 @@ module TextMagic
|
|
239
238
|
single = phones.size == 1 && phones.first.is_a?(String)
|
240
239
|
phones.flatten!
|
241
240
|
raise TextMagic::API::Error.new(4, "Insufficient parameters") if phones.empty?
|
242
|
-
hash = Executor.execute("check_number", @username, @password, :
|
241
|
+
hash = Executor.execute("check_number", @username, @password, phone: phones.join(","))
|
243
242
|
TextMagic::API::Response.check_number(hash, single)
|
244
243
|
end
|
245
|
-
alias
|
244
|
+
alias check check_number
|
245
|
+
|
246
246
|
end
|
247
|
+
|
247
248
|
end
|
data/lib/textmagic/charset.rb
CHANGED
@@ -1,30 +1,35 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module TextMagic
|
4
2
|
|
5
3
|
class API
|
6
4
|
|
7
5
|
module Charset
|
8
6
|
|
9
|
-
GSM_CHARSET =
|
10
|
-
|
7
|
+
GSM_CHARSET =
|
8
|
+
"@£$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞ\e\f^{}\\[~]|€ÆæßÉ !\"#¤%&'()*+,-./0123456789:;<=>?¡"\
|
9
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà".scan(/./u).freeze
|
10
|
+
ESCAPED_CHARS = "{}\\~[]|€".freeze
|
11
11
|
|
12
12
|
# Returns +true+ if the supplied text contains only characters from
|
13
13
|
# GSM 03.38 charset, otherwise it returns +false+.
|
14
|
-
def
|
14
|
+
def gsm?(text)
|
15
15
|
text.scan(/./u).each { |c| return false unless GSM_CHARSET.include?(c) }
|
16
16
|
true
|
17
17
|
end
|
18
|
+
alias is_gsm gsm?
|
18
19
|
|
19
20
|
# Returns +true+ if the supplied text contains characters outside of
|
20
21
|
# GSM 03.38 charset, otherwise it returns +false+.
|
21
|
-
def
|
22
|
+
def unicode?(text)
|
22
23
|
!is_gsm(text)
|
23
24
|
end
|
25
|
+
alias is_unicode unicode?
|
24
26
|
|
25
27
|
def real_length(text, unicode)
|
26
28
|
text.size + (unicode ? 0 : text.scan(/[\{\}\\~\[\]\|€]/).size)
|
27
29
|
end
|
30
|
+
|
28
31
|
end
|
32
|
+
|
29
33
|
end
|
34
|
+
|
30
35
|
end
|
data/lib/textmagic/error.rb
CHANGED
@@ -13,7 +13,8 @@ module TextMagic
|
|
13
13
|
# TextMagic::API::Error.new("error_code" => code, "error_message" => message)
|
14
14
|
def initialize(*args)
|
15
15
|
if args.first.is_a?(Hash)
|
16
|
-
@code
|
16
|
+
@code = args.first["error_code"]
|
17
|
+
@message = args.first["error_message"]
|
17
18
|
else
|
18
19
|
@code, @message = args
|
19
20
|
end
|
@@ -22,6 +23,9 @@ module TextMagic
|
|
22
23
|
def to_s
|
23
24
|
"#{@message} (#{@code})"
|
24
25
|
end
|
26
|
+
|
25
27
|
end
|
28
|
+
|
26
29
|
end
|
30
|
+
|
27
31
|
end
|
data/lib/textmagic/executor.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
require "net/http"
|
2
|
+
|
1
3
|
module TextMagic
|
4
|
+
|
2
5
|
class API
|
3
6
|
|
4
|
-
|
7
|
+
module Executor
|
5
8
|
|
6
|
-
|
7
|
-
base_uri "https://www.textmagic.com/app"
|
9
|
+
module_function
|
8
10
|
|
9
11
|
# Executes a command by sending a request to the TextMagic's Bulk
|
10
12
|
# SMS gateway. This is a low-level generic method used by methods
|
@@ -18,15 +20,20 @@ module TextMagic
|
|
18
20
|
# Returns a hash with values parsed from the server"s response if
|
19
21
|
# the command was successfully executed. In case the server replies
|
20
22
|
# with error, this method raises a TextMagic::API::Error.
|
21
|
-
def
|
23
|
+
def execute(command, username, password, options = {})
|
22
24
|
raise TextMagic::API::Error.new(3, "Command is undefined") unless command
|
23
25
|
raise TextMagic::API::Error.new(5, "Invalid username & password combination") unless username && password
|
24
|
-
options.merge!(:
|
26
|
+
options.merge!(username: username, password: password, cmd: command)
|
25
27
|
options.delete_if { |key, value| !key || !value }
|
26
|
-
|
27
|
-
|
28
|
-
response
|
28
|
+
uri = URI("https://www.textmagic.com/app/api")
|
29
|
+
response = Net::HTTP.post_form(uri, options)
|
30
|
+
result = JSON.parse(response.body) if response.body
|
31
|
+
raise Error, response.body if result && result["error_code"]
|
32
|
+
result
|
29
33
|
end
|
34
|
+
|
30
35
|
end
|
36
|
+
|
31
37
|
end
|
38
|
+
|
32
39
|
end
|
data/lib/textmagic/response.rb
CHANGED
@@ -4,21 +4,22 @@ module TextMagic
|
|
4
4
|
|
5
5
|
class API
|
6
6
|
|
7
|
-
|
7
|
+
module Response
|
8
8
|
|
9
|
-
|
9
|
+
module_function
|
10
|
+
|
11
|
+
def account(hash)
|
10
12
|
response = OpenStruct.new(hash)
|
11
13
|
response.balance = response.balance.to_f
|
12
|
-
response.balance = response.balance.to_i if response.balance % 1
|
14
|
+
response.balance = response.balance.to_i if (response.balance % 1).zero?
|
13
15
|
response
|
14
16
|
end
|
15
17
|
|
16
|
-
def
|
17
|
-
response =
|
18
|
-
|
19
|
-
response = hash["message_id"].keys.first.dup
|
18
|
+
def send(hash, single)
|
19
|
+
response = if single
|
20
|
+
hash["message_id"].keys.first.dup
|
20
21
|
else
|
21
|
-
|
22
|
+
hash["message_id"].invert
|
22
23
|
end
|
23
24
|
metaclass = class << response; self; end
|
24
25
|
metaclass.send :attr_accessor, :sent_text, :parts_count, :message_id
|
@@ -28,7 +29,7 @@ module TextMagic
|
|
28
29
|
response
|
29
30
|
end
|
30
31
|
|
31
|
-
def
|
32
|
+
def message_status(hash, single)
|
32
33
|
response = {}
|
33
34
|
hash.each do |message_id, message_hash|
|
34
35
|
status = message_hash["status"].dup
|
@@ -45,7 +46,7 @@ module TextMagic
|
|
45
46
|
single ? response.values.first : response
|
46
47
|
end
|
47
48
|
|
48
|
-
def
|
49
|
+
def receive(hash)
|
49
50
|
response = hash["messages"].collect do |message_hash|
|
50
51
|
message = "#{message_hash["from"]}: #{message_hash["text"]}"
|
51
52
|
metaclass = class << message; self; end
|
@@ -62,13 +63,16 @@ module TextMagic
|
|
62
63
|
response
|
63
64
|
end
|
64
65
|
|
65
|
-
def
|
66
|
+
def check_number(hash, single)
|
66
67
|
response = {}
|
67
68
|
hash.each do |phone, check_hash|
|
68
69
|
response[phone] = OpenStruct.new(check_hash)
|
69
70
|
end
|
70
71
|
single ? response.values.first : response
|
71
72
|
end
|
73
|
+
|
72
74
|
end
|
75
|
+
|
73
76
|
end
|
77
|
+
|
74
78
|
end
|
data/lib/textmagic/validation.rb
CHANGED
@@ -4,8 +4,8 @@ module TextMagic
|
|
4
4
|
|
5
5
|
module Validation
|
6
6
|
|
7
|
-
MAX_LENGTH_GSM = [160, 306, 459]
|
8
|
-
MAX_LENGTH_UNICODE = [70, 134, 201]
|
7
|
+
MAX_LENGTH_GSM = [160, 306, 459].freeze
|
8
|
+
MAX_LENGTH_UNICODE = [70, 134, 201].freeze
|
9
9
|
|
10
10
|
# Validates message text length. Returns +true+ if the text length is
|
11
11
|
# within the limits for the unicode/parts combination, otherwise it
|
@@ -29,6 +29,9 @@ module TextMagic
|
|
29
29
|
phones.each { |phone| return false unless phone =~ /^\d{1,15}$/ }
|
30
30
|
true
|
31
31
|
end
|
32
|
+
|
32
33
|
end
|
34
|
+
|
33
35
|
end
|
36
|
+
|
34
37
|
end
|
data/lib/textmagic/version.rb
CHANGED
data/test/test_api.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require "test_helper"
|
4
2
|
|
5
3
|
describe "API" do
|
@@ -17,7 +15,8 @@ describe "API" do
|
|
17
15
|
describe "Account command" do
|
18
16
|
|
19
17
|
before do
|
20
|
-
@username
|
18
|
+
@username = random_string
|
19
|
+
@password = random_string
|
21
20
|
@api = TextMagic::API.new(@username, @password)
|
22
21
|
@response = random_string
|
23
22
|
@processed_response = random_string
|
@@ -40,8 +39,10 @@ describe "API" do
|
|
40
39
|
describe "Send command" do
|
41
40
|
|
42
41
|
before do
|
43
|
-
@username
|
44
|
-
@
|
42
|
+
@username = random_string
|
43
|
+
@password = random_string
|
44
|
+
@text = random_string
|
45
|
+
@phone = random_phone
|
45
46
|
@api = TextMagic::API.new(@username, @password)
|
46
47
|
@response = random_string
|
47
48
|
@processed_response = random_string
|
@@ -50,46 +51,46 @@ describe "API" do
|
|
50
51
|
end
|
51
52
|
|
52
53
|
it "should call Executor execute with correct arguments" do
|
53
|
-
TextMagic::API::Executor.expects(:execute).with("send", @username, @password, :
|
54
|
+
TextMagic::API::Executor.expects(:execute).with("send", @username, @password, text: @text, phone: @phone, unicode: 0).returns(@response)
|
54
55
|
@api.send(@text, @phone)
|
55
56
|
end
|
56
57
|
|
57
58
|
it "should join multiple phone numbers supplied as an array" do
|
58
59
|
phones = Array.new(3) { random_phone }
|
59
|
-
TextMagic::API::Executor.expects(:execute).with("send", @username, @password, :
|
60
|
+
TextMagic::API::Executor.expects(:execute).with("send", @username, @password, text: @text, phone: phones.join(","), unicode: 0).returns(@response)
|
60
61
|
@api.send(@text, phones)
|
61
62
|
end
|
62
63
|
|
63
64
|
it "should join multiple phone numbers supplied as arguments" do
|
64
65
|
phones = Array.new(3) { random_phone }
|
65
|
-
TextMagic::API::Executor.expects(:execute).with("send", @username, @password, :
|
66
|
+
TextMagic::API::Executor.expects(:execute).with("send", @username, @password, text: @text, phone: phones.join(","), unicode: 0).returns(@response)
|
66
67
|
@api.send(@text, *phones)
|
67
68
|
end
|
68
69
|
|
69
70
|
it "should replace true with 1 for unicode" do
|
70
|
-
TextMagic::API::Executor.expects(:execute).with("send", @username, @password, :
|
71
|
-
@api.send(@text, @phone, :
|
71
|
+
TextMagic::API::Executor.expects(:execute).with("send", @username, @password, text: @text, phone: @phone, unicode: 1).returns(@response)
|
72
|
+
@api.send(@text, @phone, unicode: true)
|
72
73
|
end
|
73
74
|
|
74
75
|
it "should set unicode value to 0 if it is not set to by user and text contains only characters from GSM 03.38 charset" do
|
75
|
-
TextMagic::API::Executor.expects(:execute).with("send", @username, @password, :
|
76
|
+
TextMagic::API::Executor.expects(:execute).with("send", @username, @password, text: @text, phone: @phone, unicode: 0).returns(@response).times(2)
|
76
77
|
@api.send(@text, @phone)
|
77
|
-
@api.send(@text, @phone, :
|
78
|
+
@api.send(@text, @phone, unicode: false)
|
78
79
|
end
|
79
80
|
|
80
81
|
it "should raise an error if unicode is set to 0 and text contains characters outside of GSM 03.38 charset" do
|
81
82
|
text = "Вильма Привет"
|
82
83
|
assert_raises TextMagic::API::Error do
|
83
|
-
@api.send(text, @phone, :
|
84
|
+
@api.send(text, @phone, unicode: false)
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
87
88
|
it "should raise an error if unicode value is not valid" do
|
88
89
|
assert_raises TextMagic::API::Error do
|
89
|
-
@api.send(@text, @phone, :
|
90
|
+
@api.send(@text, @phone, unicode: 2 + rand(10))
|
90
91
|
end
|
91
92
|
assert_raises TextMagic::API::Error do
|
92
|
-
@api.send(@text, @phone, :
|
93
|
+
@api.send(@text, @phone, unicode: random_string)
|
93
94
|
end
|
94
95
|
end
|
95
96
|
|
@@ -124,14 +125,14 @@ describe "API" do
|
|
124
125
|
|
125
126
|
it "should support send_time option" do
|
126
127
|
time = Time.now + rand
|
127
|
-
TextMagic::API::Executor.expects(:execute).with("send", @username, @password, :
|
128
|
-
@api.send(@text, @phone, :
|
128
|
+
TextMagic::API::Executor.expects(:execute).with("send", @username, @password, text: @text, phone: @phone, unicode: 0, send_time: time.to_i).returns(@response)
|
129
|
+
@api.send(@text, @phone, send_time: time.to_i)
|
129
130
|
end
|
130
131
|
|
131
132
|
it "should convert send_time to Fixnum" do
|
132
133
|
time = Time.now + rand
|
133
|
-
TextMagic::API::Executor.expects(:execute).with("send", @username, @password, :
|
134
|
-
@api.send(@text, @phone, :
|
134
|
+
TextMagic::API::Executor.expects(:execute).with("send", @username, @password, text: @text, phone: @phone, unicode: 0, send_time: time.to_i).returns(@response)
|
135
|
+
@api.send(@text, @phone, send_time: time)
|
135
136
|
end
|
136
137
|
|
137
138
|
it "should call Response.send method to process the response hash (single phone)" do
|
@@ -151,7 +152,8 @@ describe "API" do
|
|
151
152
|
describe "Message status command" do
|
152
153
|
|
153
154
|
before do
|
154
|
-
@username
|
155
|
+
@username = random_string
|
156
|
+
@password = random_string
|
155
157
|
@api = TextMagic::API.new(@username, @password)
|
156
158
|
@response = random_string
|
157
159
|
@processed_response = random_string
|
@@ -161,19 +163,19 @@ describe "API" do
|
|
161
163
|
|
162
164
|
it "should call Executor execute with correct arguments" do
|
163
165
|
id = random_string
|
164
|
-
TextMagic::API::Executor.expects(:execute).with("message_status", @username, @password, :
|
166
|
+
TextMagic::API::Executor.expects(:execute).with("message_status", @username, @password, ids: id).returns(@response)
|
165
167
|
@api.message_status(id)
|
166
168
|
end
|
167
169
|
|
168
170
|
it "should join ids supplied as array" do
|
169
171
|
ids = Array.new(3) { random_string }
|
170
|
-
TextMagic::API::Executor.expects(:execute).with("message_status", @username, @password, :
|
172
|
+
TextMagic::API::Executor.expects(:execute).with("message_status", @username, @password, ids: ids.join(","))
|
171
173
|
@api.message_status(ids)
|
172
174
|
end
|
173
175
|
|
174
176
|
it "should join ids supplied as arguments" do
|
175
177
|
ids = Array.new(3) { random_string }
|
176
|
-
TextMagic::API::Executor.expects(:execute).with("message_status", @username, @password, :
|
178
|
+
TextMagic::API::Executor.expects(:execute).with("message_status", @username, @password, ids: ids.join(","))
|
177
179
|
@api.message_status(*ids)
|
178
180
|
end
|
179
181
|
|
@@ -199,7 +201,8 @@ describe "API" do
|
|
199
201
|
describe "Receive command" do
|
200
202
|
|
201
203
|
before do
|
202
|
-
@username
|
204
|
+
@username = random_string
|
205
|
+
@password = random_string
|
203
206
|
@api = TextMagic::API.new(@username, @password)
|
204
207
|
@response = random_string
|
205
208
|
@processed_response = random_string
|
@@ -208,13 +211,13 @@ describe "API" do
|
|
208
211
|
end
|
209
212
|
|
210
213
|
it "should call Executor execute with correct arguments" do
|
211
|
-
TextMagic::API::Executor.expects(:execute).with("receive", @username, @password, :
|
214
|
+
TextMagic::API::Executor.expects(:execute).with("receive", @username, @password, last_retrieved_id: nil)
|
212
215
|
@api.receive
|
213
216
|
end
|
214
217
|
|
215
218
|
it "should accept last_retrieved_id optional value" do
|
216
219
|
last_retrieved_id = rand(1e10)
|
217
|
-
TextMagic::API::Executor.expects(:execute).with("receive", @username, @password, :
|
220
|
+
TextMagic::API::Executor.expects(:execute).with("receive", @username, @password, last_retrieved_id: last_retrieved_id)
|
218
221
|
@api.receive(last_retrieved_id)
|
219
222
|
end
|
220
223
|
|
@@ -227,7 +230,8 @@ describe "API" do
|
|
227
230
|
describe "Delete reply command" do
|
228
231
|
|
229
232
|
before do
|
230
|
-
@username
|
233
|
+
@username = random_string
|
234
|
+
@password = random_string
|
231
235
|
@api = TextMagic::API.new(@username, @password)
|
232
236
|
@response = random_string
|
233
237
|
@processed_response = random_string
|
@@ -237,19 +241,19 @@ describe "API" do
|
|
237
241
|
|
238
242
|
it "should call Executor execute with correct arguments" do
|
239
243
|
id = random_string
|
240
|
-
TextMagic::API::Executor.expects(:execute).with("delete_reply", @username, @password, :
|
244
|
+
TextMagic::API::Executor.expects(:execute).with("delete_reply", @username, @password, ids: id)
|
241
245
|
@api.delete_reply(id)
|
242
246
|
end
|
243
247
|
|
244
248
|
it "should join ids supplied as array" do
|
245
249
|
ids = Array.new(3) { random_string }
|
246
|
-
TextMagic::API::Executor.expects(:execute).with("delete_reply", @username, @password, :
|
250
|
+
TextMagic::API::Executor.expects(:execute).with("delete_reply", @username, @password, ids: ids.join(","))
|
247
251
|
@api.delete_reply(ids)
|
248
252
|
end
|
249
253
|
|
250
254
|
it "should join ids supplied as arguments" do
|
251
255
|
ids = Array.new(3) { random_string }
|
252
|
-
TextMagic::API::Executor.expects(:execute).with("delete_reply", @username, @password, :
|
256
|
+
TextMagic::API::Executor.expects(:execute).with("delete_reply", @username, @password, ids: ids.join(","))
|
253
257
|
@api.delete_reply(*ids)
|
254
258
|
end
|
255
259
|
|
@@ -268,7 +272,8 @@ describe "API" do
|
|
268
272
|
describe "Check number command" do
|
269
273
|
|
270
274
|
before do
|
271
|
-
@username
|
275
|
+
@username = random_string
|
276
|
+
@password = random_string
|
272
277
|
@api = TextMagic::API.new(@username, @password)
|
273
278
|
@response = random_string
|
274
279
|
@processed_response = random_string
|
@@ -278,19 +283,19 @@ describe "API" do
|
|
278
283
|
|
279
284
|
it "should call Executor execute with correct arguments" do
|
280
285
|
phone = random_phone
|
281
|
-
TextMagic::API::Executor.expects(:execute).with("check_number", @username, @password, :
|
286
|
+
TextMagic::API::Executor.expects(:execute).with("check_number", @username, @password, phone: phone)
|
282
287
|
@api.check_number(phone)
|
283
288
|
end
|
284
289
|
|
285
290
|
it "should join phones supplied as array" do
|
286
291
|
phones = Array.new(3) { random_phone }
|
287
|
-
TextMagic::API::Executor.expects(:execute).with("check_number", @username, @password, :
|
292
|
+
TextMagic::API::Executor.expects(:execute).with("check_number", @username, @password, phone: phones.join(","))
|
288
293
|
@api.check_number(phones)
|
289
294
|
end
|
290
295
|
|
291
296
|
it "should join phones supplied as arguments" do
|
292
297
|
phones = Array.new(3) { random_phone }
|
293
|
-
TextMagic::API::Executor.expects(:execute).with("check_number", @username, @password, :
|
298
|
+
TextMagic::API::Executor.expects(:execute).with("check_number", @username, @password, phone: phones.join(","))
|
294
299
|
@api.check_number(*phones)
|
295
300
|
end
|
296
301
|
|
data/test/test_charset.rb
CHANGED
data/test/test_executor.rb
CHANGED
@@ -5,10 +5,10 @@ describe "Executor" do
|
|
5
5
|
describe "execute method" do
|
6
6
|
|
7
7
|
before do
|
8
|
-
|
9
|
-
|
10
|
-
@
|
11
|
-
@
|
8
|
+
@username = random_string
|
9
|
+
@password = random_string
|
10
|
+
@command = random_string
|
11
|
+
@options = random_hash
|
12
12
|
@uri = "https://www.textmagic.com/app/api"
|
13
13
|
end
|
14
14
|
|
@@ -31,28 +31,33 @@ describe "Executor" do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should send a POST request to proper uri" do
|
34
|
-
|
35
|
-
FakeWeb.register_uri(:post, @uri, :body => response)
|
34
|
+
WebMock.stub_request(:post, @uri).to_return(status: 200, body: "{}")
|
36
35
|
TextMagic::API::Executor.execute(@command, @username, @password, @options)
|
37
36
|
end
|
38
37
|
|
39
38
|
it "should not send parameters with nil keys" do
|
40
39
|
options_with_empty_values = @options.merge(nil => random_string)
|
41
|
-
@options.merge!(:
|
42
|
-
|
40
|
+
@options.merge!(username: @username, password: @password, cmd: @command)
|
41
|
+
WebMock.
|
42
|
+
stub_request(:post, @uri).
|
43
|
+
with(body: @options).
|
44
|
+
to_return(status: 200, body: "", headers: {})
|
43
45
|
TextMagic::API::Executor.execute(@command, @username, @password, options_with_empty_values)
|
44
46
|
end
|
45
47
|
|
46
48
|
it "should not send parameters with nil values" do
|
47
49
|
options_with_empty_values = @options.merge(random_string => nil)
|
48
|
-
@options.merge!(:
|
49
|
-
|
50
|
+
@options.merge!(username: @username, password: @password, cmd: @command)
|
51
|
+
WebMock.
|
52
|
+
stub_request(:post, @uri).
|
53
|
+
with(body: @options).
|
54
|
+
to_return(status: 200, body: "", headers: {})
|
50
55
|
TextMagic::API::Executor.execute(@command, @username, @password, options_with_empty_values)
|
51
56
|
end
|
52
57
|
|
53
58
|
it "should raise an error if the response contains error_code" do
|
54
59
|
response = "{\"error_code\":#{1 + rand(10)}}"
|
55
|
-
|
60
|
+
WebMock.stub_request(:post, @uri).to_return(status: 200, body: response)
|
56
61
|
assert_raises TextMagic::API::Error do
|
57
62
|
TextMagic::API::Executor.execute(@command, @username, @password, @options)
|
58
63
|
end
|
@@ -60,9 +65,12 @@ describe "Executor" do
|
|
60
65
|
|
61
66
|
it "should return a hash with values from the response" do
|
62
67
|
hash = { "this" => "is", "just" => "a", "random" => "hash" }
|
63
|
-
|
68
|
+
response = '{"this":"is","just":"a","random":"hash"}'
|
69
|
+
WebMock.stub_request(:post, @uri).to_return(status: 200, body: response)
|
64
70
|
response = TextMagic::API::Executor.execute(@command, @username, @password, @options)
|
65
71
|
assert_equal hash, response.to_hash
|
66
72
|
end
|
73
|
+
|
67
74
|
end
|
75
|
+
|
68
76
|
end
|
data/test/test_helper.rb
CHANGED
@@ -6,7 +6,7 @@ def random_string(legth = 5 + rand(10))
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def random_phone
|
9
|
-
rand(10
|
9
|
+
rand(10**12).to_s
|
10
10
|
end
|
11
11
|
|
12
12
|
def random_hash
|
@@ -15,10 +15,18 @@ def random_hash
|
|
15
15
|
hash
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
module Minitest
|
19
|
+
|
20
|
+
class Test
|
21
|
+
|
22
|
+
def self.it(name, &block)
|
23
|
+
test_name = "test_#{name.gsub(/\s+/, "_")}".to_sym
|
24
|
+
define_method(test_name, &block)
|
25
|
+
end
|
19
26
|
|
20
|
-
def self.it(name, &block)
|
21
|
-
test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
|
22
|
-
define_method(test_name, &block)
|
23
27
|
end
|
28
|
+
|
24
29
|
end
|
30
|
+
|
31
|
+
require "webmock/minitest"
|
32
|
+
WebMock.disable_net_connect!
|
data/test/test_response.rb
CHANGED
@@ -22,7 +22,8 @@ describe "Response" do
|
|
22
22
|
describe "Response to send command with single phone number" do
|
23
23
|
|
24
24
|
before do
|
25
|
-
@message_id
|
25
|
+
@message_id = random_string
|
26
|
+
@phone = random_phone
|
26
27
|
@text = random_string
|
27
28
|
@parts_count = 1 + rand(3)
|
28
29
|
@hash = { "message_id" => { @message_id => @phone }, "sent_text" => @text, "parts_count" => @parts_count }
|
@@ -45,8 +46,10 @@ describe "Response" do
|
|
45
46
|
describe "Response to send command with multiple phone numbers" do
|
46
47
|
|
47
48
|
before do
|
48
|
-
@message_id1
|
49
|
-
@
|
49
|
+
@message_id1 = random_string
|
50
|
+
@phone1 = random_phone
|
51
|
+
@message_id2 = random_string
|
52
|
+
@phone2 = random_phone
|
50
53
|
@text = random_string
|
51
54
|
@parts_count = 1 + rand(3)
|
52
55
|
@hash = { "message_id" => { @message_id1 => @phone1, @message_id2 => @phone2 }, "sent_text" => @text, "parts_count" => @parts_count }
|
@@ -91,8 +94,8 @@ describe "Response" do
|
|
91
94
|
"created_time" => @created_time.to_s,
|
92
95
|
"reply_number" => @reply_number,
|
93
96
|
"completed_time" => @completed_time.to_s,
|
94
|
-
"credits_cost" => @credits_cost
|
95
|
-
}
|
97
|
+
"credits_cost" => @credits_cost,
|
98
|
+
},
|
96
99
|
}
|
97
100
|
@response = TextMagic::API::Response.message_status(@hash, true)
|
98
101
|
end
|
@@ -142,8 +145,8 @@ describe "Response" do
|
|
142
145
|
"created_time" => @created_time,
|
143
146
|
"reply_number" => @reply_number,
|
144
147
|
"completed_time" => @completed_time,
|
145
|
-
"credits_cost" => @credits_cost
|
146
|
-
}
|
148
|
+
"credits_cost" => @credits_cost,
|
149
|
+
},
|
147
150
|
}
|
148
151
|
@response = TextMagic::API::Response.message_status(@hash, false)
|
149
152
|
end
|
@@ -189,12 +192,14 @@ describe "Response" do
|
|
189
192
|
|
190
193
|
before do
|
191
194
|
@timestamp = (Time.now - 30).to_i
|
192
|
-
@text
|
195
|
+
@text = random_string
|
196
|
+
@phone = random_phone
|
197
|
+
@message_id = random_string
|
193
198
|
@message = {
|
194
199
|
"timestamp" => @timestamp,
|
195
200
|
"from" => @phone,
|
196
201
|
"text" => @text,
|
197
|
-
"message_id" => @message_id
|
202
|
+
"message_id" => @message_id,
|
198
203
|
}
|
199
204
|
@unread = rand(1e4)
|
200
205
|
@hash = { "unread" => @unread, "messages" => [@message] }
|
@@ -239,8 +244,8 @@ describe "Response" do
|
|
239
244
|
@hash = {
|
240
245
|
@phone => {
|
241
246
|
"price" => @price,
|
242
|
-
"country" => @country
|
243
|
-
}
|
247
|
+
"country" => @country,
|
248
|
+
},
|
244
249
|
}
|
245
250
|
@response = TextMagic::API::Response.check_number(@hash, true)
|
246
251
|
end
|
@@ -267,8 +272,8 @@ describe "Response" do
|
|
267
272
|
@hash = {
|
268
273
|
@phone => {
|
269
274
|
"price" => @price,
|
270
|
-
"country" => @country
|
271
|
-
}
|
275
|
+
"country" => @country,
|
276
|
+
},
|
272
277
|
}
|
273
278
|
@response = TextMagic::API::Response.check_number(@hash, false)
|
274
279
|
end
|
data/test/test_validation.rb
CHANGED
@@ -75,11 +75,11 @@ describe "Validation" do
|
|
75
75
|
describe "validate_phones method" do
|
76
76
|
|
77
77
|
it "should return true if phone number consists of up to 15 digits" do
|
78
|
-
assert_equal true, TextMagic::API.validate_phones(rand(10
|
78
|
+
assert_equal true, TextMagic::API.validate_phones(rand(10**15).to_s)
|
79
79
|
end
|
80
80
|
|
81
81
|
it "should return false if phone number is longer than 15 digits" do
|
82
|
-
assert_equal false, TextMagic::API.validate_phones((10
|
82
|
+
assert_equal false, TextMagic::API.validate_phones((10**16 + rand(10**15)).to_s)
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should return false if phone number contains non-digits" do
|
@@ -91,7 +91,8 @@ describe "Validation" do
|
|
91
91
|
end
|
92
92
|
|
93
93
|
it "should return true if all phone numbers in a list are valid" do
|
94
|
-
phone1
|
94
|
+
phone1 = rand(10**15).to_s
|
95
|
+
phone2 = rand(10**15).to_s
|
95
96
|
assert_equal true, TextMagic::API.validate_phones(phone1, phone2)
|
96
97
|
assert_equal true, TextMagic::API.validate_phones([phone1, phone2])
|
97
98
|
end
|
@@ -101,7 +102,7 @@ describe "Validation" do
|
|
101
102
|
end
|
102
103
|
|
103
104
|
it "should return false if format of any of phone numbers in a list is invalid" do
|
104
|
-
phone1 = rand(10
|
105
|
+
phone1 = rand(10**15).to_s, rand(10**15).to_s
|
105
106
|
phone2 = random_string
|
106
107
|
assert_equal false, TextMagic::API.validate_phones(phone1, phone2)
|
107
108
|
assert_equal false, TextMagic::API.validate_phones([phone1, phone2])
|
data/textmagic.gemspec
CHANGED
@@ -1,24 +1,23 @@
|
|
1
|
-
|
1
|
+
|
2
2
|
require File.expand_path("../lib/textmagic/version", __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = ["
|
5
|
+
gem.authors = ["Vladimír Bobeš Tužinský"]
|
6
6
|
gem.email = ["vladimir@tuzinsky.com"]
|
7
|
-
gem.summary =
|
8
|
-
gem.description =
|
7
|
+
gem.summary = "Ruby interface to the TextMagic's Bulk SMS Gateway"
|
8
|
+
gem.description = "
|
9
9
|
textmagic is a Ruby interface to the TextMagic's Bulk SMS Gateway.
|
10
10
|
It can be used to easily integrate SMS features into your application.
|
11
11
|
It supports sending messages, receiving replies and more.
|
12
12
|
You need to have a valid TextMagic account to use this gem. You can get one at http://www.textmagic.com.
|
13
|
-
|
14
|
-
gem.homepage = ""
|
13
|
+
"
|
14
|
+
gem.homepage = "https://github.com/bobes/textmagic"
|
15
15
|
|
16
|
-
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
17
17
|
gem.files = `git ls-files`.split("\n")
|
18
18
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
19
|
gem.name = "textmagic"
|
20
|
+
gem.licenses = ["MIT"]
|
20
21
|
gem.require_paths = ["lib"]
|
21
22
|
gem.version = Textmagic::VERSION
|
22
|
-
|
23
|
-
gem.add_runtime_dependency "httparty", "~> 0.5"
|
24
23
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: textmagic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Vladimír Bobeš Tužinský
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: httparty
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0.5'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0.5'
|
11
|
+
date: 2017-10-02 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
27
13
|
description: "\n textmagic is a Ruby interface to the TextMagic's Bulk SMS Gateway.\n
|
28
14
|
\ It can be used to easily integrate SMS features into your application.\n It
|
29
15
|
supports sending messages, receiving replies and more.\n You need to have a valid
|
@@ -38,14 +24,16 @@ extra_rdoc_files: []
|
|
38
24
|
files:
|
39
25
|
- ".document"
|
40
26
|
- ".gitignore"
|
41
|
-
-
|
27
|
+
- ".rubocop.yml"
|
28
|
+
- ".rubocop_todo.yml"
|
29
|
+
- ".ruby-version"
|
42
30
|
- History.txt
|
43
31
|
- LICENSE
|
44
32
|
- README.md
|
45
33
|
- Rakefile
|
46
34
|
- bin/tm
|
35
|
+
- gems.rb
|
47
36
|
- lib/textmagic.rb
|
48
|
-
- lib/textmagic/.rb
|
49
37
|
- lib/textmagic/api.rb
|
50
38
|
- lib/textmagic/charset.rb
|
51
39
|
- lib/textmagic/error.rb
|
@@ -61,8 +49,9 @@ files:
|
|
61
49
|
- test/test_response.rb
|
62
50
|
- test/test_validation.rb
|
63
51
|
- textmagic.gemspec
|
64
|
-
homepage:
|
65
|
-
licenses:
|
52
|
+
homepage: https://github.com/bobes/textmagic
|
53
|
+
licenses:
|
54
|
+
- MIT
|
66
55
|
metadata: {}
|
67
56
|
post_install_message:
|
68
57
|
rdoc_options: []
|
@@ -80,15 +69,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
69
|
version: '0'
|
81
70
|
requirements: []
|
82
71
|
rubyforge_project:
|
83
|
-
rubygems_version: 2.
|
72
|
+
rubygems_version: 2.6.11
|
84
73
|
signing_key:
|
85
74
|
specification_version: 4
|
86
75
|
summary: Ruby interface to the TextMagic's Bulk SMS Gateway
|
87
|
-
test_files:
|
88
|
-
- test/test_api.rb
|
89
|
-
- test/test_charset.rb
|
90
|
-
- test/test_error.rb
|
91
|
-
- test/test_executor.rb
|
92
|
-
- test/test_helper.rb
|
93
|
-
- test/test_response.rb
|
94
|
-
- test/test_validation.rb
|
76
|
+
test_files: []
|
data/Gemfile
DELETED