mongory 2.1.1 → 2.2.0
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/CHANGELOG.md +22 -0
- data/README.md +45 -74
- data/docs/clang_bridge.md +2 -2
- data/docs/performance.md +28 -1
- data/ext/mongory_ext/extconf.rb +15 -0
- data/ext/mongory_ext/mongory-core/include/mongory-core/foundations/config.h +28 -43
- data/ext/mongory_ext/mongory-core/include/mongory-core/foundations/memory_pool.h +0 -1
- data/ext/mongory_ext/mongory-core/include/mongory-core/matchers/matcher.h +3 -4
- data/ext/mongory_ext/mongory-core/src/foundations/array.c +28 -5
- data/ext/mongory_ext/mongory-core/src/foundations/config.c +24 -22
- data/ext/mongory_ext/mongory-core/src/foundations/config_private.h +3 -3
- data/ext/mongory_ext/mongory-core/src/foundations/memory_pool.c +22 -13
- data/ext/mongory_ext/mongory-core/src/foundations/string_buffer.c +4 -3
- data/ext/mongory_ext/mongory-core/src/foundations/table.c +60 -224
- data/ext/mongory_ext/mongory-core/src/foundations/table_private.h +36 -0
- data/ext/mongory_ext/mongory-core/src/foundations/utils.c +30 -47
- data/ext/mongory_ext/mongory-core/src/foundations/utils.h +2 -5
- data/ext/mongory_ext/mongory-core/src/foundations/value.c +18 -32
- data/ext/mongory_ext/mongory-core/src/matchers/base_matcher.c +89 -104
- data/ext/mongory_ext/mongory-core/src/matchers/base_matcher.h +18 -11
- data/ext/mongory_ext/mongory-core/src/matchers/compare_matcher.c +35 -150
- data/ext/mongory_ext/mongory-core/src/matchers/composite_matcher.c +244 -418
- data/ext/mongory_ext/mongory-core/src/matchers/composite_matcher.h +30 -0
- data/ext/mongory_ext/mongory-core/src/matchers/existence_matcher.c +15 -56
- data/ext/mongory_ext/mongory-core/src/matchers/external_matcher.c +18 -39
- data/ext/mongory_ext/mongory-core/src/matchers/implicit_array_matcher.c +14 -15
- data/ext/mongory_ext/mongory-core/src/matchers/inclusion_matcher.c +67 -118
- data/ext/mongory_ext/mongory-core/src/matchers/matcher.c +373 -123
- data/ext/mongory_ext/mongory-core/src/matchers/matcher_traversable.c +20 -12
- data/ext/mongory_ext/mongory-core/src/matchers/matcher_traversable.h +1 -4
- data/ext/mongory_ext/mongory-core/src/matchers/value_matcher.c +214 -171
- data/ext/mongory_ext/mongory-core/src/matchers/value_matcher.h +8 -16
- data/ext/mongory_ext/mongory_ext.c +26 -4
- data/ext/mongory_ext/mongory_ext_internal.h +15 -3
- data/ext/mongory_ext/rb_mongory_adapters.c +52 -19
- data/ext/mongory_ext/rb_mongory_matcher.c +115 -36
- data/ext/mongory_ext/rb_mongory_value.c +124 -51
- data/lib/mongory/converters/abstract_converter.rb +5 -5
- data/lib/mongory/converters/converted.rb +0 -4
- data/lib/mongory/converters/key_converter.rb +13 -36
- data/lib/mongory/converters/value_converter.rb +4 -4
- data/lib/mongory/matchers.rb +8 -7
- data/lib/mongory/query_builder.rb +9 -0
- data/lib/mongory/utils/context.rb +0 -6
- data/lib/mongory/utils/singleton_builder.rb +1 -4
- data/lib/mongory/version.rb +1 -1
- data/lib/mongory.rb +0 -1
- data/script/coverage.rb +84 -0
- metadata +7 -7
- data/ext/mongory_ext/mongory-core/src/matchers/matcher_explainable.c +0 -117
- data/ext/mongory_ext/mongory-core/src/matchers/matcher_explainable.h +0 -29
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mongory
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- koten0224
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-12-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A Mongo-like in-memory query DSL for Ruby
|
|
14
14
|
email:
|
|
@@ -55,6 +55,7 @@ files:
|
|
|
55
55
|
- ext/mongory_ext/mongory-core/src/foundations/string_buffer.c
|
|
56
56
|
- ext/mongory_ext/mongory-core/src/foundations/string_buffer.h
|
|
57
57
|
- ext/mongory_ext/mongory-core/src/foundations/table.c
|
|
58
|
+
- ext/mongory_ext/mongory-core/src/foundations/table_private.h
|
|
58
59
|
- ext/mongory_ext/mongory-core/src/foundations/utils.c
|
|
59
60
|
- ext/mongory_ext/mongory-core/src/foundations/utils.h
|
|
60
61
|
- ext/mongory_ext/mongory-core/src/foundations/value.c
|
|
@@ -73,8 +74,6 @@ files:
|
|
|
73
74
|
- ext/mongory_ext/mongory-core/src/matchers/inclusion_matcher.c
|
|
74
75
|
- ext/mongory_ext/mongory-core/src/matchers/inclusion_matcher.h
|
|
75
76
|
- ext/mongory_ext/mongory-core/src/matchers/matcher.c
|
|
76
|
-
- ext/mongory_ext/mongory-core/src/matchers/matcher_explainable.c
|
|
77
|
-
- ext/mongory_ext/mongory-core/src/matchers/matcher_explainable.h
|
|
78
77
|
- ext/mongory_ext/mongory-core/src/matchers/matcher_traversable.c
|
|
79
78
|
- ext/mongory_ext/mongory-core/src/matchers/matcher_traversable.h
|
|
80
79
|
- ext/mongory_ext/mongory-core/src/matchers/value_matcher.c
|
|
@@ -110,6 +109,7 @@ files:
|
|
|
110
109
|
- lib/mongory/version.rb
|
|
111
110
|
- renovate.json
|
|
112
111
|
- script/bench.rb
|
|
112
|
+
- script/coverage.rb
|
|
113
113
|
- scripts/build_with_core.sh
|
|
114
114
|
- sig/mongory.rbs
|
|
115
115
|
homepage: https://mongoryhq.github.io/mongory-rb/
|
|
@@ -121,7 +121,7 @@ metadata:
|
|
|
121
121
|
homepage_uri: https://mongoryhq.github.io/mongory-rb/
|
|
122
122
|
source_code_uri: https://github.com/mongoryhq/mongory-rb
|
|
123
123
|
changelog_uri: https://github.com/mongoryhq/mongory-rb/blob/main/CHANGELOG.md
|
|
124
|
-
post_install_message:
|
|
124
|
+
post_install_message:
|
|
125
125
|
rdoc_options: []
|
|
126
126
|
require_paths:
|
|
127
127
|
- lib
|
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
137
137
|
version: '0'
|
|
138
138
|
requirements: []
|
|
139
139
|
rubygems_version: 3.4.19
|
|
140
|
-
signing_key:
|
|
140
|
+
signing_key:
|
|
141
141
|
specification_version: 4
|
|
142
142
|
summary: MongoDB-like in-memory query DSL for Ruby
|
|
143
143
|
test_files: []
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
#ifndef MONGORY_MATCHER_EXPLAINABLE_C
|
|
2
|
-
#define MONGORY_MATCHER_EXPLAINABLE_C
|
|
3
|
-
|
|
4
|
-
#include "matcher_explainable.h"
|
|
5
|
-
#include "../foundations/string_buffer.h"
|
|
6
|
-
#include "base_matcher.h"
|
|
7
|
-
#include "composite_matcher.h"
|
|
8
|
-
#include "value_matcher.h"
|
|
9
|
-
#include "../foundations/utils.h"
|
|
10
|
-
#include <stdio.h>
|
|
11
|
-
|
|
12
|
-
char *mongory_matcher_title(mongory_matcher *matcher, mongory_memory_pool *pool) {
|
|
13
|
-
mongory_value *condition = matcher->condition;
|
|
14
|
-
char *cond_str = (condition && condition->to_str) ? condition->to_str(condition, pool) : NULL;
|
|
15
|
-
if (!cond_str) {
|
|
16
|
-
return NULL;
|
|
17
|
-
}
|
|
18
|
-
return mongory_string_cpyf(pool, "%s: %s",
|
|
19
|
-
matcher->name ? matcher->name : "",
|
|
20
|
-
cond_str
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
char *mongory_matcher_title_with_field(mongory_matcher *matcher, mongory_memory_pool *pool) {
|
|
25
|
-
mongory_field_matcher *field_matcher = (mongory_field_matcher *)matcher;
|
|
26
|
-
mongory_value *condition = matcher->condition;
|
|
27
|
-
char *cond_str = (condition && condition->to_str) ? condition->to_str(condition, pool) : NULL;
|
|
28
|
-
if (!cond_str) {
|
|
29
|
-
return NULL;
|
|
30
|
-
}
|
|
31
|
-
return mongory_string_cpyf(pool, "Field: \"%s\", to match: %s",
|
|
32
|
-
field_matcher->field ? field_matcher->field : "",
|
|
33
|
-
cond_str
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
static inline char *mongory_matcher_tail_connection(int count, int total) {
|
|
38
|
-
if (total == 0) {
|
|
39
|
-
return "";
|
|
40
|
-
}
|
|
41
|
-
if (total - count == 1) {
|
|
42
|
-
return "└─ ";
|
|
43
|
-
}
|
|
44
|
-
return "├─ ";
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
static inline char *mongory_matcher_indent_connection(int count, int total) {
|
|
48
|
-
if (total == 0) {
|
|
49
|
-
return "";
|
|
50
|
-
}
|
|
51
|
-
if (total - count == 1) {
|
|
52
|
-
return " ";
|
|
53
|
-
}
|
|
54
|
-
return "│ ";
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
static mongory_explain_acc *mongory_explain_acc_child(
|
|
58
|
-
mongory_memory_pool *pool,
|
|
59
|
-
mongory_explain_acc *parent_acc,
|
|
60
|
-
int count,
|
|
61
|
-
int total
|
|
62
|
-
) {
|
|
63
|
-
char *indent = mongory_matcher_indent_connection(count, total);
|
|
64
|
-
mongory_explain_acc *next = MG_ALLOC_PTR(pool, mongory_explain_acc);
|
|
65
|
-
if (!next) {
|
|
66
|
-
return NULL;
|
|
67
|
-
}
|
|
68
|
-
next->prefix = mongory_string_cpyf(pool, "%s%s", parent_acc->prefix, indent);
|
|
69
|
-
if (!next->prefix) {
|
|
70
|
-
return NULL;
|
|
71
|
-
}
|
|
72
|
-
next->buf = parent_acc->buf;
|
|
73
|
-
return next;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
static bool mongory_matcher_append_explain_line(
|
|
77
|
-
mongory_matcher_traverse_context *ctx,
|
|
78
|
-
char *title
|
|
79
|
-
) {
|
|
80
|
-
mongory_explain_acc *acc = (mongory_explain_acc *)ctx->acc;
|
|
81
|
-
char *connection = mongory_matcher_tail_connection(ctx->count, ctx->total);
|
|
82
|
-
if (!acc || !acc->buf || !title) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
mongory_string_buffer_appendf(acc->buf, "%s%s%s\n", acc->prefix, connection, title);
|
|
86
|
-
return ctx->pool->error == NULL;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
bool mongory_matcher_base_explain(mongory_matcher *matcher, mongory_matcher_traverse_context *ctx) {
|
|
90
|
-
char *title = mongory_matcher_title(matcher, ctx->pool);
|
|
91
|
-
return mongory_matcher_append_explain_line(ctx, title);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
bool mongory_matcher_composite_explain(mongory_matcher *matcher, mongory_matcher_traverse_context *ctx) {
|
|
95
|
-
if (!mongory_matcher_base_explain(matcher, ctx)) {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
mongory_explain_acc *acc = (mongory_explain_acc *)ctx->acc;
|
|
99
|
-
ctx->acc = mongory_explain_acc_child(ctx->pool, acc, ctx->count, ctx->total);
|
|
100
|
-
return ctx->acc != NULL;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
bool mongory_matcher_value_explain(mongory_matcher *matcher, mongory_matcher_traverse_context *ctx) {
|
|
104
|
-
return mongory_matcher_composite_explain(matcher, ctx);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
bool mongory_matcher_field_explain(mongory_matcher *matcher, mongory_matcher_traverse_context *ctx) {
|
|
108
|
-
char *title = mongory_matcher_title_with_field(matcher, ctx->pool);
|
|
109
|
-
if (!mongory_matcher_append_explain_line(ctx, title)) {
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
mongory_explain_acc *acc = (mongory_explain_acc *)ctx->acc;
|
|
113
|
-
ctx->acc = mongory_explain_acc_child(ctx->pool, acc, ctx->count, ctx->total);
|
|
114
|
-
return ctx->acc != NULL;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
#endif /* MONGORY_MATCHER_EXPLAINABLE_C */
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
#ifndef MONGORY_MATCHER_EXPLAINABLE_H
|
|
2
|
-
#define MONGORY_MATCHER_EXPLAINABLE_H
|
|
3
|
-
|
|
4
|
-
#include "mongory-core/matchers/matcher.h"
|
|
5
|
-
#include "../foundations/string_buffer.h"
|
|
6
|
-
#include "matcher_traversable.h"
|
|
7
|
-
#include <mongory-core.h>
|
|
8
|
-
|
|
9
|
-
typedef struct mongory_explain_acc {
|
|
10
|
-
char *prefix;
|
|
11
|
-
mongory_string_buffer *buf;
|
|
12
|
-
} mongory_explain_acc;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @brief Explains a matcher.
|
|
17
|
-
* @param matcher The matcher to explain.
|
|
18
|
-
* @param ctx The context to use for the explanation.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
bool mongory_matcher_base_explain(struct mongory_matcher *matcher, mongory_matcher_traverse_context *ctx);
|
|
22
|
-
|
|
23
|
-
bool mongory_matcher_composite_explain(struct mongory_matcher *matcher, mongory_matcher_traverse_context *ctx);
|
|
24
|
-
|
|
25
|
-
bool mongory_matcher_field_explain(struct mongory_matcher *matcher, mongory_matcher_traverse_context *ctx);
|
|
26
|
-
|
|
27
|
-
bool mongory_matcher_value_explain(struct mongory_matcher *matcher, mongory_matcher_traverse_context *ctx);
|
|
28
|
-
|
|
29
|
-
#endif /* MONGORY_MATCHER_EXPLAINABLE_H */
|