connfu-client 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/.rspec +3 -0
- data/.rvmrc +2 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +120 -0
- data/LICENSE.txt +661 -0
- data/README.rdoc +398 -0
- data/Rakefile +38 -0
- data/bin/.DS_Store +0 -0
- data/bin/connfu-client +94 -0
- data/connfu-client.gemspec +41 -0
- data/examples/conference/application.rb +68 -0
- data/examples/conference/conference.rb +33 -0
- data/examples/conference/conference_app.rb +25 -0
- data/examples/conference/connfu.log +5 -0
- data/examples/conference/wall.rb +11 -0
- data/examples/provisioning/app/get.rb +29 -0
- data/examples/provisioning/channels/get.rb +34 -0
- data/examples/provisioning/rss/create.rb +28 -0
- data/examples/provisioning/rss/delete.rb +27 -0
- data/examples/provisioning/rss/get.rb +32 -0
- data/examples/provisioning/rss/put.rb +29 -0
- data/examples/provisioning/setup.rb +2 -0
- data/examples/provisioning/twitter/create.rb +31 -0
- data/examples/provisioning/twitter/delete.rb +27 -0
- data/examples/provisioning/twitter/get.rb +32 -0
- data/examples/provisioning/twitter/put.rb +29 -0
- data/examples/provisioning/voice/create.rb +26 -0
- data/examples/provisioning/voice/delete.rb +27 -0
- data/examples/provisioning/voice/get.rb +36 -0
- data/examples/provisioning/voice/phones/create.rb +26 -0
- data/examples/provisioning/voice/phones/delete.rb +28 -0
- data/examples/provisioning/voice/phones/get.rb +38 -0
- data/examples/provisioning/voice/put.rb +38 -0
- data/examples/provisioning/voice/whitelist/create.rb +26 -0
- data/examples/provisioning/voice/whitelist/delete.rb +27 -0
- data/examples/provisioning/voice/whitelist/get.rb +36 -0
- data/examples/provisioning/voice/whitelist/put.rb +27 -0
- data/lib/connfu.rb +134 -0
- data/lib/connfu/cli/generator.rb +71 -0
- data/lib/connfu/connfu_logger.rb +88 -0
- data/lib/connfu/connfu_message_formatter.rb +134 -0
- data/lib/connfu/connfu_stream.rb +182 -0
- data/lib/connfu/dispatcher.rb +164 -0
- data/lib/connfu/dsl.rb +84 -0
- data/lib/connfu/events.rb +32 -0
- data/lib/connfu/listener.rb +85 -0
- data/lib/connfu/listener_channel.rb +100 -0
- data/lib/connfu/message.rb +74 -0
- data/lib/connfu/provisioning.rb +12 -0
- data/lib/connfu/provisioning/application.rb +374 -0
- data/lib/connfu/provisioning/base.rb +95 -0
- data/lib/connfu/provisioning/channel.rb +79 -0
- data/lib/connfu/provisioning/phone.rb +55 -0
- data/lib/connfu/provisioning/rss.rb +21 -0
- data/lib/connfu/provisioning/twitter.rb +28 -0
- data/lib/connfu/provisioning/voice.rb +89 -0
- data/lib/connfu/provisioning/whitelist.rb +62 -0
- data/lib/connfu/version.rb +6 -0
- data/lib/rdoc/generator/template/connfu/_context.rhtml +209 -0
- data/lib/rdoc/generator/template/connfu/_head.rhtml +7 -0
- data/lib/rdoc/generator/template/connfu/class.rhtml +38 -0
- data/lib/rdoc/generator/template/connfu/file.rhtml +36 -0
- data/lib/rdoc/generator/template/connfu/index.rhtml +13 -0
- data/lib/rdoc/generator/template/connfu/resources/apple-touch-icon.png +0 -0
- data/lib/rdoc/generator/template/connfu/resources/css/github.css +129 -0
- data/lib/rdoc/generator/template/connfu/resources/css/main.css +339 -0
- data/lib/rdoc/generator/template/connfu/resources/css/panel.css +389 -0
- data/lib/rdoc/generator/template/connfu/resources/css/reset.css +53 -0
- data/lib/rdoc/generator/template/connfu/resources/favicon.ico +0 -0
- data/lib/rdoc/generator/template/connfu/resources/i/arrows.png +0 -0
- data/lib/rdoc/generator/template/connfu/resources/i/results_bg.png +0 -0
- data/lib/rdoc/generator/template/connfu/resources/i/tree_bg.png +0 -0
- data/lib/rdoc/generator/template/connfu/resources/js/highlight.pack.js +1 -0
- data/lib/rdoc/generator/template/connfu/resources/js/jquery-1.3.2.min.js +19 -0
- data/lib/rdoc/generator/template/connfu/resources/js/jquery-effect.js +593 -0
- data/lib/rdoc/generator/template/connfu/resources/js/main.js +20 -0
- data/lib/rdoc/generator/template/connfu/resources/js/searchdoc.js +628 -0
- data/lib/rdoc/generator/template/connfu/resources/panel/index.html +72 -0
- data/lib/rdoc/generator/template/connfu/se_index.rhtml +8 -0
- data/spec/connfu_message_formatter_spec.rb +88 -0
- data/spec/connfu_spec.rb +51 -0
- data/spec/connfu_stream_spec.rb +84 -0
- data/spec/dispatcher_spec.rb +227 -0
- data/spec/dsl_spec.rb +159 -0
- data/spec/listener_channel_spec.rb +130 -0
- data/spec/listener_spec.rb +67 -0
- data/spec/provisioning/application_spec.rb +47 -0
- data/spec/provisioning/channel_shared_examples.rb +52 -0
- data/spec/provisioning/channel_spec.rb +13 -0
- data/spec/provisioning/phone_spec.rb +88 -0
- data/spec/provisioning/voice_spec.rb +138 -0
- data/spec/provisioning_spec.rb +500 -0
- data/spec/spec_helper.rb +51 -0
- metadata +298 -0
data/README.rdoc
ADDED
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
|
|
2
|
+
== Welcome to connFu
|
|
3
|
+
|
|
4
|
+
connFu gem provides an easy way to get access to connFu platform using the defined DSL and the provisioning API.
|
|
5
|
+
|
|
6
|
+
connFu is a platform of Telefonica delivered by Bluevia Labs.
|
|
7
|
+
Please, check out http://www.connfu.com and if you need further information do not hesitate to contact us at *support* *at* *connfu* *dot* *com*
|
|
8
|
+
|
|
9
|
+
=== Why connFu?
|
|
10
|
+
|
|
11
|
+
* *Mash* *voice*, *data*, *text* *and* *social* *streams* like never before
|
|
12
|
+
|
|
13
|
+
* *Develop* *apps* *swiftly* – connFu does all the heavy lifting
|
|
14
|
+
|
|
15
|
+
* *Merge* social, voice and text channels into single streams
|
|
16
|
+
|
|
17
|
+
* *Global* *reach* – choose phone numbers from around the world
|
|
18
|
+
|
|
19
|
+
* *Economy* *of* *code* – do more with less
|
|
20
|
+
|
|
21
|
+
=== Use connFu to build...
|
|
22
|
+
|
|
23
|
+
* Apps that turn *social* *signals* into calls and voice messages
|
|
24
|
+
|
|
25
|
+
* *Group* *communication* apps (voice, text, social)
|
|
26
|
+
|
|
27
|
+
* *Real*-*time* collaboration tools
|
|
28
|
+
|
|
29
|
+
* *Voice* *apps* controlled by Twitter
|
|
30
|
+
|
|
31
|
+
* *CRM* *applications* (including call recording)
|
|
32
|
+
|
|
33
|
+
== Getting started
|
|
34
|
+
|
|
35
|
+
You can download the connFu-client gem directly from rubygems:
|
|
36
|
+
|
|
37
|
+
gem install connfu-client
|
|
38
|
+
|
|
39
|
+
== Introduction
|
|
40
|
+
|
|
41
|
+
This gem has two different aims:
|
|
42
|
+
|
|
43
|
+
* *connFu* *DSL*: enables an easy way to create a connFu application.
|
|
44
|
+
* *connFu* *provisioning* *API* *client*: wrapper to REST connFu API to manage applications.
|
|
45
|
+
|
|
46
|
+
== connFu DSL
|
|
47
|
+
|
|
48
|
+
connFu DSL allows you to create really powerful applications in just a few lines of code.
|
|
49
|
+
|
|
50
|
+
=== How to create an application
|
|
51
|
+
|
|
52
|
+
1. Create an application using the connFu web portal
|
|
53
|
+
2. Get the application token
|
|
54
|
+
3. Create an application scaffold using the connfu-client CLI:
|
|
55
|
+
|
|
56
|
+
connfu-client scaffold hello-world
|
|
57
|
+
|
|
58
|
+
4. Update the code generated in hello-world/application.rb with your valid application token:
|
|
59
|
+
|
|
60
|
+
token = "YOUR-VALID-CONNFU-TOKEN"
|
|
61
|
+
|
|
62
|
+
4. Run the code:
|
|
63
|
+
|
|
64
|
+
ruby application.rb
|
|
65
|
+
|
|
66
|
+
5. You'll get as output something like:
|
|
67
|
+
|
|
68
|
+
I, [2011-09-26T14:39:24.523208 #43421] INFO -- : Starting application with token 28d540c53b522e162d07baae0809115a
|
|
69
|
+
D, [2011-09-26T14:39:26.631370 #43421] DEBUG -- : The application devel-juan-1 has these channels: []
|
|
70
|
+
D, [2011-09-26T14:39:26.638779 #43421] DEBUG -- : Dispatcher initializer
|
|
71
|
+
D, [2011-09-26T14:39:26.638870 #43421] DEBUG -- : Dispatcher starts
|
|
72
|
+
D, [2011-09-26T14:39:26.639365 #43421] DEBUG -- : Dispatcher waiting for a message from the Listener
|
|
73
|
+
D, [2011-09-26T14:39:26.647047 #43421] DEBUG -- : Listener starts...
|
|
74
|
+
D, [2011-09-26T14:39:26.647200 #43421] DEBUG -- : Waiting for a message from connFu stream
|
|
75
|
+
D, [2011-09-26T14:39:26.647437 #43421] DEBUG -- : Connfu::ConnfuStream opening connection to stream.connfu.com:443
|
|
76
|
+
D, [2011-09-26T14:39:26.647535 #43421] DEBUG -- : Connfu::ConnfuStream start listening to stream /connfu-stream-devel-juan-1
|
|
77
|
+
|
|
78
|
+
=== Handling channels
|
|
79
|
+
|
|
80
|
+
A connFu channel is the way to retrieve inbound events related to the resources mapped to the application.
|
|
81
|
+
|
|
82
|
+
Actually there are three available channel types:
|
|
83
|
+
|
|
84
|
+
* *Voice*: retrieves events related to calls and inbound sms to a specific number
|
|
85
|
+
* *Twitter*: retrieves tweets related to one or more twitter accounts
|
|
86
|
+
* *RSS*: retrieves new posts in a RSS feed
|
|
87
|
+
|
|
88
|
+
An application should listen at least one kind of channel.
|
|
89
|
+
|
|
90
|
+
=== Handling voice channels
|
|
91
|
+
|
|
92
|
+
A voice channel has four related events:
|
|
93
|
+
|
|
94
|
+
* *voice*:*join*: a user joins a conference call
|
|
95
|
+
* *voice*:*leave*: a user leaves a conference call
|
|
96
|
+
* *voice*:*new**\_**topic*: the conference topic was changed
|
|
97
|
+
* *sms*:*new*: a sms sent by an user was received in the number
|
|
98
|
+
|
|
99
|
+
require 'connfu'
|
|
100
|
+
|
|
101
|
+
TOKEN = "<app-token>"
|
|
102
|
+
|
|
103
|
+
Connfu.application(TOKEN) {
|
|
104
|
+
|
|
105
|
+
listen(:voice) do |conference|
|
|
106
|
+
conference.on(:join) do |call|
|
|
107
|
+
puts "New inbound call from #{call[:from]} on number #{call[:to]}"
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
conference.on(:leave) do |call|
|
|
111
|
+
puts "#{call[:from]} has left the conference #{call[:channel_name]}"
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
conference.on(:new_topic) do |topic|
|
|
115
|
+
puts "New topic in the conference #{topic[:channel_name]}: #{topic[:content]}"
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
listen(:sms) do |sms|
|
|
120
|
+
sms.on(:new) do |message|
|
|
121
|
+
puts "New inbound sms"
|
|
122
|
+
puts "#{message}"
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
=== Handling twitter channels
|
|
129
|
+
|
|
130
|
+
A twitter channel has one related event:
|
|
131
|
+
|
|
132
|
+
* *twitter*:*new*: a new tweet sent by an associated twitter account reached the application
|
|
133
|
+
|
|
134
|
+
require 'connfu'
|
|
135
|
+
|
|
136
|
+
TOKEN = "<app-token>"
|
|
137
|
+
|
|
138
|
+
Connfu.application(TOKEN) {
|
|
139
|
+
|
|
140
|
+
listen(:twitter) do |twitter|
|
|
141
|
+
|
|
142
|
+
twitter.on(:new) do |tweet|
|
|
143
|
+
puts "#{tweet[:channel_name]} just posted a new tweet in the application: #{tweet.content}"
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
=== Examples
|
|
152
|
+
|
|
153
|
+
==== Conference room
|
|
154
|
+
|
|
155
|
+
This application defines two channels, voice and twitter, and handles conference rooms using a predefined whitelist.
|
|
156
|
+
|
|
157
|
+
Conference attendees can also tweet information regarding the chat room using the hashtag #conference.
|
|
158
|
+
|
|
159
|
+
require 'connfu'
|
|
160
|
+
|
|
161
|
+
TOKEN = "<valid-app-token>"
|
|
162
|
+
NEW_CALL_MESSAGE = "new call received"
|
|
163
|
+
|
|
164
|
+
HANG_MESSAGE = "has left the call"
|
|
165
|
+
|
|
166
|
+
Connfu.application(TOKEN) {
|
|
167
|
+
|
|
168
|
+
listen(:voice) do
|
|
169
|
+
on(:join) do |call|
|
|
170
|
+
puts "#{NEW_CALL_MESSAGE} on number #{call[:destination]}"
|
|
171
|
+
conf = ConferenceApp::find_by_conference_number(call[:destination])
|
|
172
|
+
if conf.is_allowed?(call[:origin])
|
|
173
|
+
puts "whitelist number received"
|
|
174
|
+
else
|
|
175
|
+
puts "not whitelist number"
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
on(:hang) do |call|
|
|
180
|
+
puts "#{call[:origin]} #{HANG_MESSAGE} #{call[:destination]}"
|
|
181
|
+
ConferenceApp::find(call[:destination]).end(call[:origin])
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
listen(:twitter) do |channel|
|
|
186
|
+
|
|
187
|
+
channel.filter = "text has #conference"
|
|
188
|
+
|
|
189
|
+
on(:new) do |tweet|
|
|
190
|
+
puts "A new tweet arrived"
|
|
191
|
+
conf = ConferenceApp::find_by_twitter_user(tweet[:origin])
|
|
192
|
+
conf.wall.print("#{tweet[:origin]}: has tweeted #{tweet[:destination]}")
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
listen(:foo) do |channel|
|
|
198
|
+
on(:new) do |message|
|
|
199
|
+
puts "This is an unsupported channel"
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
== Provisioning API
|
|
206
|
+
|
|
207
|
+
With the provisioning API client you can manage your application channels.
|
|
208
|
+
|
|
209
|
+
All the requests should be signed using a specific application *api_key*
|
|
210
|
+
|
|
211
|
+
require 'connfu'
|
|
212
|
+
|
|
213
|
+
application = Connfu::Provisioning::Application.new(api_key)
|
|
214
|
+
|
|
215
|
+
Actually there are three available channel types:
|
|
216
|
+
|
|
217
|
+
* *Voice*: retrieves events related to calls and inbound sms to a specific number
|
|
218
|
+
* *Twitter*: retrieves tweets related to one or more twitter accounts
|
|
219
|
+
* *RSS*: retrieves new posts in a RSS feed
|
|
220
|
+
|
|
221
|
+
In the next subsections you can find examples about how to manage channels.
|
|
222
|
+
|
|
223
|
+
Please check the folder *examples* for deeper information
|
|
224
|
+
|
|
225
|
+
=== Voice channels
|
|
226
|
+
|
|
227
|
+
The next sections show information about how to manage voice channels in an application.
|
|
228
|
+
|
|
229
|
+
==== Create a Voice channel
|
|
230
|
+
|
|
231
|
+
This snippet of code creates a voice channel and associates a phone number to the application.
|
|
232
|
+
|
|
233
|
+
require 'connfu'
|
|
234
|
+
|
|
235
|
+
application = Connfu::Provisioning::Application.new(api_key)
|
|
236
|
+
application.create_voice_channel("my-voice-channel", "UK")
|
|
237
|
+
|
|
238
|
+
Optionally a third parameter can be used defining the channel privacy settings:
|
|
239
|
+
|
|
240
|
+
* Connfu::Provisioning::Voice::Channel::WHITELIST : only a specific set of phone numbers can join the conference
|
|
241
|
+
* Connfu::Provisioning::Voice::Channel::PUBLIC : any user can join the conference
|
|
242
|
+
|
|
243
|
+
Valid country codes are _UK_ and _US_
|
|
244
|
+
|
|
245
|
+
==== Retrieve all Voice channels
|
|
246
|
+
|
|
247
|
+
This snippet of code retrieves information about the voice channels associated to the application.
|
|
248
|
+
|
|
249
|
+
require 'connfu'
|
|
250
|
+
|
|
251
|
+
application = Connfu::Provisioning::Application.new(api_key)
|
|
252
|
+
voice_channels = application.get_voice_channel
|
|
253
|
+
|
|
254
|
+
==== Retrieve a Voice channel
|
|
255
|
+
|
|
256
|
+
This snippet of code retrieves information about a specific voice channel associated to the application.
|
|
257
|
+
|
|
258
|
+
require 'connfu'
|
|
259
|
+
|
|
260
|
+
application = Connfu::Provisioning::Application.new(api_key)
|
|
261
|
+
voice_channel = application.get_voice_channel("my-voice-channel")
|
|
262
|
+
|
|
263
|
+
==== Update Voice channel
|
|
264
|
+
|
|
265
|
+
This snippet of code updates the topic, privacy setting, welcome\_message and rejected\_message associated to the voice channel.
|
|
266
|
+
|
|
267
|
+
require 'connfu'
|
|
268
|
+
|
|
269
|
+
application = Connfu::Provisioning::Application.new(api_key)
|
|
270
|
+
application.update_voice_channel("my-voice-channel",
|
|
271
|
+
{:topic =>"new topic",
|
|
272
|
+
:welcome_message => "Hello!",
|
|
273
|
+
:rejected_message => "You're not allowed to join the conference.",
|
|
274
|
+
:privacy => Connfu::Provisioning::Voice::Privacy::PUBLIC})
|
|
275
|
+
|
|
276
|
+
==== Delete a Voice channel
|
|
277
|
+
|
|
278
|
+
This snippet of code deletes a voice channel previously created.
|
|
279
|
+
|
|
280
|
+
require 'connfu'
|
|
281
|
+
|
|
282
|
+
application = Connfu::Provisioning::Application.new(api_key)
|
|
283
|
+
application.delete_voice_channel("my-voice-channel")
|
|
284
|
+
|
|
285
|
+
==== Voice Channel Whitelist
|
|
286
|
+
|
|
287
|
+
Only a predefined set of numbers can join a conference created using a voice channel. Numbers must be included in the conference whitelist before joining the conference.
|
|
288
|
+
|
|
289
|
+
===== Add a number to the whitelist
|
|
290
|
+
|
|
291
|
+
This snippet of code adds a new user to the conference whitelist.
|
|
292
|
+
|
|
293
|
+
require 'connfu'
|
|
294
|
+
|
|
295
|
+
application = Connfu::Provisioning::Application.new(api_key)
|
|
296
|
+
application.add_whitelist("my-voice-channel", "paul", "0044654332")
|
|
297
|
+
|
|
298
|
+
===== Retrieve a channel whitelist
|
|
299
|
+
|
|
300
|
+
This snippet of code retrieves a conference whitelist.
|
|
301
|
+
|
|
302
|
+
require 'connfu'
|
|
303
|
+
|
|
304
|
+
application = Connfu::Provisioning::Application.new(api_key)
|
|
305
|
+
whitelist = application.get_whitelist("my-voice-channel")
|
|
306
|
+
|
|
307
|
+
===== Delete the Voice channel whitelist
|
|
308
|
+
|
|
309
|
+
This snippet of code deletes the whole conference whitelist.
|
|
310
|
+
|
|
311
|
+
require 'connfu'
|
|
312
|
+
|
|
313
|
+
application = Connfu::Provisioning::Application.new(api_key)
|
|
314
|
+
application.delete_whitelist("my-voice-channel")
|
|
315
|
+
|
|
316
|
+
===== Delete a whitelist entry
|
|
317
|
+
|
|
318
|
+
This snippet of code deletes a specific whitelist item.
|
|
319
|
+
|
|
320
|
+
require 'connfu'
|
|
321
|
+
|
|
322
|
+
application = Connfu::Provisioning::Application.new(api_key)
|
|
323
|
+
application.delete_whitelist("my-voice-channel", "0044654332")
|
|
324
|
+
|
|
325
|
+
==== Voice channel numbers
|
|
326
|
+
|
|
327
|
+
A voice channel can have more than one mapped phone number. This will enable users from different countries join a conference with local rates.
|
|
328
|
+
|
|
329
|
+
===== Add a new number to a voice channel
|
|
330
|
+
|
|
331
|
+
This snippet of code adds a new phone number to the voice channel. The desired country must be supported.
|
|
332
|
+
|
|
333
|
+
require 'connfu'
|
|
334
|
+
|
|
335
|
+
application = Connfu::Provisioning::Application.new(api_key)
|
|
336
|
+
application.add_phone("my-voice-channel", "UK")
|
|
337
|
+
|
|
338
|
+
===== Remove a number from a voice channel
|
|
339
|
+
|
|
340
|
+
This snippet of code removes a phone number from the voice channel and release the resource.
|
|
341
|
+
|
|
342
|
+
require 'connfu'
|
|
343
|
+
|
|
344
|
+
application = Connfu::Provisioning::Application.new(api_key)
|
|
345
|
+
application.delete_phone("my-voice-channel", "0044654332")
|
|
346
|
+
|
|
347
|
+
===== Retrieve all the voice channel numbers
|
|
348
|
+
|
|
349
|
+
This snippet of code retrieves a voice channel phone lists.
|
|
350
|
+
|
|
351
|
+
require 'connfu'
|
|
352
|
+
|
|
353
|
+
application = Connfu::Provisioning::Application.new(api_key)
|
|
354
|
+
phones = application.get_phones("my-voice-channel")
|
|
355
|
+
|
|
356
|
+
=== Twitter channels
|
|
357
|
+
|
|
358
|
+
==== Create Twitter channel
|
|
359
|
+
|
|
360
|
+
This snippet of code creates a twitter channel with two twitter accounts and two hashtags to filter only those messages with a specific hashtag.
|
|
361
|
+
|
|
362
|
+
require 'connfu'
|
|
363
|
+
|
|
364
|
+
application = Connfu::Provisioning::Application.new(api_key)
|
|
365
|
+
application.create_twitter_channel("my-twitter-channel",
|
|
366
|
+
{:origin => "juandebravo", :hashtags => ["ruby", "rails]})
|
|
367
|
+
|
|
368
|
+
==== Retrieve all Twitter channels
|
|
369
|
+
|
|
370
|
+
This snippet of code retrieves information about all the twitter channels previously created.
|
|
371
|
+
|
|
372
|
+
require 'connfu'
|
|
373
|
+
|
|
374
|
+
application = Connfu::Provisioning::Application.new(api_key)
|
|
375
|
+
twitter_channels = application.get_twitter_channel
|
|
376
|
+
|
|
377
|
+
==== Retrieve a Twitter channel
|
|
378
|
+
|
|
379
|
+
This snippet of code retrieves information about a specific twitter channel previously created.
|
|
380
|
+
|
|
381
|
+
require 'connfu'
|
|
382
|
+
|
|
383
|
+
application = Connfu::Provisioning::Application.new(api_key)
|
|
384
|
+
twitter_channel = application.get_twitter_channel("my-twitter_channel")
|
|
385
|
+
|
|
386
|
+
==== Delete a Twitter channel
|
|
387
|
+
|
|
388
|
+
This snippet of code deletes a specific twitter channel previously created.
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
require 'connfu'
|
|
392
|
+
|
|
393
|
+
application = Connfu::Provisioning::Application.new(api_key)
|
|
394
|
+
application.delete_twitter_channel("my-twitter_channel")
|
|
395
|
+
|
|
396
|
+
== License
|
|
397
|
+
|
|
398
|
+
Check the file License.txt with information about GNU AFFERO GENERAL PUBLIC LICENSE Version 3
|
data/Rakefile
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'bundler'
|
|
2
|
+
require 'metric_fu'
|
|
3
|
+
|
|
4
|
+
Bundler::GemHelper.install_tasks
|
|
5
|
+
|
|
6
|
+
require 'rdoc/task'
|
|
7
|
+
|
|
8
|
+
require 'sdoc'
|
|
9
|
+
|
|
10
|
+
task :default => [:test]
|
|
11
|
+
|
|
12
|
+
require 'rspec/core/rake_task'
|
|
13
|
+
|
|
14
|
+
RSpec::Core::RakeTask.new(:test) do |spec|
|
|
15
|
+
spec.skip_bundler = true
|
|
16
|
+
spec.pattern = ['spec/*_spec.rb', 'spec/provisioning/*_spec.rb']
|
|
17
|
+
spec.rspec_opts = '--color --format doc'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
RDoc::Task.new do |rdoc|
|
|
22
|
+
rdoc.rdoc_dir = 'doc/rdoc'
|
|
23
|
+
rdoc.title = "connFu DSL #{Connfu::VERSION} documentation"
|
|
24
|
+
|
|
25
|
+
rdoc.rdoc_files.include('README.rdoc', 'LICENSE.txt')
|
|
26
|
+
|
|
27
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
28
|
+
#rdoc.rdoc_files.include('examples/**/*.rb')
|
|
29
|
+
|
|
30
|
+
rdoc.options << '-f' << 'sdoc'
|
|
31
|
+
rdoc.options << '-T' << 'connfu'
|
|
32
|
+
rdoc.options << '-c' << 'utf-8'
|
|
33
|
+
rdoc.options << '-g'
|
|
34
|
+
rdoc.options << '-m' << 'README.rdoc'
|
|
35
|
+
|
|
36
|
+
#rdoc.rdoc_files.include('README*')
|
|
37
|
+
end
|
|
38
|
+
|
data/bin/.DS_Store
ADDED
|
Binary file
|
data/bin/connfu-client
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
$:.unshift(File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib'))
|
|
4
|
+
|
|
5
|
+
require "gli"
|
|
6
|
+
|
|
7
|
+
require "connfu/version"
|
|
8
|
+
require "connfu/cli/generator"
|
|
9
|
+
|
|
10
|
+
include GLI
|
|
11
|
+
|
|
12
|
+
program_desc "connfu-client provides an easy way to manage and the fetch events in any of your connFu applications."
|
|
13
|
+
|
|
14
|
+
version Connfu::VERSION
|
|
15
|
+
|
|
16
|
+
desc "Be verbose my friend"
|
|
17
|
+
switch :v
|
|
18
|
+
|
|
19
|
+
desc "Use scaffold to create a basic application that listens to all the available connFu channels"
|
|
20
|
+
long_desc <<EOS
|
|
21
|
+
|
|
22
|
+
Use scaffold to create a basic application that listens to all the available connFu channels.
|
|
23
|
+
A connFu application can listen to one or more channels.
|
|
24
|
+
Each channel will launch the application logic based on the event fetched using the streaming endpoint that belongs to the application.
|
|
25
|
+
You need a valid application token that can be retrieved in connFu web portal, http://www.connfu.com
|
|
26
|
+
\n
|
|
27
|
+
EOS
|
|
28
|
+
|
|
29
|
+
arg_name "project_name"
|
|
30
|
+
command :scaffold do |c|
|
|
31
|
+
c.desc 'Channels the application should listen to'
|
|
32
|
+
c.default_value ":all"
|
|
33
|
+
c.flag :c
|
|
34
|
+
|
|
35
|
+
c.desc 'Main file that will contain the application logic'
|
|
36
|
+
c.default_value 'application.rb'
|
|
37
|
+
c.flag :f
|
|
38
|
+
|
|
39
|
+
c.action do |global_options, options, args|
|
|
40
|
+
if args.length < 1
|
|
41
|
+
puts c.long_description
|
|
42
|
+
usage = "Usage:"
|
|
43
|
+
usage << "\n #{$0} #{c.name} <application-name>"
|
|
44
|
+
usage << "\n\nOptions:"
|
|
45
|
+
|
|
46
|
+
c.switches.each do |s|
|
|
47
|
+
usage << "\n -#{s[0]}: #{s[1].description}"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
c.flags.each do |f|
|
|
51
|
+
usage << "\n -#{f[0]}: #{f[1].description}. Default value: #{f[1].default_value}"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
usage << "\n\n"
|
|
55
|
+
puts usage
|
|
56
|
+
raise ""
|
|
57
|
+
end
|
|
58
|
+
puts " #{green("create")} #{args[0]}"
|
|
59
|
+
|
|
60
|
+
Connfu::Cli::Generator.run(args[0], nil, options[:f])
|
|
61
|
+
|
|
62
|
+
puts " #{green("create")} #{options[:f]}"
|
|
63
|
+
|
|
64
|
+
puts " #{green("Application created!!")}"
|
|
65
|
+
puts "\n"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# Your command logic here
|
|
69
|
+
|
|
70
|
+
# If you have any errors, just raise them
|
|
71
|
+
# raise "that command made no sense"
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
pre do |global, command, options, args|
|
|
76
|
+
puts "Executing #{command.name}" if global[:v]
|
|
77
|
+
true
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
post do |global, command, options, args|
|
|
81
|
+
puts "Executed #{command.name}" if global[:v]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
on_error do |exception|
|
|
85
|
+
# Error logic here
|
|
86
|
+
# return false to skip default error handling
|
|
87
|
+
true
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def green(text)
|
|
91
|
+
"\e[32m#{text}\e[0m"
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
exit GLI.run(ARGV)
|