rdf-smart 0.0.152 → 0.0.153

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/ext/rsm.c CHANGED
@@ -218,108 +218,107 @@ VALUE rsm_execute(VALUE self, VALUE query) {
218
218
 
219
219
  world = rasqal_new_world();
220
220
 
221
- // if(!world || rasqal_world_open(world)) {
222
- // rb_raise(rb_eRuntimeError, "rasqal_world init failed");
223
- // }
224
- // raptor_world_ptr = rasqal_world_get_raptor(world);
221
+ if(!world || rasqal_world_open(world)) {
222
+ rb_raise(rb_eRuntimeError, "rasqal_world init failed");
223
+ }
224
+ raptor_world_ptr = rasqal_world_get_raptor(world);
225
+
226
+ /* #{{{ Data_Graphs*/
227
+ for (i = 0; i < RARRAY_LEN(prsm_obj->data_sources); i++) {
228
+ const char* data_source = RSTRING_PTR(RARRAY_PTR(prsm_obj->data_sources)[i]);
229
+ rasqal_data_graph *dg = NULL;
230
+ unsigned int type;
231
+
232
+ type = RASQAL_DATA_GRAPH_BACKGROUND;
233
+
234
+ if(!access((const char*)data_source, R_OK)) {
235
+ unsigned char* source_uri_string;
236
+ raptor_uri* source_uri;
237
+ raptor_uri* graph_name = NULL;
238
+
239
+ source_uri_string = raptor_uri_filename_to_uri_string((const char*)data_source);
240
+ source_uri = raptor_new_uri(raptor_world_ptr, source_uri_string);
241
+ raptor_free_memory(source_uri_string);
242
+
243
+
244
+ if(source_uri)
245
+ dg = rasqal_new_data_graph_from_uri(world,
246
+ source_uri,
247
+ graph_name,
248
+ type,
249
+ NULL, data_graph_parser_name,
250
+ NULL);
251
+
252
+ if(source_uri)
253
+ raptor_free_uri(source_uri);
254
+ } else {
255
+ raptor_uri* source_uri;
256
+ raptor_uri* graph_name = NULL;
257
+
258
+ source_uri = raptor_new_uri(raptor_world_ptr,
259
+ (const unsigned char*)data_source);
260
+
261
+ if(source_uri)
262
+ dg = rasqal_new_data_graph_from_uri(world,
263
+ source_uri,
264
+ graph_name,
265
+ type,
266
+ NULL, data_graph_parser_name,
267
+ NULL);
268
+
269
+ if(source_uri)
270
+ raptor_free_uri(source_uri);
271
+ }
272
+
273
+ if(!dg) {
274
+ rb_raise(rb_eRuntimeError, "booboo");
275
+ }
276
+
277
+ if(!data_graphs) {
278
+ data_graphs = raptor_new_sequence((raptor_data_free_handler)rasqal_free_data_graph,
279
+ NULL);
280
+
281
+ if(!data_graphs) {
282
+ rb_raise(rb_eRuntimeError, "Failed to create data graphs sequence");
283
+ }
284
+ }
285
+
286
+ raptor_sequence_push(data_graphs, dg);
287
+ }
288
+ /* #}}} */
289
+
290
+ if (!(rq = rsm_roqet_init_query(world, "sparql", query_string,data_graphs)))
291
+ goto tidy_query;
292
+
293
+ results = rasqal_query_execute(rq);
294
+
295
+ if(!results) {
296
+ fprintf(stderr, "Query execution failed\n");
297
+ goto tidy_query;
298
+ }
299
+
300
+ if(rasqal_query_results_is_bindings(results) || rasqal_query_results_is_boolean(results)) {
301
+ rsm_print_formatted_query_results(world, results, raptor_world_ptr, "json", &output, &len);
302
+ } else if(rasqal_query_results_is_graph(results)) {
303
+ rsm_print_graph_result(rq, results, raptor_world_ptr, "json", &output, &len);
304
+ } else {
305
+ rb_raise(rb_eRuntimeError, "Query returned unknown result format");
306
+ }
307
+
308
+ rasqal_free_query_results(results);
225
309
 
226
- // /* #{{{ Data_Graphs*/
227
- // for (i = 0; i < RARRAY_LEN(prsm_obj->data_sources); i++) {
228
- // const char* data_source = RSTRING_PTR(RARRAY_PTR(prsm_obj->data_sources)[i]);
229
- // rasqal_data_graph *dg = NULL;
230
- // unsigned int type;
231
- //
232
- // type = RASQAL_DATA_GRAPH_BACKGROUND;
233
- //
234
- // if(!access((const char*)data_source, R_OK)) {
235
- // unsigned char* source_uri_string;
236
- // raptor_uri* source_uri;
237
- // raptor_uri* graph_name = NULL;
238
- //
239
- // source_uri_string = raptor_uri_filename_to_uri_string((const char*)data_source);
240
- // source_uri = raptor_new_uri(raptor_world_ptr, source_uri_string);
241
- // raptor_free_memory(source_uri_string);
242
- //
243
- //
244
- // if(source_uri)
245
- // dg = rasqal_new_data_graph_from_uri(world,
246
- // source_uri,
247
- // graph_name,
248
- // type,
249
- // NULL, data_graph_parser_name,
250
- // NULL);
251
- //
252
- // if(source_uri)
253
- // raptor_free_uri(source_uri);
254
- // } else {
255
- // raptor_uri* source_uri;
256
- // raptor_uri* graph_name = NULL;
257
- //
258
- // source_uri = raptor_new_uri(raptor_world_ptr,
259
- // (const unsigned char*)data_source);
260
- //
261
- // if(source_uri)
262
- // dg = rasqal_new_data_graph_from_uri(world,
263
- // source_uri,
264
- // graph_name,
265
- // type,
266
- // NULL, data_graph_parser_name,
267
- // NULL);
268
- //
269
- // if(source_uri)
270
- // raptor_free_uri(source_uri);
271
- // }
272
- //
273
- // if(!dg) {
274
- // rb_raise(rb_eRuntimeError, "booboo");
275
- // }
276
- //
277
- // if(!data_graphs) {
278
- // data_graphs = raptor_new_sequence((raptor_data_free_handler)rasqal_free_data_graph,
279
- // NULL);
280
- //
281
- // if(!data_graphs) {
282
- // rb_raise(rb_eRuntimeError, "Failed to create data graphs sequence");
283
- // }
284
- // }
285
- //
286
- // raptor_sequence_push(data_graphs, dg);
287
- // }
288
- ///* #}}} */
289
- //
290
- // if (!(rq = rsm_roqet_init_query(world, "sparql", query_string,data_graphs)))
291
- // goto tidy_query;
292
- //
293
- // results = rasqal_query_execute(rq);
294
- //
295
- // if(!results) {
296
- // fprintf(stderr, "Query execution failed\n");
297
- // goto tidy_query;
298
- // }
299
- //
300
- // if(rasqal_query_results_is_bindings(results) || rasqal_query_results_is_boolean(results)) {
301
- // //rsm_print_formatted_query_results(world, results, raptor_world_ptr, "json", &output, &len);
302
- // } else if(rasqal_query_results_is_graph(results)) {
303
- // //rsm_print_graph_result(rq, results, raptor_world_ptr, "json", &output, &len);
304
- // } else {
305
- // rb_raise(rb_eRuntimeError, "Query returned unknown result format");
306
- // }
307
- //
308
- // rasqal_free_query_results(results);
309
- //
310
- // tidy_query:
311
- // if(data_graphs) raptor_free_sequence(data_graphs);
312
- // if(rq) rasqal_free_query(rq);
310
+ tidy_query:
311
+ if(data_graphs) raptor_free_sequence(data_graphs);
312
+ if(rq) rasqal_free_query(rq);
313
313
  rasqal_free_world(world);
314
- //
315
- // //routput = rb_str_new(output,len);
316
- // //enc = rb_enc_find_index("UTF-8");
317
- // //rb_enc_associate_index(routput, enc);
318
- //
319
- // free(output);
320
- //
321
- // //return routput;
322
- return Qnil;
314
+
315
+ routput = rb_str_new(output,len);
316
+ enc = rb_enc_find_index("UTF-8");
317
+ rb_enc_associate_index(routput, enc);
318
+
319
+ free(output);
320
+
321
+ return routput;
323
322
  }
324
323
 
325
324
  VALUE rsm_data_sources(VALUE self) {
data/ext/smart.so CHANGED
Binary file
data/rdf-smart.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rdf-smart'
3
- s.version = '0.0.152'
3
+ s.version = '0.0.153'
4
4
  s.date = '2014-06-17'
5
5
  s.summary ="RDF.rb segfaults. A lot. We don't. RDF.rb has lots of features. We don't."
6
6
  s.description ="Minimal sparql support for ruby. Basically the roqet tool from http://librdf.org, with always guessing input type, and always json output."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf-smart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.152
4
+ version: 0.0.153
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -22,12 +22,9 @@ extensions:
22
22
  - ext/extconf.rb
23
23
  extra_rdoc_files: []
24
24
  files:
25
- - ext/extconf.h
26
- - ext/rsm.o
27
25
  - ext/smart.so
28
26
  - ext/rsm.h
29
27
  - ext/rsm.c
30
- - ext/Makefile
31
28
  - ext/extconf.rb
32
29
  - ext/mkmf.log
33
30
  - lib/rdf/smart.rb
data/ext/Makefile DELETED
@@ -1,220 +0,0 @@
1
-
2
- SHELL = /bin/sh
3
-
4
- # V=0 quiet, V=1 verbose. other values don't work.
5
- V = 0
6
- Q1 = $(V:1=)
7
- Q = $(Q1:0=@)
8
- n=$(NULLCMD)
9
- ECHO1 = $(V:1=@$n)
10
- ECHO = $(ECHO1:0=@echo)
11
-
12
- #### Start of system configuration section. ####
13
-
14
- srcdir = .
15
- topdir = /usr/include/ruby-1.9.1
16
- hdrdir = /usr/include/ruby-1.9.1
17
- arch_hdrdir = /usr/include/ruby-1.9.1/$(arch)
18
- VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
19
- prefix = $(DESTDIR)/usr
20
- rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
21
- exec_prefix = $(prefix)
22
- vendorhdrdir = $(rubyhdrdir)/vendor_ruby
23
- sitehdrdir = $(rubyhdrdir)/site_ruby
24
- rubyhdrdir = $(includedir)/$(RUBY_BASE_NAME)-$(ruby_version)
25
- vendordir = $(DESTDIR)/usr/lib/ruby/vendor_ruby
26
- sitedir = $(DESTDIR)/usr/local/lib/site_ruby
27
- ridir = $(datarootdir)/$(RI_BASE_NAME)
28
- mandir = $(prefix)/share/man
29
- localedir = $(datarootdir)/locale
30
- libdir = $(exec_prefix)/lib
31
- psdir = $(docdir)
32
- pdfdir = $(docdir)
33
- dvidir = $(docdir)
34
- htmldir = $(docdir)
35
- infodir = $(prefix)/share/info
36
- docdir = $(datarootdir)/doc/$(PACKAGE)
37
- oldincludedir = $(DESTDIR)/usr/include
38
- includedir = $(prefix)/include
39
- localstatedir = $(DESTDIR)/var
40
- sharedstatedir = $(prefix)/com
41
- sysconfdir = $(DESTDIR)/etc
42
- datadir = $(datarootdir)
43
- datarootdir = $(prefix)/share
44
- libexecdir = $(prefix)/lib/ruby1.9.1
45
- sbindir = $(exec_prefix)/sbin
46
- bindir = $(exec_prefix)/bin
47
- rubylibdir = $(rubylibprefix)/$(ruby_version)
48
- archdir = $(rubylibdir)/$(arch)
49
- sitelibdir = $(sitedir)/$(ruby_version)
50
- sitearchdir = $(sitelibdir)/$(sitearch)
51
- vendorlibdir = $(vendordir)/$(ruby_version)
52
- vendorarchdir = $(vendorlibdir)/$(sitearch)
53
-
54
- NULLCMD = :
55
-
56
- CC = gcc
57
- CXX = g++
58
- LIBRUBY = $(LIBRUBY_SO)
59
- LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
60
- LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
61
- LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
62
- empty =
63
- OUTFLAG = -o $(empty)
64
- COUTFLAG = -o $(empty)
65
-
66
- RUBY_EXTCONF_H = extconf.h
67
- cflags = $(optflags) $(debugflags) $(warnflags)
68
- optflags = -O3
69
- debugflags = -ggdb
70
- warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration
71
- CFLAGS = -fPIC -DRSM_VERSION=\"0.0.152\" -std=c99 -I/usr/include/rasqal -I/usr/include/raptor2 -g -Wall -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -fno-strict-aliasing -fPIC $(ARCH_FLAG)
72
- INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
73
- DEFS =
74
- CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" -D_FORTIFY_SOURCE=2 $(DEFS) $(cppflags)
75
- CXXFLAGS = $(CFLAGS) -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -fno-strict-aliasing
76
- ldflags = -lrasqal -lraptor2 -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -L/build/buildd/ruby1.9.1-1.9.3.484/debian/lib -rdynamic -Wl,-export-dynamic
77
- dldflags =
78
- ARCH_FLAG =
79
- DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
80
- LDSHARED = $(CC) -shared
81
- LDSHAREDXX = $(CXX) -shared
82
- AR = ar
83
- EXEEXT =
84
-
85
- RUBY_BASE_NAME = ruby
86
- RUBY_INSTALL_NAME = ruby1.9.1
87
- RUBY_SO_NAME = ruby-1.9.1
88
- arch = x86_64-linux
89
- sitearch = $(arch)
90
- ruby_version = 1.9.1
91
- ruby = /usr/bin/ruby1.9.1
92
- RUBY = $(ruby)
93
- RM = rm -f
94
- RM_RF = $(RUBY) -run -e rm -- -rf
95
- RMDIRS = rmdir --ignore-fail-on-non-empty -p
96
- MAKEDIRS = /bin/mkdir -p
97
- INSTALL = /usr/bin/install -c
98
- INSTALL_PROG = $(INSTALL) -m 0755
99
- INSTALL_DATA = $(INSTALL) -m 644
100
- COPY = cp
101
- TOUCH = exit >
102
-
103
- #### End of system configuration section. ####
104
-
105
- preload =
106
-
107
- libpath = . $(libdir) /usr/lib
108
- LIBPATH = -L. -L$(libdir) -L/usr/lib
109
- DEFFILE =
110
-
111
- CLEANFILES = mkmf.log
112
- DISTCLEANFILES =
113
- DISTCLEANDIRS =
114
-
115
- extout =
116
- extout_prefix =
117
- target_prefix = /rdf
118
- LOCAL_LIBS =
119
- LIBS = $(LIBRUBYARG_SHARED) -lrasqal -lraptor2 -lpthread -lrt -ldl -lcrypt -lm -lc
120
- SRCS = rsm.c
121
- OBJS = rsm.o
122
- TARGET = smart
123
- TARGET_NAME = smart
124
- TARGET_ENTRY = Init_$(TARGET_NAME)
125
- DLLIB = $(TARGET).so
126
- EXTSTATIC =
127
- STATIC_LIB =
128
-
129
- BINDIR = $(bindir)
130
- RUBYCOMMONDIR = $(sitedir)$(target_prefix)
131
- RUBYLIBDIR = $(sitelibdir)$(target_prefix)
132
- RUBYARCHDIR = $(sitearchdir)$(target_prefix)
133
- HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
134
- ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
135
-
136
- TARGET_SO = $(DLLIB)
137
- CLEANLIBS = $(TARGET).so
138
- CLEANOBJS = *.o *.bak
139
-
140
- all: $(DLLIB)
141
- static: $(STATIC_LIB)
142
- .PHONY: all install static install-so install-rb
143
- .PHONY: clean clean-so clean-rb
144
-
145
- clean-static::
146
- clean-rb-default::
147
- clean-rb::
148
- clean-so::
149
- clean: clean-so clean-static clean-rb-default clean-rb
150
- -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
151
-
152
- distclean-rb-default::
153
- distclean-rb::
154
- distclean-so::
155
- distclean: clean distclean-so distclean-rb-default distclean-rb
156
- @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
157
- @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
158
- @-$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
159
-
160
- realclean: distclean
161
- install: install-so install-rb
162
-
163
- install-so: $(RUBYARCHDIR)/$(DLLIB)
164
- $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
165
- -$(Q)$(MAKEDIRS) $(@D)
166
- $(INSTALL_PROG) $(DLLIB) $(@D)
167
- clean-static::
168
- -$(Q)$(RM) $(STATIC_LIB)
169
- install-rb: pre-install-rb install-rb-default
170
- install-rb-default: pre-install-rb-default
171
- pre-install-rb: Makefile
172
- pre-install-rb-default: Makefile
173
- pre-install-rb-default:
174
- $(ECHO) installing default smart libraries
175
- ./.RUBYARCHDIR.time:
176
- $(Q) $(MAKEDIRS) $(RUBYARCHDIR)
177
- $(Q) $(TOUCH) $@
178
-
179
- site-install: site-install-so site-install-rb
180
- site-install-so: install-so
181
- site-install-rb: install-rb
182
-
183
- .SUFFIXES: .c .m .cc .mm .cxx .cpp .C .o
184
-
185
- .cc.o:
186
- $(ECHO) compiling $(<)
187
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
188
-
189
- .mm.o:
190
- $(ECHO) compiling $(<)
191
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
192
-
193
- .cxx.o:
194
- $(ECHO) compiling $(<)
195
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
196
-
197
- .cpp.o:
198
- $(ECHO) compiling $(<)
199
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
200
-
201
- .C.o:
202
- $(ECHO) compiling $(<)
203
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
204
-
205
- .c.o:
206
- $(ECHO) compiling $(<)
207
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
208
-
209
- .m.o:
210
- $(ECHO) compiling $(<)
211
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
212
-
213
- $(DLLIB): $(OBJS) Makefile
214
- $(ECHO) linking shared-object rdf/$(DLLIB)
215
- -$(Q)$(RM) $(@)
216
- $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
217
-
218
-
219
-
220
- $(OBJS): $(hdrdir)/ruby.h $(hdrdir)/ruby/defines.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
data/ext/extconf.h DELETED
@@ -1,3 +0,0 @@
1
- #ifndef EXTCONF_H
2
- #define EXTCONF_H
3
- #endif
data/ext/rsm.o DELETED
Binary file