-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add initial implementation of ext library
- Loading branch information
Showing
6 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,16 @@ | ||
require "bundler/gem_tasks" | ||
require 'bundler/gem_tasks' | ||
require "rake/extensiontask" | ||
require 'rake/testtask' | ||
|
||
task :default => :compile | ||
|
||
Rake::ExtensionTask.new do |t| | ||
t.name = 'jsonnet_wrap' | ||
t.ext_dir = 'ext/jsonnet' | ||
t.lib_dir = 'lib/jsonnet' | ||
end | ||
|
||
Rake::TestTask.new('test' => 'compile') do |t| | ||
t.libs << 'test' | ||
t.verbose = true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Makefile | ||
*.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require 'mkmf' | ||
|
||
dir_config('jsonnet') | ||
abort 'libjsonnet.h not found' unless have_header('libjsonnet.h') | ||
abort 'libjsonnet not found' unless have_library('jsonnet') | ||
create_makefile('jsonnet_wrap') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <ruby/ruby.h> | ||
#include <libjsonnet.h> | ||
|
||
static VALUE cVM; | ||
|
||
static VALUE | ||
jsonnet_s_version(VALUE mod) { | ||
return rb_usascii_str_new_cstr(jsonnet_version()); | ||
} | ||
|
||
void | ||
Init_jsonnet_wrap(void) { | ||
VALUE mJsonnet = rb_define_module("Jsonnet"); | ||
rb_define_singleton_method(mJsonnet, "libversion", jsonnet_s_version, 0); | ||
cVM = rb_define_class_under(mJsonnet, "VM", rb_cData); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
require "jsonnet/version" | ||
require "jsonnet/jsonnet_wrap" | ||
|
||
module Jsonnet | ||
# Your code goes here... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'jsonnet' | ||
require 'test/unit' | ||
|
||
class TestJsonnet < Test::Unit::TestCase | ||
test 'libversion returns a String' do | ||
assert_kind_of String, Jsonnet.libversion | ||
end | ||
end |