locasms 0.1.4 → 0.1.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3206ae592ae0a88e7f3622634cfc9eb3bfa1f61
4
- data.tar.gz: c183953bd011a3b8515fee13e4d35e59219d3f43
3
+ metadata.gz: 364b1c84ab3b08af2dbcbc97454606fa196b0c0f
4
+ data.tar.gz: 91f8f1d10f22abce7d0e18a9b2b6437905d61ef3
5
5
  SHA512:
6
- metadata.gz: 3aa9723d090e9549008084b59217db867dd5584ead9e2b6b54f137c4f0b17af73d010236bbe6ea480828c42b1e818280e410fdeaace6e0fe4be821f04004cd36
7
- data.tar.gz: 4d46ad710feacdf3eae061b1c3a69cdf48754ea50c4c48150b66b75a67cf1ded264988d1f100a81d9a180b0b14b61653cae3752c5cfc27d866ca3b74db1503af
6
+ metadata.gz: 4469e3539da0f5f3b9ccbd1376a43b87884fc5c6e9d3024aed4e764452eabb83a5c76c0c8b1fd4cb329008ec7ac78a34e901b69b5d0855ee31938804d5bdb0fa
7
+ data.tar.gz: b03a24dca3edf92af9cb3bcae54acd2285f2beeaef3b2c9df15cc5ffb1f763e6ebbf5302f7e3a7b865187d8a88f96055473830e079913c09ca712b00c8060c0c
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9
4
3
  - 2.0
4
+ - 2.1
5
+ - 2.2
5
6
  env:
6
7
  - TRAVIS=true
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # locasms [![Build Status](https://travis-ci.org/mcorp/locasms.png?branch=master)](https://travis-ci.org/mcorp/locasms) [![Dependency Status](https://gemnasium.com/mcorp/locasms.png)](https://gemnasium.com/mcorp/locasms)
1
+ # locasms [![Build Status](https://travis-ci.org/mcorp/locasms.png?branch=master)](https://travis-ci.org/mcorp/locasms) [![Dependency Status](https://gemnasium.com/mcorp/locasms.png)](https://gemnasium.com/mcorp/locasms) [![Code Climate](https://codeclimate.com/github/mcorp/locasms.png)](https://codeclimate.com/github/mcorp/locasms)
2
2
 
