jsonnet 0.5.1 → 0.5.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92c5f9344c4b31e1c183acd4e12b5bd596540a13c938a4eb938f0759a754adce
4
- data.tar.gz: db67d7972db0f962419dafb2b8ae8fdcd2bd7e3847f6315379a4fdaa1843b3f4
3
+ metadata.gz: 21fb3547860dbf786a960705f8ec154f2068b07679091020da431fd1b407a4fd
4
+ data.tar.gz: 7860579f2f6931a3635ccae64de7c2de558644e6833e302b6511efb00f494a17
5
5
  SHA512:
6
- metadata.gz: 3b2b912c43980ad07bb4e40c1f467c67b919c80552b6c51984699f9127a645b099e5f43e60bfe2574634d8ba8e9b2116106511ee54880eae2e876aead524169f
7
- data.tar.gz: 1aac5b2c3b9047242184d613a26730a4418abbcb35008f1a91c71279d95a6747952c46b39b5720c25ced447e3a325d1b2aef7d7de92fe11775c3033bc734368b
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.parse`
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" }')
@@ -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
- VALUE err = rb_errinfo();
48
- if (rb_obj_is_kind_of(err, rb_eException)) {
49
- VALUE msg = rb_protect(rubyjsonnet_format_exception, rb_errinfo(), NULL);
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);
@@ -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
- # jsonnet_wrap extension must be linked with c++ stdlib because
81
- # the C++ library Rapid YAML is being statically linked.
82
- rbconfig = RbConfig::MAKEFILE_CONFIG
83
- if rbconfig['LDSHAREDXX']
84
- rbconfig['LDSHARED'] = rbconfig['LDSHAREDXX']
85
- end
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
- vm_s_new(int argc, const VALUE *argv, VALUE klass)
62
+ vm_s_allocate(VALUE klass)
63
63
  {
64
64
  struct jsonnet_vm_wrap *vm;
65
- VALUE self = TypedData_Make_Struct(cVM, struct jsonnet_vm_wrap, &jsonnet_vm_type, vm);
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
- RB_REALLOC_N(ctx, struct native_callback_ctx, 0);
83
+ xfree(ctx);
85
84
  }
86
- RB_REALLOC_N(vm->native_callbacks.contexts, struct native_callback_ctx *, 0);
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
- rb_define_singleton_method(cVM, "new", vm_s_new, -1);
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);
@@ -1,3 +1,3 @@
1
1
  module Jsonnet
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.3"
3
3
  end
data/test/test_vm.rb CHANGED
@@ -54,7 +54,6 @@ class TestVM < Test::Unit::TestCase
54
54
  end
55
55
  end
56
56
 
57
-
58
57
  test 'Jsonnet::VM#evaluate evaluates snippet' do
59
58
  vm = Jsonnet::VM.new
60
59
  result = vm.evaluate(<<-EOS, filename: 'example.snippet')
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.1
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: 2022-09-24 00:00:00.000000000 Z
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