gplugin/gplugin

A bunch of random ruby work
feature/ruby-loader
2018-08-27, Gary Kramlich
7849ef8ebfd1
Parents 3166e87ee56d
Children
A bunch of random ruby work
--- a/ruby/gplugin-ruby-loader.c Mon Aug 20 23:29:20 2018 -0500
+++ b/ruby/gplugin-ruby-loader.c Mon Aug 27 22:11:45 2018 -0500
@@ -50,15 +50,27 @@
static GPluginPlugin *
gplugin_ruby_loader_query(GPLUGIN_UNUSED GPluginLoader *loader,
const gchar *filename,
- GPLUGIN_UNUSED GError **error)
+ GError **error)
{
GPluginPlugin *plugin = NULL;
- gpointer script = NULL, other = NULL;
- VALUE info = 0;
+ gpointer other = NULL;
+ VALUE module = 0, script = 0;
+ gint state = 0;
g_message("filename: %s", filename);
- script = rb_require(filename);
+ /* this is garbage and should be normalized somehow */
+ module = rb_define_module("gplugin");
+
+ script = rb_new_cstr(filename);
+ rb_load_protect(script, 1, &state);
+ if(state) {
+ if(error) {
+ *error = g_error_new(GPLUGIN_DOMAIN, 0, "failed to load %s", filename);
+ }
+
+ return NULL;
+ }
g_message("type: 0x%x", TYPE(script));
@@ -69,8 +81,6 @@
// NULL
// );
- info = rb_current_receiver();
-
g_message("info: %" G_GUINT64_FORMAT, info);
return plugin;
--- a/ruby/meson.build Mon Aug 20 23:29:20 2018 -0500
+++ b/ruby/meson.build Mon Aug 27 22:11:45 2018 -0500
@@ -7,11 +7,13 @@
'gplugin-ruby-core.c',
'gplugin-ruby-loader.c',
'gplugin-ruby-plugin.c',
+ 'gplugin-ruby-protect.c',
]
GPLUGIN_RUBY_HEADERS = [
'gplugin-ruby-loader.h',
'gplugin-ruby-plugin.h',
+ 'gplugin-ruby-protect.h',
]
_RUBYS = [['ruby-2.5', '>=2.5.0'],
@@ -42,6 +44,4 @@
)
endif # ruby
-if get_option('testing')
- subdir('tests')
-endif
+subdir('tests')
--- a/ruby/tests/plugins/basic.rb Mon Aug 20 23:29:20 2018 -0500
+++ b/ruby/tests/plugins/basic.rb Mon Aug 27 22:11:45 2018 -0500
@@ -16,3 +16,10 @@
return true
end
+q = gplugin_query()
+
+puts q.id
+puts q.name
+puts q.summary
+puts q.authors
+