3
3
  Client to consume [LocaSMS api's][0].
4
4
 
@@ -1,3 +1,3 @@
1
1
  module LocaSMS
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
data/lib/locasms.rb CHANGED
@@ -6,9 +6,11 @@ autoload :RestClient, 'rest_client'
6
6
  autoload :Logger, 'logger'
7
7
 
8
8
  module LocaSMS
9
- autoload :Client, 'locasms/client'
10
- autoload :Exception, 'locasms/exception'
11
- autoload :Numbers, 'locasms/numbers'
9
+ autoload :Client, 'locasms/client'
10
+ autoload :Exception, 'locasms/exception'
11
+ autoload :InvalidLogin, 'locasms/exception'
12
+ autoload :InvalidOperation, 'locasms/exception'
13
+ autoload :Numbers, 'locasms/numbers'
12
14
  autoload :RestClient, 'locasms/rest_client'
13
15
 
14
16
  module Helpers
data/locasms.gemspec CHANGED
@@ -6,8 +6,8 @@ require 'locasms/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "locasms"
8
8
  spec.version = LocaSMS::VERSION
9
- spec.authors = ["Adilson Carvalho"]
10
- spec.email = ["lc.adilson@gmail.com"]
9
+ spec.authors = ["Adilson Carvalho", "Leonardo Saraiva", "Marco Carvalho"]
10
+ spec.email = ["lc.adilson@gmail.com", "vyper@maneh.org", "marco.carvalho.swasthya@gmail.com"]
11
11
  spec.description = %q{Cliente para o serviço de disparo de SMS da LocaSMS}
12
12
  spec.summary = %q{Cliente para o serviço de disparo de SMS da LocaSMS}
13
13
  spec.homepage = "https://github.com/mcorp/locasms"
@@ -19,11 +19,11 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency 'bundler', '~> 1.3'
22
- spec.add_development_dependency 'rake', '~> 0.9.2'
22
+ spec.add_development_dependency 'rake', '~> 10.4.2'
23
23
 
24
24
  # test stuff
25
- spec.add_development_dependency 'rspec', '~> 2.5'
26
- spec.add_development_dependency 'fuubar', '~> 1.1.0'
25
+ spec.add_development_dependency 'rspec', '~> 3.2'
26
+ spec.add_development_dependency 'fuubar', '~> 2.0.0'
27
27
 
28
28
  # run tests automatically
29
29
  spec.add_development_dependency 'guard'
@@ -5,18 +5,18 @@ describe LocaSMS::Client do
5
5
  subject { LocaSMS::Client.new :login, :password, rest_client: rest_client }
6
6
 
7
7
  describe '.initialize' do
8
- it { subject.login.should be(:login) }
9
- it { subject.password.should be(:password) }
8
+ it { expect(subject.login).to be(:login) }
9
+ it { expect(subject.password).to be(:password) }
10
10
  end
11
11
 
12
12
  describe '#deliver' do
13
13
  it 'Should send SMS' do
14
- subject.should_receive(:numbers)
14
+ expect(subject).to receive(:numbers)
15
15
  .once
16
16
  .with([:a, :b, :c])
17
17
  .and_return('XXX')
18
18
 
19
- rest_client.should_receive(:get)
19
+ expect(rest_client).to receive(:get)
20
20
  .once
21
21
  .with(:sendsms, msg: 'given message', numbers:'XXX')
22
22
  .and_return({})
@@ -25,30 +25,30 @@ describe LocaSMS::Client do
25
25
  end
26
26
 
27
27
  it 'Should not send SMS' do
28
- subject.should_receive(:numbers)
28
+ expect(subject).to receive(:numbers)
29
29
  .once
30
30
  .with([:a, :b, :c])
31
31
  .and_raise(LocaSMS::Exception)
32
32
 
33
- rest_client.should_receive(:get).never
33
+ expect(rest_client).to receive(:get).never
34
34
 
35
- lambda{ subject.deliver('given message', :a, :b, :c) }.should raise_error(LocaSMS::Exception)
35
+ expect { subject.deliver('given message', :a, :b, :c) }.to raise_error(LocaSMS::Exception)
36
36
  end
37
37
  end
38
38
 
39
39
  describe '#deliver_at' do
40
40
  it 'Should send SMS' do
41
- subject.should_receive(:numbers)
41
+ expect(subject).to receive(:numbers)
42
42
  .once
43
43
  .with([:a, :b, :c])
44
44
  .and_return('XXX')
45
45
 
46
- LocaSMS::Helpers::DateTimeHelper.should_receive(:split)
46
+ expect(LocaSMS::Helpers::DateTimeHelper).to receive(:split)
47
47
  .once
48
48
  .with(:datetime)
49
49
  .and_return(%w[date time])
50
50
 
51
- rest_client.should_receive(:get)
51
+ expect(rest_client).to receive(:get)
52
52
  .once
53
53
  .with(:sendsms, msg: 'given message', numbers:'XXX', jobdate: 'date', jobtime: 'time')
54
54
  .and_return({})
@@ -57,25 +57,25 @@ describe LocaSMS::Client do
57
57
  end
58
58
 
59
59
  it 'Should not send SMS' do
60
- subject.should_receive(:numbers)
60
+ expect(subject).to receive(:numbers)
61
61
  .once
62
62
  .with([:a, :b, :c])
63
63
  .and_raise(LocaSMS::Exception)
64
64
 
65
- LocaSMS::Helpers::DateTimeHelper.should_receive(:split)
65
+ expect(LocaSMS::Helpers::DateTimeHelper).to receive(:split)
66
66
  .once
67
67
  .with(:datetime)
68
68
  .and_return(%w[date time])
69
69
 
70
- rest_client.should_receive(:get).never
70
+ expect(rest_client).to receive(:get).never
71
71
 
72
- lambda{ subject.deliver_at('given message', :datetime, :a, :b, :c) }.should raise_error(LocaSMS::Exception)
72
+ expect { subject.deliver_at('given message', :datetime, :a, :b, :c) }.to raise_error(LocaSMS::Exception)
73
73
  end
74
74
  end
75
75
 
76
76
  describe '#balance' do
77
77
  it 'Should check param assignment' do
78
- rest_client.should_receive(:get)
78
+ expect(rest_client).to receive(:get)
79
79
  .once
80
80
  .with(:getbalance)
81
81
  .and_return({})
@@ -92,7 +92,7 @@ describe LocaSMS::Client do
92
92
  campaign_release: :releasesms
93
93
  }[method]
94
94
 
95
- rest_client.should_receive(:get)
95
+ expect(rest_client).to receive(:get)
96
96
  .once
97
97
  .with(rest_method, id: '12345')
98
98
  .and_return({})
@@ -5,7 +5,7 @@ describe LocaSMS::Helpers::DateTimeHelper do
5
5
 
6
6
  describe '#parse' do
7
7
  it 'Should call the class method' do
