edn_turbo 0.5.3 → 0.5.4
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 +4 -4
- data/.gitignore +2 -0
- data/Gemfile +2 -0
- data/Rakefile +2 -3
- data/bin/ppedn +11 -12
- data/bin/ppedn-ruby +6 -5
- data/ext/edn_turbo/depend +5 -3
- data/ext/edn_turbo/edn_parser.cc +297 -295
- data/ext/edn_turbo/edn_parser.rl +20 -18
- data/ext/edn_turbo/extconf.rb +7 -11
- data/ext/edn_turbo/main.cc +28 -27
- data/ext/edn_turbo/{edn_parser.h → parser.h} +0 -42
- data/ext/edn_turbo/parser_def.cc +197 -0
- data/ext/edn_turbo/util.cc +240 -0
- data/ext/edn_turbo/util.h +39 -0
- data/ext/edn_turbo/util_unicode.cc +36 -0
- data/ext/edn_turbo/util_unicode.h +14 -0
- data/lib/edn_turbo/edn_parser.rb +6 -3
- data/lib/edn_turbo/version.rb +4 -2
- data/lib/edn_turbo.rb +2 -0
- data/test/test_output_diff.rb +38 -49
- metadata +9 -7
- data/ext/edn_turbo/edn_parser_util.cc +0 -424
- data/ext/edn_turbo/edn_parser_util.h +0 -11
- data/ext/edn_turbo/edn_parser_util_unicode.cc +0 -33
@@ -0,0 +1,240 @@
|
|
1
|
+
#include <iostream>
|
2
|
+
#include <string>
|
3
|
+
#include <sstream>
|
4
|
+
#include <limits>
|
5
|
+
|
6
|
+
#include <ruby/ruby.h>
|
7
|
+
#include <ruby/encoding.h>
|
8
|
+
|
9
|
+
#include "util.h"
|
10
|
+
#include "util_unicode.h"
|
11
|
+
|
12
|
+
namespace edn
|
13
|
+
{
|
14
|
+
//
|
15
|
+
// used to determine max number of chars in string value of a type
|
16
|
+
template <typename T>
|
17
|
+
static std::size_t get_max_chars(T)
|
18
|
+
{
|
19
|
+
std::stringstream s;
|
20
|
+
s << std::fixed << std::numeric_limits<T>::max();
|
21
|
+
return s.str().length();
|
22
|
+
}
|
23
|
+
|
24
|
+
static const std::size_t LL_max_chars = get_max_chars<>((long) 1);
|
25
|
+
static const std::size_t LD_max_chars = get_max_chars<>((double) 1);
|
26
|
+
|
27
|
+
//
|
28
|
+
// throw runtime error
|
29
|
+
static void throw_error(int error)
|
30
|
+
{
|
31
|
+
if (error == 0)
|
32
|
+
return;
|
33
|
+
|
34
|
+
VALUE err = rb_errinfo();
|
35
|
+
rb_raise(CLASS_OF(err), "%s", RSTRING_PTR(rb_obj_as_string(err)));
|
36
|
+
}
|
37
|
+
|
38
|
+
// =================================================================
|
39
|
+
// work-around for idiotic rb_protect convention in order to avoid
|
40
|
+
// using ruby/rice
|
41
|
+
//
|
42
|
+
typedef VALUE (edn_rb_f_type)( VALUE arg );
|
43
|
+
|
44
|
+
// we're using at most 2 args
|
45
|
+
struct prot_args {
|
46
|
+
prot_args(VALUE r, ID m) :
|
47
|
+
receiver(r), method(m), count(0) {
|
48
|
+
}
|
49
|
+
prot_args(VALUE r, ID m, VALUE arg) :
|
50
|
+
receiver(r), method(m), count(1) {
|
51
|
+
args[0] = arg;
|
52
|
+
}
|
53
|
+
prot_args(VALUE r, ID m, VALUE arg1, VALUE arg2) :
|
54
|
+
receiver(r), method(m), count(2) {
|
55
|
+
args[0] = arg1;
|
56
|
+
args[1] = arg2;
|
57
|
+
}
|
58
|
+
|
59
|
+
VALUE call() const {
|
60
|
+
return ((count == 0) ?
|
61
|
+
rb_funcall( receiver, method, 0 ) :
|
62
|
+
rb_funcall2( receiver, method, count, args ));
|
63
|
+
}
|
64
|
+
|
65
|
+
private:
|
66
|
+
VALUE receiver;
|
67
|
+
ID method;
|
68
|
+
int count;
|
69
|
+
VALUE args[2];
|
70
|
+
};
|
71
|
+
|
72
|
+
// this allows us to wrap with rb_protect()
|
73
|
+
static inline VALUE edn_wrap_funcall2( VALUE arg ) {
|
74
|
+
const prot_args* a = reinterpret_cast<const prot_args*>(arg);
|
75
|
+
if (a)
|
76
|
+
return a->call();
|
77
|
+
return Qnil;
|
78
|
+
}
|
79
|
+
|
80
|
+
static inline VALUE edn_prot_rb_funcall( edn_rb_f_type func, VALUE args ) {
|
81
|
+
int error;
|
82
|
+
VALUE s = rb_protect( func, args, &error );
|
83
|
+
if (error) throw_error(error);
|
84
|
+
return s;
|
85
|
+
}
|
86
|
+
|
87
|
+
static inline VALUE edn_prot_rb_new_str(const char* str) {
|
88
|
+
int error;
|
89
|
+
VALUE s = rb_protect( reinterpret_cast<VALUE (*)(VALUE)>(rb_str_new_cstr),
|
90
|
+
reinterpret_cast<VALUE>(str), &error );
|
91
|
+
if (error) throw_error(error);
|
92
|
+
return s;
|
93
|
+
}
|
94
|
+
|
95
|
+
static inline VALUE edn_rb_enc_associate_utf8(VALUE str) {
|
96
|
+
return rb_enc_associate(str, rb_utf8_encoding() );
|
97
|
+
}
|
98
|
+
|
99
|
+
// =================================================================
|
100
|
+
// utils
|
101
|
+
namespace util
|
102
|
+
{
|
103
|
+
// utility method to convert a primitive in string form to a
|
104
|
+
// ruby type
|
105
|
+
template <class T>
|
106
|
+
static inline T buftotype(const char* p, std::size_t len) {
|
107
|
+
T val;
|
108
|
+
std::string buf;
|
109
|
+
buf.append(p, len);
|
110
|
+
std::istringstream(buf) >> val;
|
111
|
+
return val;
|
112
|
+
}
|
113
|
+
|
114
|
+
//
|
115
|
+
// convert to int.. if string rep has more digits than long can
|
116
|
+
// hold, call into ruby to get a big num
|
117
|
+
VALUE integer_to_ruby(const char* str, std::size_t len)
|
118
|
+
{
|
119
|
+
// if something bigger than a long is needed, call into
|
120
|
+
// ruby side to get the correct value
|
121
|
+
if (str[len-1] == 'M' || len >= LL_max_chars)
|
122
|
+
{
|
123
|
+
std::string buf(str, len);
|
124
|
+
VALUE vs = edn_prot_rb_new_str(buf.c_str());
|
125
|
+
prot_args args(vs, RUBY_STRING_TO_I_METHOD);
|
126
|
+
return edn_prot_rb_funcall( edn_wrap_funcall2, reinterpret_cast<VALUE>(&args) );
|
127
|
+
}
|
128
|
+
|
129
|
+
return LONG2NUM(buftotype<long>(str, len));
|
130
|
+
}
|
131
|
+
|
132
|
+
//
|
133
|
+
// as above.. TODO: check exponential..
|
134
|
+
VALUE float_to_ruby(const char* str, std::size_t len)
|
135
|
+
{
|
136
|
+
// if big decimal is needed, call into ruby side to get
|
137
|
+
// the correct value
|
138
|
+
if (str[len-1] == 'M' || len >= LD_max_chars)
|
139
|
+
{
|
140
|
+
std::string buf(str, len);
|
141
|
+
VALUE vs = edn_prot_rb_new_str(buf.c_str());
|
142
|
+
|
143
|
+
if (str[len-1] == 'M') {
|
144
|
+
return call_module_fn(rb_mEDN, EDN_MAKE_BIG_DECIMAL_METHOD, vs);
|
145
|
+
}
|
146
|
+
|
147
|
+
prot_args args(vs, RUBY_STRING_TO_F_METHOD);
|
148
|
+
return edn_prot_rb_funcall( edn_wrap_funcall2, reinterpret_cast<VALUE>(&args) );
|
149
|
+
}
|
150
|
+
|
151
|
+
return rb_float_new(buftotype<double>(str, len));
|
152
|
+
}
|
153
|
+
|
154
|
+
|
155
|
+
//
|
156
|
+
// read from a StringIO - expensive!!!
|
157
|
+
//
|
158
|
+
VALUE ruby_io_read(VALUE io)
|
159
|
+
{
|
160
|
+
prot_args args(io, RUBY_READ_METHOD);
|
161
|
+
return edn_prot_rb_funcall( edn_wrap_funcall2, reinterpret_cast<VALUE>(&args) );
|
162
|
+
}
|
163
|
+
|
164
|
+
//
|
165
|
+
// copies the string data, unescaping any present values that need to be replaced
|
166
|
+
//
|
167
|
+
bool parse_byte_stream(const char *p_start, const char *p_end, VALUE& v_utf8, bool encode)
|
168
|
+
{
|
169
|
+
if (p_end > p_start) {
|
170
|
+
std::string buf;
|
171
|
+
|
172
|
+
if (encode) {
|
173
|
+
if (!util::unicode::to_utf8(p_start, (uint32_t) (p_end - p_start), buf))
|
174
|
+
return false;
|
175
|
+
}
|
176
|
+
else {
|
177
|
+
buf.append(p_start, p_end - p_start);
|
178
|
+
}
|
179
|
+
|
180
|
+
// utf-8 encode
|
181
|
+
VALUE vs = edn_prot_rb_new_str(buf.c_str());
|
182
|
+
int error;
|
183
|
+
v_utf8 = rb_protect( edn_rb_enc_associate_utf8, vs, &error);
|
184
|
+
if (error) throw_error(error);
|
185
|
+
return true;
|
186
|
+
} else if (p_end == p_start) {
|
187
|
+
v_utf8 = rb_str_new("", 0);
|
188
|
+
return true;
|
189
|
+
}
|
190
|
+
|
191
|
+
return false;
|
192
|
+
}
|
193
|
+
|
194
|
+
//
|
195
|
+
// handles things like \c, \newline
|
196
|
+
//
|
197
|
+
bool parse_escaped_char(const char *p, const char *pe, VALUE& v)
|
198
|
+
{
|
199
|
+
std::string buf;
|
200
|
+
std::size_t len = pe - p;
|
201
|
+
buf.append(p, len);
|
202
|
+
|
203
|
+
if (len > 1) {
|
204
|
+
if (buf == "newline") buf = '\n';
|
205
|
+
else if (buf == "tab") buf = '\t';
|
206
|
+
else if (buf == "return") buf = '\r';
|
207
|
+
else if (buf == "space") buf = ' ';
|
208
|
+
else if (buf == "formfeed") buf = '\f';
|
209
|
+
else if (buf == "backspace") buf = '\b';
|
210
|
+
// TODO: is this supported?
|
211
|
+
else if (buf == "verticaltab") buf = '\v';
|
212
|
+
else return false;
|
213
|
+
}
|
214
|
+
|
215
|
+
v = edn_prot_rb_new_str( buf.c_str() );
|
216
|
+
return true;
|
217
|
+
}
|
218
|
+
|
219
|
+
|
220
|
+
//
|
221
|
+
// get a set representation from the ruby side. See edn_turbo.rb
|
222
|
+
VALUE call_module_fn(VALUE module, ID method)
|
223
|
+
{
|
224
|
+
prot_args args(module, method);
|
225
|
+
return edn_prot_rb_funcall( edn_wrap_funcall2, reinterpret_cast<VALUE>(&args) );
|
226
|
+
}
|
227
|
+
|
228
|
+
VALUE call_module_fn(VALUE module, ID method, VALUE value)
|
229
|
+
{
|
230
|
+
prot_args args(module, method, value);
|
231
|
+
return edn_prot_rb_funcall( edn_wrap_funcall2, reinterpret_cast<VALUE>(&args) );
|
232
|
+
}
|
233
|
+
|
234
|
+
VALUE call_module_fn(VALUE module, ID method, VALUE name, VALUE data)
|
235
|
+
{
|
236
|
+
prot_args args(module, method, name, data);
|
237
|
+
return edn_prot_rb_funcall( edn_wrap_funcall2, reinterpret_cast<VALUE>(&args) );
|
238
|
+
}
|
239
|
+
}
|
240
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
namespace edn
|
4
|
+
{
|
5
|
+
extern VALUE rb_mEDN;
|
6
|
+
extern VALUE rb_mEDNT;
|
7
|
+
|
8
|
+
extern VALUE EDN_MAKE_SYMBOL_METHOD;
|
9
|
+
extern VALUE EDN_MAKE_LIST_METHOD;
|
10
|
+
extern VALUE EDN_MAKE_SET_METHOD;
|
11
|
+
extern VALUE EDN_MAKE_BIG_DECIMAL_METHOD;
|
12
|
+
extern VALUE EDN_TAGGED_ELEM_METHOD;
|
13
|
+
extern VALUE EDN_EOF_CONST;
|
14
|
+
|
15
|
+
extern VALUE EDNT_EXTENDED_VALUE_METHOD;
|
16
|
+
|
17
|
+
extern VALUE RUBY_STRING_TO_I_METHOD;
|
18
|
+
extern VALUE RUBY_STRING_TO_F_METHOD;
|
19
|
+
extern VALUE RUBY_READ_METHOD;
|
20
|
+
|
21
|
+
namespace util
|
22
|
+
{
|
23
|
+
// defined in edn_parser_util.cc
|
24
|
+
VALUE integer_to_ruby(const char* str, std::size_t len);
|
25
|
+
VALUE float_to_ruby (const char* str, std::size_t len);
|
26
|
+
|
27
|
+
VALUE ruby_io_read(VALUE io);
|
28
|
+
|
29
|
+
bool parse_byte_stream (const char *p, const char *pe, VALUE& rslt, bool encode);
|
30
|
+
bool parse_escaped_char(const char *p, const char *pe, VALUE& rslt);
|
31
|
+
|
32
|
+
VALUE call_module_fn(VALUE module, ID method);
|
33
|
+
VALUE call_module_fn(VALUE module, ID method, VALUE value);
|
34
|
+
VALUE call_module_fn(VALUE module, ID method, VALUE value1, VALUE value2);
|
35
|
+
|
36
|
+
// edn_parser_util_unicode.cc
|
37
|
+
bool to_utf8(const char *s, uint32_t len, std::string& rslt);
|
38
|
+
}
|
39
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#include <string>
|
2
|
+
|
3
|
+
//
|
4
|
+
// needed to define this in its own file because icu and ruby have
|
5
|
+
// differing definitions for Uchar and the compiler complains
|
6
|
+
//
|
7
|
+
#include <unicode/utypes.h>
|
8
|
+
#include <unicode/ustring.h>
|
9
|
+
#include <unicode/ucnv.h>
|
10
|
+
#include <unicode/unistr.h>
|
11
|
+
|
12
|
+
#include "util_unicode.h"
|
13
|
+
|
14
|
+
namespace edn
|
15
|
+
{
|
16
|
+
namespace util
|
17
|
+
{
|
18
|
+
namespace unicode
|
19
|
+
{
|
20
|
+
//
|
21
|
+
// unescapes any values that need to be replaced, saves it to utf8
|
22
|
+
//
|
23
|
+
bool to_utf8(const char *s, uint32_t len, std::string& rslt)
|
24
|
+
{
|
25
|
+
icu::UnicodeString ustr(s, len);
|
26
|
+
|
27
|
+
if (ustr.isBogus()) {
|
28
|
+
return false;
|
29
|
+
}
|
30
|
+
|
31
|
+
ustr.unescape().toUTF8String(rslt);
|
32
|
+
return true;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
data/lib/edn_turbo/edn_parser.rb
CHANGED
@@ -1,18 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# methods specific to edn_turbo
|
1
5
|
module EDNT
|
2
6
|
# Bind the given meta to the value.
|
3
7
|
def self.extend_for_meta(value, ext_meta)
|
4
|
-
|
5
8
|
meta = ext_meta
|
6
9
|
|
7
10
|
metadata = meta.reduce({}) do |acc, m|
|
8
11
|
case m
|
9
12
|
when Symbol then acc.merge(m => true)
|
10
|
-
when EDN::Type::Symbol then acc.merge(:
|
13
|
+
when EDN::Type::Symbol then acc.merge(tag: m)
|
11
14
|
else acc.merge(m)
|
12
15
|
end
|
13
16
|
end
|
14
17
|
|
15
|
-
|
18
|
+
unless metadata.empty?
|
16
19
|
value.extend EDN::Metadata
|
17
20
|
value.metadata = metadata
|
18
21
|
end
|
data/lib/edn_turbo/version.rb
CHANGED
data/lib/edn_turbo.rb
CHANGED
data/test/test_output_diff.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# -*- coding: utf-8 -*-
|
3
|
-
$LOAD_PATH << File.expand_path(
|
3
|
+
$LOAD_PATH << File.expand_path(File.dirname(__FILE__) + '/../lib')
|
4
4
|
require 'minitest/autorun'
|
5
5
|
require 'edn_turbo'
|
6
6
|
require 'date'
|
7
7
|
|
8
8
|
class EDNT_Test < Minitest::Test
|
9
|
-
|
10
9
|
def setup
|
11
10
|
@parser = EDNT::Parser.new
|
12
11
|
end
|
@@ -47,7 +46,7 @@ class EDNT_Test < Minitest::Test
|
|
47
46
|
output
|
48
47
|
end
|
49
48
|
|
50
|
-
#
|
49
|
+
# ============================================================================
|
51
50
|
# tests start here
|
52
51
|
#
|
53
52
|
def test_false
|
@@ -95,8 +94,8 @@ class EDNT_Test < Minitest::Test
|
|
95
94
|
|
96
95
|
check_file('test/values.edn',
|
97
96
|
[false, true, nil, "this is a test", "this\tis\\only\ta\ttest\rof\"various\nescaped\\values",
|
98
|
-
[
|
99
|
-
|
97
|
+
['c', "\n", "\t"],
|
98
|
+
'123➪456®789']
|
100
99
|
)
|
101
100
|
end
|
102
101
|
|
@@ -104,103 +103,94 @@ class EDNT_Test < Minitest::Test
|
|
104
103
|
|
105
104
|
check_file('test/inst.edn',
|
106
105
|
[
|
107
|
-
DateTime.rfc3339(
|
108
|
-
DateTime.rfc3339(
|
109
|
-
DateTime.rfc3339(
|
110
|
-
DateTime.rfc3339(
|
111
|
-
DateTime.rfc3339(
|
106
|
+
DateTime.rfc3339('1985-04-12T23:20:50.52Z'),
|
107
|
+
DateTime.rfc3339('1996-12-19T16:39:57-08:00'),
|
108
|
+
DateTime.rfc3339('1990-12-31T23:59:60Z'),
|
109
|
+
DateTime.rfc3339('1990-12-31T15:59:60-08:00'),
|
110
|
+
DateTime.rfc3339('1937-01-01T12:00:27.87+00:20')
|
112
111
|
]
|
113
112
|
)
|
114
113
|
end
|
115
114
|
|
116
115
|
def test_builtin_tagged_uuid
|
117
116
|
|
118
|
-
check_file('test/uuid.edn',
|
117
|
+
check_file('test/uuid.edn', 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6')
|
119
118
|
|
120
119
|
end
|
121
120
|
|
122
121
|
def test_sets
|
123
|
-
|
124
122
|
check_file('test/set.edn',
|
125
123
|
[ Set.new(),
|
126
124
|
Set.new([1, Set.new([:abc])]),
|
127
125
|
Set.new([1]),
|
128
|
-
Set.new([1,
|
129
|
-
Set.new([1, 2, 3, [4, 5],
|
126
|
+
Set.new([1, 'abc' ]),
|
127
|
+
Set.new([1, 2, 3, [4, 5], 'abc', 23.3])
|
130
128
|
]
|
131
129
|
)
|
132
|
-
|
133
130
|
end
|
134
131
|
|
135
132
|
def test_symbol
|
136
|
-
|
137
133
|
check_file('test/symbol.edn',
|
138
134
|
[
|
139
|
-
EDN::Type::Symbol.new(
|
140
|
-
EDN::Type::Symbol.new(
|
135
|
+
EDN::Type::Symbol.new('asymbol'),
|
136
|
+
EDN::Type::Symbol.new('.asymbol'),
|
141
137
|
EDN::Type::Symbol.new("with'_a_'"),
|
142
|
-
EDN::Type::Symbol.new(
|
143
|
-
EDN::Type::Symbol.new(
|
144
|
-
EDN::Type::Symbol.new(
|
145
|
-
EDN::Type::Symbol.new(
|
138
|
+
EDN::Type::Symbol.new('with.123'),
|
139
|
+
EDN::Type::Symbol.new('-with.123'),
|
140
|
+
EDN::Type::Symbol.new('/'),
|
141
|
+
EDN::Type::Symbol.new('>:FOuy/+'),
|
146
142
|
]
|
147
143
|
)
|
148
|
-
|
149
144
|
end
|
150
145
|
|
151
146
|
def test_unicode
|
152
|
-
|
153
147
|
check_file('test/unicode.edn',
|
154
148
|
[:text,
|
155
149
|
"Page \u0018, October 2009 TechTIPS",
|
156
|
-
|
150
|
+
'This should be an unfilled star: ☆']
|
157
151
|
)
|
158
152
|
end
|
159
153
|
|
160
154
|
def test_vector
|
161
|
-
|
162
155
|
check_file('test/vector_1.edn',
|
163
|
-
[true, true, 34, [true, nil,
|
156
|
+
[true, true, 34, [true, nil, 'añ', '', :test, [3213.23]]]
|
164
157
|
)
|
165
158
|
end
|
166
159
|
|
167
160
|
def test_list
|
168
|
-
|
169
161
|
check_file('test/list_1.edn',
|
170
|
-
[22, 3312,
|
162
|
+
[22, 3312, 'dss', {:powerpuff=>[:buttercup, :bubbles, :blossom]}]
|
171
163
|
)
|
172
|
-
|
173
164
|
end
|
174
165
|
|
175
166
|
def test_map
|
176
|
-
|
177
167
|
check_file('test/map1.edn',
|
178
|
-
{:key_a1=>true,:key_a2=>false,:key_a3=>[1, 2, 3,
|
179
|
-
:key_a4=>{:key_a31=>23, :key_a32=>24.4},
|
180
|
-
:embedded=>[true, {:c2g_md5=>
|
168
|
+
{:key_a1=>true,:key_a2=>false,:key_a3=>[1, 2, 3, 'test string', nil, {1=>2}],
|
169
|
+
:key_a4=>{:key_a31=>23, :key_a32=>24.4},'string_key'=>:kval,
|
170
|
+
:embedded=>[true, {:c2g_md5=>'2bbee1cd3045710db6fec432b00d1e0c'}],
|
181
171
|
2=>{:a=>:b}}
|
182
172
|
)
|
183
173
|
|
184
174
|
check_file('test/map2.edn',
|
185
|
-
{:
|
175
|
+
{int: 1, string: 'hello', char: 'a', array: [0, 1], hash: {key: 'value'}}
|
186
176
|
)
|
187
177
|
end
|
188
178
|
|
189
179
|
|
190
180
|
def test_metadata
|
191
181
|
f = check_file('test/metadata.edn', [98.6, 99.7])
|
192
|
-
assert_equal({:doc=>
|
182
|
+
assert_equal({:doc=>'This is my vector', rel: :temps}, f.metadata)
|
193
183
|
end
|
194
184
|
|
195
185
|
def test_metadata2
|
196
186
|
f = check_file('test/metadata2.edn', [1, 2])
|
197
|
-
assert_equal({:
|
187
|
+
assert_equal({ foo: true, tag: EDN::Type::Symbol.new('String'), bar: 2 }, f.metadata)
|
198
188
|
end
|
199
189
|
|
200
190
|
def test_metadata_in_vector
|
201
191
|
check_file('test/meta_in_vector.edn',
|
202
192
|
[ [ EDN::Type::Symbol.new('c'), :d, true ],
|
203
|
-
DateTime.rfc3339(
|
193
|
+
DateTime.rfc3339('1390-09-07T21:27:03+00:00')
|
204
194
|
]
|
205
195
|
)
|
206
196
|
end
|
@@ -220,7 +210,7 @@ class EDNT_Test < Minitest::Test
|
|
220
210
|
|
221
211
|
def test_tagged_elem
|
222
212
|
|
223
|
-
EDN.register(
|
213
|
+
EDN.register('edn_turbo/test_tagged') do |data|
|
224
214
|
Tagged.new(data).to_s
|
225
215
|
end
|
226
216
|
|
@@ -257,7 +247,7 @@ class EDNT_Test < Minitest::Test
|
|
257
247
|
end
|
258
248
|
|
259
249
|
REF_MAP3_DATA = {:meta=>{:data_format_version=>304,
|
260
|
-
:filename=>
|
250
|
+
:filename=>'test/colorspan.pdf',
|
261
251
|
:is_ok=>true,
|
262
252
|
:font_engine_ok=>true,
|
263
253
|
:pdf_ver_major=>1,
|
@@ -388,7 +378,7 @@ class EDNT_Test < Minitest::Test
|
|
388
378
|
end
|
389
379
|
|
390
380
|
def test_ruby_file_io
|
391
|
-
File.open(
|
381
|
+
File.open('test/true.edn', 'r') do |f|
|
392
382
|
# now test setting the source and using read (although one-shot)
|
393
383
|
@parser.set_input(f)
|
394
384
|
output = @parser.read
|
@@ -397,12 +387,12 @@ class EDNT_Test < Minitest::Test
|
|
397
387
|
end
|
398
388
|
|
399
389
|
def test_ruby_file_io_long
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
390
|
+
File.open('test/map3.edn', 'r') do |f|
|
391
|
+
# now test setting the source and using read (although one-shot)
|
392
|
+
@parser.set_input(f)
|
393
|
+
output = @parser.read
|
394
|
+
assert_equal(REF_MAP3_DATA, output)
|
395
|
+
end
|
406
396
|
end
|
407
397
|
|
408
398
|
def test_ruby_string_io
|
@@ -415,11 +405,10 @@ class EDNT_Test < Minitest::Test
|
|
415
405
|
|
416
406
|
def test_init_arg
|
417
407
|
# test passing IO to constructor
|
418
|
-
File.open(
|
408
|
+
File.open('test/map3.edn', 'r') do |f|
|
419
409
|
p = EDNT::Parser.new(f)
|
420
410
|
output = p.read
|
421
411
|
assert_equal(REF_MAP3_DATA, output)
|
422
412
|
end
|
423
413
|
end
|
424
|
-
|
425
414
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edn_turbo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ed Porras
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: edn
|
@@ -83,13 +83,15 @@ files:
|
|
83
83
|
- bin/ppedn-ruby
|
84
84
|
- ext/edn_turbo/depend
|
85
85
|
- ext/edn_turbo/edn_parser.cc
|
86
|
-
- ext/edn_turbo/edn_parser.h
|
87
86
|
- ext/edn_turbo/edn_parser.rl
|
88
|
-
- ext/edn_turbo/edn_parser_util.cc
|
89
|
-
- ext/edn_turbo/edn_parser_util.h
|
90
|
-
- ext/edn_turbo/edn_parser_util_unicode.cc
|
91
87
|
- ext/edn_turbo/extconf.rb
|
92
88
|
- ext/edn_turbo/main.cc
|
89
|
+
- ext/edn_turbo/parser.h
|
90
|
+
- ext/edn_turbo/parser_def.cc
|
91
|
+
- ext/edn_turbo/util.cc
|
92
|
+
- ext/edn_turbo/util.h
|
93
|
+
- ext/edn_turbo/util_unicode.cc
|
94
|
+
- ext/edn_turbo/util_unicode.h
|
93
95
|
- lib/edn_turbo.rb
|
94
96
|
- lib/edn_turbo/edn_parser.rb
|
95
97
|
- lib/edn_turbo/version.rb
|
@@ -114,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
116
|
version: '0'
|
115
117
|
requirements: []
|
116
118
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.
|
119
|
+
rubygems_version: 2.6.11
|
118
120
|
signing_key:
|
119
121
|
specification_version: 3
|
120
122
|
summary: Read EDN files
|