surrealist 1.3.3 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -1
- data/lib/surrealist/builder.rb +2 -1
- data/lib/surrealist/hash_utils.rb +4 -4
- data/lib/surrealist/serializer.rb +3 -1
- data/lib/surrealist/string_utils.rb +10 -7
- data/lib/surrealist/version.rb +1 -1
- data/lib/surrealist/wrapper.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: 1442bb3902c4cc204433160a3ae4d079eb5dc017b7e334bf4e5295dbd9a80dd1
|
4
|
+
data.tar.gz: 1801f742b22ffb29bc1dd274506e9b586d56d083f1c66563af9543fe91dd3eba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02d1b2eb290eee36a0680da61d928ea8a2e0a5ec06da975dbff4439747576bc7147dfe0c80c1722ea1769895996c992c63a960bef19abb9555d2233cab99a7e7
|
7
|
+
data.tar.gz: f3aa6d613311fa504d380b8ad3ce1909a1d0b77353187d4575e0405cae6f5b306782aa3a563fc46b858eb06f6795cd0c2a275b156a0757a441a53eb56e469ee7
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# 1.3.4
|
2
|
+
|
3
|
+
## Fixed
|
4
|
+
* Performance and memory improvements ([@krzysiek1507][])[#140](https://github.com/nesaulov/surrealist/pull/140)
|
5
|
+
* Fix serializing when direct instance method call returns nil ([@past-one][]) [#141](https://github.com/nesaulov/surrealist/pull/141)
|
6
|
+
|
1
7
|
# 1.3.3
|
2
8
|
|
3
9
|
## Fixed
|
@@ -133,3 +139,4 @@
|
|
133
139
|
[@gjhenrique]: https://github.com/gjhenrique
|
134
140
|
[@kolasss]: https://github.com/kolasss
|
135
141
|
[@wildkain]: https://github.com/wildkain
|
142
|
+
[@krzysiek1507]: https://github.com/krzysiek1507
|
data/Gemfile
CHANGED
data/lib/surrealist/builder.rb
CHANGED
@@ -4,7 +4,8 @@ module Surrealist
|
|
4
4
|
# A class that builds a hash from the schema and type-checks the values.
|
5
5
|
class Builder
|
6
6
|
# Struct to carry schema along
|
7
|
-
Schema = Struct.new(:key, :value)
|
7
|
+
Schema = Struct.new(:key, :value)
|
8
|
+
Schema.freeze
|
8
9
|
|
9
10
|
# @param [Carrier] carrier instance of Surrealist::Carrier
|
10
11
|
# @param [Hash] schema the schema defined in the object's class.
|
@@ -12,10 +12,10 @@ module Surrealist
|
|
12
12
|
#
|
13
13
|
# @return [Hash] camelized hash.
|
14
14
|
def camelize_hash(hash)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
return hash unless hash.is_a?(Hash)
|
16
|
+
|
17
|
+
hash.each_with_object({}) do |(k, v), obj|
|
18
|
+
obj[camelize_key(k, false)] = camelize_hash(v)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -107,7 +107,9 @@ module Surrealist
|
|
107
107
|
|
108
108
|
# Methods not found inside serializer will be invoked on the object
|
109
109
|
def method_missing(method, *args, &block)
|
110
|
-
object.
|
110
|
+
return super unless object.respond_to?(method)
|
111
|
+
|
112
|
+
object.public_send(method, *args, &block)
|
111
113
|
end
|
112
114
|
|
113
115
|
# Methods not found inside serializer will be invoked on the object
|
@@ -19,11 +19,12 @@ module Surrealist
|
|
19
19
|
#
|
20
20
|
# @return [String] new underscored string.
|
21
21
|
def underscore(string)
|
22
|
-
string.gsub(NAMESPACES_SEPARATOR, UNDERSCORE)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
dup = string.gsub(NAMESPACES_SEPARATOR, UNDERSCORE)
|
23
|
+
dup.gsub!(DASH_REGEXP1, UNDERSCORE_SUBSTITUTE)
|
24
|
+
dup.gsub!(DASH_REGEXP2, UNDERSCORE_SUBSTITUTE)
|
25
|
+
dup.tr!(DASH, UNDERSCORE)
|
26
|
+
dup.downcase!
|
27
|
+
dup
|
27
28
|
end
|
28
29
|
|
29
30
|
# Camelizes a string.
|
@@ -71,8 +72,10 @@ module Surrealist
|
|
71
72
|
def break_namespaces(klass, camelize, nesting_level)
|
72
73
|
Surrealist::ExceptionRaiser.raise_invalid_nesting!(nesting_level) unless nesting_level.positive?
|
73
74
|
|
74
|
-
klass.split(NAMESPACES_SEPARATOR).last(nesting_level).reverse
|
75
|
-
camelize ?
|
75
|
+
klass.split(NAMESPACES_SEPARATOR).last(nesting_level).reverse!.inject({}) do |a, n|
|
76
|
+
key = (camelize ? camelize(uncapitalize(n), false) : underscore(n)).to_sym
|
77
|
+
|
78
|
+
{ key => a }
|
76
79
|
end
|
77
80
|
end
|
78
81
|
|
data/lib/surrealist/version.rb
CHANGED
data/lib/surrealist/wrapper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: surrealist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikita Esaulov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|