8
- subject.should_receive(:parse)
8
+ expect(subject).to receive(:parse)
9
9
  .once
10
10
  .with(:value)
11
11
 
@@ -15,7 +15,7 @@ describe LocaSMS::Helpers::DateTimeHelper do
15
15
 
16
16
  describe '#split' do
17
17
  it 'Should call the class method' do
18
- subject.should_receive(:split)
18
+ expect(subject).to receive(:split)
19
19
  .once
20
20
  .with(:value)
21
21
 
@@ -38,12 +38,12 @@ describe LocaSMS::Helpers::DateTimeHelper do
38
38
 
39
39
  describe '.split' do
40
40
  it 'Should break a date into date and time' do
41
- subject.should_receive(:parse)
41
+ expect(subject).to receive(:parse)
42
42
  .once
43
43
  .with(:datetime)
44
44
  .and_return(Time.parse('1977-03-14 14:12:00'))
45
45
 
46
- subject.split(:datetime).should == %w(14/03/1977 14:12)
46
+ expect(subject.split(:datetime)).to eq(%w(14/03/1977 14:12))
47
47
  end
48
48
  end
49
49
 
@@ -5,74 +5,102 @@ describe LocaSMS::Numbers do
5
5
 
6
6
  describe '.initialize' do
7
7
  subject do
8
- LocaSMS::Numbers.any_instance
9
- .should_receive(:evaluate)
10
- .once
11
- .with([:numbers])
12
- .and_return({ good: [1,3], bad: [2,4] })
8
+ expect_any_instance_of(LocaSMS::Numbers).
9
+ to receive(:evaluate).
10
+ once.
11
+ with([:numbers]).
12
+ and_return(good: [1, 3], bad: [2, 4])
13
13
  LocaSMS::Numbers.new :numbers
14
14
  end
15
15
 
16
- it{ subject.good.should == [1,3] }
17
- it{ subject.bad.should == [2,4] }
16
+ it { expect(subject.good).to eq([1, 3]) }
17
+ it { expect(subject.bad).to eq([2, 4]) }
18
18
  end
19
19
 
20
20
  describe '#normalize' do
21
- it{ subject.normalize('+55 (11) 8888-9999').should == %w(551188889999) }
22
- it{ subject.normalize('55', ['11', '22']).should == %w(55 11 22) }
23
- it{ subject.normalize(['55', 'ZZ', '22']).should == %w(55 ZZ 22) }
24
- it{ subject.normalize('55,44,33', ['ZZ', '22,11']).should == %w(55 44 33 ZZ 22 11) }
25
- it{ subject.normalize(55, [11, 22]).should == %w(55 11 22) }
26
- it{ subject.normalize('Z').should == ['Z'] }
27
- it{ subject.normalize(nil).should == [] }
21
+ it do
22
+ expect(subject.normalize('+55 (11) 8888-9999')).to(
23
+ eq(%w(551188889999))
24
+ )
25
+ end
26
+ it do
27
+ expect(subject.normalize('55', ['11', '22'])).to(
28
+ eq(%w(55 11 22))
29
+ )
30
+ end
31
+ it do
32
+ expect(subject.normalize(['55', 'ZZ', '22'])).to(
33
+ eq(%w(55 ZZ 22))
34
+ )
35
+ end
36
+ it do
37
+ expect(subject.normalize('55,44,33', ['ZZ', '22,11'])).to(
38
+ eq(%w(55 44 33 ZZ 22 11))
39
+ )
40
+ end
41
+ it do
42
+ expect(subject.normalize(55, [11, 22])).to(
43
+ eq(%w(55 11 22))
44
+ )
45
+ end
46
+ it { expect(subject.normalize('Z')).to eq(['Z']) }
47
+ it { expect(subject.normalize(nil)).to eq([]) }
28
48
  end
29
49
 
30
50
  describe '#valid_number?' do
31
- it{ subject.valid_number?('+55 (11) 8888-9999').should be_false }
32
- it{ subject.valid_number?('88889999').should be_false }
33
- it{ subject.valid_number?('988889999').should be_false }
34
- it{ subject.valid_number?('ABC').should be_false }
35
- it{ subject.valid_number?('').should be_false }
36
- it{ subject.valid_number?(nil).should be_false }
51
+ it { expect(subject.valid_number?('+55 (11) 8888-9999')).to be_falsey }
52
+ it { expect(subject.valid_number?('88889999')).to be_falsey }
53
+ it { expect(subject.valid_number?('988889999')).to be_falsey }
54
+ it { expect(subject.valid_number?('ABC')).to be_falsey }
55
+ it { expect(subject.valid_number?('')).to be_falsey }
56
+ it { expect(subject.valid_number?(nil)).to be_falsey }
37
57
 
38
- it{ subject.valid_number?('1188889999').should be_true }
39
- it{ subject.valid_number?('11988889999').should be_true }
58
+ it { expect(subject.valid_number?('1188889999')).to be_truthy }
59
+ it { expect(subject.valid_number?('11988889999')).to be_truthy }
40
60
  end
41
61
 
42
62
  describe '#evaluate' do
43
63
  it 'Should separate numbers in good and bad' do
44
- subject.should_receive(:normalize)
45
- .once
46
- .with([:numbers])
47
- .and_return([:good, :bad])
48
- subject.should_receive(:valid_number?)
49
- .once
50
- .with(:good)
51
- .and_return(true)
52
- subject.should_receive(:valid_number?)
53
- .once
54
- .with(:bad)
55
- .and_return(false)
56
- subject.evaluate(:numbers).should == { good: [:good], bad: [:bad] }
64
+ expect(subject).to receive(:normalize).
65
+ once.
66
+ with([:numbers]).
67
+ and_return([:good, :bad])
68
+ expect(subject).to receive(:valid_number?).
69
+ once.
70
+ with(:good).
71
+ and_return(true)
72
+ expect(subject).to receive(:valid_number?).
73
+ once.
74
+ with(:bad).
75
+ and_return(false)
76
+ expect(subject.evaluate(:numbers)).to(
77
+ eq(good: [:good], bad: [:bad])
78
+ )
57
79
  end
58
80
  end
59
81
 
60
82
  describe '#bad?' do
61
- it{ subject.should_receive(:bad).once.and_return([ ]); subject.bad?.should be_false }
62
- it{ subject.should_receive(:bad).once.and_return([1]); subject.bad?.should be_true }
83
+ it do
84
+ expect(subject).to receive(:bad).once.and_return([ ])
85
+ expect(subject.bad?).to be_falsey
86
+ end
87
+ it do
88
+ expect(subject).to receive(:bad).once.and_return([1])
89
+ expect(subject.bad?).to be_truthy
90
+ end
63
91
  end
64
92
 
65
93
  describe '#to_s' do
66
94
  it 'Should return and empty string' do
67
- subject.to_s.should == ''
95
+ expect(subject.to_s).to eq('')
68
96
  end
69
97
 
70
98
  it 'Should return all good numbers in a string comma separated' do
71
- subject.should_receive(:good)
72
- .once
73
- .and_return([1,2,3,4])
74
- subject.to_s.should == '1,2,3,4'
99
+ expect(subject).to receive(:good).
100
+ once.
101
+ and_return([1, 2, 3, 4])
102
+ expect(subject.to_s).to eq('1,2,3,4')
75
103
  end
76
104
  end
77
105
 
78
- end
106
+ end
@@ -4,8 +4,8 @@ describe LocaSMS::RestClient do
4
4
  describe '.initialize' do
5
5
  context 'When giving proper initialization parameters' do
6
6
  subject { LocaSMS::RestClient.new :url, :params }
7
- it { subject.base_url.should be(:url) }
8
- it { subject.base_params.should be(:params) }
7
+ it { expect(subject.base_url).to be(:url) }
8
+ it { expect(subject.base_params).to be(:params) }
9
9
  end
10
10
  end
11
11
 
@@ -16,31 +16,31 @@ describe LocaSMS::RestClient do
16
16
  describe '#params_for' do
17
17
  subject { LocaSMS::RestClient.new :url, { b1: 'X' } }
18
18
 
19
- it{ subject.params_for(:action).should == {action: :action, b1: 'X'} }
20
- it{ subject.params_for(:action, p1: 10).should == {action: :action, b1: 'X', p1: 10} }
19
+ it { expect(subject.params_for(:action)).to eq({action: :action, b1: 'X'}) }
20
+ it { expect(subject.params_for(:action, p1: 10)).to eq({action: :action, b1: 'X', p1: 10}) }
21
21
  end
22
22
 
23
23
  describe '#parse_response' do
24
24
  subject { LocaSMS::RestClient.new :url, :params }
25
25
 
26
26
  it 'Should raise exception on invalid operation' do
27
- lambda{ subject.parse_response(:action, '0:OPERACAO INVALIDA') }.should raise_error(LocaSMS::InvalidOperation)
27
+ expect { subject.parse_response(:action, '0:OPERACAO INVALIDA') }.to raise_error(LocaSMS::InvalidOperation)
28
28
  end
29
29
 
30
30
  it 'Should raise exception on a failed response' do
