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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03b3b9607bd4d83e7848c7ff0a3e247147f8af67f15a4b017b19d3c0c9742147
4
- data.tar.gz: dac6c3c5040e5df0c452808a96d9edb96f8ec47f366d70f5308ea85aeecb06f9
3
+ metadata.gz: 1442bb3902c4cc204433160a3ae4d079eb5dc017b7e334bf4e5295dbd9a80dd1
4
+ data.tar.gz: 1801f742b22ffb29bc1dd274506e9b586d56d083f1c66563af9543fe91dd3eba
5
5
  SHA512:
6
- metadata.gz: fbae1762a9545c3aab9831cb9acfbef3a8ae754d0fdc73dc4c64c3bdeb4f92edf9f4fc861ec6156c330a54a0dd7fe6b2747fca9c97bf6f07a89a3c0f7bd1c795
7
- data.tar.gz: 63ce4bceaa20ba5a4d770cacfd0f4fc574206ee58c22524ea63147ea11a4ced49bc19197895fc0ccfdee24706b410951c789243e3201e037de4fecbe212d46f7
6
+ metadata.gz: 02d1b2eb290eee36a0680da61d928ea8a2e0a5ec06da975dbff4439747576bc7147dfe0c80c1722ea1769895996c992c63a960bef19abb9555d2233cab99a7e7
7
+ data.tar.gz: f3aa6d613311fa504d380b8ad3ce1909a1d0b77353187d4575e0405cae6f5b306782aa3a563fc46b858eb06f6795cd0c2a275b156a0757a441a53eb56e469ee7
@@ -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
@@ -15,6 +15,6 @@ group :development, :test do
15
15
  gem 'rom-repository'
16
16
  gem 'rom-sql'
17
17
  gem 'sequel'
18
- gem 'sqlite3', '~> 1.3.6'
18
+ gem 'sqlite3', '~> 1.4.1'
19
19
  gem 'yard', require: false unless ENV['TRAVIS']
20
20
  end
@@ -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).freeze
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
- if hash.is_a?(Hash)
16
- Hash[hash.map { |k, v| [camelize_key(k, false), camelize_hash(v)] }]
17
- else
18
- hash
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.public_send(method, *args, &block) || super
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
- .gsub(DASH_REGEXP1, UNDERSCORE_SUBSTITUTE)
24
- .gsub(DASH_REGEXP2, UNDERSCORE_SUBSTITUTE)
25
- .tr(DASH, UNDERSCORE)
26
- .downcase
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.inject({}) do |a, n|
75
- camelize ? Hash[camelize(uncapitalize(n), false).to_sym => a] : Hash[underscore(n).to_sym => a]
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
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Surrealist
4
4
  # Defines the version of Surrealist
5
- VERSION = '1.3.3'
5
+ VERSION = '1.3.4'
6
6
  end
@@ -60,7 +60,7 @@ module Surrealist
60
60
  else
61
61
  Surrealist::StringUtils.underscore(root).to_sym
62
62
  end
63
- result = Hash[root_key => {}]
63
+ result = { root_key => {} }
64
64
  Surrealist::Copier.deep_copy(schema, result[root_key])
65
65
 
66
66
  result
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.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-03-18 00:00:00.000000000 Z
11
+ date: 2019-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj