panko_serializer 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.clang-format +13 -3
- data/.travis.yml +5 -1
- data/Rakefile +7 -1
- data/benchmarks/bm_serialization_descriptor.rb +0 -1
- data/benchmarks/type_casts/bm_active_record.rb +0 -1
- data/benchmarks/type_casts/bm_panko.rb +0 -1
- data/ext/panko_serializer/attributes_writer/active_record.h +1 -1
- data/ext/panko_serializer/attributes_writer/type_cast/time_conversion.c +42 -18
- data/ext/panko_serializer/attributes_writer/type_cast/time_conversion.h +2 -0
- data/ext/panko_serializer/attributes_writer/type_cast/type_cast.c +3 -3
- data/ext/panko_serializer/attributes_writer/writer.h +1 -1
- data/ext/panko_serializer/panko_serializer.h +1 -1
- data/ext/panko_serializer/serialization_descriptor/serialization_descriptor.c +3 -4
- data/ext/panko_serializer/serialization_descriptor/serialization_descriptor.h +3 -1
- data/lib/panko/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe095c4ba577a1757ae1cfde90e6847bb6064753dd34e68aaa0c16d6bb9cc844
|
4
|
+
data.tar.gz: 5b3d50d6dc2191240069fa36733248197a96555a1b130c405d799d9ca982e9ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7e73c88806d3195cf9c63aeed87ff67739cc4ff31a6f0121ebe59612627c8f4b020e64eba2aaa55d56242a616e4de177996263c7c18cb5416124e7364f32977
|
7
|
+
data.tar.gz: 91505d9d99eddab0e81e05340ea324c0350507ff9fcc6db77fc9c4efc34c84bd28f9ee69d3b3e876ee23e0258ad785971c1a85893af35307c3882948eb7996b2
|
data/.clang-format
CHANGED
@@ -59,6 +59,7 @@ ForEachMacros:
|
|
59
59
|
- foreach
|
60
60
|
- Q_FOREACH
|
61
61
|
- BOOST_FOREACH
|
62
|
+
IncludeBlocks: Preserve
|
62
63
|
IncludeCategories:
|
63
64
|
- Regex: '^<ext/.*\.h>'
|
64
65
|
Priority: 2
|
@@ -80,9 +81,10 @@ MacroBlockBegin: ''
|
|
80
81
|
MacroBlockEnd: ''
|
81
82
|
MaxEmptyLinesToKeep: 1
|
82
83
|
NamespaceIndentation: None
|
84
|
+
ObjCBinPackProtocolList: Never
|
83
85
|
ObjCBlockIndentWidth: 2
|
84
86
|
ObjCSpaceAfterProperty: false
|
85
|
-
ObjCSpaceBeforeProtocolList:
|
87
|
+
ObjCSpaceBeforeProtocolList: true
|
86
88
|
PenaltyBreakAssignment: 2
|
87
89
|
PenaltyBreakBeforeFirstCallParameter: 1
|
88
90
|
PenaltyBreakComment: 300
|
@@ -92,8 +94,13 @@ PenaltyExcessCharacter: 1000000
|
|
92
94
|
PenaltyReturnTypeOnItsOwnLine: 200
|
93
95
|
PointerAlignment: Left
|
94
96
|
RawStringFormats:
|
95
|
-
-
|
96
|
-
|
97
|
+
- Language: TextProto
|
98
|
+
Delimiters:
|
99
|
+
- pb
|
100
|
+
- PB
|
101
|
+
- proto
|
102
|
+
- PROTO
|
103
|
+
CanonicalDelimiter: ''
|
97
104
|
BasedOnStyle: google
|
98
105
|
ReflowComments: true
|
99
106
|
SortIncludes: true
|
@@ -101,7 +108,10 @@ SortUsingDeclarations: true
|
|
101
108
|
SpaceAfterCStyleCast: false
|
102
109
|
SpaceAfterTemplateKeyword: true
|
103
110
|
SpaceBeforeAssignmentOperators: true
|
111
|
+
SpaceBeforeCtorInitializerColon: true
|
112
|
+
SpaceBeforeInheritanceColon: true
|
104
113
|
SpaceBeforeParens: ControlStatements
|
114
|
+
SpaceBeforeRangeBasedForLoopColon: true
|
105
115
|
SpaceInEmptyParentheses: false
|
106
116
|
SpacesBeforeTrailingComments: 2
|
107
117
|
SpacesInAngles: false
|
data/.travis.yml
CHANGED
@@ -3,13 +3,17 @@ cache: bundler
|
|
3
3
|
language: ruby
|
4
4
|
rvm:
|
5
5
|
- 2.5.1
|
6
|
+
- ruby-head
|
7
|
+
matrix:
|
8
|
+
allow_failures:
|
9
|
+
- rvm: ruby-head
|
6
10
|
|
7
11
|
env:
|
8
12
|
global:
|
9
13
|
- GIT_NAME: Travis CI
|
10
14
|
- GIT_EMAIL: nobody@nobody.org
|
11
15
|
|
12
|
-
install: bundle install --path=vendor/bundle --retry=3
|
16
|
+
install: bundle install --path=vendor/bundle --retry=3
|
13
17
|
|
14
18
|
before_install:
|
15
19
|
- gem install bundler
|
data/Rakefile
CHANGED
@@ -54,7 +54,13 @@ def run_benchmarks(files, items_count: 7_000)
|
|
54
54
|
|
55
55
|
lines = run_process "ITEMS_COUNT=#{items_count} RAILS_ENV=production ruby #{benchmark_file}"
|
56
56
|
rows = lines.map do |line|
|
57
|
-
|
57
|
+
begin
|
58
|
+
row = JSON.parse(line)
|
59
|
+
rescue JSON::ParserError
|
60
|
+
puts "> Failed parsing json"
|
61
|
+
puts lines.join
|
62
|
+
exit
|
63
|
+
end
|
58
64
|
row.values
|
59
65
|
end
|
60
66
|
|
@@ -70,7 +70,6 @@ ar_type_convert ActiveRecord::Type::String, 1, "1"
|
|
70
70
|
ar_type_convert ActiveRecord::Type::Text, 1, "1"
|
71
71
|
ar_type_convert ActiveRecord::Type::Integer, "1", 1
|
72
72
|
ar_type_convert ActiveRecord::Type::Float, "1.23", 1.23
|
73
|
-
ar_type_convert ActiveRecord::Type::Float, "Infinity", 0.0
|
74
73
|
ar_type_convert ActiveRecord::Type::Boolean, "true", true
|
75
74
|
ar_type_convert ActiveRecord::Type::Boolean, "t", true
|
76
75
|
|
@@ -49,7 +49,6 @@ panko_type_convert ActiveRecord::Type::String, 1, "1"
|
|
49
49
|
panko_type_convert ActiveRecord::Type::Text, 1, "1"
|
50
50
|
panko_type_convert ActiveRecord::Type::Integer, "1", 1
|
51
51
|
panko_type_convert ActiveRecord::Type::Float, "1.23", 1.23
|
52
|
-
panko_type_convert ActiveRecord::Type::Float, "Infinity", ::Float::INFINITY
|
53
52
|
panko_type_convert ActiveRecord::Type::Boolean, "true", true
|
54
53
|
panko_type_convert ActiveRecord::Type::Boolean, "t", true
|
55
54
|
|
@@ -25,22 +25,38 @@ VALUE is_iso8601_time_string(const char* value) {
|
|
25
25
|
return r >= 0 ? Qtrue : Qfalse;
|
26
26
|
}
|
27
27
|
|
28
|
-
void
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
void append_region_str(const char* source,
|
29
|
+
char** to,
|
30
|
+
int regionBegin,
|
31
|
+
int regionEnd) {
|
32
32
|
long iter = 0;
|
33
|
-
|
34
|
-
for (iter = region->beg[region_number]; iter < regionEnd; iter++) {
|
33
|
+
for (iter = regionBegin; iter < regionEnd; iter++) {
|
35
34
|
*(*to)++ = source[iter];
|
36
35
|
}
|
37
36
|
}
|
38
37
|
|
39
|
-
|
38
|
+
bool is_iso_ar_iso_datetime_string_fast_case(const char* value) {
|
39
|
+
return (
|
40
|
+
// year
|
41
|
+
isdigit(value[0]) && isdigit(value[1]) && isdigit(value[2]) &&
|
42
|
+
isdigit(value[3]) && value[4] == '-' &&
|
43
|
+
// month
|
44
|
+
isdigit(value[5]) && isdigit(value[6]) && value[7] == '-' &&
|
45
|
+
// mday
|
46
|
+
isdigit(value[8]) && isdigit(value[9]) && value[10] == ' ' &&
|
47
|
+
|
48
|
+
// hour
|
49
|
+
isdigit(value[11]) && isdigit(value[12]) && value[13] == ':' &&
|
50
|
+
// minute
|
51
|
+
isdigit(value[14]) && isdigit(value[15]) && value[16] == ':' &&
|
52
|
+
// seconds
|
53
|
+
isdigit(value[17]) && isdigit(value[18]));
|
54
|
+
}
|
55
|
+
|
56
|
+
bool is_iso_ar_iso_datetime_string_slow_case(const char* value) {
|
40
57
|
const UChar *start, *range, *end;
|
41
58
|
OnigPosition r;
|
42
59
|
OnigRegion* region = onig_region_new();
|
43
|
-
volatile VALUE output;
|
44
60
|
|
45
61
|
const UChar* str = (const UChar*)(value);
|
46
62
|
|
@@ -50,34 +66,42 @@ VALUE iso_ar_iso_datetime_string(const char* value) {
|
|
50
66
|
r = onig_search(ar_iso_datetime_regex, str, end, start, range, region,
|
51
67
|
ONIG_OPTION_NONE);
|
52
68
|
|
53
|
-
|
54
|
-
|
69
|
+
onig_region_free(region, 1);
|
70
|
+
|
71
|
+
return (r >= 0);
|
72
|
+
}
|
73
|
+
|
74
|
+
VALUE iso_ar_iso_datetime_string(const char* value) {
|
75
|
+
if (is_iso_ar_iso_datetime_string_fast_case(value) == true ||
|
76
|
+
is_iso_ar_iso_datetime_string_slow_case(value) == true) {
|
77
|
+
volatile VALUE output;
|
78
|
+
|
55
79
|
char buf[21] = "";
|
56
80
|
char* cur = buf;
|
57
81
|
|
58
|
-
|
82
|
+
append_region_str(value, &cur, 0, 4);
|
59
83
|
*cur++ = '-';
|
60
84
|
|
61
|
-
|
85
|
+
append_region_str(value, &cur, 5, 7);
|
62
86
|
*cur++ = '-';
|
63
87
|
|
64
|
-
|
88
|
+
append_region_str(value, &cur, 8, 10);
|
65
89
|
*cur++ = 'T';
|
66
90
|
|
67
|
-
|
91
|
+
append_region_str(value, &cur, 11, 13);
|
68
92
|
*cur++ = ':';
|
69
93
|
|
70
|
-
|
94
|
+
append_region_str(value, &cur, 14, 16);
|
71
95
|
*cur++ = ':';
|
72
96
|
|
73
|
-
|
97
|
+
append_region_str(value, &cur, 17, 19);
|
74
98
|
*cur++ = 'Z';
|
75
99
|
|
76
100
|
output = rb_str_new(buf, cur - buf);
|
101
|
+
return output;
|
77
102
|
}
|
78
103
|
|
79
|
-
|
80
|
-
return output;
|
104
|
+
return Qnil;
|
81
105
|
}
|
82
106
|
|
83
107
|
void build_regex(OnigRegex* reg, const UChar* pattern) {
|
@@ -243,8 +243,8 @@ VALUE cast_boolean_type(VALUE value) {
|
|
243
243
|
return Qnil;
|
244
244
|
}
|
245
245
|
|
246
|
-
if(RB_TYPE_P(value, T_STRING)) {
|
247
|
-
if(RSTRING_LEN(value) == 0) {
|
246
|
+
if (RB_TYPE_P(value, T_STRING)) {
|
247
|
+
if (RSTRING_LEN(value) == 0) {
|
248
248
|
return Qnil;
|
249
249
|
}
|
250
250
|
|
@@ -262,7 +262,7 @@ VALUE cast_boolean_type(VALUE value) {
|
|
262
262
|
return value == INT2NUM(1) ? Qtrue : Qfalse;
|
263
263
|
}
|
264
264
|
|
265
|
-
return
|
265
|
+
return Qundef;
|
266
266
|
}
|
267
267
|
|
268
268
|
bool is_date_time_type(VALUE type_klass) {
|
@@ -1,9 +1,9 @@
|
|
1
1
|
#include <ruby.h>
|
2
2
|
|
3
3
|
#include "attributes_writer/writer.h"
|
4
|
-
#include "serialization_descriptor/serialization_descriptor.h"
|
5
4
|
#include "serialization_descriptor/association.h"
|
6
5
|
#include "serialization_descriptor/attribute.h"
|
6
|
+
#include "serialization_descriptor/serialization_descriptor.h"
|
7
7
|
|
8
8
|
VALUE serialize_subject(VALUE key,
|
9
9
|
VALUE subject,
|
@@ -6,7 +6,6 @@ static ID context_id;
|
|
6
6
|
static ID scope_id;
|
7
7
|
static ID object_id;
|
8
8
|
|
9
|
-
|
10
9
|
static void sd_free(SerializationDescriptor sd) {
|
11
10
|
if (!sd) {
|
12
11
|
return;
|
@@ -59,7 +58,6 @@ SerializationDescriptor sd_read(VALUE descriptor) {
|
|
59
58
|
return (SerializationDescriptor)DATA_PTR(descriptor);
|
60
59
|
}
|
61
60
|
|
62
|
-
|
63
61
|
void sd_set_writer(SerializationDescriptor sd, VALUE subject) {
|
64
62
|
if (sd->attributes_writer.object_type != Unknown) {
|
65
63
|
return;
|
@@ -90,7 +88,9 @@ VALUE sd_serializer_ref(VALUE self) {
|
|
90
88
|
return sd->serializer;
|
91
89
|
}
|
92
90
|
|
93
|
-
void sd_apply_serializer_config(SerializationDescriptor descriptor,
|
91
|
+
void sd_apply_serializer_config(SerializationDescriptor descriptor,
|
92
|
+
VALUE serializer,
|
93
|
+
VALUE object) {
|
94
94
|
rb_ivar_set(serializer, object_id, object);
|
95
95
|
if (descriptor->context != Qnil && descriptor->context != Qundef) {
|
96
96
|
rb_ivar_set(serializer, context_id, descriptor->context);
|
@@ -99,7 +99,6 @@ void sd_apply_serializer_config(SerializationDescriptor descriptor, VALUE serial
|
|
99
99
|
if (descriptor->scope != Qnil && descriptor->scope != Qundef) {
|
100
100
|
rb_ivar_set(serializer, scope_id, descriptor->scope);
|
101
101
|
}
|
102
|
-
|
103
102
|
}
|
104
103
|
VALUE sd_attributes_set(VALUE self, VALUE attributes) {
|
105
104
|
SerializationDescriptor sd = (SerializationDescriptor)DATA_PTR(self);
|
@@ -28,7 +28,9 @@ SerializationDescriptor sd_read(VALUE descriptor);
|
|
28
28
|
void sd_mark(SerializationDescriptor data);
|
29
29
|
|
30
30
|
VALUE sd_build_serializer(SerializationDescriptor descriptor);
|
31
|
-
void sd_apply_serializer_config(SerializationDescriptor descriptor,
|
31
|
+
void sd_apply_serializer_config(SerializationDescriptor descriptor,
|
32
|
+
VALUE serializer,
|
33
|
+
VALUE object);
|
32
34
|
void sd_set_writer(SerializationDescriptor sd, VALUE subject);
|
33
35
|
|
34
36
|
void panko_init_serialization_descriptor(VALUE mPanko);
|
data/lib/panko/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: panko_serializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yosi Attias
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|