ucengine 0.1.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/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +165 -0
- data/README.rdoc +7 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/doc/UCEngine.html +769 -0
- data/doc/UCEngine/Debug.html +179 -0
- data/doc/created.rid +2 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +71 -0
- data/doc/js/darkfish.js +116 -0
- data/doc/js/jquery.js +32 -0
- data/doc/js/quicksearch.js +114 -0
- data/doc/js/thickbox-compressed.js +10 -0
- data/doc/lib/ucengine_rb.html +58 -0
- data/doc/rdoc.css +706 -0
- data/lib/ucengine.rb +192 -0
- data/test/helper.rb +10 -0
- data/test/test_ucengine.rb +7 -0
- data/ucengine.rb.gemspec +57 -0
- metadata +130 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 3, 29 June 2007
|
3
|
+
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
6
|
+
of this license document, but changing it is not allowed.
|
7
|
+
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "ucengine"
|
8
|
+
gem.summary = %Q{Ruby library for UCEngine}
|
9
|
+
gem.description = %Q{ucengine.rb is a Ruby library to consume the UCEngine API}
|
10
|
+
gem.email = "victor.goya@af83.com"
|
11
|
+
gem.homepage = "http://github.com/AF83/ucengine.rb"
|
12
|
+
gem.authors = ["AF83"]
|
13
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
14
|
+
gem.add_dependency "json", ">=0"
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
Rake::TestTask.new(:test) do |test|
|
24
|
+
test.libs << 'lib' << 'test'
|
25
|
+
test.pattern = 'test/**/test_*.rb'
|
26
|
+
test.verbose = true
|
27
|
+
end
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'rcov/rcovtask'
|
31
|
+
Rcov::RcovTask.new do |test|
|
32
|
+
test.libs << 'test'
|
33
|
+
test.pattern = 'test/**/test_*.rb'
|
34
|
+
test.verbose = true
|
35
|
+
end
|
36
|
+
rescue LoadError
|
37
|
+
task :rcov do
|
38
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
task :test => :check_dependencies
|
43
|
+
|
44
|
+
task :default => :test
|
45
|
+
|
46
|
+
require 'rake/rdoctask'
|
47
|
+
Rake::RDocTask.new do |rdoc|
|
48
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
49
|
+
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
51
|
+
rdoc.title = "ucengine.rb #{version}"
|
52
|
+
rdoc.rdoc_files.include('README*')
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
54
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/doc/UCEngine.html
ADDED
@@ -0,0 +1,769 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
7
|
+
|
8
|
+
<title>Class: UCEngine</title>
|
9
|
+
|
10
|
+
<link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
|
11
|
+
|
12
|
+
<script src="./js/jquery.js" type="text/javascript"
|
13
|
+
charset="utf-8"></script>
|
14
|
+
<script src="./js/thickbox-compressed.js" type="text/javascript"
|
15
|
+
charset="utf-8"></script>
|
16
|
+
<script src="./js/quicksearch.js" type="text/javascript"
|
17
|
+
charset="utf-8"></script>
|
18
|
+
<script src="./js/darkfish.js" type="text/javascript"
|
19
|
+
charset="utf-8"></script>
|
20
|
+
|
21
|
+
</head>
|
22
|
+
<body class="class">
|
23
|
+
|
24
|
+
<div id="metadata">
|
25
|
+
<div id="home-metadata">
|
26
|
+
<div id="home-section" class="section">
|
27
|
+
<h3 class="section-header">
|
28
|
+
<a href="./index.html">Home</a>
|
29
|
+
<a href="./index.html#classes">Classes</a>
|
30
|
+
<a href="./index.html#methods">Methods</a>
|
31
|
+
</h3>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="file-metadata">
|
36
|
+
<div id="file-list-section" class="section">
|
37
|
+
<h3 class="section-header">In Files</h3>
|
38
|
+
<div class="section-body">
|
39
|
+
<ul>
|
40
|
+
|
41
|
+
<li><a href="./lib/ucengine_rb.html?TB_iframe=true&height=550&width=785"
|
42
|
+
class="thickbox" title="lib/ucengine.rb">lib/ucengine.rb</a></li>
|
43
|
+
|
44
|
+
</ul>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
|
48
|
+
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<div id="class-metadata">
|
52
|
+
|
53
|
+
<!-- Parent Class -->
|
54
|
+
|
55
|
+
<div id="parent-class-section" class="section">
|
56
|
+
<h3 class="section-header">Parent</h3>
|
57
|
+
|
58
|
+
<p class="link">Object</p>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
|
62
|
+
|
63
|
+
<!-- Namespace Contents -->
|
64
|
+
|
65
|
+
|
66
|
+
<!-- Method Quickref -->
|
67
|
+
|
68
|
+
<div id="method-list-section" class="section">
|
69
|
+
<h3 class="section-header">Methods</h3>
|
70
|
+
<ul class="link-list">
|
71
|
+
|
72
|
+
<li><a href="#method-c-encode">::encode</a></li>
|
73
|
+
|
74
|
+
<li><a href="#method-c-new">::new</a></li>
|
75
|
+
|
76
|
+
<li><a href="#method-i-connect">#connect</a></li>
|
77
|
+
|
78
|
+
<li><a href="#method-i-debug">#debug</a></li>
|
79
|
+
|
80
|
+
<li><a href="#method-i-delete">#delete</a></li>
|
81
|
+
|
82
|
+
<li><a href="#method-i-get">#get</a></li>
|
83
|
+
|
84
|
+
<li><a href="#method-i-post">#post</a></li>
|
85
|
+
|
86
|
+
<li><a href="#method-i-publish">#publish</a></li>
|
87
|
+
|
88
|
+
<li><a href="#method-i-put">#put</a></li>
|
89
|
+
|
90
|
+
<li><a href="#method-i-subscribe">#subscribe</a></li>
|
91
|
+
|
92
|
+
<li><a href="#method-i-time">#time</a></li>
|
93
|
+
|
94
|
+
</ul>
|
95
|
+
</div>
|
96
|
+
|
97
|
+
|
98
|
+
<!-- Included Modules -->
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<div id="project-metadata">
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
<div id="classindex-section" class="section project-section">
|
107
|
+
<h3 class="section-header">Class Index
|
108
|
+
<span class="search-toggle"><img src="./images/find.png"
|
109
|
+
height="16" width="16" alt="[+]"
|
110
|
+
title="show/hide quicksearch" /></span></h3>
|
111
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
112
|
+
<fieldset>
|
113
|
+
<legend>Quicksearch</legend>
|
114
|
+
<input type="text" name="quicksearch" value=""
|
115
|
+
class="quicksearch-field" />
|
116
|
+
</fieldset>
|
117
|
+
</form>
|
118
|
+
|
119
|
+
<ul class="link-list">
|
120
|
+
|
121
|
+
<li><a href="./UCEngine.html">UCEngine</a></li>
|
122
|
+
|
123
|
+
</ul>
|
124
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
125
|
+
</div>
|
126
|
+
|
127
|
+
|
128
|
+
</div>
|
129
|
+
</div>
|
130
|
+
|
131
|
+
<div id="documentation">
|
132
|
+
<h1 class="class">UCEngine</h1>
|
133
|
+
|
134
|
+
<div id="description">
|
135
|
+
<p>
|
136
|
+
This class is the main and only class in ucengine.rb, it handles
|
137
|
+
connections and request to the <a href="UCEngine.html">UCEngine</a> server.
|
138
|
+
</p>
|
139
|
+
<pre>
|
140
|
+
uce = UCEngine.new("localhost", 4567)
|
141
|
+
uce.connect("bibi", :password => 'abcd') do |uce|
|
142
|
+
uce.subscribe(["af83"], :type => 'chat.message.new', :search => 'HTML5') do |event|
|
143
|
+
uce.push(:location => [event['org'], event['meeting']]
|
144
|
+
:from => 'bot',
|
145
|
+
:type => 'chat.message.new',
|
146
|
+
:metadata => {"text" => "Hey, you were talking about HTML5"})
|
147
|
+
end
|
148
|
+
end</pre>
|
149
|
+
|
150
|
+
</div>
|
151
|
+
|
152
|
+
<!-- Constants -->
|
153
|
+
|
154
|
+
<div id="constants-list" class="section">
|
155
|
+
<h3 class="section-header">Constants</h3>
|
156
|
+
<dl>
|
157
|
+
|
158
|
+
<dt><a name="DEBUG">DEBUG</a></dt>
|
159
|
+
|
160
|
+
<dd class="description"><p>
|
161
|
+
Print every request and everything above.
|
162
|
+
</p></dd>
|
163
|
+
|
164
|
+
|
165
|
+
<dt><a name="WARNING">WARNING</a></dt>
|
166
|
+
|
167
|
+
<dd class="description"><p>
|
168
|
+
Print everything that seems fishy.
|
169
|
+
</p></dd>
|
170
|
+
|
171
|
+
|
172
|
+
<dt><a name="ERROR">ERROR</a></dt>
|
173
|
+
|
174
|
+
<dd class="description"><p>
|
175
|
+
Print regular errors, usually HTTP errors.
|
176
|
+
</p></dd>
|
177
|
+
|
178
|
+
|
179
|
+
<dt><a name="CRITICAL">CRITICAL</a></dt>
|
180
|
+
|
181
|
+
<dd class="description"><p>
|
182
|
+
Only print critical errors (bad hostname or port, etc).
|
183
|
+
</p></dd>
|
184
|
+
|
185
|
+
|
186
|
+
<dt><a name="QUIET">QUIET</a></dt>
|
187
|
+
|
188
|
+
<dd class="description"><p>
|
189
|
+
Don’t print anything (default).
|
190
|
+
</p></dd>
|
191
|
+
|
192
|
+
|
193
|
+
</dl>
|
194
|
+
</div>
|
195
|
+
|
196
|
+
|
197
|
+
<!-- Attributes -->
|
198
|
+
|
199
|
+
|
200
|
+
<!-- Methods -->
|
201
|
+
|
202
|
+
<div id="public-class-method-details" class="method-section section">
|
203
|
+
<h3 class="section-header">Public Class Methods</h3>
|
204
|
+
|
205
|
+
|
206
|
+
<div id="new-method" class="method-detail ">
|
207
|
+
<a name="method-c-new"></a>
|
208
|
+
|
209
|
+
<div class="method-heading">
|
210
|
+
|
211
|
+
<span class="method-name">new</span><span
|
212
|
+
class="method-args">(host, port, debug = UCEngine::QUIET)</span>
|
213
|
+
<span class="method-click-advice">click to toggle source</span>
|
214
|
+
|
215
|
+
</div>
|
216
|
+
|
217
|
+
<div class="method-description">
|
218
|
+
|
219
|
+
<p>
|
220
|
+
Create a new <a href="UCEngine.html">UCEngine</a> object.
|
221
|
+
‘host’ is the hostname of the <a
|
222
|
+
href="UCEngine.html">UCEngine</a> server and ‘port’ is to TCP
|
223
|
+
port to connect to. Note that this method doesn’t create a new
|
224
|
+
connection, see the <a href="UCEngine.html#method-i-connect">#</a> method.
|
225
|
+
An additional ‘debug’ parameter set the debug level of the
|
226
|
+
library, all the debug information are written in the error output.
|
227
|
+
</p>
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
<div class="method-source-code"
|
232
|
+
id="new-source">
|
233
|
+
<pre>
|
234
|
+
<span class="ruby-comment cmt"># File lib/ucengine.rb, line 44</span>
|
235
|
+
44: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>, <span class="ruby-identifier">debug</span> = <span class="ruby-constant">UCEngine</span><span class="ruby-operator">::</span><span class="ruby-constant">QUIET</span>)
|
236
|
+
45: <span class="ruby-ivar">@host</span> = <span class="ruby-identifier">host</span>
|
237
|
+
46: <span class="ruby-ivar">@port</span> = <span class="ruby-identifier">port</span>
|
238
|
+
47: <span class="ruby-ivar">@http</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>)
|
239
|
+
48: <span class="ruby-ivar">@threads</span> = []
|
240
|
+
49: <span class="ruby-ivar">@debug</span> = <span class="ruby-identifier">debug</span>
|
241
|
+
50: <span class="ruby-identifier">debug</span>(<span class="ruby-constant">UCEngine</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>, <span class="ruby-node">"Initialisation complete for #{host}:#{port}."</span>)
|
242
|
+
51: <span class="ruby-keyword kw">end</span></pre>
|
243
|
+
</div>
|
244
|
+
|
245
|
+
</div>
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
</div>
|
251
|
+
|
252
|
+
|
253
|
+
</div>
|
254
|
+
|
255
|
+
<div id="protected-class-method-details" class="method-section section">
|
256
|
+
<h3 class="section-header">Protected Class Methods</h3>
|
257
|
+
|
258
|
+
|
259
|
+
<div id="encode-method" class="method-detail ">
|
260
|
+
<a name="method-c-encode"></a>
|
261
|
+
|
262
|
+
<div class="method-heading">
|
263
|
+
|
264
|
+
<span class="method-name">encode</span><span
|
265
|
+
class="method-args">(params)</span>
|
266
|
+
<span class="method-click-advice">click to toggle source</span>
|
267
|
+
|
268
|
+
</div>
|
269
|
+
|
270
|
+
<div class="method-description">
|
271
|
+
|
272
|
+
<p>
|
273
|
+
Encode parameters
|
274
|
+
</p>
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
<div class="method-source-code"
|
279
|
+
id="encode-source">
|
280
|
+
<pre>
|
281
|
+
<span class="ruby-comment cmt"># File lib/ucengine.rb, line 149</span>
|
282
|
+
149: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">UCEngine</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-identifier">params</span>)
|
283
|
+
150: <span class="ruby-identifier">params</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-node">"#{k}=#{CGI::escape(v.to_s)}"</span> }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">'&'</span>)
|
284
|
+
151: <span class="ruby-keyword kw">end</span></pre>
|
285
|
+
</div>
|
286
|
+
|
287
|
+
</div>
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
</div>
|
293
|
+
|
294
|
+
|
295
|
+
</div>
|
296
|
+
|
297
|
+
<div id="public-instance-method-details" class="method-section section">
|
298
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
299
|
+
|
300
|
+
|
301
|
+
<div id="connect-method" class="method-detail ">
|
302
|
+
<a name="method-i-connect"></a>
|
303
|
+
|
304
|
+
<div class="method-heading">
|
305
|
+
|
306
|
+
<span class="method-name">connect</span><span
|
307
|
+
class="method-args">(uid, credential)</span>
|
308
|
+
<span class="method-click-advice">click to toggle source</span>
|
309
|
+
|
310
|
+
</div>
|
311
|
+
|
312
|
+
<div class="method-description">
|
313
|
+
|
314
|
+
<p>
|
315
|
+
Connect to the <a href="UCEngine.html">UCEngine</a> server with the User ID
|
316
|
+
‘uid’ and the its credential.
|
317
|
+
</p>
|
318
|
+
<pre>
|
319
|
+
uce = UCEngine.new("localhost", 4567)
|
320
|
+
uce.connect("bibi", :password => 'abcd') do |uce|
|
321
|
+
... your code goes here
|
322
|
+
end
|
323
|
+
</pre>
|
324
|
+
<p>
|
325
|
+
It is currently possible to use :token or :password as authentification
|
326
|
+
method.
|
327
|
+
</p>
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
<div class="method-source-code"
|
332
|
+
id="connect-source">
|
333
|
+
<pre>
|
334
|
+
<span class="ruby-comment cmt"># File lib/ucengine.rb, line 62</span>
|
335
|
+
62: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">connect</span>(<span class="ruby-identifier">uid</span>, <span class="ruby-identifier">credential</span>)
|
336
|
+
63: <span class="ruby-ivar">@uid</span> = <span class="ruby-identifier">uid</span>
|
337
|
+
64: <span class="ruby-identifier">response</span> = <span class="ruby-identifier">put</span>(<span class="ruby-node">"/presence/#{@uid}"</span>, {<span class="ruby-value">:auth</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'token'</span>, <span class="ruby-value">:credential</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">credential</span>[<span class="ruby-value">:token</span>]})
|
338
|
+
65: <span class="ruby-ivar">@sid</span> = <span class="ruby-identifier">response</span>[<span class="ruby-value str">'result'</span>]
|
339
|
+
66: <span class="ruby-identifier">debug</span>(<span class="ruby-constant">UCEngine</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>, <span class="ruby-node">"Authentification complete for #{@uid}/#{@sid}."</span>)
|
340
|
+
67: <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">self</span>
|
341
|
+
68: <span class="ruby-ivar">@threads</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">thread</span><span class="ruby-operator">|</span>
|
342
|
+
69: <span class="ruby-identifier">thread</span>.<span class="ruby-identifier">join</span>
|
343
|
+
70: <span class="ruby-keyword kw">end</span>
|
344
|
+
71: <span class="ruby-keyword kw">end</span></pre>
|
345
|
+
</div>
|
346
|
+
|
347
|
+
</div>
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
</div>
|
353
|
+
|
354
|
+
|
355
|
+
<div id="publish-method" class="method-detail ">
|
356
|
+
<a name="method-i-publish"></a>
|
357
|
+
|
358
|
+
<div class="method-heading">
|
359
|
+
|
360
|
+
<span class="method-name">publish</span><span
|
361
|
+
class="method-args">(event)</span>
|
362
|
+
<span class="method-click-advice">click to toggle source</span>
|
363
|
+
|
364
|
+
</div>
|
365
|
+
|
366
|
+
<div class="method-description">
|
367
|
+
|
368
|
+
<p>
|
369
|
+
Publish an event. Publishing an event require a few mandatories parameters:
|
370
|
+
</p>
|
371
|
+
<dl>
|
372
|
+
<dt>:location</dt><dd><p>
|
373
|
+
As described in the subscribe method: [“organisation”,
|
374
|
+
“meeting”] publish the event in a specific meeting,
|
375
|
+
[“organisation”] publish the event in the organisation and []:
|
376
|
+
publish the event in the server root.
|
377
|
+
</p>
|
378
|
+
</dd>
|
379
|
+
<dt>:type</dt><dd><p>
|
380
|
+
The type of event to send, the format of this type is usually
|
381
|
+
‘namespace.object.action’, for example:
|
382
|
+
‘chat.message.new’, ‘twitter.tweet.new’,
|
383
|
+
‘internal.user.update‘
|
384
|
+
</p>
|
385
|
+
</dd>
|
386
|
+
<dt>:parent</dt><dd><p>
|
387
|
+
The id of the parent, this parameter is useful to build event hierarchy.
|
388
|
+
</p>
|
389
|
+
</dd>
|
390
|
+
<dt>:metadata</dt><dd><p>
|
391
|
+
A hash of freely defined values to append to the event.
|
392
|
+
</p>
|
393
|
+
</dd>
|
394
|
+
</dl>
|
395
|
+
<pre>
|
396
|
+
uce.publish(:location => ["af83", "WebWorkersCamp"],
|
397
|
+
:type => 'presentation.slide.add'
|
398
|
+
:metadata => {:url => 'http://myserver/slides/03.png',
|
399
|
+
:index => 3})</pre>
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
<div class="method-source-code"
|
404
|
+
id="publish-source">
|
405
|
+
<pre>
|
406
|
+
<span class="ruby-comment cmt"># File lib/ucengine.rb, line 123</span>
|
407
|
+
123: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">publish</span>(<span class="ruby-identifier">event</span>)
|
408
|
+
124: <span class="ruby-identifier">debug</span>(<span class="ruby-constant">UCEngine</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>, <span class="ruby-node">"Publish to #{event[:location]}, type: #{event[:type]}, parent: #{event[:parent]}, metadata: #{event[:metadata]}"</span>)
|
409
|
+
125: <span class="ruby-identifier">params</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
|
410
|
+
126: <span class="ruby-identifier">params</span>[<span class="ruby-value">:type</span>] = <span class="ruby-identifier">event</span>[<span class="ruby-value">:type</span>]
|
411
|
+
127: <span class="ruby-identifier">params</span>[<span class="ruby-value">:parent</span>] = <span class="ruby-identifier">event</span>[<span class="ruby-value">:parent</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">event</span>[<span class="ruby-value">:parent</span>]
|
412
|
+
128: <span class="ruby-identifier">metadata</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
|
413
|
+
129: <span class="ruby-identifier">params</span>[<span class="ruby-node">"metadata[#{key}]"</span>] = <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">key</span>]
|
414
|
+
130: <span class="ruby-keyword kw">end</span>
|
415
|
+
131: <span class="ruby-identifier">put</span>(<span class="ruby-node">"/event/#{event[:location].join("/")}"</span>, <span class="ruby-identifier">params</span>)
|
416
|
+
132: <span class="ruby-keyword kw">end</span></pre>
|
417
|
+
</div>
|
418
|
+
|
419
|
+
</div>
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
|
424
|
+
</div>
|
425
|
+
|
426
|
+
|
427
|
+
<div id="subscribe-method" class="method-detail ">
|
428
|
+
<a name="method-i-subscribe"></a>
|
429
|
+
|
430
|
+
<div class="method-heading">
|
431
|
+
|
432
|
+
<span class="method-name">subscribe</span><span
|
433
|
+
class="method-args">(location, params = {})</span>
|
434
|
+
<span class="method-click-advice">click to toggle source</span>
|
435
|
+
|
436
|
+
</div>
|
437
|
+
|
438
|
+
<div class="method-description">
|
439
|
+
|
440
|
+
<p>
|
441
|
+
Subscribe to an event stream. The ‘location’ parameter is where
|
442
|
+
you’re expecting the events to come:
|
443
|
+
</p>
|
444
|
+
<ul>
|
445
|
+
<li><p>
|
446
|
+
[“organisation”, “meeting”]: events from a specific
|
447
|
+
meeting.
|
448
|
+
</p>
|
449
|
+
</li>
|
450
|
+
<li><p>
|
451
|
+
[“organisation”]: events from all meetings of the organisation
|
452
|
+
and for the organisation itself.
|
453
|
+
</p>
|
454
|
+
</li>
|
455
|
+
<li><p>
|
456
|
+
[]: all events.
|
457
|
+
</p>
|
458
|
+
</li>
|
459
|
+
</ul>
|
460
|
+
<p>
|
461
|
+
The function takes extra parameters: :type => the type of event (ex.
|
462
|
+
‘chat.message.new’, ‘internal.user.add’, etc).
|
463
|
+
:from => the origin of the message, the value is an uid. :parent => the id
|
464
|
+
of the the parent event. :search => list of keywords that match the
|
465
|
+
metadata of the returned events
|
466
|
+
</p>
|
467
|
+
<pre>
|
468
|
+
uce.subscribe(["af83"], :type => 'internal.meeting.add', :search => 'HTML5') do |event|
|
469
|
+
puts "A new meeting about HTML5 was created"
|
470
|
+
end</pre>
|
471
|
+
|
472
|
+
|
473
|
+
|
474
|
+
<div class="method-source-code"
|
475
|
+
id="subscribe-source">
|
476
|
+
<pre>
|
477
|
+
<span class="ruby-comment cmt"># File lib/ucengine.rb, line 89</span>
|
478
|
+
89: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">subscribe</span>(<span class="ruby-identifier">location</span>, <span class="ruby-identifier">params</span> = {})
|
479
|
+
90: <span class="ruby-identifier">debug</span>(<span class="ruby-constant">UCEngine</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>, <span class="ruby-node">"Subscribe to #{location} with #{params}."</span>)
|
480
|
+
91: <span class="ruby-ivar">@threads</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span>
|
481
|
+
92: <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">start</span>(<span class="ruby-ivar">@host</span>, <span class="ruby-ivar">@port</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">http</span><span class="ruby-operator">|</span>
|
482
|
+
93: <span class="ruby-identifier">params</span>[<span class="ruby-value">:_async</span>] = <span class="ruby-value str">"lp"</span>
|
483
|
+
94: <span class="ruby-identifier">params</span>[<span class="ruby-value">:start</span>] = <span class="ruby-value">0</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">params</span>[<span class="ruby-value">:start</span>]
|
484
|
+
95: <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
|
485
|
+
96: <span class="ruby-keyword kw">begin</span>
|
486
|
+
97: <span class="ruby-identifier">events</span> = <span class="ruby-identifier">get</span>(<span class="ruby-node">"/event/#{location.join("/")}"</span>, <span class="ruby-identifier">params</span>, <span class="ruby-identifier">http</span>)[<span class="ruby-value str">'result'</span>]
|
487
|
+
98: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Timeout</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>
|
488
|
+
99: <span class="ruby-keyword kw">retry</span>
|
489
|
+
100: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">EOFError</span>
|
490
|
+
101: <span class="ruby-identifier">sleep</span> <span class="ruby-value">10</span>
|
491
|
+
102: <span class="ruby-keyword kw">retry</span>
|
492
|
+
103: <span class="ruby-keyword kw">end</span>
|
493
|
+
104: <span class="ruby-identifier">events</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">event</span><span class="ruby-operator">|</span>
|
494
|
+
105: <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">event</span>
|
495
|
+
106: <span class="ruby-keyword kw">end</span>
|
496
|
+
107: <span class="ruby-identifier">params</span>[<span class="ruby-value">:start</span>] = <span class="ruby-identifier">events</span>[<span class="ruby-value">1</span>][<span class="ruby-value str">'datetime'</span>] <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
|
497
|
+
108: <span class="ruby-keyword kw">end</span>
|
498
|
+
109: <span class="ruby-keyword kw">end</span>
|
499
|
+
110: <span class="ruby-keyword kw">end</span>
|
500
|
+
111: <span class="ruby-keyword kw">end</span></pre>
|
501
|
+
</div>
|
502
|
+
|
503
|
+
</div>
|
504
|
+
|
505
|
+
|
506
|
+
|
507
|
+
|
508
|
+
</div>
|
509
|
+
|
510
|
+
|
511
|
+
<div id="time-method" class="method-detail ">
|
512
|
+
<a name="method-i-time"></a>
|
513
|
+
|
514
|
+
<div class="method-heading">
|
515
|
+
|
516
|
+
<span class="method-name">time</span><span
|
517
|
+
class="method-args">()</span>
|
518
|
+
<span class="method-click-advice">click to toggle source</span>
|
519
|
+
|
520
|
+
</div>
|
521
|
+
|
522
|
+
<div class="method-description">
|
523
|
+
|
524
|
+
<p>
|
525
|
+
Return the current timestamp from the server. The timestamp is expressed in
|
526
|
+
milliseconds from Epoch (january 1st 1970). This function can be useful if
|
527
|
+
you need to search for events from <em>now</em>.
|
528
|
+
</p>
|
529
|
+
<pre>
|
530
|
+
uce.time -> 1240394032</pre>
|
531
|
+
|
532
|
+
|
533
|
+
|
534
|
+
<div class="method-source-code"
|
535
|
+
id="time-source">
|
536
|
+
<pre>
|
537
|
+
<span class="ruby-comment cmt"># File lib/ucengine.rb, line 140</span>
|
538
|
+
140: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">time</span>
|
539
|
+
141: <span class="ruby-identifier">time</span> = <span class="ruby-identifier">get</span>(<span class="ruby-value str">"/time"</span>, <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>)[<span class="ruby-value str">'result'</span>].<span class="ruby-identifier">to_i</span>
|
540
|
+
142: <span class="ruby-identifier">debug</span>(<span class="ruby-constant">UCEngine</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>, <span class="ruby-node">"Fecth timestamp from UCEngine: #{time}"</span>)
|
541
|
+
143: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">time</span>
|
542
|
+
144: <span class="ruby-keyword kw">end</span></pre>
|
543
|
+
</div>
|
544
|
+
|
545
|
+
</div>
|
546
|
+
|
547
|
+
|
548
|
+
|
549
|
+
|
550
|
+
</div>
|
551
|
+
|
552
|
+
|
553
|
+
</div>
|
554
|
+
|
555
|
+
<div id="protected-instance-method-details" class="method-section section">
|
556
|
+
<h3 class="section-header">Protected Instance Methods</h3>
|
557
|
+
|
558
|
+
|
559
|
+
<div id="debug-method" class="method-detail ">
|
560
|
+
<a name="method-i-debug"></a>
|
561
|
+
|
562
|
+
<div class="method-heading">
|
563
|
+
|
564
|
+
<span class="method-name">debug</span><span
|
565
|
+
class="method-args">(level, message)</span>
|
566
|
+
<span class="method-click-advice">click to toggle source</span>
|
567
|
+
|
568
|
+
</div>
|
569
|
+
|
570
|
+
<div class="method-description">
|
571
|
+
|
572
|
+
<p>
|
573
|
+
Print debug messages
|
574
|
+
</p>
|
575
|
+
|
576
|
+
|
577
|
+
|
578
|
+
<div class="method-source-code"
|
579
|
+
id="debug-source">
|
580
|
+
<pre>
|
581
|
+
<span class="ruby-comment cmt"># File lib/ucengine.rb, line 154</span>
|
582
|
+
154: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">debug</span>(<span class="ruby-identifier">level</span>, <span class="ruby-identifier">message</span>)
|
583
|
+
155: <span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">write</span>(<span class="ruby-node">"#{message}\n\n"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">level</span> <span class="ruby-operator">>=</span> <span class="ruby-ivar">@debug</span>
|
584
|
+
156: <span class="ruby-keyword kw">end</span></pre>
|
585
|
+
</div>
|
586
|
+
|
587
|
+
</div>
|
588
|
+
|
589
|
+
|
590
|
+
|
591
|
+
|
592
|
+
</div>
|
593
|
+
|
594
|
+
|
595
|
+
<div id="delete-method" class="method-detail ">
|
596
|
+
<a name="method-i-delete"></a>
|
597
|
+
|
598
|
+
<div class="method-heading">
|
599
|
+
|
600
|
+
<span class="method-name">delete</span><span
|
601
|
+
class="method-args">(path, params)</span>
|
602
|
+
<span class="method-click-advice">click to toggle source</span>
|
603
|
+
|
604
|
+
</div>
|
605
|
+
|
606
|
+
<div class="method-description">
|
607
|
+
|
608
|
+
<p>
|
609
|
+
Handle DELETE requests
|
610
|
+
</p>
|
611
|
+
|
612
|
+
|
613
|
+
|
614
|
+
<div class="method-source-code"
|
615
|
+
id="delete-source">
|
616
|
+
<pre>
|
617
|
+
<span class="ruby-comment cmt"># File lib/ucengine.rb, line 183</span>
|
618
|
+
183: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">params</span>)
|
619
|
+
184: <span class="ruby-identifier">params</span>[<span class="ruby-value str">'_method'</span>] = <span class="ruby-value str">"DELETE"</span>
|
620
|
+
185: <span class="ruby-identifier">post</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">params</span>)
|
621
|
+
186: <span class="ruby-keyword kw">end</span></pre>
|
622
|
+
</div>
|
623
|
+
|
624
|
+
</div>
|
625
|
+
|
626
|
+
|
627
|
+
|
628
|
+
|
629
|
+
</div>
|
630
|
+
|
631
|
+
|
632
|
+
<div id="get-method" class="method-detail ">
|
633
|
+
<a name="method-i-get"></a>
|
634
|
+
|
635
|
+
<div class="method-heading">
|
636
|
+
|
637
|
+
<span class="method-name">get</span><span
|
638
|
+
class="method-args">(path, params, http = @http)</span>
|
639
|
+
<span class="method-click-advice">click to toggle source</span>
|
640
|
+
|
641
|
+
</div>
|
642
|
+
|
643
|
+
<div class="method-description">
|
644
|
+
|
645
|
+
<p>
|
646
|
+
Handle GET requests
|
647
|
+
</p>
|
648
|
+
|
649
|
+
|
650
|
+
|
651
|
+
<div class="method-source-code"
|
652
|
+
id="get-source">
|
653
|
+
<pre>
|
654
|
+
<span class="ruby-comment cmt"># File lib/ucengine.rb, line 159</span>
|
655
|
+
159: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">params</span>, <span class="ruby-identifier">http</span> = <span class="ruby-ivar">@http</span>)
|
656
|
+
160: <span class="ruby-identifier">params</span>[<span class="ruby-value">:uid</span>] = <span class="ruby-ivar">@uid</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@uid</span>
|
657
|
+
161: <span class="ruby-identifier">params</span>[<span class="ruby-value">:sid</span>] = <span class="ruby-ivar">@sid</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@sid</span>
|
658
|
+
162: <span class="ruby-identifier">result</span> = <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">http</span>.<span class="ruby-identifier">get</span>(<span class="ruby-node">"/api/0.1/#{path}?#{UCEngine.encode(params)}"</span>).<span class="ruby-identifier">body</span>)
|
659
|
+
163: <span class="ruby-identifier">debug</span>(<span class="ruby-constant">UCEngine</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>, <span class="ruby-node">"Request: GET /api/0.1/#{path}?#{UCEngine.encode(params)}\nResult: #{result}"</span>)
|
660
|
+
164: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>
|
661
|
+
165: <span class="ruby-keyword kw">end</span></pre>
|
662
|
+
</div>
|
663
|
+
|
664
|
+
</div>
|
665
|
+
|
666
|
+
|
667
|
+
|
668
|
+
|
669
|
+
</div>
|
670
|
+
|
671
|
+
|
672
|
+
<div id="post-method" class="method-detail ">
|
673
|
+
<a name="method-i-post"></a>
|
674
|
+
|
675
|
+
<div class="method-heading">
|
676
|
+
|
677
|
+
<span class="method-name">post</span><span
|
678
|
+
class="method-args">(path, params, http = @http)</span>
|
679
|
+
<span class="method-click-advice">click to toggle source</span>
|
680
|
+
|
681
|
+
</div>
|
682
|
+
|
683
|
+
<div class="method-description">
|
684
|
+
|
685
|
+
<p>
|
686
|
+
Handle POST requests
|
687
|
+
</p>
|
688
|
+
|
689
|
+
|
690
|
+
|
691
|
+
<div class="method-source-code"
|
692
|
+
id="post-source">
|
693
|
+
<pre>
|
694
|
+
<span class="ruby-comment cmt"># File lib/ucengine.rb, line 168</span>
|
695
|
+
168: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">post</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">params</span>, <span class="ruby-identifier">http</span> = <span class="ruby-ivar">@http</span>)
|
696
|
+
169: <span class="ruby-identifier">params</span>[<span class="ruby-value">:uid</span>] = <span class="ruby-ivar">@uid</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@uid</span>
|
697
|
+
170: <span class="ruby-identifier">params</span>[<span class="ruby-value">:sid</span>] = <span class="ruby-ivar">@sid</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@sid</span>
|
698
|
+
171: <span class="ruby-identifier">result</span> = <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">http</span>.<span class="ruby-identifier">post</span>(<span class="ruby-node">"/api/0.1/#{path}"</span>, <span class="ruby-constant">UCEngine</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-identifier">params</span>)).<span class="ruby-identifier">body</span>)
|
699
|
+
172: <span class="ruby-identifier">debug</span>(<span class="ruby-constant">UCEngine</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>, <span class="ruby-node">"Request: POST /api/0.1/#{path}?#{UCEngine.encode(params)}\nResult: #{result}"</span>)
|
700
|
+
173: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>
|
701
|
+
174: <span class="ruby-keyword kw">end</span></pre>
|
702
|
+
</div>
|
703
|
+
|
704
|
+
</div>
|
705
|
+
|
706
|
+
|
707
|
+
|
708
|
+
|
709
|
+
</div>
|
710
|
+
|
711
|
+
|
712
|
+
<div id="put-method" class="method-detail ">
|
713
|
+
<a name="method-i-put"></a>
|
714
|
+
|
715
|
+
<div class="method-heading">
|
716
|
+
|
717
|
+
<span class="method-name">put</span><span
|
718
|
+
class="method-args">(path, params)</span>
|
719
|
+
<span class="method-click-advice">click to toggle source</span>
|
720
|
+
|
721
|
+
</div>
|
722
|
+
|
723
|
+
<div class="method-description">
|
724
|
+
|
725
|
+
<p>
|
726
|
+
Handle PUT requests
|
727
|
+
</p>
|
728
|
+
|
729
|
+
|
730
|
+
|
731
|
+
<div class="method-source-code"
|
732
|
+
id="put-source">
|
733
|
+
<pre>
|
734
|
+
<span class="ruby-comment cmt"># File lib/ucengine.rb, line 177</span>
|
735
|
+
177: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">put</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">params</span>)
|
736
|
+
178: <span class="ruby-identifier">params</span>[<span class="ruby-value str">'_method'</span>] = <span class="ruby-value str">"PUT"</span>
|
737
|
+
179: <span class="ruby-identifier">post</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">params</span>)
|
738
|
+
180: <span class="ruby-keyword kw">end</span></pre>
|
739
|
+
</div>
|
740
|
+
|
741
|
+
</div>
|
742
|
+
|
743
|
+
|
744
|
+
|
745
|
+
|
746
|
+
</div>
|
747
|
+
|
748
|
+
|
749
|
+
</div>
|
750
|
+
|
751
|
+
|
752
|
+
</div>
|
753
|
+
|
754
|
+
|
755
|
+
<div id="rdoc-debugging-section-dump" class="debugging-section">
|
756
|
+
|
757
|
+
<p>Disabled; run with --debug to generate this.</p>
|
758
|
+
|
759
|
+
</div>
|
760
|
+
|
761
|
+
<div id="validator-badges">
|
762
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
763
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
764
|
+
Rdoc Generator</a> 1.1.6</small>.</p>
|
765
|
+
</div>
|
766
|
+
|
767
|
+
</body>
|
768
|
+
</html>
|
769
|
+
|