gnip_api 1.2.2 → 1.2.3
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +24 -3
- data/README.md +70 -33
- data/Rakefile +7 -0
- data/doc/rdoc/classes/Gnip/Activity.html +354 -0
- data/doc/rdoc/classes/Gnip/Actor.html +300 -0
- data/doc/rdoc/classes/Gnip/GnipData.html +154 -0
- data/doc/rdoc/classes/Gnip/Message.html +236 -0
- data/doc/rdoc/classes/Gnip/SystemMessage.html +190 -0
- data/doc/rdoc/classes/Gnip/TwitterComplianceMessage.html +194 -0
- data/doc/rdoc/classes/Gnip/UndefinedMessage.html +83 -0
- data/doc/rdoc/classes/Gnip/Url.html +194 -0
- data/doc/rdoc/classes/Gnip.html +95 -0
- data/doc/rdoc/classes/GnipApi/Adapter.html +287 -0
- data/doc/rdoc/classes/GnipApi/Configuration.html +194 -0
- data/doc/rdoc/classes/GnipApi/Endpoints.html +191 -0
- data/doc/rdoc/classes/GnipApi/Errors/Adapter/GnipSoftwareError.html +83 -0
- data/doc/rdoc/classes/GnipApi/Errors/Adapter/RateLimitError.html +83 -0
- data/doc/rdoc/classes/GnipApi/Errors/Adapter/RequestError.html +56 -0
- data/doc/rdoc/classes/GnipApi/Errors/Adapter.html +66 -0
- data/doc/rdoc/classes/GnipApi/Errors/Configuration/InvalidOutputFormat.html +83 -0
- data/doc/rdoc/classes/GnipApi/Errors/Configuration.html +58 -0
- data/doc/rdoc/classes/GnipApi/Errors/JsonParser/ParseError.html +56 -0
- data/doc/rdoc/classes/GnipApi/Errors/JsonParser.html +64 -0
- data/doc/rdoc/classes/GnipApi/Errors/MissingAdapter.html +83 -0
- data/doc/rdoc/classes/GnipApi/Errors/MissingCredentials.html +83 -0
- data/doc/rdoc/classes/GnipApi/Errors/PowerTrack/MissingRules.html +83 -0
- data/doc/rdoc/classes/GnipApi/Errors/PowerTrack/StreamDown.html +56 -0
- data/doc/rdoc/classes/GnipApi/Errors/PowerTrack.html +65 -0
- data/doc/rdoc/classes/GnipApi/Errors/Search/MissingParameters.html +83 -0
- data/doc/rdoc/classes/GnipApi/Errors/Search.html +64 -0
- data/doc/rdoc/classes/GnipApi/Errors.html +79 -0
- data/doc/rdoc/classes/GnipApi/JsonParser.html +101 -0
- data/doc/rdoc/classes/GnipApi/PowerTrack/Buffer.html +237 -0
- data/doc/rdoc/classes/GnipApi/PowerTrack/Rule.html +196 -0
- data/doc/rdoc/classes/GnipApi/PowerTrack/Rules.html +188 -0
- data/doc/rdoc/classes/GnipApi/PowerTrack/Stream.html +359 -0
- data/doc/rdoc/classes/GnipApi/PowerTrack.html +73 -0
- data/doc/rdoc/classes/GnipApi/Request.html +216 -0
- data/doc/rdoc/classes/GnipApi/Response.html +232 -0
- data/doc/rdoc/classes/GnipApi/Search.html +101 -0
- data/doc/rdoc/classes/GnipApi.html +252 -0
- data/doc/rdoc/created.rid +24 -0
- data/doc/rdoc/css/style.css +343 -0
- data/doc/rdoc/files/LICENSE_txt.html +73 -0
- data/doc/rdoc/files/README_md.html +299 -0
- data/doc/rdoc/files/lib/gnip_api/adapter_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/configuration_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/endpoints_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/errors_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/gnip/activity_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/gnip/actor_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/gnip/gnip_data_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/gnip/message_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/gnip/system_message_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/gnip/twitter_compliance_message_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/gnip/url_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/json_parser_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/power_track/buffer_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/power_track/rule_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/power_track/rules_rb.html +55 -0
- data/doc/rdoc/files/lib/gnip_api/power_track/stream_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/request_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/response_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/search_rb.html +55 -0
- data/doc/rdoc/files/lib/gnip_api/version_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api_rb.html +84 -0
- data/doc/rdoc/fr_class_index.html +92 -0
- data/doc/rdoc/fr_file_index.html +41 -0
- data/doc/rdoc/fr_method_index.html +4791 -0
- data/doc/rdoc/index.html +15 -0
- data/gnip_api.gemspec +3 -1
- data/lib/gnip_api/configuration.rb +18 -4
- data/lib/gnip_api/errors.rb +0 -1
- data/lib/gnip_api/power_track/buffer.rb +60 -14
- data/lib/gnip_api/power_track/stream.rb +52 -17
- data/lib/gnip_api/response.rb +3 -2
- data/lib/gnip_api/version.rb +1 -1
- data/spec/gnip_api/power_track/buffer_spec.rb +8 -0
- data/spec/gnip_api/response_spec.rb +16 -0
- data/spec/spec_helper.rb +1 -0
- metadata +97 -2
@@ -0,0 +1,287 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
|
+
<html lang='en'>
|
3
|
+
<head>
|
4
|
+
<title>GnipApi::Adapter</title>
|
5
|
+
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
|
6
|
+
<link href='../../css/style.css' media='screen' rel='stylesheet' type='text/css'>
|
7
|
+
<script type='text/javascript'>
|
8
|
+
function popupCode(url) {
|
9
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
10
|
+
}
|
11
|
+
|
12
|
+
function toggleCode(id) {
|
13
|
+
var code = document.getElementById(id)
|
14
|
+
|
15
|
+
code.style.display = code.style.display != 'block' ? 'block' : 'none'
|
16
|
+
return true
|
17
|
+
}
|
18
|
+
|
19
|
+
// Make codeblocks hidden by default
|
20
|
+
document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
|
21
|
+
</script>
|
22
|
+
</head>
|
23
|
+
<body class='page'>
|
24
|
+
<div class='class' id='wrapper'>
|
25
|
+
<div class='header'>
|
26
|
+
<h1 class='name'><span class='type'>class</span>
|
27
|
+
GnipApi::Adapter
|
28
|
+
</h1>
|
29
|
+
<ol class='paths'>
|
30
|
+
<li>
|
31
|
+
<a href="../../files/lib/gnip_api/adapter_rb.html">lib/gnip_api/adapter.rb</a>
|
32
|
+
</li>
|
33
|
+
<li class='other'>
|
34
|
+
<a href="../../files/lib/gnip_api/request_rb.html">lib/gnip_api/request.rb</a>
|
35
|
+
</li>
|
36
|
+
<li>
|
37
|
+
<a class='show' href='#' onclick='this.parentNode.parentNode.className += " expanded"; this.parentNode.removeChild(this); return false'>show all</a>
|
38
|
+
</li>
|
39
|
+
</ol>
|
40
|
+
<div class='parent'>
|
41
|
+
Superclass:
|
42
|
+
<strong>Object</strong>
|
43
|
+
</div>
|
44
|
+
</div>
|
45
|
+
<div id='content'>
|
46
|
+
<div id='text'>
|
47
|
+
<div id='description'>
|
48
|
+
<p>The interface to the world. Wraps the net adapter of choice and exposes
|
49
|
+
common methods for the rest of the classes to use, abstracting details of
|
50
|
+
the request/response. A note on the data: HTTParty was selected over Excon
|
51
|
+
for the simple reason that Excon doesn't handle GZip responses.
|
52
|
+
HTTParty uses net/http under the hood and handles this as expected.
|
53
|
+
However, for reasons I don't know at this point, the Zlib responsible
|
54
|
+
of inflating the GZip compressed data waits to fill in a buffer in order to
|
55
|
+
return a decompressed chunk. You can test this on a farily busy stream and
|
56
|
+
you'll see that all chunks you receive decompressed are almsot always
|
57
|
+
16384 bytes. Additionally, the rn <a href="../Gnip.html">Gnip</a> sends as
|
58
|
+
a keep alive signal seems to be buffered further. As a result I expose 2
|
59
|
+
additional methods for consuming the stream that uses Curl instead. Curl
|
60
|
+
handles the GZip data better. You can launch it in a shell and the keep
|
61
|
+
alive signals are properly there. These alternatives are a bit of a cheat,
|
62
|
+
but allows delegation of handling the actual connection and the GZip data.</p>
|
63
|
+
|
64
|
+
<p><a href="Adapter.html#method-i-stream_get">stream_get</a> will work as
|
65
|
+
usual, using HTTParty and Net::HTTP stuff.</p>
|
66
|
+
|
67
|
+
<p><a href="Adapter.html#method-i-io_curl_stream">io_curl_stream</a> will
|
68
|
+
launch a subprocess and capture output with IO.popen. This method behaves
|
69
|
+
similarly to <a href="Adapter.html#method-i-stream_get">stream_get</a>
|
70
|
+
regarding the keep alive signals. However, these are returned all at once
|
71
|
+
when a bigger chunk of data is sent over the stream. Still, it reads them
|
72
|
+
well and can be handled.</p>
|
73
|
+
|
74
|
+
<p><a href="Adapter.html#method-i-pty_curl_stream">pty_curl_stream</a> is
|
75
|
+
different. Using the PTY features, a shell is opened and the output
|
76
|
+
captured is as (in my opinion) should be. All keep-alive signals are
|
77
|
+
returned when received with no wait at all.</p>
|
78
|
+
|
79
|
+
<p>All this will remain experimental until tested on a real environment. I
|
80
|
+
recomment to use <a href="Adapter.html#method-i-stream_get">stream_get</a>
|
81
|
+
which was already tested and works as expected.</p>
|
82
|
+
</div>
|
83
|
+
<div id='method-list'>
|
84
|
+
<h2>Methods</h2>
|
85
|
+
<h3>Public Class</h3>
|
86
|
+
<ol>
|
87
|
+
<li><a href="#method-c-new">new</a></li>
|
88
|
+
</ol>
|
89
|
+
<h3>Public Instance</h3>
|
90
|
+
<ol>
|
91
|
+
<li><a href="#attribute-i-debug">debug</a></li>
|
92
|
+
<li><a href="#method-i-delete">delete</a></li>
|
93
|
+
<li><a href="#method-i-get">get</a></li>
|
94
|
+
<li><a href="#method-i-io_curl_stream">io_curl_stream</a></li>
|
95
|
+
<li><a href="#attribute-i-logger">logger</a></li>
|
96
|
+
<li><a href="#method-i-post">post</a></li>
|
97
|
+
<li><a href="#method-i-pty_curl_stream">pty_curl_stream</a></li>
|
98
|
+
<li><a href="#method-i-stream_get">stream_get</a></li>
|
99
|
+
</ol>
|
100
|
+
</div>
|
101
|
+
<div id='context'>
|
102
|
+
</div>
|
103
|
+
<div id='section'>
|
104
|
+
<div id='constants-list'>
|
105
|
+
<h2>Constants</h2>
|
106
|
+
<div class='name-list'>
|
107
|
+
<table summary='Constants'>
|
108
|
+
<tr class='top-aligned-row context-row'>
|
109
|
+
<td class='context-item-name'>DELETE</td>
|
110
|
+
<td>=</td>
|
111
|
+
<td class='context-item-value'>'DELETE'</td>
|
112
|
+
<td> </td>
|
113
|
+
<td class='context-item-desc'></td>
|
114
|
+
</tr>
|
115
|
+
<tr class='top-aligned-row context-row'>
|
116
|
+
<td class='context-item-name'>GET</td>
|
117
|
+
<td>=</td>
|
118
|
+
<td class='context-item-value'>'GET'</td>
|
119
|
+
<td> </td>
|
120
|
+
<td class='context-item-desc'></td>
|
121
|
+
</tr>
|
122
|
+
<tr class='top-aligned-row context-row'>
|
123
|
+
<td class='context-item-name'>POST</td>
|
124
|
+
<td>=</td>
|
125
|
+
<td class='context-item-value'>'POST'</td>
|
126
|
+
<td> </td>
|
127
|
+
<td class='context-item-desc'></td>
|
128
|
+
</tr>
|
129
|
+
</table>
|
130
|
+
</div>
|
131
|
+
</div>
|
132
|
+
<div id='attribute-list'>
|
133
|
+
<h2 class='section-bar'>Attributes</h2>
|
134
|
+
<div class='name-list'>
|
135
|
+
<table>
|
136
|
+
<tr class='top-aligned-row context-row'>
|
137
|
+
<td class='context-item-name'>
|
138
|
+
<a name='attribute-i-debug'>debug</a>
|
139
|
+
</td>
|
140
|
+
<td class='context-item-value'>[R]</td>
|
141
|
+
<td class='context-item-desc'></td>
|
142
|
+
</tr>
|
143
|
+
<tr class='top-aligned-row context-row'>
|
144
|
+
<td class='context-item-name'>
|
145
|
+
<a name='attribute-i-logger'>logger</a>
|
146
|
+
</td>
|
147
|
+
<td class='context-item-value'>[R]</td>
|
148
|
+
<td class='context-item-desc'></td>
|
149
|
+
</tr>
|
150
|
+
</table>
|
151
|
+
</div>
|
152
|
+
</div>
|
153
|
+
<div id='methods'>
|
154
|
+
<h2>Public Class methods</h2>
|
155
|
+
<div class='method public-class' id='method-method-c-new'>
|
156
|
+
<a name='method-c-new'></a>
|
157
|
+
<div class='synopsis'>
|
158
|
+
<span class='name'>new</span>
|
159
|
+
<span class='arguments'>()</span>
|
160
|
+
|
161
|
+
</div>
|
162
|
+
<div class='description'>
|
163
|
+
|
164
|
+
</div>
|
165
|
+
<div class='source'>
|
166
|
+
<a class='source-toggle' href='#' onclick='toggleCode('method-c-new-source'); return false'>
|
167
|
+
[show source]
|
168
|
+
</a>
|
169
|
+
<pre id='method-c-new-source'><span class="ruby-comment"># File lib/gnip_api/adapter.rb, line 38</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>
 <span class="ruby-identifier">raise</span> <span class="ruby-constant">GnipApi</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">MissingCredentials</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">GnipApi</span>.<span class="ruby-identifier">credentials?</span>
 <span class="ruby-ivar">@logger</span> = <span class="ruby-constant">GnipApi</span>.<span class="ruby-identifier">config</span>.<span class="ruby-identifier">logger</span>
 <span class="ruby-ivar">@debug</span> = <span class="ruby-constant">GnipApi</span>.<span class="ruby-identifier">config</span>.<span class="ruby-identifier">debug</span>
