rj_schema 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rj_schema/rj_schema.cpp +4 -7
- data/lib/rj_schema.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: a1a69f6b3d192c21c9ec108ddac23ab6a7d5360ffc50be83414a5ed751216e47
|
4
|
+
data.tar.gz: 939bd3f2fc82b77df0c35f11d7e9345782875d909e38f042ffe7a9c8d8426d65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1607700248a092bd5dcce95a4966f2d761eede35403e8178b0166df15507ff35a29932c2e1b03e41fe12c4e0c46b71fca8237330a89e72274c8db3d16425fa29
|
7
|
+
data.tar.gz: 63d7e7300d82bf026736496e45c0066c95fe73e9d6ee1f48f323c4f19693860f19a6963dc66c3669ecaccfae83f60a64d86e2a875b83342eb566a01c0d945d22
|
data/ext/rj_schema/rj_schema.cpp
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
#include <rapidjson/filereadstream.h>
|
19
19
|
#include <rapidjson/prettywriter.h>
|
20
20
|
|
21
|
-
typedef std::unordered_map<
|
21
|
+
typedef std::unordered_map<ID, rapidjson::SchemaDocument> SchemaCollection;
|
22
22
|
|
23
23
|
class SchemaDocumentProvider : public rapidjson::IRemoteSchemaDocumentProvider {
|
24
24
|
SchemaCollection* schema_collection;
|
@@ -26,7 +26,7 @@ class SchemaDocumentProvider : public rapidjson::IRemoteSchemaDocumentProvider {
|
|
26
26
|
public:
|
27
27
|
SchemaDocumentProvider(SchemaCollection* schema_collection) : schema_collection(schema_collection) { }
|
28
28
|
virtual const rapidjson::SchemaDocument* GetRemoteDocument(const char* uri, rapidjson::SizeType length) {
|
29
|
-
auto it = schema_collection->find(
|
29
|
+
auto it = schema_collection->find(rb_intern2(uri, length));
|
30
30
|
if (it == schema_collection->end())
|
31
31
|
throw std::invalid_argument(std::string("$ref remote schema not provided: ") + uri);
|
32
32
|
return &it->second;
|
@@ -79,10 +79,7 @@ VALUE perform_validation(VALUE self, VALUE schema_arg, VALUE document_arg, bool
|
|
79
79
|
};
|
80
80
|
|
81
81
|
if (SYMBOL_P(schema_arg)) {
|
82
|
-
|
83
|
-
auto it = schema_manager->collection.find(
|
84
|
-
std::string(StringValuePtr(schema_arg), RSTRING_LEN(schema_arg))
|
85
|
-
);
|
82
|
+
auto it = schema_manager->collection.find(SYM2ID(schema_arg));
|
86
83
|
if (it == schema_manager->collection.end())
|
87
84
|
rb_raise(rb_eArgError, "schema not found");
|
88
85
|
return validate(it->second);
|
@@ -124,7 +121,7 @@ extern "C" int validator_initialize_load_schema(VALUE key, VALUE value, VALUE in
|
|
124
121
|
|
125
122
|
try {
|
126
123
|
schema_manager->collection.emplace(
|
127
|
-
|
124
|
+
rb_to_id(key),
|
128
125
|
rapidjson::SchemaDocument(
|
129
126
|
parse_document(value),
|
130
127
|
StringValuePtr(key),
|
data/lib/rj_schema.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rj_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Semmler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|