nibbme 1.0.0
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/CHANGELOG.rdoc +0 -0
- data/LICENSE +18 -0
- data/README.rdoc +208 -0
- data/Rakefile +25 -0
- data/config/nibbme.yml +13 -0
- data/lib/nibbme.rb +26 -0
- data/lib/nibbme/abstract_base.rb +10 -0
- data/lib/nibbme/client.rb +4 -0
- data/lib/nibbme/group.rb +4 -0
- data/lib/nibbme/message.rb +19 -0
- data/lib/nibbme/tasks.rb +25 -0
- data/lib/nibbme/version.rb +9 -0
- data/test/nibbme_test.rb +8 -0
- data/test/test_helper.rb +3 -0
- metadata +79 -0
data/CHANGELOG.rdoc
ADDED
File without changes
|
data/LICENSE
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Copyright (c) 2009 Kristijan Sedlak
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
7
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
8
|
+
subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
15
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
16
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,208 @@
|
|
1
|
+
= Nibbme - SMS web service proxy
|
2
|
+
|
3
|
+
The library is a simple {ActiveResource}[http://api.rubyonrails.org/classes/ActiveResource/Base.html]-based
|
4
|
+
proxy that allows you to communicate with the {Nibbme bulk SMS web service}[http://www.nibbme.com].
|
5
|
+
{Nibbme}[http://www.nibbme.com] is a restfull-designed sistem and you can easily {create your own plugin/gem}[http://www.nibbme.com/wiki]
|
6
|
+
based on the Wiki they provide. If you like plugins and gems read on :).
|
7
|
+
|
8
|
+
|
9
|
+
== Installation
|
10
|
+
|
11
|
+
The recommended way is to install a gem:
|
12
|
+
|
13
|
+
gem install nibbme
|
14
|
+
|
15
|
+
Add this line to your rails project's {RAILS_ROOT}/config/environment.rb:
|
16
|
+
|
17
|
+
config.gem 'nibbme'
|
18
|
+
|
19
|
+
Because Rails can't load rake tasks from gems open {RAILS_ROOT}/Rakefile and add this:
|
20
|
+
|
21
|
+
begin
|
22
|
+
require 'nibbme/tasks'
|
23
|
+
rescue LoadError
|
24
|
+
STDERR.puts "Run `rake gems:install` to install nibbme"
|
25
|
+
end
|
26
|
+
|
27
|
+
Open the console and redirect it to your project's root and run the install task:
|
28
|
+
|
29
|
+
$ rake nibbme:install
|
30
|
+
|
31
|
+
The task creates a configuration file inside your {RAILS_ROOT}/config directory. Now
|
32
|
+
open this file and set variables. The file should look something like this:
|
33
|
+
|
34
|
+
# Nibbme configuration file
|
35
|
+
|
36
|
+
default: &defaults
|
37
|
+
site: 'https://www.nibbme.com'
|
38
|
+
email:
|
39
|
+
password:
|
40
|
+
|
41
|
+
development:
|
42
|
+
<<: *defaults
|
43
|
+
|
44
|
+
test:
|
45
|
+
<<: *defaults
|
46
|
+
|
47
|
+
production:
|
48
|
+
<<: *defaults
|
49
|
+
|
50
|
+
That's it! You are ready to rock & role.
|
51
|
+
|
52
|
+
|
53
|
+
== Example usage
|
54
|
+
|
55
|
+
You will use this library like you use any other {ActiveResource}[http://api.rubyonrails.org/classes/ActiveResource/Base.html]
|
56
|
+
classes.
|
57
|
+
|
58
|
+
=== Groups
|
59
|
+
|
60
|
+
You can request data simply by calling a +find+ method.
|
61
|
+
|
62
|
+
groups = Nibbme::Group.find(:all)
|
63
|
+
groups = Nibbme::Group.find(:first)
|
64
|
+
groups = Nibbme::Group.find(:last)
|
65
|
+
|
66
|
+
Note that this will return only the items on the first page. You can pass the +page+ variable to
|
67
|
+
get the items on the subpage. If the request is empty you know there is no more items.
|
68
|
+
|
69
|
+
# Request the second page
|
70
|
+
groups = Nibbme::Group.find(:all, :params => { :page => 1 })
|
71
|
+
|
72
|
+
You can also filter the list through a +tags+ variable.
|
73
|
+
|
74
|
+
# Request the second page but filter only the items containing the words 'sun' and 'fun'
|
75
|
+
groups = Nibbme::Group.find(:all, :params => { :page => 1, :tags => 'sun fun' })
|
76
|
+
|
77
|
+
You can check if an item exists by calling the +exists?+ method.
|
78
|
+
|
79
|
+
# Check if the group with ID=1 exists
|
80
|
+
exists = Nibbme::Group.exists?(1)
|
81
|
+
|
82
|
+
You can also create, update and destroy groups.
|
83
|
+
|
84
|
+
# Create an empty group
|
85
|
+
group = Nibbme::Group.create
|
86
|
+
|
87
|
+
# Create a group with title and destription
|
88
|
+
group = Nibbme::Group.create(:title => 'School friends', :description => 'All my friends from the school in US.')
|
89
|
+
|
90
|
+
# Update a group with ID=15
|
91
|
+
group = Nibbme::Group.find(15)
|
92
|
+
group.title = 'Nibbme Members'
|
93
|
+
group.save
|
94
|
+
|
95
|
+
# Destroy a group with ID=12
|
96
|
+
group = Nibbme::Group.find(12)
|
97
|
+
group.destroy
|
98
|
+
|
99
|
+
=== Clients
|
100
|
+
|
101
|
+
You can request data simply by calling a +find+ method.
|
102
|
+
|
103
|
+
clients = Nibbme::Client.find(:all)
|
104
|
+
clients = Nibbme::Client.find(:first)
|
105
|
+
clients = Nibbme::Client.find(:last)
|
106
|
+
|
107
|
+
Note that this will return only the items on the first page. You can pass the +page+ variable to
|
108
|
+
get the items on the subpage. If the request is empty you know there is no more items.
|
109
|
+
|
110
|
+
# Request the second page
|
111
|
+
clients = Nibbme::Client.find(:all, :params => { :page => 1 })
|
112
|
+
|
113
|
+
You can also filter the list through a +tags+ variable.
|
114
|
+
|
115
|
+
# Request the second page but filter only the items containing the word 'john'
|
116
|
+
clients = Nibbme::Client.find(:all, :params => { :page => 1, :tags => 'john' })
|
117
|
+
|
118
|
+
You can check if an item exists by calling the +exists?+ method.
|
119
|
+
|
120
|
+
# Check if the client with ID=1 exists
|
121
|
+
exists = Nibbme::Client.exists?(1)
|
122
|
+
|
123
|
+
You can also create, update and destroy clients.
|
124
|
+
|
125
|
+
# Create an empty client
|
126
|
+
client = Nibbme::Client.create
|
127
|
+
|
128
|
+
# Create a client with all information
|
129
|
+
client = Nibbme::Client.create(:cell_phone => '99999999', :country_id => 44, :name => 'John', :surname => 'Hill', :group_ids => '22,41,512')
|
130
|
+
|
131
|
+
# Update a client with ID=15
|
132
|
+
client = Nibbme::Client.find(15)
|
133
|
+
client.country_id = 44
|
134
|
+
client.save
|
135
|
+
|
136
|
+
# Destroy a client with ID=12
|
137
|
+
client = Nibbme::Client.find(12)
|
138
|
+
client.destroy
|
139
|
+
|
140
|
+
=== Messages
|
141
|
+
|
142
|
+
You can request data simply by calling a +find+ method.
|
143
|
+
|
144
|
+
messages = Nibbme::Message.find(:all)
|
145
|
+
messages = Nibbme::Message.find(:first)
|
146
|
+
messages = Nibbme::Message.find(:last)
|
147
|
+
|
148
|
+
Note that this will return only the items on the first page. You can pass the +page+ variable to
|
149
|
+
get the items on the subpage. If the request is empty you know there is no more items.
|
150
|
+
|
151
|
+
# Request the second page
|
152
|
+
messages = Nibbme::Message.find(:all, :params => { :page => 1 })
|
153
|
+
|
154
|
+
You can also filter the list through a +tags+ variable.
|
155
|
+
|
156
|
+
# Request the second page but filter only the items containing the word 'john'
|
157
|
+
messages = Nibbme::Message.find(:all, :params => { :page => 1, :tags => 'john' })
|
158
|
+
|
159
|
+
You can check if an item exists by calling the +exists?+ method.
|
160
|
+
|
161
|
+
# Check if the message with ID=1 exists
|
162
|
+
exists = Nibbme::Message.exists?(1)
|
163
|
+
|
164
|
+
You can also create, update and destroy messages.
|
165
|
+
|
166
|
+
# Create an empty message
|
167
|
+
message = Nibbme::Message.create
|
168
|
+
|
169
|
+
# Create a message with a full info
|
170
|
+
message = Nibbme::Message.create(:text => 'This is my SMS message.', :active_from => 3.hours.from_now, :group_ids => '21,44,5')
|
171
|
+
|
172
|
+
# Update a message with ID=15
|
173
|
+
message = Nibbme::Message.find(15)
|
174
|
+
message.text = 'Nibbme is rocks!'
|
175
|
+
message.save
|
176
|
+
|
177
|
+
# Destroy a message with ID=12
|
178
|
+
message = Nibbme::Message.find(12)
|
179
|
+
message.destroy
|
180
|
+
|
181
|
+
You can queue a message by calling a +queue+ method.
|
182
|
+
|
183
|
+
# Queue a message with ID=12
|
184
|
+
message = Nibbme::Message.find(12)
|
185
|
+
message.queue
|
186
|
+
|
187
|
+
You can reset/restart the delivery process by calling a +reset+ method.
|
188
|
+
|
189
|
+
# Reset delivery process for a message with ID=12
|
190
|
+
message = Nibbme::Message.find(12)
|
191
|
+
message.reset
|
192
|
+
|
193
|
+
=== Error Handling
|
194
|
+
|
195
|
+
Similar to ActiveRecord all errors are logged as part of +errors+ variable.
|
196
|
+
|
197
|
+
# Producing an error on the cell_phone field
|
198
|
+
message = Message.create(:cell_phone => 'aaaaa')
|
199
|
+
message.errors[:cell_phone]
|
200
|
+
|
201
|
+
You can find more about error handling {here}[http://api.rubyonrails.org/classes/ActiveResource/Validations.html].
|
202
|
+
|
203
|
+
|
204
|
+
== Links
|
205
|
+
|
206
|
+
* Detailed information about the Nibbme web service are available on {the official Nibbme site}[http://www.nibbme.com].
|
207
|
+
* All the latest Nibbme news and tutorials are available on {the official Nibbme blog site}[http://blog.nibbme.com].
|
208
|
+
* You can find more about Nibbme integration on {the Nibbme WikiBook}[http://www.nibbme.com/wiki].
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
6
|
+
|
7
|
+
desc 'Default: run unit tests.'
|
8
|
+
task :default => :test
|
9
|
+
|
10
|
+
desc 'Test the nibbme plugin.'
|
11
|
+
Rake::TestTask.new(:test) do |t|
|
12
|
+
t.libs << 'lib'
|
13
|
+
t.libs << 'test'
|
14
|
+
t.pattern = 'test/**/*_test.rb'
|
15
|
+
t.verbose = true
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'Generate documentation for the nibbme plugin.'
|
19
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
20
|
+
rdoc.rdoc_dir = 'rdoc'
|
21
|
+
rdoc.title = 'Nibbme'
|
22
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
23
|
+
rdoc.rdoc_files.include('README')
|
24
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
25
|
+
end
|
data/config/nibbme.yml
ADDED
data/lib/nibbme.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Nibbme
|
2
|
+
class Tools
|
3
|
+
class << self
|
4
|
+
|
5
|
+
def config
|
6
|
+
df = File.join(File.dirname(__FILE__), '..', 'config', 'nibbme.yml')
|
7
|
+
cf = File.join(RAILS_ROOT, 'config', 'nibbme.yml')
|
8
|
+
config = YAML.load_file(df)[RAILS_ENV]
|
9
|
+
config = config.merge!(YAML.load_file(cf)[RAILS_ENV]) if File.exists?(cf) && YAML.load_file(cf) && YAML.load_file(cf)[RAILS_ENV]
|
10
|
+
config
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
NIBBME_CONFIG = Nibbme::Tools.config
|
18
|
+
|
19
|
+
%w( nibbme/version
|
20
|
+
nibbme/abstract_base
|
21
|
+
nibbme/client
|
22
|
+
nibbme/group
|
23
|
+
nibbme/message
|
24
|
+
).each do |lib|
|
25
|
+
require File.join(File.dirname(__FILE__), lib)
|
26
|
+
end
|
data/lib/nibbme/group.rb
ADDED
data/lib/nibbme/tasks.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
namespace :nibbme do
|
2
|
+
|
3
|
+
desc "Install Nibbme plugin"
|
4
|
+
task :install do
|
5
|
+
path = File.join(RAILS_ROOT, 'config', 'nibbme.yml')
|
6
|
+
if !File.exists?(path)
|
7
|
+
f = File.new(path, "w")
|
8
|
+
f.puts("# Nibbme configuration file")
|
9
|
+
f.puts("#")
|
10
|
+
f.puts("# development:")
|
11
|
+
f.puts("# <<: *defaults")
|
12
|
+
f.puts("#")
|
13
|
+
f.puts("# test:")
|
14
|
+
f.puts("# <<: *defaults")
|
15
|
+
f.puts("#")
|
16
|
+
f.puts("# production:")
|
17
|
+
f.puts("# <<: *defaults")
|
18
|
+
f.close
|
19
|
+
puts " Create config/nibbme.yml"
|
20
|
+
else
|
21
|
+
puts " Exists config/nibbme.yml"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/test/nibbme_test.rb
ADDED
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nibbme
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 1.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Kristijan Sedlak
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-05-08 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: The nibbme library provides a simple and powerful API for communicationg with the Nibbme SMS web service at www.nibbme.com.
|
22
|
+
email: xpepermint@gmail.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- README.rdoc
|
29
|
+
- LICENSE
|
30
|
+
- CHANGELOG.rdoc
|
31
|
+
files:
|
32
|
+
- Rakefile
|
33
|
+
- lib/nibbme/abstract_base.rb
|
34
|
+
- lib/nibbme/client.rb
|
35
|
+
- lib/nibbme/group.rb
|
36
|
+
- lib/nibbme/message.rb
|
37
|
+
- lib/nibbme/tasks.rb
|
38
|
+
- lib/nibbme/version.rb
|
39
|
+
- lib/nibbme.rb
|
40
|
+
- test/nibbme_test.rb
|
41
|
+
- test/test_helper.rb
|
42
|
+
- config/nibbme.yml
|
43
|
+
- README.rdoc
|
44
|
+
- LICENSE
|
45
|
+
- CHANGELOG.rdoc
|
46
|
+
has_rdoc: true
|
47
|
+
homepage: http://github.com/xpepermint/nibbme
|
48
|
+
licenses: []
|
49
|
+
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options:
|
52
|
+
- --main
|
53
|
+
- README.rdoc
|
54
|
+
- --charset=UTF-8
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
version: "0"
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
version: "0"
|
71
|
+
requirements: []
|
72
|
+
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 1.3.6
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: Nibbme bulk SMS plugin for web frameworks and other applications
|
78
|
+
test_files: []
|
79
|
+
|