djanoa 0.0.1 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/LICENSE.md +18 -22
- data/README.md +13 -6
- data/djanoa.gemspec +12 -13
- data/lib/djanoa.rb +1 -0
- data/lib/djanoa/received_message.rb +35 -0
- data/lib/djanoa/response.rb +1 -1
- data/lib/generators/djanoa/install_generator.rb +43 -0
- data/lib/generators/templates/controller.rb +12 -0
- data/lib/generators/templates/initializer.rb +5 -0
- data/lib/generators/templates/migration.rb +11 -0
- data/lib/generators/templates/model.rb +22 -0
- metadata +17 -9
data/Gemfile
ADDED
data/LICENSE.md
CHANGED
@@ -1,24 +1,20 @@
|
|
1
|
-
Copyright (c)
|
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:
|
1
|
+
Copyright (c) 2013 Cheikh Sidya CAMARA
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
derived from this software without specific prior written permission.
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
14
10
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
SOFTWARE
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Djanoa
|
2
2
|
======
|
3
3
|
|
4
|
-
|
4
|
+
Client Ruby pour la plateforme [Djanoa](http://www.djanoa.com).
|
5
5
|
|
6
6
|
Installation
|
7
7
|
------------
|
@@ -16,9 +16,11 @@ Il faut d'abord créer un compte sur [le site de djanoa](http://www.djanoa.com).
|
|
16
16
|
|
17
17
|
Ensuite vous faites les configurations
|
18
18
|
```ruby
|
19
|
+
require 'djanoa'
|
20
|
+
|
19
21
|
Djanoa.configure do |config|
|
20
|
-
config.from
|
21
|
-
config.account_code
|
22
|
+
config.from = VOTRE_NUMERO_COURT
|
23
|
+
config.account_code = CODE_DE_VOTRE_COMPTE
|
22
24
|
config.application_pass = MOT_DE_PASSE
|
23
25
|
end
|
24
26
|
```
|
@@ -39,14 +41,19 @@ Le code suivant permet d'envoyer un SMS et, s'il y'a une erreur, affiche le code
|
|
39
41
|
r = Djanoa.send_sms '221777777777', 'juste pour tester mon gem'
|
40
42
|
|
41
43
|
if r.sent?
|
44
|
+
puts "le sms est envoyé"
|
45
|
+
else
|
42
46
|
puts r.error.code
|
43
47
|
puts r.error.message
|
44
48
|
puts r.error.ip
|
45
|
-
else
|
46
|
-
puts "le sms est envoyé"
|
47
49
|
end
|
48
50
|
```
|
49
51
|
|
52
|
+
Utilisation avec Rails
|
53
|
+
----------------------
|
54
|
+
|
55
|
+
Coming soon ... :-)
|
56
|
+
|
50
57
|
Copyright
|
51
58
|
---------
|
52
|
-
Copyright 2013 Cheikh Sidya CAMARA. Voir
|
59
|
+
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
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
Gem::Specification.new do |s|
|
3
|
-
s.name
|
4
|
-
s.version
|
5
|
-
s.default_executable
|
3
|
+
s.name = "djanoa"
|
4
|
+
s.version = "1.0.1"
|
5
|
+
s.default_executable = "djanoa"
|
6
6
|
|
7
7
|
s.add_dependency 'rest-client', '>= 1.6.7'
|
8
8
|
s.add_dependency "nokogiri", "~> 1.5.6"
|
9
9
|
s.required_rubygems_version = '>= 1.3.6'
|
10
|
-
s.authors
|
11
|
-
s.date
|
12
|
-
s.description
|
13
|
-
s.email
|
14
|
-
s.files
|
15
|
-
s.
|
16
|
-
s.
|
17
|
-
s.
|
18
|
-
s.
|
19
|
-
s.summary = s.description
|
10
|
+
s.authors = ["Cheikh Sidya CAMARA"]
|
11
|
+
s.date = %q{2013-03-30}
|
12
|
+
s.description = %q{Client Ruby pour la plateforme Djanoa.}
|
13
|
+
s.email = %q{scicasoft@gmail.com}
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.homepage = %q{http://rubygems.org/gems/djanoa}
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubygems_version = %q{1.6.2}
|
18
|
+
s.summary = s.description
|
20
19
|
end
|
data/lib/djanoa.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
module Djanoa
|
2
|
+
class ReceivedMessage
|
3
|
+
attr_reader :from, :to, :message
|
4
|
+
|
5
|
+
# Instantiates a new response object
|
6
|
+
# @param params [Hash]
|
7
|
+
# @return [Djanoa::ReceivedSms]
|
8
|
+
|
9
|
+
def initialize params
|
10
|
+
@from = params[:from]
|
11
|
+
@to = params[:to]
|
12
|
+
@message = params[:text]
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
# Return the words off the sms
|
17
|
+
# @return [Array]
|
18
|
+
|
19
|
+
def words
|
20
|
+
@message.split
|
21
|
+
end
|
22
|
+
|
23
|
+
def method_missing(m, *args)
|
24
|
+
if m.to_s[/word_(.+)_exists?/]
|
25
|
+
return false if $1.to_i.zero?
|
26
|
+
return !words[$1.to_i-1].nil?
|
27
|
+
elsif m.to_s[/word_(.+)/]
|
28
|
+
return nil if $1.to_i.zero?
|
29
|
+
return words[$1.to_i-1]
|
30
|
+
else
|
31
|
+
super
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/djanoa/response.rb
CHANGED
@@ -10,7 +10,7 @@ module Djanoa
|
|
10
10
|
|
11
11
|
def initialize response = ""
|
12
12
|
doc = Nokogiri::Slop response
|
13
|
-
@sent = doc.root.name == "DjanoaResponse"
|
13
|
+
@sent = doc.root.name == "DjanoaResponse"
|
14
14
|
unless @sent
|
15
15
|
code = doc.DjanoaError.Code.content.to_i
|
16
16
|
message = doc.DjanoaError.Error.content
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
module Djanoa
|
5
|
+
module Generators
|
6
|
+
|
7
|
+
class InstallGenerator < Rails::Generators::Base
|
8
|
+
|
9
|
+
include Rails::Generators::Migration
|
10
|
+
source_root File.expand_path("../../templates", __FILE__)
|
11
|
+
|
12
|
+
def self.next_migration_number(dirname)
|
13
|
+
if ActiveRecord::Base.timestamped_migrations
|
14
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
15
|
+
else
|
16
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_migration_file
|
21
|
+
migration_template 'migration.rb', 'db/migrate/djanoa_migration.rb'
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_model
|
25
|
+
template "model.rb", File.join('app/models', "djanoa_message.rb")
|
26
|
+
end
|
27
|
+
|
28
|
+
def create_controller
|
29
|
+
template "controller.rb", File.join('app/controllers', "djanoa_messages_controller.rb")
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_initializer_file
|
33
|
+
template 'initializer.rb', File.join('config/initializers', "djanoa.rb")
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_route
|
37
|
+
route "get '/new_sms' => 'djanoa_messages#new_sms', defaults: {format: 'xml'}"
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
class DjanoaMessagesController < ApplicationController
|
3
|
+
def new_sms
|
4
|
+
message = DjanoaMessage.create(from: params[:from], to: params[:to], message: params[:text])
|
5
|
+
|
6
|
+
reponse = 'Hello :-)'
|
7
|
+
|
8
|
+
respond_to do |format|
|
9
|
+
format.xml {render xml: ({Sms: 'Hello :-)'}.to_xml(root: 'Response'))}
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class DjanoaMessage < ActiveRecord::Base
|
2
|
+
attr_accessible :from, :to, :message
|
3
|
+
|
4
|
+
# Return the words off the sms
|
5
|
+
# @return [Array]
|
6
|
+
|
7
|
+
def words
|
8
|
+
message.split
|
9
|
+
end
|
10
|
+
|
11
|
+
def method_missing(m, *args)
|
12
|
+
if m.to_s[/word_(.+)_exists?/]
|
13
|
+
return false if $1.to_i.zero?
|
14
|
+
return !words[$1.to_i-1].nil?
|
15
|
+
elsif m.to_s[/word_(.+)/]
|
16
|
+
return nil if $1.to_i.zero?
|
17
|
+
return words[$1.to_i-1]
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: djanoa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
16
|
-
requirement: &
|
16
|
+
requirement: &8178400 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.6.7
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *8178400
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: nokogiri
|
27
|
-
requirement: &
|
27
|
+
requirement: &8177220 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,19 +32,26 @@ dependencies:
|
|
32
32
|
version: 1.5.6
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
36
|
-
description:
|
35
|
+
version_requirements: *8177220
|
36
|
+
description: Client Ruby pour la plateforme Djanoa.
|
37
37
|
email: scicasoft@gmail.com
|
38
38
|
executables: []
|
39
39
|
extensions: []
|
40
40
|
extra_rdoc_files: []
|
41
41
|
files:
|
42
|
+
- Gemfile
|
42
43
|
- LICENSE.md
|
43
44
|
- README.md
|
44
45
|
- djanoa.gemspec
|
46
|
+
- lib/djanoa.rb
|
45
47
|
- lib/djanoa/error.rb
|
48
|
+
- lib/djanoa/received_message.rb
|
46
49
|
- lib/djanoa/response.rb
|
47
|
-
- lib/djanoa.rb
|
50
|
+
- lib/generators/djanoa/install_generator.rb
|
51
|
+
- lib/generators/templates/controller.rb
|
52
|
+
- lib/generators/templates/initializer.rb
|
53
|
+
- lib/generators/templates/migration.rb
|
54
|
+
- lib/generators/templates/model.rb
|
48
55
|
homepage: http://rubygems.org/gems/djanoa
|
49
56
|
licenses: []
|
50
57
|
post_install_message:
|
@@ -68,5 +75,6 @@ rubyforge_project:
|
|
68
75
|
rubygems_version: 1.8.17
|
69
76
|
signing_key:
|
70
77
|
specification_version: 3
|
71
|
-
summary:
|
78
|
+
summary: Client Ruby pour la plateforme Djanoa.
|
72
79
|
test_files: []
|
80
|
+
has_rdoc:
|