serega 0.40.0 → 0.40.1
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/LICENSE.txt +21 -0
- data/README.md +90 -107
- data/VERSION +1 -1
- data/lib/serega/attribute.rb +2 -0
- data/lib/serega/attribute_normalizer.rb +2 -0
- data/lib/serega/attribute_value_resolvers/batch.rb +3 -0
- data/lib/serega/attribute_value_resolvers/const.rb +3 -0
- data/lib/serega/attribute_value_resolvers/delegate.rb +4 -0
- data/lib/serega/attribute_value_resolvers/hash_access.rb +6 -0
- data/lib/serega/attribute_value_resolvers/keyword.rb +3 -0
- data/lib/serega/data_builder.rb +2 -0
- data/lib/serega/engine/level.rb +2 -0
- data/lib/serega/engine/level_queue.rb +2 -0
- data/lib/serega/engine/loader.rb +3 -0
- data/lib/serega/helpers/serializer_class_helper.rb +2 -0
- data/lib/serega/object_serializer.rb +2 -0
- data/lib/serega/plan.rb +3 -0
- data/lib/serega/plan_point.rb +2 -0
- data/lib/serega/plugins/activerecord_preloads/activerecord_preloads.rb +22 -16
- data/lib/serega/plugins/activerecord_preloads/lib/preloader.rb +6 -0
- data/lib/serega/plugins/camel_case/camel_case.rb +13 -13
- data/lib/serega/plugins/context_metadata/context_metadata.rb +8 -1
- data/lib/serega/plugins/depth_limit/depth_limit.rb +15 -12
- data/lib/serega/plugins/explicit_many_option/explicit_many_option.rb +12 -10
- data/lib/serega/plugins/explicit_many_option/validations/check_opt_many.rb +1 -0
- data/lib/serega/plugins/formatters/formatters.rb +18 -10
- data/lib/serega/plugins/if/if.rb +29 -32
- data/lib/serega/plugins/if/validations/check_opt_if.rb +1 -0
- data/lib/serega/plugins/if/validations/check_opt_if_value.rb +1 -0
- data/lib/serega/plugins/if/validations/check_opt_unless.rb +1 -0
- data/lib/serega/plugins/if/validations/check_opt_unless_value.rb +1 -0
- data/lib/serega/plugins/metadata/meta_attribute.rb +2 -0
- data/lib/serega/plugins/metadata/metadata.rb +14 -12
- data/lib/serega/plugins/metadata/validations/check_block.rb +1 -0
- data/lib/serega/plugins/metadata/validations/check_opt_const.rb +1 -0
- data/lib/serega/plugins/metadata/validations/check_opt_hide_empty.rb +1 -0
- data/lib/serega/plugins/metadata/validations/check_opt_hide_nil.rb +1 -0
- data/lib/serega/plugins/metadata/validations/check_opt_value.rb +1 -0
- data/lib/serega/plugins/metadata/validations/check_opts.rb +1 -0
- data/lib/serega/plugins/metadata/validations/check_path.rb +1 -0
- data/lib/serega/plugins/presenter/presenter.rb +10 -7
- data/lib/serega/plugins/root/root.rb +10 -6
- data/lib/serega/plugins/string_modifiers/parse_string_modifiers.rb +1 -0
- data/lib/serega/plugins/string_modifiers/string_modifiers.rb +21 -0
- data/lib/serega/plugins.rb +2 -0
- data/lib/serega/utils/collection_detector.rb +2 -0
- data/lib/serega/utils/enum_deep_dup.rb +2 -0
- data/lib/serega/utils/enum_deep_freeze.rb +2 -0
- data/lib/serega/utils/method_signature.rb +2 -0
- data/lib/serega/utils/serialized_attribute_error.rb +2 -0
- data/lib/serega/utils/symbol_name.rb +2 -0
- data/lib/serega/utils/to_hash.rb +2 -0
- data/lib/serega/validations/attribute/check_block.rb +3 -0
- data/lib/serega/validations/attribute/check_name.rb +3 -0
- data/lib/serega/validations/attribute/check_opt_base_serializer.rb +3 -0
- data/lib/serega/validations/attribute/check_opt_batch.rb +3 -0
- data/lib/serega/validations/attribute/check_opt_const.rb +3 -0
- data/lib/serega/validations/attribute/check_opt_delegate.rb +3 -0
- data/lib/serega/validations/attribute/check_opt_hash_access.rb +3 -0
- data/lib/serega/validations/attribute/check_opt_hide.rb +3 -0
- data/lib/serega/validations/attribute/check_opt_many.rb +3 -0
- data/lib/serega/validations/attribute/check_opt_method.rb +3 -0
- data/lib/serega/validations/attribute/check_opt_preload.rb +3 -0
- data/lib/serega/validations/attribute/check_opt_serializer.rb +3 -0
- data/lib/serega/validations/attribute/check_opt_value.rb +3 -0
- data/lib/serega/validations/check_attribute_params.rb +3 -0
- data/lib/serega/validations/check_batch_loader_params.rb +3 -0
- data/lib/serega/validations/check_initiate_params.rb +3 -0
- data/lib/serega/validations/check_serialize_params.rb +3 -0
- data/lib/serega/validations/initiate/check_modifiers.rb +3 -0
- data/lib/serega/validations/utils/check_allowed_keys.rb +3 -0
- data/lib/serega/validations/utils/check_opt_is_bool.rb +3 -0
- data/lib/serega/validations/utils/check_opt_is_hash.rb +3 -0
- data/lib/serega/validations/utils/check_opt_is_string_or_symbol.rb +3 -0
- data/lib/serega.rb +6 -0
- metadata +13 -16
|
@@ -4,14 +4,17 @@ class Serega
|
|
|
4
4
|
#
|
|
5
5
|
# Validations
|
|
6
6
|
#
|
|
7
|
+
# @private
|
|
7
8
|
module SeregaValidations
|
|
8
9
|
#
|
|
9
10
|
# Validations for attribute params
|
|
10
11
|
#
|
|
12
|
+
# @private
|
|
11
13
|
class CheckAttributeParams
|
|
12
14
|
#
|
|
13
15
|
# Validations for attribute params instance methods
|
|
14
16
|
#
|
|
17
|
+
# @private
|
|
15
18
|
module InstanceMethods
|
|
16
19
|
# @return [Symbol] validated attribute name
|
|
17
20
|
attr_reader :name
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class Serega
|
|
4
|
+
# @private
|
|
4
5
|
module SeregaValidations
|
|
5
6
|
#
|
|
6
7
|
# Batch loader parameters validators
|
|
7
8
|
#
|
|
9
|
+
# @private
|
|
8
10
|
class CheckBatchLoaderParams
|
|
9
11
|
#
|
|
10
12
|
# batch_loader parameters validation instance methods
|
|
11
13
|
#
|
|
14
|
+
# @private
|
|
12
15
|
module InstanceMethods
|
|
13
16
|
# @return [Symbol] validated batch_loader name
|
|
14
17
|
attr_reader :name
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class Serega
|
|
4
|
+
# @private
|
|
4
5
|
module SeregaValidations
|
|
5
6
|
#
|
|
6
7
|
# Validations of serializer initialization options
|
|
7
8
|
#
|
|
9
|
+
# @private
|
|
8
10
|
class CheckInitiateParams
|
|
9
11
|
#
|
|
10
12
|
# Validations of serializer initialization options instance methods
|
|
11
13
|
#
|
|
14
|
+
# @private
|
|
12
15
|
module InstanceMethods
|
|
13
16
|
# @return [Hash] validated initialization options
|
|
14
17
|
attr_reader :opts
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class Serega
|
|
4
|
+
# @private
|
|
4
5
|
module SeregaValidations
|
|
5
6
|
#
|
|
6
7
|
# Validations of serialization options
|
|
7
8
|
#
|
|
9
|
+
# @private
|
|
8
10
|
class CheckSerializeParams
|
|
9
11
|
#
|
|
10
12
|
# Validations of serialization options instance methods
|
|
11
13
|
#
|
|
14
|
+
# @private
|
|
12
15
|
module InstanceMethods
|
|
13
16
|
attr_reader :opts
|
|
14
17
|
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class Serega
|
|
4
|
+
# @private
|
|
4
5
|
module SeregaValidations
|
|
5
6
|
#
|
|
6
7
|
# Validations that take place when initializing serializer
|
|
7
8
|
#
|
|
9
|
+
# @private
|
|
8
10
|
module Initiate
|
|
9
11
|
#
|
|
10
12
|
# Modifiers validation
|
|
11
13
|
#
|
|
14
|
+
# @private
|
|
12
15
|
class CheckModifiers
|
|
13
16
|
#
|
|
14
17
|
# Validates provided fields names are existing attributes
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class Serega
|
|
4
|
+
# @private
|
|
4
5
|
module SeregaValidations
|
|
5
6
|
#
|
|
6
7
|
# Validations Utilities
|
|
7
8
|
#
|
|
9
|
+
# @private
|
|
8
10
|
module Utils
|
|
9
11
|
#
|
|
10
12
|
# Utility to check all hash keys are allowed
|
|
11
13
|
#
|
|
14
|
+
# @private
|
|
12
15
|
class CheckAllowedKeys
|
|
13
16
|
# Checks hash keys are allowed
|
|
14
17
|
#
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class Serega
|
|
4
|
+
# @private
|
|
4
5
|
module SeregaValidations
|
|
6
|
+
# @private
|
|
5
7
|
module Utils
|
|
6
8
|
#
|
|
7
9
|
# Utility to check hash key value is boolean
|
|
8
10
|
#
|
|
11
|
+
# @private
|
|
9
12
|
class CheckOptIsBool
|
|
10
13
|
# Checks hash key has boolean value
|
|
11
14
|
#
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class Serega
|
|
4
|
+
# @private
|
|
4
5
|
module SeregaValidations
|
|
6
|
+
# @private
|
|
5
7
|
module Utils
|
|
6
8
|
#
|
|
7
9
|
# Utility to check hash key value is String or Symbol
|
|
8
10
|
#
|
|
11
|
+
# @private
|
|
9
12
|
class CheckOptIsStringOrSymbol
|
|
10
13
|
# Checks hash key has String or Symbol value
|
|
11
14
|
#
|
data/lib/serega.rb
CHANGED
|
@@ -6,10 +6,12 @@ require_relative "serega/version"
|
|
|
6
6
|
class Serega
|
|
7
7
|
# Frozen hash
|
|
8
8
|
# @return [Hash] frozen hash
|
|
9
|
+
# @private
|
|
9
10
|
FROZEN_EMPTY_HASH = {}.freeze
|
|
10
11
|
|
|
11
12
|
# Frozen array
|
|
12
13
|
# @return [Array] frozen array
|
|
14
|
+
# @private
|
|
13
15
|
FROZEN_EMPTY_ARRAY = [].freeze
|
|
14
16
|
|
|
15
17
|
# Empty modifiers/serialization options (used when serializing with no opts provided)
|
|
@@ -136,6 +138,7 @@ class Serega
|
|
|
136
138
|
#
|
|
137
139
|
# @return [Boolean] Is plugin used
|
|
138
140
|
#
|
|
141
|
+
# @private
|
|
139
142
|
def plugin_used?(name)
|
|
140
143
|
plugin_name =
|
|
141
144
|
case name
|
|
@@ -151,6 +154,7 @@ class Serega
|
|
|
151
154
|
#
|
|
152
155
|
# @return [Hash] attributes list
|
|
153
156
|
#
|
|
157
|
+
# @private
|
|
154
158
|
def attributes
|
|
155
159
|
@attributes ||= {}
|
|
156
160
|
end
|
|
@@ -160,6 +164,7 @@ class Serega
|
|
|
160
164
|
#
|
|
161
165
|
# @return [Hash] batch loaders list
|
|
162
166
|
#
|
|
167
|
+
# @private
|
|
163
168
|
def batch_loaders
|
|
164
169
|
@batch_loaders ||= {}
|
|
165
170
|
end
|
|
@@ -417,6 +422,7 @@ class Serega
|
|
|
417
422
|
# This plan can be traversed to find serialized attributes and nested attributes.
|
|
418
423
|
#
|
|
419
424
|
# @return [Serega::SeregaPlan] Serialization plan
|
|
425
|
+
# @private
|
|
420
426
|
attr_reader :plan
|
|
421
427
|
|
|
422
428
|
#
|
metadata
CHANGED
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: serega
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.40.
|
|
4
|
+
version: 0.40.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
- Andrey
|
|
7
|
+
- Andrey
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
12
|
-
description:
|
|
13
|
-
JSON
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
- Multiple ways to solve N+1 problems
|
|
18
|
-
- Built-in presenter
|
|
19
|
-
- No dependencies
|
|
20
|
-
- Plugin system as in Roda or Shrine
|
|
12
|
+
description: Serializes Ruby objects into Hashes, ready for further conversion to
|
|
13
|
+
JSON or other formats, with a simple DSL for selecting fields and solving N+1 queries
|
|
14
|
+
through batch loading. Extendable through a Roda/Shrine-style plugin system, with
|
|
15
|
+
built-in plugins for presenters, formatters, camel_case keys, depth limiting, and
|
|
16
|
+
more. No runtime dependencies.
|
|
21
17
|
email:
|
|
22
|
-
-
|
|
18
|
+
- andreyruby@yandex.ru
|
|
23
19
|
executables: []
|
|
24
20
|
extensions: []
|
|
25
21
|
extra_rdoc_files: []
|
|
26
22
|
files:
|
|
23
|
+
- LICENSE.txt
|
|
27
24
|
- README.md
|
|
28
25
|
- VERSION
|
|
29
26
|
- lib/serega.rb
|
|
@@ -101,13 +98,13 @@ files:
|
|
|
101
98
|
- lib/serega/validations/utils/check_opt_is_hash.rb
|
|
102
99
|
- lib/serega/validations/utils/check_opt_is_string_or_symbol.rb
|
|
103
100
|
- lib/serega/version.rb
|
|
104
|
-
homepage: https://github.com/
|
|
101
|
+
homepage: https://github.com/andreyruby/serega
|
|
105
102
|
licenses:
|
|
106
103
|
- MIT
|
|
107
104
|
metadata:
|
|
108
|
-
source_code_uri: https://github.com/
|
|
105
|
+
source_code_uri: https://github.com/andreyruby/serega
|
|
109
106
|
documentation_uri: https://www.rubydoc.info/gems/serega
|
|
110
|
-
changelog_uri: https://github.com/
|
|
107
|
+
changelog_uri: https://github.com/andreyruby/serega/blob/master/CHANGELOG.md
|
|
111
108
|
rdoc_options: []
|
|
112
109
|
require_paths:
|
|
113
110
|
- lib
|
|
@@ -124,5 +121,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
124
121
|
requirements: []
|
|
125
122
|
rubygems_version: 4.0.13
|
|
126
123
|
specification_version: 4
|
|
127
|
-
summary:
|
|
124
|
+
summary: Ruby Serializer
|
|
128
125
|
test_files: []
|