soup-ruby 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -1
- data/ext/soup/extconf.rb +103 -0
- data/ext/soup/soup.c +381 -0
- data/ext/soup/soup.rd +45 -0
- data/lib/soup/version.rb +1 -1
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8417f165649590d2812c9f23b1d8d835403f8659
|
4
|
+
data.tar.gz: 7bd581fed65b6d943d944ee432bafdb1fc9920fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afec2298738caaa47d3956326fde54b703e8712b1965ea06f8dbfc491d8534106b16ab20895a417307b49487891896d058e95a58e14584d189c22b65c319deb0
|
7
|
+
data.tar.gz: 5a731a4d5fbba390463b418ab0bcc4a7fc5b708b73fbd1a5d60eb59635d0f5352b5105020ee30f53ca79434082994f7ac2c06ff0915ec815cc31ccd16c08310f
|
data/Rakefile
CHANGED
@@ -31,7 +31,8 @@ spec = Gem::Specification.new do |s|
|
|
31
31
|
s.add_dependency("rubber-generate", ">= 0.0.17")
|
32
32
|
s.platform = Gem::Platform::RUBY
|
33
33
|
s.extensions = FileList["ext/*/extconf.rb"]
|
34
|
-
|
34
|
+
s.licenses = ['The Ruby License']
|
35
|
+
s.files = FileList['ext/*/*.{c,h,cr,rd,rb}'] + ['Rakefile', 'README.md'] + FileList['lib/**/*.rb']
|
35
36
|
s.description = <<-EOF
|
36
37
|
Libsoup bindings for ruby. Partial coverage sufficient to allow HTTP requests to be handled without blocking the mainloop.
|
37
38
|
|
data/ext/soup/extconf.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
use_gems = false
|
3
|
+
begin
|
4
|
+
require 'mkmf-gnome2'
|
5
|
+
rescue LoadError
|
6
|
+
use_gems = true
|
7
|
+
end
|
8
|
+
|
9
|
+
if use_gems or Object.const_defined?('Gem')
|
10
|
+
require 'rubygems'
|
11
|
+
gem 'glib2'
|
12
|
+
require 'mkmf-gnome2'
|
13
|
+
%w[rbglib.h rbgtk.h rbpango.h rbatk.h].each do |header|
|
14
|
+
Gem.find_files(header).each do |f|
|
15
|
+
$CFLAGS += " '-I#{File.dirname(f)}'"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
# Look for headers in {gem_root}/ext/{package}
|
20
|
+
if use_gems
|
21
|
+
%w[
|
22
|
+
glib2 gdk_pixbuf2 atk gtk2 ].each do |package|
|
23
|
+
require package
|
24
|
+
$CFLAGS += " -I"+Gem.loaded_specs[package].full_gem_path+"/ext/"+package
|
25
|
+
end
|
26
|
+
end
|
27
|
+
if RbConfig::CONFIG.has_key?('rubyhdrdir')
|
28
|
+
$CFLAGS += " -I" + RbConfig::CONFIG['rubyhdrdir']+'/ruby'
|
29
|
+
end
|
30
|
+
|
31
|
+
$CFLAGS += " -I."
|
32
|
+
have_func("rb_errinfo")
|
33
|
+
PKGConfig.have_package("gtk+-2.0") or exit(-1)
|
34
|
+
PKGConfig.have_package("libsoup-2.4") or exit(-1)
|
35
|
+
have_header("libsoup/soup.h") or exit(-1)
|
36
|
+
|
37
|
+
STDOUT.print("checking for new allocation framework... ") # for ruby-1.7
|
38
|
+
if Object.respond_to? :allocate
|
39
|
+
STDOUT.print "yes
|
40
|
+
"
|
41
|
+
$defs << "-DHAVE_OBJECT_ALLOCATE"
|
42
|
+
else
|
43
|
+
STDOUT.print "no
|
44
|
+
"
|
45
|
+
end
|
46
|
+
|
47
|
+
top = File.expand_path(File.dirname(__FILE__) + '/..') # XXX
|
48
|
+
$CFLAGS += " " + ['glib/src'].map{|d|
|
49
|
+
"-I" + File.join(top, d)
|
50
|
+
}.join(" ")
|
51
|
+
|
52
|
+
have_func("rb_define_alloc_func") # for ruby-1.8
|
53
|
+
|
54
|
+
#set_output_lib('libruby-soup.a')
|
55
|
+
if /cygwin|mingw/ =~ RUBY_PLATFORM
|
56
|
+
top = "../.."
|
57
|
+
[
|
58
|
+
["glib/src", "ruby-glib2"],
|
59
|
+
].each{|d,l|
|
60
|
+
$LDFLAGS << sprintf(" -L%s/%s", top, d)
|
61
|
+
$libs << sprintf(" -l%s", l)
|
62
|
+
}
|
63
|
+
end
|
64
|
+
begin
|
65
|
+
srcdir = File.expand_path(File.dirname($0))
|
66
|
+
|
67
|
+
begin
|
68
|
+
|
69
|
+
obj_ext = "."+$OBJEXT
|
70
|
+
|
71
|
+
$libs = $libs.split(/ /).uniq.join(' ')
|
72
|
+
$source_files = Dir.glob(sprintf("%s/*.c", srcdir)).map{|fname|
|
73
|
+
fname[0, srcdir.length+1] = ''
|
74
|
+
fname
|
75
|
+
}
|
76
|
+
$objs = $source_files.collect do |item|
|
77
|
+
item.gsub(/.c$/, obj_ext)
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# create Makefile
|
82
|
+
#
|
83
|
+
$defs << "-DRUBY_SOUP_COMPILATION"
|
84
|
+
# $CFLAGS << $defs.join(' ')
|
85
|
+
create_makefile("soup", srcdir)
|
86
|
+
raise Interrupt if not FileTest.exist? "Makefile"
|
87
|
+
|
88
|
+
File.open("Makefile", "a") do |mfile|
|
89
|
+
$source_files.each do |e|
|
90
|
+
mfile.print sprintf("%s: %s
|
91
|
+
", e.gsub(/.c$/, obj_ext), e)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
ensure
|
95
|
+
#Dir.chdir ".."
|
96
|
+
end
|
97
|
+
|
98
|
+
#create_top_makefile()
|
99
|
+
rescue Interrupt
|
100
|
+
print " [error] " + $!.to_s + "
|
101
|
+
"
|
102
|
+
end
|
103
|
+
|
data/ext/soup/soup.c
ADDED
@@ -0,0 +1,381 @@
|
|
1
|
+
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
2
|
+
/* Includes */
|
3
|
+
#include <ruby.h>
|
4
|
+
#include <stdlib.h>
|
5
|
+
#include <stdio.h>
|
6
|
+
#include <string.h>
|
7
|
+
#include "libsoup/soup.h"
|
8
|
+
|
9
|
+
/* Setup types */
|
10
|
+
/* Try not to clash with other definitions of bool... */
|
11
|
+
typedef int rubber_bool;
|
12
|
+
#define bool rubber_bool
|
13
|
+
|
14
|
+
/* Prototypes */
|
15
|
+
#include "rbglib.h"
|
16
|
+
|
17
|
+
#include "rbgtk.h"
|
18
|
+
|
19
|
+
#if defined(G_PLATFORM_WIN32) && !defined(RUBY_GTK2_STATIC_COMPILATION)
|
20
|
+
# ifdef RUBY_GTK2_COMPILATION
|
21
|
+
# define RUBY_GTK2_VAR __declspec(dllexport)
|
22
|
+
# else
|
23
|
+
# define RUBY_GTK2_VAR extern __declspec(dllimport)
|
24
|
+
# endif
|
25
|
+
#else
|
26
|
+
# define RUBY_GTK2_VAR extern
|
27
|
+
#endif
|
28
|
+
|
29
|
+
RUBY_GTK2_VAR VALUE mGtk;
|
30
|
+
RUBY_GTK2_VAR VALUE mGdk;
|
31
|
+
|
32
|
+
#define RBGTK_INITIALIZE(obj,gtkobj) (rbgtk_initialize_gtkobject(obj, GTK_OBJECT(gtkobj)))
|
33
|
+
static VALUE mSoup;
|
34
|
+
static VALUE cSession;
|
35
|
+
static VALUE
|
36
|
+
Session_queue(VALUE self, VALUE __v_message);
|
37
|
+
static VALUE
|
38
|
+
Session_send(VALUE self, VALUE __v_msg);
|
39
|
+
static VALUE
|
40
|
+
Session_pause(VALUE self, VALUE __v_msg);
|
41
|
+
static VALUE
|
42
|
+
Session_unpause(VALUE self, VALUE __v_msg);
|
43
|
+
static VALUE
|
44
|
+
Session_abort(VALUE self);
|
45
|
+
static VALUE cSessionAsync;
|
46
|
+
static VALUE
|
47
|
+
SessionAsync_initialize(VALUE self);
|
48
|
+
static VALUE cURI;
|
49
|
+
static VALUE
|
50
|
+
URI_initialize(VALUE self, VALUE __v_uri_string);
|
51
|
+
static VALUE
|
52
|
+
URI_to_s(VALUE self);
|
53
|
+
static VALUE cMessage;
|
54
|
+
static VALUE
|
55
|
+
Message_initialize(VALUE self, VALUE __v_method, VALUE __v_uri);
|
56
|
+
static VALUE
|
57
|
+
Message_set_request_header(VALUE self, VALUE __v_name, VALUE __v_value);
|
58
|
+
static VALUE
|
59
|
+
Message_unset_request_header(VALUE self, VALUE __v_name);
|
60
|
+
static VALUE
|
61
|
+
Message_set_request_body(VALUE self, VALUE __v_type, VALUE body);
|
62
|
+
static VALUE
|
63
|
+
Message_get_response_header(VALUE self, VALUE __v_name);
|
64
|
+
static VALUE
|
65
|
+
Message_each_response_header(VALUE self);
|
66
|
+
static VALUE
|
67
|
+
Message_response_body(VALUE self);
|
68
|
+
static VALUE _gcpool_RubyFunc = Qnil;
|
69
|
+
static void __gcpool_RubyFunc_add(VALUE val);
|
70
|
+
static void __gcpool_RubyFunc_del(VALUE val);
|
71
|
+
#define RUBYFUNC_ADD(val) __gcpool_RubyFunc_add(val)
|
72
|
+
#define RUBYFUNC_DEL(val) __gcpool_RubyFunc_del(val)
|
73
|
+
|
74
|
+
/* Inline C code */
|
75
|
+
|
76
|
+
#include <intern.h>
|
77
|
+
|
78
|
+
#define INIT(obj, gobj) __my_init(obj, G_OBJECT(gobj))
|
79
|
+
|
80
|
+
static inline void __my_init(VALUE obj, GObject *gobj) {
|
81
|
+
g_object_ref(gobj);
|
82
|
+
g_object_ref_sink(gobj);
|
83
|
+
G_INITIALIZE(obj, gobj);
|
84
|
+
}
|
85
|
+
|
86
|
+
static inline VALUE strOrNil(const char *str) {
|
87
|
+
if (str) {
|
88
|
+
return rb_str_new2(str);
|
89
|
+
} else {
|
90
|
+
return Qnil;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
static void queue_callback(SoupSession *session, SoupMessage *message, gpointer user_data) {
|
95
|
+
VALUE block = (VALUE)user_data;
|
96
|
+
volatile VALUE ary = rb_ary_new3(2, GOBJ2RVAL(session), GOBJ2RVAL(message));
|
97
|
+
if (RTEST(rb_proc_call(block, ary))) {
|
98
|
+
// Truthy - requeue
|
99
|
+
soup_session_requeue_message(session, message);
|
100
|
+
} else {
|
101
|
+
RUBYFUNC_DEL(block);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
static void each_header(const char *name, const char *value, gpointer user_data) {
|
106
|
+
VALUE block = (VALUE)user_data;
|
107
|
+
volatile VALUE ary = rb_ary_new3(2, rb_str_new2(name), rb_str_new2(value));
|
108
|
+
rb_proc_call(block, ary);
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
/* Code */
|
113
|
+
static VALUE
|
114
|
+
Session_queue(VALUE self, VALUE __v_message)
|
115
|
+
{
|
116
|
+
SoupMessage * message; SoupMessage * __orig_message;
|
117
|
+
SoupSession *_self = ((SoupSession*)RVAL2GOBJ(self));
|
118
|
+
__orig_message = message = RVAL2GOBJ(__v_message);
|
119
|
+
|
120
|
+
#line 52 "/home/geoff/Projects/soup/ext/soup/soup.cr"
|
121
|
+
|
122
|
+
do {
|
123
|
+
if (rb_block_given_p()) { VALUE block =
|
124
|
+
rb_block_proc();
|
125
|
+
RUBYFUNC_ADD(block);
|
126
|
+
soup_session_queue_message(_self, message, queue_callback, (void*)block);
|
127
|
+
} else { soup_session_queue_message(_self, message, NULL, NULL);
|
128
|
+
}
|
129
|
+
|
130
|
+
} while(0);
|
131
|
+
|
132
|
+
return Qnil;
|
133
|
+
}
|
134
|
+
|
135
|
+
static VALUE
|
136
|
+
Session_send(VALUE self, VALUE __v_msg)
|
137
|
+
{
|
138
|
+
VALUE __p_retval = Qnil;
|
139
|
+
SoupMessage * msg; SoupMessage * __orig_msg;
|
140
|
+
SoupSession *_self = ((SoupSession*)RVAL2GOBJ(self));
|
141
|
+
__orig_msg = msg = RVAL2GOBJ(__v_msg);
|
142
|
+
|
143
|
+
#line 62 "/home/geoff/Projects/soup/ext/soup/soup.cr"
|
144
|
+
do { __p_retval = UINT2NUM(soup_session_send_message(_self, msg)); goto out; } while(0);
|
145
|
+
out:
|
146
|
+
return __p_retval;
|
147
|
+
}
|
148
|
+
|
149
|
+
static VALUE
|
150
|
+
Session_pause(VALUE self, VALUE __v_msg)
|
151
|
+
{
|
152
|
+
SoupMessage * msg; SoupMessage * __orig_msg;
|
153
|
+
SoupSession *_self = ((SoupSession*)RVAL2GOBJ(self));
|
154
|
+
__orig_msg = msg = RVAL2GOBJ(__v_msg);
|
155
|
+
|
156
|
+
#line 66 "/home/geoff/Projects/soup/ext/soup/soup.cr"
|
157
|
+
soup_session_pause_message(_self, msg);
|
158
|
+
|
159
|
+
return Qnil;
|
160
|
+
}
|
161
|
+
|
162
|
+
static VALUE
|
163
|
+
Session_unpause(VALUE self, VALUE __v_msg)
|
164
|
+
{
|
165
|
+
SoupMessage * msg; SoupMessage * __orig_msg;
|
166
|
+
SoupSession *_self = ((SoupSession*)RVAL2GOBJ(self));
|
167
|
+
__orig_msg = msg = RVAL2GOBJ(__v_msg);
|
168
|
+
|
169
|
+
#line 70 "/home/geoff/Projects/soup/ext/soup/soup.cr"
|
170
|
+
soup_session_unpause_message(_self, msg);
|
171
|
+
|
172
|
+
return Qnil;
|
173
|
+
}
|
174
|
+
|
175
|
+
static VALUE
|
176
|
+
Session_abort(VALUE self)
|
177
|
+
{
|
178
|
+
SoupSession *_self = ((SoupSession*)RVAL2GOBJ(self));
|
179
|
+
|
180
|
+
#line 74 "/home/geoff/Projects/soup/ext/soup/soup.cr"
|
181
|
+
soup_session_abort(_self);
|
182
|
+
|
183
|
+
return Qnil;
|
184
|
+
}
|
185
|
+
|
186
|
+
static VALUE
|
187
|
+
SessionAsync_initialize(VALUE self)
|
188
|
+
{
|
189
|
+
|
190
|
+
#line 81 "/home/geoff/Projects/soup/ext/soup/soup.cr"
|
191
|
+
INIT(self, soup_session_async_new());
|
192
|
+
|
193
|
+
return Qnil;
|
194
|
+
}
|
195
|
+
|
196
|
+
static VALUE
|
197
|
+
URI_initialize(VALUE self, VALUE __v_uri_string)
|
198
|
+
{
|
199
|
+
char * uri_string; char * __orig_uri_string;
|
200
|
+
__orig_uri_string = uri_string = ( NIL_P(__v_uri_string) ? NULL : StringValuePtr(__v_uri_string) );
|
201
|
+
|
202
|
+
#line 88 "/home/geoff/Projects/soup/ext/soup/soup.cr"
|
203
|
+
INIT(self, soup_uri_new(uri_string));
|
204
|
+
|
205
|
+
return Qnil;
|
206
|
+
}
|
207
|
+
|
208
|
+
static VALUE
|
209
|
+
URI_to_s(VALUE self)
|
210
|
+
{
|
211
|
+
VALUE __p_retval = Qnil;
|
212
|
+
SoupURI * _self = ((SoupURI *)RVAL2BOXED(self, SOUP_TYPE_URI));
|
213
|
+
|
214
|
+
#line 91 "/home/geoff/Projects/soup/ext/soup/soup.cr"
|
215
|
+
do { __p_retval = rb_str_new2(soup_uri_to_string(_self, FALSE)); goto out; } while(0);
|
216
|
+
out:
|
217
|
+
return __p_retval;
|
218
|
+
}
|
219
|
+
|
220
|
+
static VALUE
|
221
|
+
Message_initialize(VALUE self, VALUE __v_method, VALUE __v_uri)
|
222
|
+
{
|
223
|
+
char * method; char * __orig_method;
|
224
|
+
char * uri; char * __orig_uri;
|
225
|
+
__orig_method = method = ( NIL_P(__v_method) ? NULL : StringValuePtr(__v_method) );
|
226
|
+
__orig_uri = uri = ( NIL_P(__v_uri) ? NULL : StringValuePtr(__v_uri) );
|
227
|
+
|
228
|
+
#line 98 "/home/geoff/Projects/soup/ext/soup/soup.cr"
|
229
|
+
INIT(self, soup_message_new(method, uri));
|
230
|
+
|
231
|
+
return Qnil;
|
232
|
+
}
|
233
|
+
|
234
|
+
static VALUE
|
235
|
+
Message_set_request_header(VALUE self, VALUE __v_name, VALUE __v_value)
|
236
|
+
{
|
237
|
+
char * name; char * __orig_name;
|
238
|
+
char * value; char * __orig_value;
|
239
|
+
SoupMessage *_self = ((SoupMessage*)RVAL2GOBJ(self));
|
240
|
+
__orig_name = name = ( NIL_P(__v_name) ? NULL : StringValuePtr(__v_name) );
|
241
|
+
__orig_value = value = ( NIL_P(__v_value) ? NULL : StringValuePtr(__v_value) );
|
242
|
+
|
243
|
+
#line 102 "/home/geoff/Projects/soup/ext/soup/soup.cr"
|
244
|
+
soup_message_headers_replace(_self->request_headers, name, value);
|
245
|
+
|
246
|
+
return self;
|
247
|
+
}
|
248
|
+
|
249
|
+
static VALUE
|
250
|
+
Message_unset_request_header(VALUE self, VALUE __v_name)
|
251
|
+
{
|
252
|
+
char * name; char * __orig_name;
|
253
|
+
SoupMessage *_self = ((SoupMessage*)RVAL2GOBJ(self));
|
254
|
+
__orig_name = name = ( NIL_P(__v_name) ? NULL : StringValuePtr(__v_name) );
|
255
|
+
|
256
|
+
#line 106 "/home/geoff/Projects/soup/ext/soup/soup.cr"
|
257
|
+
soup_message_headers_remove(_self->request_headers, name);
|
258
|
+
|
259
|
+
return Qnil;
|
260
|
+
}
|
261
|
+
|
262
|
+
static VALUE
|
263
|
+
Message_set_request_body(VALUE self, VALUE __v_type, VALUE body)
|
264
|
+
{
|
265
|
+
char * type; char * __orig_type;
|
266
|
+
SoupMessage *_self = ((SoupMessage*)RVAL2GOBJ(self));
|
267
|
+
__orig_type = type = ( NIL_P(__v_type) ? NULL : StringValuePtr(__v_type) );
|
268
|
+
Check_Type(body, T_STRING);
|
269
|
+
|
270
|
+
#line 110 "/home/geoff/Projects/soup/ext/soup/soup.cr"
|
271
|
+
soup_message_set_request(_self, type, SOUP_MEMORY_COPY, RSTRING_PTR(body), RSTRING_LEN(body));
|
272
|
+
|
273
|
+
return self;
|
274
|
+
}
|
275
|
+
|
276
|
+
static VALUE
|
277
|
+
Message_get_response_header(VALUE self, VALUE __v_name)
|
278
|
+
{
|
279
|
+
VALUE __p_retval = Qnil;
|
280
|
+
char * name; char * __orig_name;
|
281
|
+
SoupMessage *_self = ((SoupMessage*)RVAL2GOBJ(self));
|
282
|
+
__orig_name = name = ( NIL_P(__v_name) ? NULL : StringValuePtr(__v_name) );
|
283
|
+
|
284
|
+
#line 114 "/home/geoff/Projects/soup/ext/soup/soup.cr"
|
285
|
+
do { __p_retval = rb_str_new2(soup_message_headers_get_one(_self->response_headers, name)); goto out; } while(0);
|
286
|
+
out:
|
287
|
+
return __p_retval;
|
288
|
+
}
|
289
|
+
|
290
|
+
static VALUE
|
291
|
+
Message_each_response_header(VALUE self)
|
292
|
+
{
|
293
|
+
SoupMessage *_self = ((SoupMessage*)RVAL2GOBJ(self));
|
294
|
+
|
295
|
+
#line 118 "/home/geoff/Projects/soup/ext/soup/soup.cr"
|
296
|
+
|
297
|
+
do {
|
298
|
+
VALUE block =
|
299
|
+
rb_block_proc();
|
300
|
+
rb_need_block();
|
301
|
+
soup_message_headers_foreach(_self->response_headers, each_header, (gpointer)block);
|
302
|
+
|
303
|
+
|
304
|
+
} while(0);
|
305
|
+
|
306
|
+
return Qnil;
|
307
|
+
}
|
308
|
+
|
309
|
+
static VALUE
|
310
|
+
Message_response_body(VALUE self)
|
311
|
+
{
|
312
|
+
VALUE __p_retval = Qnil;
|
313
|
+
SoupMessage *_self = ((SoupMessage*)RVAL2GOBJ(self));
|
314
|
+
|
315
|
+
#line 124 "/home/geoff/Projects/soup/ext/soup/soup.cr"
|
316
|
+
|
317
|
+
do {
|
318
|
+
SoupBuffer * buffer =
|
319
|
+
soup_message_body_flatten(_self->response_body);
|
320
|
+
volatile VALUE str =
|
321
|
+
rb_str_new(buffer->data, buffer->length);
|
322
|
+
soup_buffer_free(buffer);
|
323
|
+
do { __p_retval = str; goto out; } while(0);
|
324
|
+
|
325
|
+
} while(0);
|
326
|
+
|
327
|
+
out:
|
328
|
+
return __p_retval;
|
329
|
+
}
|
330
|
+
|
331
|
+
static void __gcpool_RubyFunc_add(VALUE val)
|
332
|
+
{
|
333
|
+
if (_gcpool_RubyFunc == Qnil)
|
334
|
+
{
|
335
|
+
_gcpool_RubyFunc = rb_ary_new3(1, val);
|
336
|
+
}
|
337
|
+
else
|
338
|
+
{
|
339
|
+
rb_ary_push(_gcpool_RubyFunc, val);
|
340
|
+
}
|
341
|
+
}
|
342
|
+
|
343
|
+
static void __gcpool_RubyFunc_del(VALUE val)
|
344
|
+
{
|
345
|
+
if (_gcpool_RubyFunc == Qnil)
|
346
|
+
{
|
347
|
+
rb_warn("Trying to remove object from empty GC queue RubyFunc");
|
348
|
+
return;
|
349
|
+
}
|
350
|
+
rb_ary_delete(_gcpool_RubyFunc, val);
|
351
|
+
// If nothing is referenced, don't keep an empty array in the pool...
|
352
|
+
if (RARRAY_LEN(_gcpool_RubyFunc) == 0)
|
353
|
+
_gcpool_RubyFunc = Qnil;
|
354
|
+
}
|
355
|
+
|
356
|
+
/* Init */
|
357
|
+
void
|
358
|
+
Init_soup(void)
|
359
|
+
{
|
360
|
+
mSoup = rb_define_module("Soup");
|
361
|
+
cSession = G_DEF_CLASS(SOUP_TYPE_SESSION, "Session", mSoup);
|
362
|
+
rb_define_method(cSession, "queue", Session_queue, 1);
|
363
|
+
rb_define_method(cSession, "send", Session_send, 1);
|
364
|
+
rb_define_method(cSession, "pause", Session_pause, 1);
|
365
|
+
rb_define_method(cSession, "unpause", Session_unpause, 1);
|
366
|
+
rb_define_method(cSession, "abort", Session_abort, 0);
|
367
|
+
cSessionAsync = G_DEF_CLASS(SOUP_TYPE_SESSION_ASYNC, "SessionAsync", mSoup);
|
368
|
+
rb_define_method(cSessionAsync, "initialize", SessionAsync_initialize, 0);
|
369
|
+
cURI = G_DEF_CLASS(SOUP_TYPE_URI, "URI", mSoup);
|
370
|
+
rb_define_method(cURI, "initialize", URI_initialize, 1);
|
371
|
+
rb_define_method(cURI, "to_s", URI_to_s, 0);
|
372
|
+
cMessage = G_DEF_CLASS(SOUP_TYPE_MESSAGE, "Message", mSoup);
|
373
|
+
rb_define_method(cMessage, "initialize", Message_initialize, 2);
|
374
|
+
rb_define_method(cMessage, "set_request_header", Message_set_request_header, 2);
|
375
|
+
rb_define_method(cMessage, "unset_request_header", Message_unset_request_header, 1);
|
376
|
+
rb_define_method(cMessage, "set_request_body", Message_set_request_body, 2);
|
377
|
+
rb_define_method(cMessage, "get_response_header", Message_get_response_header, 1);
|
378
|
+
rb_define_method(cMessage, "each_response_header", Message_each_response_header, 0);
|
379
|
+
rb_define_method(cMessage, "response_body", Message_response_body, 0);
|
380
|
+
rb_gc_register_address(&_gcpool_RubyFunc);
|
381
|
+
}
|
data/ext/soup/soup.rd
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
= module Soup
|
2
|
+
== class Soup::Session
|
3
|
+
--- Soup::Session#queue(SoupMessage* message)
|
4
|
+
|
5
|
+
|
6
|
+
--- Soup::Session#send(SoupMessage* msg)
|
7
|
+
|
8
|
+
|
9
|
+
--- Soup::Session#pause(SoupMessage* msg)
|
10
|
+
|
11
|
+
|
12
|
+
--- Soup::Session#unpause(SoupMessage* msg)
|
13
|
+
|
14
|
+
|
15
|
+
--- Soup::Session#abort
|
16
|
+
|
17
|
+
== class Soup::SessionAsync
|
18
|
+
--- Soup::SessionAsync.new
|
19
|
+
|
20
|
+
== class Soup::URI
|
21
|
+
--- Soup::URI.new(String uri_string)
|
22
|
+
|
23
|
+
|
24
|
+
--- Soup::URI#to_s
|
25
|
+
|
26
|
+
== class Soup::Message
|
27
|
+
--- Soup::Message.new(String method, String uri)
|
28
|
+
|
29
|
+
|
30
|
+
--- Soup::Message#set_request_header(String name, String value)
|
31
|
+
|
32
|
+
|
33
|
+
--- Soup::Message#unset_request_header(String name)
|
34
|
+
|
35
|
+
|
36
|
+
--- Soup::Message#set_request_body(String type, String body)
|
37
|
+
|
38
|
+
|
39
|
+
--- Soup::Message#get_response_header(String name)
|
40
|
+
|
41
|
+
|
42
|
+
--- Soup::Message#each_response_header
|
43
|
+
|
44
|
+
--- Soup::Message#response_body
|
45
|
+
|
data/lib/soup/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soup-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geoff Youngs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-03-
|
11
|
+
date: 2013-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubber-generate
|
@@ -33,15 +33,20 @@ description: |+
|
|
33
33
|
|
34
34
|
email: git@intersect-uk.co.uk
|
35
35
|
executables: []
|
36
|
-
extensions:
|
36
|
+
extensions:
|
37
|
+
- ext/soup/extconf.rb
|
37
38
|
extra_rdoc_files: []
|
38
39
|
files:
|
40
|
+
- ext/soup/extconf.rb
|
41
|
+
- ext/soup/soup.c
|
39
42
|
- ext/soup/soup.cr
|
43
|
+
- ext/soup/soup.rd
|
40
44
|
- Rakefile
|
41
45
|
- README.md
|
42
46
|
- lib/soup/version.rb
|
43
47
|
homepage: http://github.com/geoffyoungs/soup-ruby
|
44
|
-
licenses:
|
48
|
+
licenses:
|
49
|
+
- The Ruby License
|
45
50
|
metadata: {}
|
46
51
|
post_install_message:
|
47
52
|
rdoc_options: []
|