jsonnet 0.5.1 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +45 -0
- data/README.md +1 -1
- data/ext/jsonnet/callbacks.c +11 -3
- data/ext/jsonnet/extconf.rb +7 -6
- data/ext/jsonnet/vm.c +6 -8
- data/lib/jsonnet/version.rb +1 -1
- data/test/test_vm.rb +0 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21fb3547860dbf786a960705f8ec154f2068b07679091020da431fd1b407a4fd
|
4
|
+
data.tar.gz: 7860579f2f6931a3635ccae64de7c2de558644e6833e302b6511efb00f494a17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1abbd8abe2a2670b366bd249ed92106d06c55e43db8c3ffd4c263c7151b985361a653f8d032782e0a5a3900af0e26d3f2a6a761246669463fbc0d22999df498
|
7
|
+
data.tar.gz: 59e92b2680be878b8dfeb29c876aa877eaa22562ee5e60a4deb98f24b8e7cf27702f1e3b78404f31f21be1e6d0475e606e90398805f1b92d20bcdbcdd1ef7b7d
|
@@ -0,0 +1,45 @@
|
|
1
|
+
name: Run Unit Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ "master" ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ "master" ]
|
8
|
+
|
9
|
+
permissions:
|
10
|
+
contents: read
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
test:
|
14
|
+
name: Test
|
15
|
+
strategy:
|
16
|
+
matrix:
|
17
|
+
ruby-version: ['2.7', '3.0', '3.1', '3.2']
|
18
|
+
os: ['ubuntu-latest', 'macos-latest']
|
19
|
+
runs-on: ${{ matrix.os }}
|
20
|
+
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v3
|
23
|
+
- name: Set up Ruby
|
24
|
+
uses: ruby/setup-ruby@v1
|
25
|
+
with:
|
26
|
+
ruby-version: ${{ matrix.ruby-version }}
|
27
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
28
|
+
- name: Run tests
|
29
|
+
run: bundle exec rake test
|
30
|
+
|
31
|
+
test-with-system-lib:
|
32
|
+
name: Test with system library
|
33
|
+
runs-on: ubuntu-latest
|
34
|
+
|
35
|
+
steps:
|
36
|
+
- uses: actions/checkout@v3
|
37
|
+
- name: Set up Ruby
|
38
|
+
uses: ruby/setup-ruby@v1
|
39
|
+
with:
|
40
|
+
ruby-version: 3.1
|
41
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
42
|
+
- name: Prepare libjsonnet
|
43
|
+
run: sudo apt install libjsonnet-dev
|
44
|
+
- name: Run tests
|
45
|
+
run: env JSONNET_USE_SYSTEM_LIBRARIES=1 bundle exec rake test
|
data/README.md
CHANGED
@@ -63,7 +63,7 @@ gem install jsonnet -- --use-system-libraries
|
|
63
63
|
|
64
64
|
Load the library with `require "jsonnet"`
|
65
65
|
|
66
|
-
You can evaluate a string of Jsonnet using `Jsonnet.
|
66
|
+
You can evaluate a string of Jsonnet using `Jsonnet.evaluate`
|
67
67
|
|
68
68
|
```
|
69
69
|
irb(main):002:0> Jsonnet.evaluate('{ foo: "bar" }')
|
data/ext/jsonnet/callbacks.c
CHANGED
@@ -11,6 +11,14 @@
|
|
11
11
|
*/
|
12
12
|
#define RUBYJSONNET_GLOBAL_ESCAPE_MAGIC "\x07\x03\x0c:rubytag:\x07\x03\x0c:"
|
13
13
|
|
14
|
+
/* Copied from vm_core.h in Ruby. State variables in global escapes have
|
15
|
+
* this value when an exception is raised.
|
16
|
+
*
|
17
|
+
* TODO(yugui) Find a better way to distinguish "raise" from "throw".
|
18
|
+
* It is not a very good idea to depend on the implementation details of Ruby.
|
19
|
+
*/
|
20
|
+
#define RUBY_TAG_RAISE 0x6
|
21
|
+
|
14
22
|
/*
|
15
23
|
* callback support in VM
|
16
24
|
*/
|
@@ -44,9 +52,9 @@ invoke_callback(VALUE args)
|
|
44
52
|
static VALUE
|
45
53
|
rescue_callback(int state, const char *fmt, ...)
|
46
54
|
{
|
47
|
-
|
48
|
-
|
49
|
-
VALUE msg = rb_protect(rubyjsonnet_format_exception,
|
55
|
+
if (state == RUBY_TAG_RAISE) {
|
56
|
+
VALUE err = rb_errinfo();
|
57
|
+
VALUE msg = rb_protect(rubyjsonnet_format_exception, err, NULL);
|
50
58
|
if (msg == Qnil) {
|
51
59
|
va_list ap;
|
52
60
|
va_start(ap, fmt);
|
data/ext/jsonnet/extconf.rb
CHANGED
@@ -77,12 +77,13 @@ unless using_system_libraries?
|
|
77
77
|
$LIBPATH = ["#{recipe.path}/lib"] | $LIBPATH
|
78
78
|
$CPPFLAGS << " -I#{recipe.path}/include"
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
80
|
+
end
|
81
|
+
|
82
|
+
# jsonnet_wrap extension must be linked with c++ stdlib because
|
83
|
+
# the C++ library Rapid YAML is being statically linked.
|
84
|
+
rbconfig = RbConfig::MAKEFILE_CONFIG
|
85
|
+
if rbconfig['LDSHAREDXX']
|
86
|
+
rbconfig['LDSHARED'] = rbconfig['LDSHAREDXX']
|
86
87
|
end
|
87
88
|
|
88
89
|
abort 'libjsonnet.h not found' unless have_header('libjsonnet.h')
|
data/ext/jsonnet/vm.c
CHANGED
@@ -59,16 +59,15 @@ rubyjsonnet_obj_to_vm(VALUE wrap)
|
|
59
59
|
}
|
60
60
|
|
61
61
|
static VALUE
|
62
|
-
|
62
|
+
vm_s_allocate(VALUE klass)
|
63
63
|
{
|
64
64
|
struct jsonnet_vm_wrap *vm;
|
65
|
-
VALUE self = TypedData_Make_Struct(
|
65
|
+
VALUE self = TypedData_Make_Struct(klass, struct jsonnet_vm_wrap, &jsonnet_vm_type, vm);
|
66
66
|
vm->vm = jsonnet_make();
|
67
67
|
vm->import_callback = Qnil;
|
68
68
|
vm->native_callbacks.len = 0;
|
69
69
|
vm->native_callbacks.contexts = NULL;
|
70
70
|
|
71
|
-
rb_obj_call_init(self, argc, argv);
|
72
71
|
return self;
|
73
72
|
}
|
74
73
|
|
@@ -81,11 +80,10 @@ vm_free(void *ptr)
|
|
81
80
|
|
82
81
|
for (i = 0; i < vm->native_callbacks.len; ++i) {
|
83
82
|
struct native_callback_ctx *ctx = vm->native_callbacks.contexts[i];
|
84
|
-
|
83
|
+
xfree(ctx);
|
85
84
|
}
|
86
|
-
|
87
|
-
|
88
|
-
RB_REALLOC_N(vm, struct jsonnet_vm_wrap, 0);
|
85
|
+
xfree(vm->native_callbacks.contexts);
|
86
|
+
xfree(vm);
|
89
87
|
}
|
90
88
|
|
91
89
|
static void
|
@@ -390,7 +388,7 @@ void
|
|
390
388
|
rubyjsonnet_init_vm(VALUE mJsonnet)
|
391
389
|
{
|
392
390
|
cVM = rb_define_class_under(mJsonnet, "VM", rb_cObject);
|
393
|
-
|
391
|
+
rb_define_alloc_func(cVM, vm_s_allocate);
|
394
392
|
rb_define_private_method(cVM, "eval_file", vm_evaluate_file, 3);
|
395
393
|
rb_define_private_method(cVM, "eval_snippet", vm_evaluate, 3);
|
396
394
|
rb_define_private_method(cVM, "fmt_file", vm_fmt_file, 2);
|
data/lib/jsonnet/version.rb
CHANGED
data/test/test_vm.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonnet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuki Yugui Sonoda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mini_portile2
|
@@ -89,6 +89,7 @@ extensions:
|
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
91
|
- ".clang-format"
|
92
|
+
- ".github/workflows/ruby.yml"
|
92
93
|
- ".gitignore"
|
93
94
|
- ".travis.yml"
|
94
95
|
- Gemfile
|