djanoa 0.0.1
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.
- data/LICENSE.md +24 -0
- data/README.md +52 -0
- data/djanoa.gemspec +20 -0
- data/lib/djanoa/error.rb +18 -0
- data/lib/djanoa/response.rb +29 -0
- data/lib/djanoa.rb +36 -0
- metadata +72 -0
data/LICENSE.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Copyright (c) 1998, Regents of the University of California
|
2
|
+
All rights reserved.
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
4
|
+
modification, are permitted provided that the following conditions are met:
|
5
|
+
|
6
|
+
* Redistributions of source code must retain the above copyright
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
|
+
* Redistributions in binary form must reproduce the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
|
+
* Neither the name of the University of California, Berkeley nor the
|
12
|
+
names of its contributors may be used to endorse or promote products
|
13
|
+
derived from this software without specific prior written permission.
|
14
|
+
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
|
16
|
+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
17
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
|
19
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
20
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
21
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
22
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
23
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
24
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
Djanoa
|
2
|
+
======
|
3
|
+
|
4
|
+
Interface Ruby pour envoyer des SMS avec la plateforme [Djanoa](http://www.djanoa.com).
|
5
|
+
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
```bash
|
9
|
+
gem install djanoa
|
10
|
+
```
|
11
|
+
|
12
|
+
Utilisation
|
13
|
+
-----------
|
14
|
+
|
15
|
+
Il faut d'abord créer un compte sur [le site de djanoa](http://www.djanoa.com).
|
16
|
+
|
17
|
+
Ensuite vous faites les configurations
|
18
|
+
```ruby
|
19
|
+
Djanoa.configure do |config|
|
20
|
+
config.from = VOTRE_NUMERO_COURT
|
21
|
+
config.account_code = CODE_DE_VOTRE_COMPTE
|
22
|
+
config.application_pass = MOT_DE_PASSE
|
23
|
+
end
|
24
|
+
```
|
25
|
+
|
26
|
+
ensuite pour envoyer un SMS il suffit de faire :
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
Djanoa.send_sms '221777777777', 'juste pour tester mon gem'
|
30
|
+
```
|
31
|
+
|
32
|
+
Gestion des erreurs
|
33
|
+
-------------------
|
34
|
+
|
35
|
+
Si vous voulez allez plus loin vous pouvez récupérer la réponse et voir s'il n'y a pas d'erreur.
|
36
|
+
|
37
|
+
Le code suivant permet d'envoyer un SMS et, s'il y'a une erreur, affiche le code de l'erreur, le message d'erreur ainsi que l'adresse IP de l'envoyeur.
|
38
|
+
```ruby
|
39
|
+
r = Djanoa.send_sms '221777777777', 'juste pour tester mon gem'
|
40
|
+
|
41
|
+
if r.sent?
|
42
|
+
puts r.error.code
|
43
|
+
puts r.error.message
|
44
|
+
puts r.error.ip
|
45
|
+
else
|
46
|
+
puts "le sms est envoyé"
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
Copyright
|
51
|
+
---------
|
52
|
+
Copyright 2013 Cheikh Sidya CAMARA. Voir [la LICENSE](https://github.com/scicasoft/djanoa/blob/master/LICENSE.md) pour plus de détails.
|
data/djanoa.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.name = "djanoa"
|
4
|
+
s.version = "0.0.1"
|
5
|
+
s.default_executable = "djanoa"
|
6
|
+
|
7
|
+
s.add_dependency 'rest-client', '>= 1.6.7'
|
8
|
+
s.add_dependency "nokogiri", "~> 1.5.6"
|
9
|
+
s.required_rubygems_version = '>= 1.3.6'
|
10
|
+
s.authors = ["Cheikh Sidya CAMARA"]
|
11
|
+
s.date = %q{2013-03-07}
|
12
|
+
s.description = %q{une gem pour interfacer les applications ruby avec la plateforma Djanoa}
|
13
|
+
s.email = %q{scicasoft@gmail.com}
|
14
|
+
s.files = %w(LICENSE.md README.md djanoa.gemspec)
|
15
|
+
s.files += Dir.glob("lib/**/*.rb")
|
16
|
+
s.homepage = %q{http://rubygems.org/gems/djanoa}
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubygems_version = %q{1.6.2}
|
19
|
+
s.summary = s.description
|
20
|
+
end
|
data/lib/djanoa/error.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Djanoa
|
2
|
+
class Error
|
3
|
+
attr_reader :code, :message, :ip
|
4
|
+
|
5
|
+
# Instantiates a new django error object
|
6
|
+
# @param code [Integer]
|
7
|
+
# @param message [String]
|
8
|
+
# @param ip [String]
|
9
|
+
# @return [Djanoa::Error]
|
10
|
+
|
11
|
+
def initialize code, message, ip
|
12
|
+
@code = code
|
13
|
+
@message = message
|
14
|
+
@ip = ip
|
15
|
+
self
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module Djanoa
|
4
|
+
class Response
|
5
|
+
attr_reader :sent, :error
|
6
|
+
|
7
|
+
# Instantiates a new response object
|
8
|
+
# @param response [String]
|
9
|
+
# @return [Djanoa::Response]
|
10
|
+
|
11
|
+
def initialize response = ""
|
12
|
+
doc = Nokogiri::Slop response
|
13
|
+
@sent = doc.root.name == "DjanoaResponse" ? true : false
|
14
|
+
unless @sent
|
15
|
+
code = doc.DjanoaError.Code.content.to_i
|
16
|
+
message = doc.DjanoaError.Error.content
|
17
|
+
ip = doc.DjanoaError.IP.content
|
18
|
+
@error = Error.new code, message, ip
|
19
|
+
end
|
20
|
+
|
21
|
+
self
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [Boolean]
|
25
|
+
def sent?
|
26
|
+
return @sent
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/djanoa.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'djanoa/error'
|
2
|
+
require 'djanoa/response'
|
3
|
+
|
4
|
+
require 'uri'
|
5
|
+
require 'rest-client'
|
6
|
+
|
7
|
+
module Djanoa
|
8
|
+
BASE_URL = "http://djanoa.com/sms/"
|
9
|
+
class << self
|
10
|
+
attr_writer :from, :account_code, :application_pass
|
11
|
+
attr_reader :response
|
12
|
+
|
13
|
+
# A method to allow configuration options to be set in a block
|
14
|
+
# @return [Djanoa]
|
15
|
+
def configure
|
16
|
+
yield self
|
17
|
+
self
|
18
|
+
end
|
19
|
+
|
20
|
+
# Send a new sms
|
21
|
+
# @param phone [String]
|
22
|
+
# @param message [String]
|
23
|
+
# @return [Djanoa::Response]
|
24
|
+
def send_sms phone, message
|
25
|
+
message = URI.escape message
|
26
|
+
response = RestClient.get "#{sender_base_url}/?from=#{@from}&to=#{phone}&text=#{message}&pass=#{@application_pass}"
|
27
|
+
@response = Response.new response
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def sender_base_url
|
33
|
+
"#{BASE_URL}#{@account_code}/out"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: djanoa
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Cheikh Sidya CAMARA
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: &18793600 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.6.7
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *18793600
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: nokogiri
|
27
|
+
requirement: &19633140 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.5.6
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *19633140
|
36
|
+
description: une gem pour interfacer les applications ruby avec la plateforma Djanoa
|
37
|
+
email: scicasoft@gmail.com
|
38
|
+
executables: []
|
39
|
+
extensions: []
|
40
|
+
extra_rdoc_files: []
|
41
|
+
files:
|
42
|
+
- LICENSE.md
|
43
|
+
- README.md
|
44
|
+
- djanoa.gemspec
|
45
|
+
- lib/djanoa/error.rb
|
46
|
+
- lib/djanoa/response.rb
|
47
|
+
- lib/djanoa.rb
|
48
|
+
homepage: http://rubygems.org/gems/djanoa
|
49
|
+
licenses: []
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.3.6
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.8.17
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: une gem pour interfacer les applications ruby avec la plateforma Djanoa
|
72
|
+
test_files: []
|