smslist 0.0.1 → 0.0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # Smslist
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/smslist.png)][gem]
3
4
  [![Build Status](https://secure.travis-ci.org/lebedev-yury/smslist.png?branch=master)][travis]
4
5
  [![Dependency Status](https://gemnasium.com/lebedev-yury/smslist.png?travis)][gemnasium]
5
6
  [![Code Climate](https://codeclimate.com/github/lebedev-yury/smslist.png)][codeclimate]
6
7
  [![Coverage Status](https://coveralls.io/repos/lebedev-yury/smslist/badge.png?branch=master)][coveralls]
7
8
 
9
+ [gem]: https://rubygems.org/gems/smslist
8
10
  [travis]: http://travis-ci.org/lebedev-yury/smslist
9
11
  [gemnasium]: https://gemnasium.com/lebedev-yury/smslist
10
12
  [codeclimate]: https://codeclimate.com/github/lebedev-yury/smslist
@@ -91,7 +93,6 @@ You will get a hash for id, with state and datetime, or error message.
91
93
  This library aims to support and is [tested against][travis] the following Ruby
92
94
  implementations:
93
95
 
94
- * Ruby 1.8.7
95
96
  * Ruby 1.9.2
96
97
  * Ruby 1.9.3
97
98
  * Ruby 2.0.0
data/Rakefile CHANGED
@@ -4,8 +4,8 @@ Bundler::GemHelper.install_tasks
4
4
  require 'rspec/core/rake_task'
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
 
7
- task :test => :spec
8
- task :default => :spec
7
+ task test: :spec
8
+ task default: :spec
9
9
 
10
10
  namespace :doc do
11
11
  require 'yard'
@@ -2,9 +2,9 @@ module Smslist
2
2
  module Authentication
3
3
  def authentication
4
4
  if token
5
- {:token => token}
5
+ {token: token}
6
6
  elsif login && password
7
- {:login => login, :password => password}
7
+ {login: login, password: password}
8
8
  else
9
9
  raise Smslist::UnauthorizedError.new('Access token, or login '\
10
10
  'and password are not initialized')
@@ -18,11 +18,11 @@ module Smslist
18
18
  end
19
19
 
20
20
  body = build_xml_body do |xml|
21
- xml.message(type: "#{ 'flash' if options[:flash] }sms") {
21
+ xml.message(type:"#{ 'flash' if options[:flash] }sms") {
22
22
  xml.sender sms_sender
23
- xml.text_ text.encode(:xml => :text)
23
+ xml.text_ text.encode(xml: :text)
24
24
  recipients.each_with_index do |recipient, index|
25
- xml.abonent :phone => recipient, :number_sms => index + 1
25
+ xml.abonent phone: recipient, number_sms: index + 1
26
26
  end
27
27
  }
28
28
  end
@@ -38,10 +38,10 @@ module Smslist
38
38
  if node.text == 'send'
39
39
  [
40
40
  recipients[node[:number_sms].to_i - 1],
41
- {:status => :ok, :id => node['id_sms'].to_i, :parts => node['parts'].to_i }
41
+ {status: :ok, id: node['id_sms'].to_i, parts: node['parts'].to_i }
42
42
  ]
43
43
  else
44
- [recipients[node[:number_sms].to_i - 1], { :error => node.text }]
44
+ [recipients[node[:number_sms].to_i - 1], { error: node.text }]
45
45
  end
46
46
  end
47
47
 
@@ -47,13 +47,13 @@ module Smslist
47
47
  [
48
48
  node['id_sms'],
49
49
  {
50
- :state => node.text,
51
- :datetime => DateTime.strptime(node['time'], '%Y-%m-%d %H:%M:%S')
50
+ state: node.text,
51
+ datetime: (DateTime.strptime(node['time'], '%Y-%m-%d %H:%M:%S') rescue nil)
52
52
  }
53
53
  ]
54
54
  else
55
- [node['id_sms'], { :state => node.text,
56
- :error => STATE_ERRORS[node['err'].to_i] }]
55
+ [node['id_sms'], { state: node.text,
56
+ error: STATE_ERRORS[node['err'].to_i] }]
57
57
  end
58
58
  end
59
59
 
@@ -3,14 +3,14 @@ require 'httparty'
3
3
  module Smslist
4
4
  module Request
5
5
  def post(xml, method = nil)
6
- HTTParty.post request_uri(method), :body => xml, :headers => headers
6
+ HTTParty.post request_uri(method), body: xml, headers: headers
7
7
  end
8
8
 
9
9
  def build_xml_body(&block)
10
- Nokogiri::XML::Builder.new(:encoding => 'utf-8') do |xml|
10
+ Nokogiri::XML::Builder.new(encoding: 'utf-8') do |xml|
11
11
  xml.request {
12
12
  xml.security {
13
- authentication.each { |k, v| xml.send(k, :value => v) }
13
+ authentication.each { |k, v| xml.send(k, value: v) }
14
14
  }
15
15
  xml.instance_eval(&block) if block_given?
16
16
  }
@@ -1,3 +1,3 @@
1
1
  module Smslist
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.1.1'
3
3
  end
@@ -4,4 +4,5 @@
4
4
  <state id_sms="1002" time="2011-01-01 12:57:46" err="0">deliver</state>
5
5
  <state id_sms="1003" time="2011-01-01 12:57:46" err="0">expired</state>
6
6
  <state id_sms="1004" time="" err="1">not_deliver</state>
7
+ <state id_sms="1005" time="" err="0">send</state>
7
8
  </response>
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Smslist::Client::Balance do
6
- let(:client) { Smslist::Client.new(:token => 'secret') }
6
+ let(:client) { Smslist::Client.new(token: 'secret') }
7
7
 
8
8
  describe '#balance' do
9
9
  it 'returns remaining balance' do
@@ -6,7 +6,7 @@ describe Smslist::Client::Sms do
6
6
 
7
7
  describe '#send_sms' do
8
8
  context 'sender is set' do
9
- let(:client) { Smslist::Client.new(:token => 'secret', :sender => '4000') }
9
+ let(:client) { Smslist::Client.new(token: 'secret', sender: '4000') }
10
10
  let(:recipients) { %w(79031234567 79032345678 79033456789 79034567890) }
11
11
 
12
12
  before(:each) { stub_post('').to_return(xml_response('sms.xml')) }
@@ -16,18 +16,18 @@ describe Smslist::Client::Sms do
16
16
  end
17
17
 
18
18
  it 'includes a Hash for sent messages, with status, id and parts count' do
19
- expect(client.send_sms('Hello everyone', recipients, :flash => true))
20
- .to include('79031234567' => { :status => :ok, :id => 1001, :parts => 2 })
19
+ expect(client.send_sms('Hello everyone', recipients, flash: true)).
20
+ to include('79031234567' => { status: :ok, id: 1001, parts: 2 })
21
21
  end
22
22
 
23
23
  it 'includes a Hash for not sent messages' do
24
- expect(client.send_sms('Hello everyone', recipients))
25
- .to include('79034567890' => { :error => 'Номер телефона присутствует в стоп-листе.' })
24
+ expect(client.send_sms('Hello everyone', recipients)).
25
+ to include('79034567890' => { error: 'Номер телефона присутствует в стоп-листе.' })
26
26
  end
27
27
  end
28
28
 
29
29
  context 'sender is not set' do
30
- let(:client) { Smslist::Client.new(:token => 'secret') }
30
+ let(:client) { Smslist::Client.new(token: 'secret') }
31
31
  let(:recipients) { %w(79031234567) }
32
32
 
33
33
  it 'raises NoSenderError' do
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  describe Smslist::Client::State do
6
6
 
7
7
  describe '#state' do
8
- let(:client) { Smslist::Client.new(:token => 'secret') }
8
+ let(:client) { Smslist::Client.new(token: 'secret') }
9
9
  let(:message_ids) { %w(1001 1002 1003 1004) }
10
10
 
11
11
  before(:each) { stub_post('state.php').to_return(xml_response('state.xml')) }
@@ -24,9 +24,14 @@ describe Smslist::Client::State do
24
24
  end
25
25
 
26
26
  it 'includes a Hash for not delivered messages' do
27
- expect(client.state(message_ids))
28
- .to include('1004' => { :state => 'not_deliver',
29
- :error => 'The subscriber is absent or out of a coverage' })
27
+ expect(client.state(message_ids)).
28
+ to include('1004' => { state: 'not_deliver',
29
+ error: 'The subscriber is absent or out of a coverage' })
30
+ end
31
+
32
+ it 'includes a Hash for pending messages' do
33
+ expect(client.state(message_ids)).
34
+ to include('1005' => { state: 'send', datetime: nil })
30
35
  end
31
36
  end
32
37
  end
@@ -13,19 +13,19 @@ describe Smslist::Client do
13
13
  describe '#authentication' do
14
14
  it 'hash with a token, if token, login and password are set' do
15
15
  client = Smslist::Client.new(
16
- :login => 'username',
17
- :password => 'secret',
18
- :token => 'api_token'
16
+ login: 'username',
17
+ password: 'secret',
18
+ token: 'api_token'
19
19
  )
20
- expect(client.authentication).to eql({ :token => 'api_token' })
20
+ expect(client.authentication).to eql({ token: 'api_token' })
21
21
  end
22
22
 
23
23
  it 'hash with login and password, if login and password are set' do
24
24
  client = Smslist::Client.new(
25
- :login => 'username',
26
- :password => 'secret'
25
+ login: 'username',
26
+ password: 'secret'
27
27
  )
28
- expect(client.authentication).to eql({ :login => 'username', :password => 'secret' })
28
+ expect(client.authentication).to eql({ login: 'username', password: 'secret' })
29
29
  end
30
30
 
31
31
  it 'raises Smslist::UnauthorizedError, if credentials are not set' do
@@ -38,7 +38,7 @@ describe Smslist::Client do
38
38
  end
39
39
 
40
40
  context 'wrong credentials' do
41
- let(:client) { Smslist::Client.new(:token => 'secret') }
41
+ let(:client) { Smslist::Client.new(token: 'secret') }
42
42
  before(:each) do
43
43
  stub_post('balance.php').to_return(xml_response('wrong_credentials.xml'))
44
44
  end
@@ -8,6 +8,22 @@ describe Smslist do
8
8
  end
9
9
  end
10
10
 
11
+ describe '.method_missing' do
12
+ context 'delegates to new client' do
13
+ let(:client) { Smslist }
14
+ it 'delegates method to Smslist::Client' do
15
+ expect(client.respond_to?(:configure)).to eq(true)
16
+ end
17
+ end
18
+
19
+ context 'delegates to Smslist' do
20
+ let(:client) { Smslist.new }
21
+ it 'delegates method to Smslist::Client' do
22
+ expect(client.respond_to?(:balance)).to eq(true)
23
+ end
24
+ end
25
+ end
26
+
11
27
  describe '.respond_to?' do
12
28
  it 'is true if method exists' do
13
29
  expect(Smslist.respond_to?(:new, true)).to eq(true)
@@ -25,9 +25,9 @@ end
25
25
 
26
26
  def xml_response(file)
27
27
  {
28
- :body => fixture(file),
29
- :headers => {
30
- :content_type => 'text/xml; charset=utf-8'
28
+ body: fixture(file),
29
+ headers: {
30
+ content_type: 'text/xml; charset=utf-8'
31
31
  }
32
32
  }
33
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smslist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-16 00:00:00.000000000 Z
12
+ date: 2013-04-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty