usamin 7.7.9 → 7.7.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +62 -42
- data/Rakefile +12 -10
- data/ext/usamin/default_parse_flags.hpp +6 -0
- data/ext/usamin/extconf.rb +11 -6
- data/ext/usamin/generator.cpp +219 -0
- data/ext/usamin/generator.hpp +11 -0
- data/ext/usamin/parser.cpp +100 -0
- data/ext/usamin/parser.hpp +9 -0
- data/ext/usamin/parser_helper.hpp +131 -0
- data/ext/usamin/rb_common.cpp +60 -0
- data/ext/usamin/rb_common.hpp +15 -0
- data/ext/usamin/rb_usamin_array.cpp +453 -0
- data/ext/usamin/rb_usamin_array.hpp +29 -0
- data/ext/usamin/rb_usamin_hash.cpp +517 -0
- data/ext/usamin/rb_usamin_hash.hpp +37 -0
- data/ext/usamin/rb_usamin_value.cpp +327 -0
- data/ext/usamin/rb_usamin_value.hpp +24 -0
- data/ext/usamin/rubynized_rapidjson.cpp +21 -0
- data/ext/usamin/rubynized_rapidjson.hpp +18 -0
- data/ext/usamin/usamin.cpp +23 -1759
- data/ext/usamin/usamin_value.cpp +14 -0
- data/ext/usamin/usamin_value.hpp +17 -0
- data/lib/usamin.rb +2 -0
- data/lib/usamin/overwrite.rb +35 -28
- data/lib/usamin/version.rb +3 -1
- data/usamin.gemspec +19 -18
- metadata +24 -6
@@ -0,0 +1,14 @@
|
|
1
|
+
#include "usamin_value.hpp"
|
2
|
+
#include <ruby.h>
|
3
|
+
#include "rubynized_rapidjson.hpp"
|
4
|
+
|
5
|
+
UsaminValue::UsaminValue(RubynizedValue *value, const bool free_flag, const VALUE root_document) {
|
6
|
+
this->value = value;
|
7
|
+
this->free_flag = free_flag;
|
8
|
+
this->root_document = root_document;
|
9
|
+
}
|
10
|
+
|
11
|
+
UsaminValue::~UsaminValue() {
|
12
|
+
if (value && free_flag)
|
13
|
+
delete (RubynizedDocument *)value;
|
14
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#ifndef USAMIN_USAMIN_VALUE_HPP
|
2
|
+
#define USAMIN_USAMIN_VALUE_HPP
|
3
|
+
|
4
|
+
#include <ruby.h>
|
5
|
+
#include "rubynized_rapidjson.hpp"
|
6
|
+
|
7
|
+
class UsaminValue {
|
8
|
+
public:
|
9
|
+
RubynizedValue *value;
|
10
|
+
VALUE root_document;
|
11
|
+
bool free_flag;
|
12
|
+
|
13
|
+
UsaminValue(RubynizedValue *value = nullptr, const bool free_flag = false, const VALUE root_document = Qnil);
|
14
|
+
~UsaminValue();
|
15
|
+
};
|
16
|
+
|
17
|
+
#endif
|
data/lib/usamin.rb
CHANGED
data/lib/usamin/overwrite.rb
CHANGED
@@ -1,40 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
1
4
|
require 'usamin'
|
2
5
|
|
3
6
|
module JSON
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
+
def self.generate(object, **options)
|
8
|
+
options[:indent] ? Usamin.pretty_generate(object, indent: options[:indent]) : Usamin.generate(object)
|
9
|
+
end
|
7
10
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
+
def self.pretty_generate(object, **options)
|
12
|
+
options[:indent] ? Usamin.pretty_generate(object, indent: options[:indent]) : Usamin.pretty_generate(object)
|
13
|
+
end
|
11
14
|
|
12
|
-
|
13
|
-
|
15
|
+
def self.parse(source, **options)
|
16
|
+
begin
|
17
|
+
Usamin.parse(source, symbolize_names: options[:symbolize_names])
|
18
|
+
rescue Usamin::ParserError
|
19
|
+
raise JSON::ParserError.new($!.message)
|
14
20
|
end
|
21
|
+
end
|
15
22
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
23
|
+
def self.load(source, proc = nil, **options)
|
24
|
+
ret = Usamin.parse(source, **options)
|
25
|
+
LoadProcCaller.load_call_proc(ret, proc) if proc
|
26
|
+
ret
|
27
|
+
end
|
21
28
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
32
|
-
proc.call(object)
|
29
|
+
class LoadProcCaller
|
30
|
+
def self.load_call_proc(object, proc)
|
31
|
+
if object.is_a?(Array)
|
32
|
+
object.each{|e| load_call_proc(e, proc)}
|
33
|
+
elsif object.is_a?(Hash)
|
34
|
+
object.each do |k, v|
|
35
|
+
proc.call(k)
|
36
|
+
load_call_proc(v, proc)
|
33
37
|
end
|
38
|
+
end
|
39
|
+
proc.call(object)
|
34
40
|
end
|
41
|
+
end
|
35
42
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
43
|
+
class << self
|
44
|
+
alias fast_generate generate
|
45
|
+
alias restore load
|
46
|
+
end
|
40
47
|
end
|
data/lib/usamin/version.rb
CHANGED
data/usamin.gemspec
CHANGED
@@ -1,29 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
|
-
lib = File.expand_path(
|
3
|
-
|
4
|
-
require
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$:.unshift(lib) unless $:.include?(lib)
|
5
|
+
require 'usamin/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'usamin'
|
8
9
|
spec.version = Usamin::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
10
|
+
spec.authors = ['Ishotihadus']
|
11
|
+
spec.email = ['hanachan.pao@gmail.com']
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
13
|
+
spec.summary = 'A RapidJSON Wrapper for Ruby'
|
14
|
+
spec.description = 'A fast JSON serializer / deserializer for Ruby with RapidJSON.'
|
15
|
+
spec.homepage = 'https://github.com/Ishotihadus/usamin'
|
16
|
+
spec.license = 'MIT'
|
16
17
|
|
17
18
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
19
|
f.match(%r{^(test|spec|features)/})
|
19
20
|
end
|
20
|
-
spec.bindir =
|
21
|
-
spec.executables = spec.files.grep(%r{^exe/}) {
|
22
|
-
spec.require_paths = [
|
23
|
-
spec.extensions = [
|
21
|
+
spec.bindir = 'exe'
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f)}
|
23
|
+
spec.require_paths = ['lib']
|
24
|
+
spec.extensions = ['ext/usamin/extconf.rb']
|
24
25
|
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
26
|
+
spec.add_development_dependency 'bundler'
|
27
|
+
spec.add_development_dependency 'pry'
|
28
|
+
spec.add_development_dependency 'rake'
|
29
|
+
spec.add_development_dependency 'rake-compiler'
|
29
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: usamin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.7.
|
4
|
+
version: 7.7.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ishotihadus
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: pry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
42
|
+
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rake-compiler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -82,8 +82,26 @@ files:
|
|
82
82
|
- Rakefile
|
83
83
|
- bin/console
|
84
84
|
- bin/setup
|
85
|
+
- ext/usamin/default_parse_flags.hpp
|
85
86
|
- ext/usamin/extconf.rb
|
87
|
+
- ext/usamin/generator.cpp
|
88
|
+
- ext/usamin/generator.hpp
|
89
|
+
- ext/usamin/parser.cpp
|
90
|
+
- ext/usamin/parser.hpp
|
91
|
+
- ext/usamin/parser_helper.hpp
|
92
|
+
- ext/usamin/rb_common.cpp
|
93
|
+
- ext/usamin/rb_common.hpp
|
94
|
+
- ext/usamin/rb_usamin_array.cpp
|
95
|
+
- ext/usamin/rb_usamin_array.hpp
|
96
|
+
- ext/usamin/rb_usamin_hash.cpp
|
97
|
+
- ext/usamin/rb_usamin_hash.hpp
|
98
|
+
- ext/usamin/rb_usamin_value.cpp
|
99
|
+
- ext/usamin/rb_usamin_value.hpp
|
100
|
+
- ext/usamin/rubynized_rapidjson.cpp
|
101
|
+
- ext/usamin/rubynized_rapidjson.hpp
|
86
102
|
- ext/usamin/usamin.cpp
|
103
|
+
- ext/usamin/usamin_value.cpp
|
104
|
+
- ext/usamin/usamin_value.hpp
|
87
105
|
- lib/usamin.rb
|
88
106
|
- lib/usamin/overwrite.rb
|
89
107
|
- lib/usamin/version.rb
|
@@ -107,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
125
|
- !ruby/object:Gem::Version
|
108
126
|
version: '0'
|
109
127
|
requirements: []
|
110
|
-
rubygems_version: 3.
|
128
|
+
rubygems_version: 3.1.2
|
111
129
|
signing_key:
|
112
130
|
specification_version: 4
|
113
131
|
summary: A RapidJSON Wrapper for Ruby
|