31
- lambda{ subject.parse_response(:action, '{"status":0,"data":null,"msg":"FALHA EPICA"}') }.should raise_error(LocaSMS::Exception, 'FALHA EPICA')
31
+ expect { subject.parse_response(:action, '{"status":0,"data":null,"msg":"FALHA EPICA"}') }.to raise_error(LocaSMS::Exception, 'FALHA EPICA')
32
32
  end
33
33
 
34
34
  it 'Should raise exception on a failed login attempt' do
35
- lambda{ subject.parse_response(:action, '{"status":0,"data":null,"msg":"FALHA AO REALIZAR LOGIN"}') }.should raise_error(LocaSMS::InvalidLogin)
35
+ expect { subject.parse_response(:action, '{"status":0,"data":null,"msg":"FALHA AO REALIZAR LOGIN"}') }.to raise_error(LocaSMS::InvalidLogin)
36
36
  end
37
37
 
38
38
  it 'Should return the non-json value as a json' do
39
- subject.parse_response(:action, 'non-json return').should == {'status' => 1, 'data' => 'non-json return', "msg" => nil}
39
+ expect(subject.parse_response(:action, 'non-json return')).to eq({'status' => 1, 'data' => 'non-json return', "msg" => nil})
40
40
  end
41
41
 
42
42
  it 'Should return a parsed json return' do
43
- subject.parse_response(:action, '{"status":1,"data":28,"msg":null}').should == {'status' => 1, 'data' => 28, "msg" => nil}
43
+ expect(subject.parse_response(:action, '{"status":1,"data":28,"msg":null}')).to eq({'status' => 1, 'data' => 28, "msg" => nil})
44
44
  end
45
45
  end
46
46
 
metadata CHANGED
@@ -1,14 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locasms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adilson Carvalho
8
+ - Leonardo Saraiva
9
+ - Marco Carvalho
8
10
  autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
11
- date: 2013-10-17 00:00:00.000000000 Z
13
+ date: 2015-03-10 00:00:00.000000000 Z
12
14
  dependencies:
13
15
  - !ruby/object:Gem::Dependency
14
16
  name: bundler
@@ -30,42 +32,42 @@ dependencies:
30
32
  requirements:
31
33
  - - ~>
32
34
  - !ruby/object:Gem::Version
33
- version: 0.9.2
35
+ version: 10.4.2
34
36
  type: :development
35
37
  prerelease: false
36
38
  version_requirements: !ruby/object:Gem::Requirement
37
39
  requirements:
38
40
  - - ~>
39
41
  - !ruby/object:Gem::Version
40
- version: 0.9.2
42
+ version: 10.4.2
41
43
  - !ruby/object:Gem::Dependency
42
44
  name: rspec
43
45
  requirement: !ruby/object:Gem::Requirement
44
46
  requirements:
45
47
  - - ~>
46
48
  - !ruby/object:Gem::Version
47
- version: '2.5'
49
+ version: '3.2'
48
50
  type: :development
49
51
  prerelease: false
50
52
  version_requirements: !ruby/object:Gem::Requirement
51
53
  requirements:
52
54
  - - ~>
53
55
  - !ruby/object:Gem::Version
54
- version: '2.5'
56
+ version: '3.2'
55
57
  - !ruby/object:Gem::Dependency
56
58
  name: fuubar
57
59
  requirement: !ruby/object:Gem::Requirement
58
60
  requirements:
59
61
  - - ~>
60
62
  - !ruby/object:Gem::Version
61
- version: 1.1.0
63
+ version: 2.0.0
62
64
  type: :development
63
65
  prerelease: false
64
66
  version_requirements: !ruby/object:Gem::Requirement
65
67
  requirements:
66
68
  - - ~>
67
69
  - !ruby/object:Gem::Version
68
- version: 1.1.0
70
+ version: 2.0.0
69
71
  - !ruby/object:Gem::Dependency
70
72
  name: guard
71
73
  requirement: !ruby/object:Gem::Requirement
@@ -167,6 +169,8 @@ dependencies:
167
169
  description: Cliente para o serviço de disparo de SMS da LocaSMS
168
170
  email:
169
171
  - lc.adilson@gmail.com
172
+ - vyper@maneh.org
173
+ - marco.carvalho.swasthya@gmail.com
170
174
  executables: []
171
175
  extensions: []
172
176
  extra_rdoc_files: []
@@ -213,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
217
  version: '0'
214
218
  requirements: []
215
219
  rubyforge_project:
216
- rubygems_version: 2.0.6
220
+ rubygems_version: 2.4.6
217
221
  signing_key:
218
222
  specification_version: 4
219
223
  summary: Cliente para o serviço de disparo de SMS da LocaSMS