ucl 0.1.1 → 0.1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/ucl.c +37 -27
- data/ucl.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5badf6c3422aac319ce132dfde865c7e5532b5b6617ffdad9e5383026c176f7a
|
4
|
+
data.tar.gz: 6cac2b1806cfb4997ca0de3239c48b4241ef16ed0a64dd5f4772f2d79ab02937
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9aba6119424b9e6d8488c870330b1603b79dadd74f3896f34eafb09c3eb30fb60fc20788dd8dbb9308ea405b14e7b65a037c9ed870c1697533af9dd72b91e34
|
7
|
+
data.tar.gz: b4e5702dac98848b069a09e611342e8607dcf580baa44c6da905a255c83e9b2f4aac02c2f4f8bf83c16a848b886fd3b085b9e93616a2437132926af181248e26
|
data/ext/ucl.c
CHANGED
@@ -25,6 +25,11 @@
|
|
25
25
|
static VALUE mUCL = Qundef;
|
26
26
|
static VALUE eUCLError = Qundef;
|
27
27
|
|
28
|
+
static int ucl_allowed_flags = UCL_PARSER_KEY_LOWERCASE |
|
29
|
+
UCL_PARSER_NO_TIME |
|
30
|
+
UCL_PARSER_DISABLE_MACRO |
|
31
|
+
UCL_PARSER_NO_FILEVARS ;
|
32
|
+
|
28
33
|
|
29
34
|
VALUE
|
30
35
|
_iterate_valid_ucl(ucl_object_t const *root, int flags)
|
@@ -36,7 +41,7 @@ _iterate_valid_ucl(ucl_object_t const *root, int flags)
|
|
36
41
|
|
37
42
|
VALUE lst = rb_ary_new();
|
38
43
|
|
39
|
-
while ((obj =
|
44
|
+
while ((obj = ucl_iterate_object (root, &it, false))) {
|
40
45
|
VALUE val;
|
41
46
|
|
42
47
|
switch (obj->type) {
|
@@ -63,7 +68,7 @@ _iterate_valid_ucl(ucl_object_t const *root, int flags)
|
|
63
68
|
case UCL_OBJECT:
|
64
69
|
it_obj = NULL;
|
65
70
|
val = rb_hash_new();
|
66
|
-
while ((cur =
|
71
|
+
while ((cur = ucl_iterate_object(obj, &it_obj, true))) {
|
67
72
|
const char *obj_key = ucl_object_key(cur);
|
68
73
|
VALUE key = (flags & UCL_PARSER_KEY_SYMBOL)
|
69
74
|
? rb_id2sym(rb_intern(obj_key))
|
@@ -75,7 +80,7 @@ _iterate_valid_ucl(ucl_object_t const *root, int flags)
|
|
75
80
|
case UCL_ARRAY:
|
76
81
|
it_obj = NULL;
|
77
82
|
val = rb_ary_new();
|
78
|
-
while ((cur =
|
83
|
+
while ((cur = ucl_iterate_object (obj, &it_obj, true))) {
|
79
84
|
rb_ary_push(val, _iterate_valid_ucl(cur, flags));
|
80
85
|
}
|
81
86
|
break;
|
@@ -130,11 +135,6 @@ ucl_s_set_flags(VALUE klass, VALUE val)
|
|
130
135
|
static VALUE
|
131
136
|
ucl_s_parse(int argc, VALUE *argv, VALUE klass)
|
132
137
|
{
|
133
|
-
static int allowed_flags = UCL_PARSER_KEY_LOWERCASE |
|
134
|
-
UCL_PARSER_NO_TIME |
|
135
|
-
UCL_PARSER_DISABLE_MACRO |
|
136
|
-
UCL_PARSER_NO_FILEVARS ;
|
137
|
-
|
138
138
|
VALUE data, flags;
|
139
139
|
rb_scan_args(argc, argv, "11", &data, &flags);
|
140
140
|
if (NIL_P(flags)) flags = ucl_s_get_flags(mUCL);
|
@@ -142,7 +142,7 @@ ucl_s_parse(int argc, VALUE *argv, VALUE klass)
|
|
142
142
|
rb_check_type(data, T_STRING);
|
143
143
|
rb_check_type(flags, T_FIXNUM);
|
144
144
|
|
145
|
-
int c_flags = FIX2INT(flags) &
|
145
|
+
int c_flags = FIX2INT(flags) & ucl_allowed_flags;
|
146
146
|
|
147
147
|
struct ucl_parser *parser =
|
148
148
|
ucl_parser_new(c_flags | UCL_PARSER_NO_IMPLICIT_ARRAYS);
|
@@ -152,20 +152,16 @@ ucl_s_parse(int argc, VALUE *argv, VALUE klass)
|
|
152
152
|
RSTRING_LEN(data));
|
153
153
|
|
154
154
|
if (ucl_parser_get_error(parser)) {
|
155
|
-
|
155
|
+
const char *errormsg = ucl_parser_get_error(parser);
|
156
|
+
if (parser != NULL) { ucl_parser_free(parser); }
|
157
|
+
rb_raise(eUCLError, "%s", errormsg);
|
156
158
|
}
|
157
159
|
|
158
160
|
ucl_object_t *root = ucl_parser_get_object(parser);
|
161
|
+
VALUE res = _iterate_valid_ucl(root, FIX2INT(flags));
|
159
162
|
|
160
|
-
|
161
|
-
|
162
|
-
if (parser != NULL) {
|
163
|
-
ucl_parser_free(parser);
|
164
|
-
}
|
165
|
-
|
166
|
-
if (root != NULL) {
|
167
|
-
ucl_object_unref(root);
|
168
|
-
}
|
163
|
+
if (parser != NULL) { ucl_parser_free(parser); }
|
164
|
+
if (root != NULL) { ucl_object_unref(root); }
|
169
165
|
|
170
166
|
return res;
|
171
167
|
}
|
@@ -187,17 +183,31 @@ ucl_s_load_file(int argc, VALUE *argv, VALUE klass)
|
|
187
183
|
{
|
188
184
|
VALUE file, flags;
|
189
185
|
rb_scan_args(argc, argv, "11", &file, &flags);
|
186
|
+
if (NIL_P(flags)) flags = ucl_s_get_flags(mUCL);
|
190
187
|
|
191
|
-
|
192
|
-
|
193
|
-
|
188
|
+
rb_check_type(file, T_STRING);
|
189
|
+
rb_check_type(flags, T_FIXNUM);
|
190
|
+
|
191
|
+
int c_flags = FIX2INT(flags) & ucl_allowed_flags;
|
192
|
+
char *c_file = StringValueCStr(file);
|
193
|
+
|
194
|
+
struct ucl_parser *parser =
|
195
|
+
ucl_parser_new(c_flags | UCL_PARSER_NO_IMPLICIT_ARRAYS);
|
196
|
+
ucl_parser_add_file(parser, c_file);
|
197
|
+
|
198
|
+
if (ucl_parser_get_error(parser)) {
|
199
|
+
const char *errormsg = ucl_parser_get_error(parser);
|
200
|
+
if (parser != NULL) { ucl_parser_free(parser); }
|
201
|
+
rb_raise(eUCLError, "%s", errormsg);
|
202
|
+
}
|
194
203
|
|
195
|
-
|
196
|
-
VALUE
|
197
|
-
2, read_args, RB_PASS_KEYWORDS);
|
204
|
+
ucl_object_t *root = ucl_parser_get_object(parser);
|
205
|
+
VALUE res = _iterate_valid_ucl(root, FIX2INT(flags));
|
198
206
|
|
199
|
-
|
200
|
-
|
207
|
+
if (parser != NULL) { ucl_parser_free(parser); }
|
208
|
+
if (root != NULL) { ucl_object_unref(root); }
|
209
|
+
|
210
|
+
return res;
|
201
211
|
}
|
202
212
|
|
203
213
|
|
data/ucl.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ucl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.1
|
4
|
+
version: 0.1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stéphane D'Alu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2+
|
14
14
|
|
@@ -43,7 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
version: '0'
|
45
45
|
requirements: []
|
46
|
-
rubygems_version: 3.
|
46
|
+
rubygems_version: 3.4.2
|
47
47
|
signing_key:
|
48
48
|
specification_version: 4
|
49
49
|
summary: Universal configuration library parser
|