<span class="ruby-keyword">end</span></pre>
|
170
|
+
</div>
|
171
|
+
</div>
|
172
|
+
<h2>Public Instance methods</h2>
|
173
|
+
<div class='method public-instance' id='method-method-i-delete'>
|
174
|
+
<a name='method-i-delete'></a>
|
175
|
+
<div class='synopsis'>
|
176
|
+
<span class='name'>delete</span>
|
177
|
+
<span class='arguments'>(request)</span>
|
178
|
+
|
179
|
+
</div>
|
180
|
+
<div class='description'>
|
181
|
+
|
182
|
+
</div>
|
183
|
+
<div class='source'>
|
184
|
+
<a class='source-toggle' href='#' onclick='toggleCode('method-i-delete-source'); return false'>
|
185
|
+
[show source]
|
186
|
+
</a>
|
187
|
+
<pre id='method-i-delete-source'><span class="ruby-comment"># File lib/gnip_api/adapter.rb, line 56</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">delete</span> <span class="ruby-identifier">request</span>
 <span class="ruby-identifier">options</span> = <span class="ruby-identifier">default_options</span>(<span class="ruby-identifier">request</span>)
 <span class="ruby-identifier">data</span> = <span class="ruby-constant">HTTParty</span>.<span class="ruby-identifier">post</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">options</span>
 <span class="ruby-identifier">create_response</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">data</span>.<span class="ruby-identifier">code</span>, <span class="ruby-identifier">data</span>.<span class="ruby-identifier">body</span>, <span class="ruby-identifier">data</span>.<span class="ruby-identifier">headers</span>)
