textveloper 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f9d538254268a34a6d2b4ff94357781dc437f09
4
- data.tar.gz: c2acc9fbea122f270005d18add10428ad6b80780
3
+ metadata.gz: fb13e6515739f34b203ac84a0d13a326c3661a7a
4
+ data.tar.gz: 455fe700e59e2a684ce6321aaa61de83a93c0365
5
5
  SHA512:
6
- metadata.gz: 4d5b4d61a0a861accb362860835338f0000c1f9b47ed05bca3673f600607f702e2097a2e91a2e583a68c24fecea9d4d55bee498de2af31f6d40f61b4a4a548ec
7
- data.tar.gz: 692d74e8319d1b91bcbb56e3f61b5e96dee8484205d835f4bfeb5a5aa3eb01190868dc18cdd04e8ae78a6fe4b4038b51635fc27176eba8bbb896799a9f7a2aa5
6
+ metadata.gz: f64e59c6063f38108cf3ae246c1d32a0a90dff01279c7cdbc72a26799b30e69641424b0fb7463925a134b77af26b4d0620dc2ae0467c42f81e9dbc938103a798
7
+ data.tar.gz: 3fc202d17f5c90c636bfa11d1534e87ca426036cd6e48b7467dc267c10d8b73abdf8f899f69189e2a7712322c4d66d2891b1c5518a0c17d3b3fc8ce2ee10f36f
data/lib/textveloper.rb CHANGED
@@ -36,7 +36,7 @@ module Textveloper
36
36
 
37
37
  def send_sms(number,message)
38
38
  response = []
39
- if message.size <= 140
39
+ if message.size <= 160
40
40
  response << core_operation(number,message)
41
41
  else
42
42
  chunck_message(message).each do |m|
@@ -48,7 +48,7 @@ module Textveloper
48
48
 
49
49
  def mass_messages(numbers, message)
50
50
  response = []
51
- if message.size <= 140
51
+ if message.size <= 160
52
52
  numbers.each do |number|
53
53
  response << core_operation(number, message)
54
54
  end
@@ -112,6 +112,8 @@ module Textveloper
112
112
  data
113
113
  end
114
114
 
115
+ private
116
+
115
117
  def format_phone(phone_number)
116
118
  phone_number.nil? ? "" : phone_number.gsub(/\W/,"").sub(/^58/,"").sub(/(^4)/, '0\1')
117
119
  end
@@ -121,10 +123,14 @@ module Textveloper
121
123
  end
122
124
 
123
125
  def chunck_message(message)
124
- message.scan(/.{1,140}/)
126
+ #Leave space for pagination i.e: "BLAh blah blah (2/3)"
127
+ paginate(message.scan(/.{1,155}/).map(&:strip))
128
+ end
129
+
130
+ def paginate(arr)
131
+ arr.map!.with_index {|elem,i| elem << " #{i+1}/#{arr.size}" }
125
132
  end
126
133
 
127
- private
128
134
 
129
135
  def url
130
136
  'http://api.textveloper.com/'
@@ -1,3 +1,3 @@
1
1
  module Textveloper
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -54,18 +54,18 @@ describe Textveloper do
54
54
  end
55
55
 
56
56
  it "formatear el numero de telefono a la forma 04xxxxxxxx" do
57
- notificator.format_phone("+584121234567").should eq("04121234567")
58
- notificator.format_phone("+58-412.123.45.67").should eq("04121234567")
59
- notificator.format_phone("0412-123-45-67").should eq("04121234567")
60
- notificator.format_phone("0412.123.45.67").should eq("04121234567")
61
- notificator.format_phone("+58-412.158.58.58").should eq("04121585858")
62
- notificator.format_phone("58.412.1.2.3.4.5.6.7").should eq("04121234567")
63
- notificator.format_phone("+58 412 123 45 67").should eq("04121234567")
57
+ notificator.send(:format_phone,"+584121234567").should eq("04121234567")
58
+ notificator.send(:format_phone,"+58-412.123.45.67").should eq("04121234567")
59
+ notificator.send(:format_phone,"0412-123-45-67").should eq("04121234567")
60
+ notificator.send(:format_phone,"0412.123.45.67").should eq("04121234567")
61
+ notificator.send(:format_phone,"+58-412.158.58.58").should eq("04121585858")
62
+ notificator.send(:format_phone,"58.412.1.2.3.4.5.6.7").should eq("04121234567")
63
+ notificator.send(:format_phone,"+58 412 123 45 67").should eq("04121234567")
64
64
 
65
65
  end
66
66
 
67
67
  it "formatear response a hash " do
68
- notificator.hash_contructor(points).should eq(hash_response_points)
68
+ notificator.send(:hash_contructor,points).should eq(hash_response_points)
69
69
  end
70
70
 
71
71
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: textveloper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gustavo Gimenez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-10 00:00:00.000000000 Z
11
+ date: 2014-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curb