summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/g
diff options
context:
space:
mode:
authorDaniel Bovensiepen <[email protected]>2012-09-21 19:56:28 +0800
committerDaniel Bovensiepen <[email protected]>2012-09-21 19:56:28 +0800
commitd6f2f55b46ceddd986e7ba42fb8269aef0ca8e77 (patch)
tree9e3a405436789e9c782a6c4c00eafed4301df809 /mrbgems/g
parentf93572c531c1e69dc0c5d2c2bfd03fc83044158c (diff)
downloadmruby-d6f2f55b46ceddd986e7ba42fb8269aef0ca8e77.tar.gz
mruby-d6f2f55b46ceddd986e7ba42fb8269aef0ca8e77.zip
Add Support for Ruby Extensions, C Extensions and Test Integration
Diffstat (limited to 'mrbgems/g')
-rw-r--r--mrbgems/g/clib_example/Makefile (renamed from mrbgems/g/hello_world/Makefile)2
-rw-r--r--mrbgems/g/clib_example/README.md4
-rw-r--r--mrbgems/g/clib_example/src/clib_example.c17
-rw-r--r--mrbgems/g/clib_example/test/clib_example.rb3
-rw-r--r--mrbgems/g/hello_world/src/hello_world.c17
-rw-r--r--mrbgems/g/hello_world/test/hello_world.rb3
-rw-r--r--mrbgems/g/mrblib_example/Makefile7
-rw-r--r--mrbgems/g/mrblib_example/README.md (renamed from mrbgems/g/hello_world/README.md)0
-rw-r--r--mrbgems/g/mrblib_example/mrblib/mrblib_example.rb5
-rw-r--r--mrbgems/g/mrblib_example/test/mrblib_example.rb3
10 files changed, 40 insertions, 21 deletions
diff --git a/mrbgems/g/hello_world/Makefile b/mrbgems/g/clib_example/Makefile
index c03910bf6..2cd523905 100644
--- a/mrbgems/g/hello_world/Makefile
+++ b/mrbgems/g/clib_example/Makefile
@@ -1,6 +1,6 @@
include ../../Makefile4gem
-GEM := hello_world
+GEM := clib_example
GEM_C_FILES := $(wildcard $(SRC_DIR)/*.c)
GEM_OBJECTS := $(patsubst %.c, %.o, $(GEM_C_FILES))
diff --git a/mrbgems/g/clib_example/README.md b/mrbgems/g/clib_example/README.md
new file mode 100644
index 000000000..289f6635d
--- /dev/null
+++ b/mrbgems/g/clib_example/README.md
@@ -0,0 +1,4 @@
+CLib Extension Example
+=========
+
+This is an example gem which implements a C extension.
diff --git a/mrbgems/g/clib_example/src/clib_example.c b/mrbgems/g/clib_example/src/clib_example.c
new file mode 100644
index 000000000..2ab8682b2
--- /dev/null
+++ b/mrbgems/g/clib_example/src/clib_example.c
@@ -0,0 +1,17 @@
+#include <mruby.h>
+#include <stdio.h>
+
+static struct RClass *_class_clib;
+
+static mrb_value
+mrb_clib_example(mrb_state *mrb, mrb_value self)
+{
+ puts("A C Extension");
+ return self;
+}
+
+void
+mrb_clib_example_gem_init(mrb_state* mrb) {
+ _class_clib = mrb_define_module(mrb, "CLib");
+ mrb_define_class_method(mrb, _class_clib, "clib_method", mrb_clib_example, ARGS_NONE());
+}
diff --git a/mrbgems/g/clib_example/test/clib_example.rb b/mrbgems/g/clib_example/test/clib_example.rb
new file mode 100644
index 000000000..348b9271d
--- /dev/null
+++ b/mrbgems/g/clib_example/test/clib_example.rb
@@ -0,0 +1,3 @@
+assert('CLib Extension') do
+ CLib.respond_to? :clib_method
+end
diff --git a/mrbgems/g/hello_world/src/hello_world.c b/mrbgems/g/hello_world/src/hello_world.c
deleted file mode 100644
index 75d353542..000000000
--- a/mrbgems/g/hello_world/src/hello_world.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <mruby.h>
-#include <stdio.h>
-
-static struct RClass *_class_hw;
-
-static mrb_value
-mrb_hello_world(mrb_state *mrb, mrb_value self)
-{
- puts("Hello World");
- return self;
-}
-
-void
-mrb_hello_world_gem_init(mrb_state* mrb) {
- _class_hw = mrb_define_module(mrb, "HW");
- mrb_define_class_method(mrb, _class_hw, "say", mrb_hello_world, ARGS_NONE());
-}
diff --git a/mrbgems/g/hello_world/test/hello_world.rb b/mrbgems/g/hello_world/test/hello_world.rb
deleted file mode 100644
index 2d8c335db..000000000
--- a/mrbgems/g/hello_world/test/hello_world.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-assert('Hello World') do
- HW.respond_to? :say
-end
diff --git a/mrbgems/g/mrblib_example/Makefile b/mrbgems/g/mrblib_example/Makefile
new file mode 100644
index 000000000..a43677842
--- /dev/null
+++ b/mrbgems/g/mrblib_example/Makefile
@@ -0,0 +1,7 @@
+include ../../Makefile4gem
+
+GEM := mrblib_example
+
+gem-all :
+
+gem-clean :
diff --git a/mrbgems/g/hello_world/README.md b/mrbgems/g/mrblib_example/README.md
index 42792567f..42792567f 100644
--- a/mrbgems/g/hello_world/README.md
+++ b/mrbgems/g/mrblib_example/README.md
diff --git a/mrbgems/g/mrblib_example/mrblib/mrblib_example.rb b/mrbgems/g/mrblib_example/mrblib/mrblib_example.rb
new file mode 100644
index 000000000..444f32236
--- /dev/null
+++ b/mrbgems/g/mrblib_example/mrblib/mrblib_example.rb
@@ -0,0 +1,5 @@
+class MRBLib
+ def MRBLib.mrblib_method
+ puts "A Ruby Extension"
+ end
+end
diff --git a/mrbgems/g/mrblib_example/test/mrblib_example.rb b/mrbgems/g/mrblib_example/test/mrblib_example.rb
new file mode 100644
index 000000000..40189ffdd
--- /dev/null
+++ b/mrbgems/g/mrblib_example/test/mrblib_example.rb
@@ -0,0 +1,3 @@
+assert('MRBLib extension') do
+ MRBLib.respond_to? :mrblib_method
+end