<span class="ruby-keyword">end</span></pre>
|
188
|
+
</div>
|
189
|
+
</div>
|
190
|
+
<div class='method public-instance' id='method-method-i-get'>
|
191
|
+
<a name='method-i-get'></a>
|
192
|
+
<div class='synopsis'>
|
193
|
+
<span class='name'>get</span>
|
194
|
+
<span class='arguments'>(request)</span>
|
195
|
+
|
196
|
+
</div>
|
197
|
+
<div class='description'>
|
198
|
+
|
199
|
+
</div>
|
200
|
+
<div class='source'>
|
201
|
+
<a class='source-toggle' href='#' onclick='toggleCode('method-i-get-source'); return false'>
|
202
|
+
[show source]
|
203
|
+
</a>
|
204
|
+
<pre id='method-i-get-source'><span class="ruby-comment"># File lib/gnip_api/adapter.rb, line 44</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">get</span> <span class="ruby-identifier">request</span>
 <span class="ruby-identifier">options</span> = <span class="ruby-identifier">default_options</span>(<span class="ruby-identifier">request</span>)
 <span class="ruby-identifier">data</span> = <span class="ruby-constant">HTTParty</span>.<span class="ruby-identifier">get</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">options</span>
 <span class="ruby-identifier">create_response</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">data</span>.<span class="ruby-identifier">code</span>, <span class="ruby-identifier">data</span>.<span class="ruby-identifier">body</span>, <span class="ruby-identifier">data</span>.<span class="ruby-identifier">headers</span>)
<span class="ruby-keyword">end</span></pre>
|
205
|
+
</div>
|
206
|
+
</div>
|
207
|
+
<div class='method public-instance' id='method-method-i-io_curl_stream'>
|
208
|
+
<a name='method-i-io_curl_stream'></a>
|
209
|
+
<div class='synopsis'>
|
210
|
+
<span class='name'>io_curl_stream</span>
|
211
|
+
<span class='arguments'>(request)</span>
|
212
|
+
|
213
|
+
</div>
|
214
|
+
<div class='description'>
|
215
|
+
|
216
|
+
</div>
|
217
|
+
<div class='source'>
|
218
|
+
<a class='source-toggle' href='#' onclick='toggleCode('method-i-io_curl_stream-source'); return false'>
|
219
|
+
[show source]
|
220
|
+
</a>
|
221
|
+
<pre id='method-i-io_curl_stream-source'><span class="ruby-comment"># File lib/gnip_api/adapter.rb, line 74</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">io_curl_stream</span> <span class="ruby-identifier">request</span>
 <span class="ruby-identifier">request</span>.<span class="ruby-identifier">log!</span>
 <span class="ruby-identifier">auth_header</span> = <span class="ruby-node">"Authorization: Basic #{base64_auth}"</span>
 <span class="ruby-identifier">cmd</span> = <span class="ruby-node">"curl --compressed -s --header \"#{auth_header}\" \"#{request.uri}\""</span>
 <span class="ruby-keyword">begin</span>
 <span class="ruby-constant">IO</span>.<span class="ruby-identifier">popen</span>(<span class="ruby-identifier">cmd</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">io</span><span class="ruby-operator">|</span>
 <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span> = <span class="ruby-identifier">io</span>.<span class="ruby-identifier">gets</span>.<span class="ruby-identifier">strip</span> <span class="ruby-keyword">do</span>
 <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span> <span class="ruby-string">"Keep alive received"</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">==</span> <span class="ruby-string">''</span>
 <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">==</span> <span class="ruby-string">''</span>
 <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">line</span>)
 <span class="ruby-keyword">end</span>
 <span class="ruby-keyword">end</span>
 <span class="ruby-keyword">ensure</span>
 <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">warn</span> <span class="ruby-string">"Stream closed"</span>
 <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
|
222
|
+
</div>
|
223
|
+
</div>
|
224
|
+
<div class='method public-instance' id='method-method-i-post'>
|
225
|
+
<a name='method-i-post'></a>
|
226
|
+
<div class='synopsis'>
|
227
|
+
<span class='name'>post</span>
|
228
|
+
<span class='arguments'>(request)</span>
|
229
|
+
|
230
|
+
</div>
|
231
|
+
<div class='description'>
|
232
|
+
|
233
|
+
</div>
|
234
|
+
<div class='source'>
|
235
|
+
<a class='source-toggle' href='#' onclick='toggleCode('method-i-post-source'); return false'>
|
236
|
+
[show source]
|
237
|
+
</a>
|
238
|
+
<pre id='method-i-post-source'><span class="ruby-comment"># File lib/gnip_api/adapter.rb, line 50</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">post</span> <span class="ruby-identifier">request</span>
 <span class="ruby-identifier">options</span> = <span class="ruby-identifier">default_options</span>(<span class="ruby-identifier">request</span>)
 <span class="ruby-identifier">data</span> = <span class="ruby-constant">HTTParty</span>.<span class="ruby-identifier">post</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">options</span>
 <span class="ruby-identifier">create_response</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">data</span>.<span class="ruby-identifier">code</span>, <span class="ruby-identifier">data</span>.<span class="ruby-identifier">body</span>, <span class="ruby-identifier">data</span>.<span class="ruby-identifier">headers</span>)
<span class="ruby-keyword">end</span></pre>
|
239
|
+
</div>
|
240
|
+
</div>
|
241
|
+
<div class='method public-instance' id='method-method-i-pty_curl_stream'>
|
242
|
+
<a name='method-i-pty_curl_stream'></a>
|
243
|
+
<div class='synopsis'>
|
244
|
+
<span class='name'>pty_curl_stream</span>
|
245
|
+
<span class='arguments'>(request)</span>
|
246
|
+
|
247
|
+
</div>
|
248
|
+
<div class='description'>
|
249
|
+
|
250
|
+
</div>
|
251
|
+
<div class='source'>
|
252
|
+
<a class='source-toggle' href='#' onclick='toggleCode('method-i-pty_curl_stream-source'); return false'>
|
253
|
+
[show source]
|
254
|
+
</a>
|
255
|
+
<pre id='method-i-pty_curl_stream-source'><span class="ruby-comment"># File lib/gnip_api/adapter.rb, line 91</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">pty_curl_stream</span> <span class="ruby-identifier">request</span>
 <span class="ruby-identifier">request</span>.<span class="ruby-identifier">log!</span>
 <span class="ruby-identifier">auth_header</span> = <span class="ruby-node">"Authorization: Basic #{base64_auth}"</span>
 <span class="ruby-identifier">cmd</span> = <span class="ruby-node">"curl --compressed -s --header \"#{auth_header}\" \"#{request.uri}\""</span>
 <span class="ruby-keyword">begin</span>
 <span class="ruby-constant">PTY</span>.<span class="ruby-identifier">spawn</span>(<span class="ruby-identifier">cmd</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">stdout</span>, <span class="ruby-identifier">stdin</span>, <span class="ruby-identifier">pid</span><span class="ruby-operator">|</span>
 <span class="ruby-keyword">begin</span>
 <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
 <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span> <span class="ruby-string">"Keep alive received"</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">strip</span> <span class="ruby-operator">==</span> <span class="ruby-string">''</span>
 <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">strip</span> <span class="ruby-operator">==</span> <span class="ruby-string">''</span>
 <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">line</span>.<span class="ruby-identifier">strip</span>)
 <span class="ruby-keyword">end</span>
 <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EIO</span>
 <span class="ruby-keyword">end</span>
 <span class="ruby-keyword">end</span>
 <span class="ruby-keyword">rescue</span> <span class="ruby-constant">PTY</span><span class="ruby-operator">::</span><span class="ruby-constant">ChildExited</span>
 <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">warn</span> <span class="ruby-string">"Stream closed"</span>
 <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
|
256
|
+
</div>
|
257
|
+
</div>
|
258
|
+
<div class='method public-instance' id='method-method-i-stream_get'>
|
259
|
+
<a name='method-i-stream_get'></a>
|
260
|
+
<div class='synopsis'>
|
261
|
+
<span class='name'>stream_get</span>
|
262
|
+
<span class='arguments'>(request)</span>
|
263
|
+
|
264
|
+
</div>
|
265
|
+
<div class='description'>
|
266
|
+
|
267
|
+
</div>
|
268
|
+
<div class='source'>
|
269
|
+
<a class='source-toggle' href='#' onclick='toggleCode('method-i-stream_get-source'); return false'>
|
270
|
+
[show source]
|
271
|
+
</a>
|
272
|
+
<pre id='method-i-stream_get-source'><span class="ruby-comment"># File lib/gnip_api/adapter.rb, line 62</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">stream_get</span> <span class="ruby-identifier">request</span>
 <span class="ruby-identifier">request</span>.<span class="ruby-identifier">log!</span>
 <span class="ruby-keyword">begin</span>
 <span class="ruby-constant">HTTParty</span>.<span class="ruby-identifier">get</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">uri</span>, <span class="ruby-value">:headers</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">headers</span>, <span class="ruby-value">:stream_body</span> =<span class="ruby-operator">></span> <span class="ruby-keyword">true</span>, <span class="ruby-value">:basic_auth</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">auth</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">data</span><span class="ruby-operator">|</span>
 <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">data</span>)
 <span class="ruby-keyword">end</span>
 <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">BufError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">error</span>
 <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span> <span class="ruby-node">"STREAM ERROR -> #{error.class} -- #{error.message}\n"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">error</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">"\n"</span>)
 <span class="ruby-identifier">raise</span> <span class="ruby-identifier">error</span>
 <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
|
273
|
+
</div>
|
274
|
+
</div>
|
275
|
+
</div>
|
276
|
+
</div>
|
277
|
+
|
278
|
+
</div>
|
279
|
+
</div>
|
280
|
+
|
281
|
+
<div id='footer-push'></div>
|
282
|
+
</div>
|
283
|
+
<div id='footer'>
|
284
|
+
<a href="https://github.com/rdoc/hanna-nouveau"><strong>Hanna Nouveau</strong> RDoc template</a>
|
285
|
+
</div>
|
286
|
+
</body>
|
287
|
+
</html>
|
@@ -0,0 +1,194 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
|
+
<html lang='en'>
|
3
|
+
<head>
|
4
|
+
<title>GnipApi::Configuration</title>
|
5
|
+
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
|
6
|
+
<link href='../../css/style.css' media='screen' rel='stylesheet' type='text/css'>
|
7
|
+
<script type='text/javascript'>
|
8
|
+
function popupCode(url) {
|
9
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
10
|
+
}
|
11
|
+
|
12
|
+
function toggleCode(id) {
|
13
|
+
var code = document.getElementById(id)
|
14
|
+
|
15
|
+
code.style.display = code.style.display != 'block' ? 'block' : 'none'
|
16
|
+
return true
|
17
|
+
}
|
18
|
+
|
19
|
+
// Make codeblocks hidden by default
|
20
|
+
document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
|
21
|
+
</script>
|
22
|
+
</head>
|
23
|
+
<body class='page'>
|
24
|
+
<div class='class' id='wrapper'>
|
25
|
+
<div class='header'>
|
26
|
+
<h1 class='name'><span class='type'>class</span>
|
27
|
+
GnipApi::Configuration
|
28
|
+
</h1>
|
29
|
+
<ol class='paths'>
|
30
|
+
<li>
|
31
|
+
<a href="../../files/lib/gnip_api/configuration_rb.html">lib/gnip_api/configuration.rb</a>
|
32
|
+
</li>
|
33
|
+
</ol>
|
34
|
+
<div class='parent'>
|
35
|
+
Superclass:
|
36
|
+
<strong>Object</strong>
|
37
|
+
</div>
|
38
|
+
</div>
|
39
|
+
<div id='content'>
|
40
|
+
<div id='text'>
|
41
|
+
<div id='description'>
|
42
|
+
<p>Configurations for the <a href="../GnipApi.html">GnipApi</a> gem.</p>
|
43
|
+
|
44
|
+
<p>Defaults:</p>
|
45
|
+
<ul><li>
|
46
|
+
<p>logger: *Logger.new('tmp/gnip_api.log')*</p>
|
47
|
+
</li><li>
|
48
|
+
<p><a
|
49
|
+
href="Configuration.html#attribute-i-request_timeout">#request_timeout</a>:
|
50
|
+
<strong>60</strong></p>
|
51
|
+
</li><li>
|
52
|
+
<p>debug: <strong>false</strong></p>
|
53
|
+
</li><li>
|
54
|
+
<p><a href="Configuration.html#attribute-i-enable_gzip">#enable_gzip</a>:
|
55
|
+
<strong>true</strong></p>
|
56
|
+
</li><li>
|
57
|
+
<p><a href="Configuration.html#attribute-i-log_level">#log_level</a>:
|
58
|
+
<strong>Logger::WARN</strong></p>
|
59
|
+
</li><li>
|
60
|
+
<p>buffer_limit: <strong>1000000</strong></p>
|
61
|
+
</li></ul>
|
62
|
+
</div>
|
63
|
+
<div id='method-list'>
|
64
|
+
<h2>Methods</h2>
|
65
|
+
<h3>Public Class</h3>
|
66
|
+
<ol>
|
67
|
+
<li><a href="#method-c-new">new</a></li>
|
68
|
+
</ol>
|
69
|
+
<h3>Public Instance</h3>
|
70
|
+
<ol>
|
71
|
+
<li><a href="#attribute-i-account">account</a></li>
|
72
|
+
<li><a href="#attribute-i-debug">debug</a></li>
|
73
|
+
<li><a href="#attribute-i-enable_gzip">enable_gzip</a></li>
|
74
|
+
<li><a href="#attribute-i-label">label</a></li>
|
75
|
+
<li><a href="#attribute-i-log_level">log_level</a></li>
|
76
|
+
<li><a href="#attribute-i-logger">logger</a></li>
|
77
|
+
<li><a href="#attribute-i-password">password</a></li>
|
78
|
+
<li><a href="#attribute-i-request_timeout">request_timeout</a></li>
|
79
|
+
<li><a href="#attribute-i-source">source</a></li>
|
80
|
+
<li><a href="#attribute-i-user">user</a></li>
|
81
|
+
</ol>
|
82
|
+
</div>
|
83
|
+
<div id='context'>
|
84
|
+
</div>
|
85
|
+
<div id='section'>
|
86
|
+
<div id='attribute-list'>
|
87
|
+
<h2 class='section-bar'>Attributes</h2>
|
88
|
+
<div class='name-list'>
|
89
|
+
<table>
|
90
|
+
<tr class='top-aligned-row context-row'>
|
91
|
+
<td class='context-item-name'>
|
92
|
+
<a name='attribute-i-account'>account</a>
|
93
|
+
</td>
|
94
|
+
<td class='context-item-value'>[RW]</td>
|
95
|
+
<td class='context-item-desc'></td>
|
96
|
+
</tr>
|
97
|
+
<tr class='top-aligned-row context-row'>
|
98
|
+
<td class='context-item-name'>
|
99
|
+
<a name='attribute-i-debug'>debug</a>
|
100
|
+
</td>
|
101
|
+
<td class='context-item-value'>[RW]</td>
|
102
|
+
<td class='context-item-desc'></td>
|
103
|
+
</tr>
|
104
|
+
<tr class='top-aligned-row context-row'>
|
105
|
+
<td class='context-item-name'>
|
106
|
+
<a name='attribute-i-enable_gzip'>enable_gzip</a>
|
107
|
+
</td>
|
108
|
+
<td class='context-item-value'>[RW]</td>
|
109
|
+
<td class='context-item-desc'></td>
|
110
|
+
</tr>
|
111
|
+
<tr class='top-aligned-row context-row'>
|
112
|
+
<td class='context-item-name'>
|
113
|
+
<a name='attribute-i-label'>label</a>
|
114
|
+
</td>
|
115
|
+
<td class='context-item-value'>[RW]</td>
|
116
|
+
<td class='context-item-desc'></td>
|
117
|
+
</tr>
|
118
|
+
<tr class='top-aligned-row context-row'>
|
119
|
+
<td class='context-item-name'>
|
120
|
+
<a name='attribute-i-log_level'>log_level</a>
|
121
|
+
</td>
|
122
|
+
<td class='context-item-value'>[RW]</td>
|
123
|
+
<td class='context-item-desc'></td>
|
124
|
+
</tr>
|
125
|
+
<tr class='top-aligned-row context-row'>
|
126
|
+
<td class='context-item-name'>
|
127
|
+
<a name='attribute-i-logger'>logger</a>
|
128
|
+
</td>
|
129
|
+
<td class='context-item-value'>[RW]</td>
|
130
|
+
<td class='context-item-desc'></td>
|
131
|
+
</tr>
|
132
|
+
<tr class='top-aligned-row context-row'>
|
133
|
+
<td class='context-item-name'>
|
134
|
+
<a name='attribute-i-password'>password</a>
|
135
|
+
</td>
|
136
|
+
<td class='context-item-value'>[RW]</td>
|
137
|
+
<td class='context-item-desc'></td>
|
138
|
+
</tr>
|
139
|
+
<tr class='top-aligned-row context-row'>
|
140
|
+
<td class='context-item-name'>
|
141
|
+
<a name='attribute-i-request_timeout'>request_timeout</a>
|
142
|
+
</td>
|
143
|
+
<td class='context-item-value'>[RW]</td>
|
144
|
+
<td class='context-item-desc'></td>
|
145
|
+
</tr>
|
146
|
+
<tr class='top-aligned-row context-row'>
|
147
|
+
<td class='context-item-name'>
|
148
|
+
<a name='attribute-i-source'>source</a>
|
149
|
+
</td>
|
150
|
+
<td class='context-item-value'>[RW]</td>
|
151
|
+
<td class='context-item-desc'></td>
|
152
|
+
</tr>
|
153
|
+
<tr class='top-aligned-row context-row'>
|
154
|
+
<td class='context-item-name'>
|
155
|
+
<a name='attribute-i-user'>user</a>
|
156
|
+
</td>
|
157
|
+
<td class='context-item-value'>[RW]</td>
|
158
|
+
<td class='context-item-desc'></td>
|
159
|
+
</tr>
|
160
|
+
</table>
|
161
|
+
</div>
|
162
|
+
</div>
|
163
|
+
<div id='methods'>
|
164
|
+
<h2>Public Class methods</h2>
|
165
|
+
<div class='method public-class' id='method-method-c-new'>
|
166
|
+
<a name='method-c-new'></a>
|
167
|
+
<div class='synopsis'>
|
168
|
+
<span class='name'>new</span>
|
169
|
+
<span class='arguments'>()</span>
|
170
|
+
|
171
|
+
</div>
|
172
|
+
<div class='description'>
|
173
|
+
|
174
|
+
</div>
|
175
|
+
<div class='source'>
|
176
|
+
<a class='source-toggle' href='#' onclick='toggleCode('method-c-new-source'); return false'>
|
177
|
+
[show source]
|
178
|
+
</a>
|
179
|
+
<pre id='method-c-new-source'><span class="ruby-comment"># File lib/gnip_api/configuration.rb, line 15</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>
 <span class="ruby-ivar">@logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">'tmp/gnip_api.log'</span>)
 <span class="ruby-ivar">@request_timeout</span> = <span class="ruby-value">60</span>
 <span class="ruby-ivar">@debug</span> = <span class="ruby-keyword">false</span>
 <span class="ruby-ivar">@enable_gzip</span> = <span class="ruby-keyword">true</span>

 <span class="ruby-ivar">@log_level</span> = <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">WARN</span>
 <span class="ruby-ivar">@logger</span>.<span class="ruby-identifier">level</span> = <span class="ruby-ivar">@log_level</span>
<span class="ruby-keyword">end</span></pre>
|
180
|
+
</div>
|
181
|
+
</div>
|
182
|
+
</div>
|
183
|
+
</div>
|
184
|
+
|
185
|
+
</div>
|
186
|
+
</div>
|
187
|
+
|
188
|
+
<div id='footer-push'></div>
|
189
|
+
</div>
|
190
|
+
<div id='footer'>
|
191
|
+
<a href="https://github.com/rdoc/hanna-nouveau"><strong>Hanna Nouveau</strong> RDoc template</a>
|
192
|
+
</div>
|
193
|
+
</body>
|
194
|
+
</html>
|