bright_serializer 0.3.1 → 0.5.0

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: 193184e7a6c008dc18745e187bbf375a9c42a6568d0730ed39dcea3c04888115
4
- data.tar.gz: e574c34963493d24af6039f534f4074e398d0515f30d6d4ae716c0e8ffbbad33
3
+ metadata.gz: ccd3ca73a3a175ff41e1b661b1d4287e330e51fac24cc4483e88f231d711006c
4
+ data.tar.gz: 2d326508db9454e2ff3923731572710caa07f11584f3cf06bf9634e851e5bbcc
5
5
  SHA512:
6
- metadata.gz: 4271988147d4f68f39a1846d7cbcbdba6cbc445e2ee28c58160f8a124658cd6cebd4bebf5e0c5e4f56c811229ccb295c44e914ddeaba4c0289fe232c12cf0b59
7
- data.tar.gz: ee98dfaf4e70a123bfe5ea46dc0817e0beaefb93238f21ed856da0eb5e722a864c9bc42256611ec81bdd6722d3f751afb9e1b8d1a42b8219c7a77c3fbabe1180
6
+ metadata.gz: 2c025a5b514015a760587254fb18e5a8eaf3d58e522031300f6d4a5a3049ba7af0462371cb951ec3637f471ffd015981a74affd8fc1d4d20b9fe87874d598082
7
+ data.tar.gz: 4a6182583ccb22ee99360852c3dc0ca6d8b097cba21dba8608062325f7958bc1a90f774b87e19e389785e042a90c7aab4da30f548efda101085e0f7af08bdc5e
data/README.md CHANGED
@@ -74,7 +74,7 @@ class AccountSerializer
74
74
  include BrightSerializer::Serializer
75
75
  attributes :id, :first_name, :last_name
76
76
 
77
- attribute :email, if: -> { |object, params| params[:current_user].is_admin? }
77
+ attribute :email, if: proc { |object, params| params[:current_user].is_admin? }
78
78
  end
79
79
  ```
80
80
 
@@ -108,7 +108,18 @@ AccountSerializer.new(Account.first, fields: [:first_name, :last_name]).to_json
108
108
 
109
109
  ### Relations
110
110
 
111
- For now, relations or declared like any other attribute.
111
+ `has_one`, `has_many` and `belongs_to` helper methods can be use to use an other
112
+ serializer for nested attributes and relations.
113
+
114
+ * The `serializer` option must be provided.
115
+
116
+ When using theses methods you can pass options that will be apply like any other attributes.
117
+
118
+ * The option `if` can be pass to show or hide the relation.
119
+ * The option `entity` to generate API documentation.
120
+ * The option `fields` to only serializer some attributes of the nested object.
121
+ * The option `params` can be passed, it will be merged with the parent params.
122
+ * A block can be passed and the return value will be serialized with the `serializer` passed.
112
123
 
113
124
  ```ruby
114
125
  class FriendSerializer
@@ -120,10 +131,27 @@ class AccountSerializer
120
131
  include BrightSerializer::Serializer
121
132
  attributes :id, :first_name, :last_name
122
133
 
123
- attribute :friends do |object|
124
- FriendSerializer.new(object.friends)
125
- end
134
+ has_many :friends, serializer: 'FriendSerializer'
135
+ end
136
+ ```
137
+
138
+ ```ruby
139
+ # Block
140
+ has_one :best_friend, serializer: 'FriendSerializer' do |object, params|
141
+ # ...
126
142
  end
143
+
144
+ # If
145
+ belongs_to :best_friend_of, serializer: 'FriendSerializer', if: proc { |object, params| '...' }
146
+
147
+ # Fields
148
+ has_one :best_friend, serializer: 'FriendSerializer', fields: [:first_name, :last_name]
149
+
150
+ # Params
151
+ has_one :best_friend, serializer: 'FriendSerializer', params: { static_param: true }
152
+
153
+ # Entity
154
+ has_one :best_friend, serializer: 'FriendSerializer', entity: { description: '...' }
127
155
  ```
128
156
 
129
157
  ### Entity
@@ -138,21 +166,26 @@ class AccountSerializer
138
166
  attribute :id, entity: { type: :string, description: 'The id of the account' }
139
167
  attribute :name
140
168
 
141
- attribute :friends,
169
+ has_many :friends, serializer: 'FriendSerializer',
142
170
  entity: {
143
- type: :array, items: { ref: 'FriendSerializer' }, description: 'The list the account friends.'
144
- } do |object|
145
- FriendSerializer.new(object.friends)
146
- end
171
+ type: :array, description: 'The list the account friends.'
172
+ }
147
173
  end
148
-
149
174
  ```
175
+
150
176
  Callable values are supported.
151
177
 
152
178
  ```ruby
153
179
  { entity: { type: :string, enum: -> { SomeModel::ENUMVALUES } } }
154
180
  ```
155
181
 
182
+ For relations only `type` need to be defined, `ref` will use the same class has `serializer`.
183
+
184
+ ```ruby
185
+ has_many :friends, serializer: 'FriendSerializer', entity: { type: :array }
186
+ has_one :best_friend, serializer: 'FriendSerializer', entity: { type: :object }
187
+ ```
188
+
156
189
  ### Instance
157
190
 
158
191
  If you have defined instance methods inside your serializer you can access them inside block attribute.
@@ -172,6 +205,16 @@ class AccountSerializer
172
205
  end
173
206
  ```
174
207
 
208
+ ## Benchmark
209
+
210
+ Event if the main goal is not performance, it has very good result.
211
+
212
+ ```sh
213
+ ruby benchmarks/collection.rb
214
+ ```
215
+
216
+ <img src="benchmarks/ips.png" width="400px">
217
+
175
218
  ## Development
176
219
 
177
220
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -17,18 +17,7 @@ module BrightSerializer
17
17
  def serialize(serializer_instance, object, params)
18
18
  return unless object
19
19
 
20
- value =
21
- if @block
22
- if @block.arity.abs == 1
23
- serializer_instance.instance_exec(object, &@block)
24
- else
25
- serializer_instance.instance_exec(object, params, &@block)
26
- end
27
- elsif object.is_a?(Hash)
28
- object.key?(key) ? object[key] : object[key.to_s]
29
- else
30
- object.send(key)
31
- end
20
+ value = attribute_value(serializer_instance, object, params)
32
21
 
33
22
  value.respond_to?(:serializable_hash) ? value.serializable_hash : value
34
23
  end
@@ -38,5 +27,21 @@ module BrightSerializer
38
27
 
39
28
  @condition.call(object, params)
40
29
  end
30
+
31
+ private
32
+
33
+ def attribute_value(serializer_instance, object, params)
34
+ if @block
35
+ if @block.arity.negative?
36
+ serializer_instance.instance_exec(object, &@block)
37
+ else
38
+ serializer_instance.instance_exec(object, params, &@block)
39
+ end
40
+ elsif object.is_a?(Hash)
41
+ object.key?(key) ? object[key] : object[key.to_s]
42
+ else
43
+ object.public_send(key)
44
+ end
45
+ end
41
46
  end
42
47
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrightSerializer
4
+ class AttributeRelation < Attribute
5
+ def initialize(key, serializer, condition, entity, options, &block)
6
+ @serializer = serializer
7
+ @options = options || {}
8
+
9
+ add_entity_ref!(entity)
10
+ super(key, condition, entity, &block)
11
+ end
12
+
13
+ def serialize(serializer_instance, object, params)
14
+ return unless object
15
+
16
+ merged_params = nil
17
+ merged_params = (params || {}).merge(@options[:params] || {}) if params || @options[:params]
18
+ value = attribute_value(serializer_instance, object, merged_params)
19
+
20
+ class_serializer.new(value, params: merged_params, **@options).serializable_hash
21
+ end
22
+
23
+ private
24
+
25
+ def class_serializer
26
+ @class_serializer ||= @serializer.is_a?(String) ? @serializer.constantize : @serializer
27
+ end
28
+
29
+ def add_entity_ref!(entity)
30
+ return unless entity
31
+
32
+ if entity[:type].to_sym == :object && entity[:ref].nil?
33
+ entity[:ref] = @serializer
34
+ elsif entity[:type].to_sym == :array && entity.dig(:items, :ref).nil?
35
+ entity[:items] ||= {}
36
+ entity[:items][:ref] = @serializer
37
+ end
38
+ end
39
+ end
40
+ end
@@ -24,7 +24,7 @@ module BrightSerializer
24
24
  object = nested_hash(@definition, 'ref')
25
25
  return unless object
26
26
 
27
- ref_entity_name = Inflector.constantize(object.delete('ref')).entity_name
27
+ ref_entity_name = object.delete('ref').constantize.entity_name
28
28
  relation = "#/definitions/#{ref_entity_name}"
29
29
  object['$ref'] = relation
30
30
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrightSerializer
4
+ module Extensions
5
+ module Instrumentation
6
+ SERIALIZABLE_HASH_NOTIFICATION = 'render.bright_serializer.serializable_hash'
7
+ SERIALIZED_JSON_NOTIFICATION = 'render.bright_serializer.serializable_json'
8
+
9
+ def serializable_hash
10
+ ActiveSupport::Notifications.instrument(SERIALIZABLE_HASH_NOTIFICATION, serializer: self.class.name) do
11
+ super
12
+ end
13
+ end
14
+
15
+ alias to_hash serializable_hash
16
+
17
+ def serializable_json(*_args)
18
+ ActiveSupport::Notifications.instrument(SERIALIZED_JSON_NOTIFICATION, serializer: self.class.name) do
19
+ super
20
+ end
21
+ end
22
+
23
+ alias to_json serializable_json
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrightSerializer
4
+ module Extensions
5
+ def self.included(base)
6
+ instrumentation_extension(base)
7
+ end
8
+
9
+ def self.instrumentation_extension(base)
10
+ return unless defined? ActiveSupport
11
+
12
+ require_relative 'extensions/instrumentation'
13
+ base.prepend Instrumentation
14
+ end
15
+ end
16
+ end
@@ -29,37 +29,6 @@ class Inflector
29
29
  underscored_word
30
30
  end
31
31
 
32
- # File activesupport/lib/active_support/inflector/methods.rb, line 271
33
- def constantize(camel_cased_word)
34
- names = camel_cased_word.split('::')
35
-
36
- # Trigger a built-in NameError exception including the ill-formed constant in the message.
37
- Object.const_get(camel_cased_word) if names.empty?
38
-
39
- # Remove the first blank element in case of '::ClassName' notation.
40
- names.shift if names.size > 1 && names.first.empty?
41
-
42
- names.inject(Object) do |constant, name|
43
- if constant == Object
44
- constant.const_get(name)
45
- else
46
- candidate = constant.const_get(name)
47
- next candidate if constant.const_defined?(name, false)
48
- next candidate unless Object.const_defined?(name)
49
-
50
- # Go down the ancestors to check if it is owned directly. The check
51
- # stops when we reach Object or the end of ancestors tree.
52
- constant = constant.ancestors.each_with_object(constant) do |ancestor, const|
53
- break const if ancestor == Object
54
- break ancestor if ancestor.const_defined?(name, false)
55
- end
56
-
57
- # owner is in Object, so raise
58
- constant.const_get(name, false)
59
- end
60
- end
61
- end
62
-
63
32
  # File active_support/core_ext/hash/keys.rb, line 116
64
33
  def deep_transform_keys_in_object(object, &block)
65
34
  case object
@@ -1,13 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'oj'
4
- require 'set'
5
4
  require_relative 'attribute'
5
+ require_relative 'attribute_relation'
6
6
  require_relative 'inflector'
7
7
  require_relative 'entity/base'
8
+ require_relative 'extensions'
8
9
 
9
10
  module BrightSerializer
10
11
  module Serializer
12
+ include Extensions
13
+
11
14
  SUPPORTED_TRANSFORMATION = %i[camel camel_lower dash underscore].freeze
12
15
  DEFAULT_OJ_OPTIONS = { mode: :compat, time_format: :ruby, use_to_json: true }.freeze
13
16
 
@@ -20,14 +23,13 @@ module BrightSerializer
20
23
  def initialize(object, **options)
21
24
  @object = object
22
25
  @params = options.delete(:params)
23
-
24
- fields = options.delete(:fields)
25
- @fields = fields ? Set.new(fields) : nil
26
+ @fields = options.delete(:fields)
26
27
  end
27
28
 
28
- def serialize(object)
29
- self.class.attributes_to_serialize.each_with_object({}) do |attribute, result|
30
- next if !@fields.nil? && !@fields.include?(attribute.key)
29
+ def serialize(object, attributes_to_serialize)
30
+ return nil if @object.nil?
31
+
32
+ attributes_to_serialize.each_with_object({}) do |attribute, result|
31
33
  next unless attribute.condition?(object, @params)
32
34
 
33
35
  result[attribute.transformed_key] = attribute.serialize(self, object, @params)
@@ -36,9 +38,9 @@ module BrightSerializer
36
38
 
37
39
  def serializable_hash
38
40
  if @object.respond_to?(:each) && !@object.respond_to?(:each_pair)
39
- @object.map { |o| serialize o }
41
+ @object.map { |o| serialize(o, instance_attributes_to_serialize) }
40
42
  else
41
- serialize(@object)
43
+ serialize(@object, instance_attributes_to_serialize)
42
44
  end
43
45
  end
44
46
 
@@ -60,8 +62,9 @@ module BrightSerializer
60
62
  subclass.instance_variable_set(:@transform_method, @transform_method) unless subclass.transform_method
61
63
  end
62
64
 
63
- def attributes(*attributes, **options, &block)
64
- attributes.each do |key|
65
+ def attributes(*args, &block)
66
+ options = args.extract_options!
67
+ args.each do |key|
65
68
  attribute = Attribute.new(key, options[:if], options[:entity], &block)
66
69
  attribute.transformed_key = run_transform_key(key)
67
70
  @attributes_to_serialize << attribute
@@ -70,9 +73,20 @@ module BrightSerializer
70
73
 
71
74
  alias attribute attributes
72
75
 
76
+ def has_one(key, serializer:, **options, &block) # rubocop:disable Naming/PredicateName
77
+ attribute = AttributeRelation.new(
78
+ key, serializer, options.delete(:if), options.delete(:entity), options, &block
79
+ )
80
+ attribute.transformed_key = run_transform_key(key)
81
+ @attributes_to_serialize << attribute
82
+ end
83
+
84
+ alias has_many has_one
85
+ alias belongs_to has_one
86
+
73
87
  def set_key_transform(transform_name) # rubocop:disable Naming/AccessorMethodName
74
88
  unless SUPPORTED_TRANSFORMATION.include?(transform_name)
75
- raise ArgumentError "Invalid transformation: #{SUPPORTED_TRANSFORMATION}"
89
+ raise ArgumentError, "Invalid transformation: #{SUPPORTED_TRANSFORMATION}"
76
90
  end
77
91
 
78
92
  @transform_method = transform_name
@@ -100,5 +114,18 @@ module BrightSerializer
100
114
  name.split('::').last.downcase
101
115
  end
102
116
  end
117
+
118
+ private
119
+
120
+ def instance_attributes_to_serialize
121
+ @instance_attributes_to_serialize ||=
122
+ if @fields.nil?
123
+ self.class.attributes_to_serialize
124
+ else
125
+ self.class.attributes_to_serialize.select do |field|
126
+ @fields.include?(field.key)
127
+ end
128
+ end
129
+ end
103
130
  end
104
131
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BrightSerializer
4
- VERSION = '0.3.1'
4
+ VERSION = '0.5.0'
5
5
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'active_support/core_ext/string/inflections'
4
+ require 'active_support/core_ext/array/extract_options'
3
5
  require 'bright_serializer/version'
4
6
 
5
7
  module BrightSerializer
metadata CHANGED
@@ -1,79 +1,37 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bright_serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Francis Bastien
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-28 00:00:00.000000000 Z
11
+ date: 2023-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: oj
14
+ name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3'
19
+ version: '5.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '3'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '2'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
24
+ - - ">="
39
25
  - !ruby/object:Gem::Version
40
- version: '2'
26
+ version: '5.2'
41
27
  - !ruby/object:Gem::Dependency
42
- name: faker
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '2'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '2'
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '13.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '13.0'
69
- - !ruby/object:Gem::Dependency
70
- name: rspec
28
+ name: oj
71
29
  requirement: !ruby/object:Gem::Requirement
72
30
  requirements:
73
31
  - - "~>"
74
32
  - !ruby/object:Gem::Version
75
33
  version: '3.0'
76
- type: :development
34
+ type: :runtime
77
35
  prerelease: false
78
36
  version_requirements: !ruby/object:Gem::Requirement
79
37
  requirements:
@@ -85,23 +43,19 @@ email:
85
43
  - jfbastien@petalmd.com
86
44
  executables: []
87
45
  extensions: []
88
- extra_rdoc_files: []
46
+ extra_rdoc_files:
47
+ - LICENSE.txt
48
+ - README.md
89
49
  files:
90
- - ".gitignore"
91
- - ".rspec"
92
- - ".rubocop.yml"
93
- - ".ruby-version"
94
- - CHANGELOG.md
95
- - Gemfile
96
- - Gemfile.lock
97
50
  - LICENSE.txt
98
51
  - README.md
99
- - Rakefile
100
- - bright_serializer.gemspec
101
52
  - lib/bright_serializer.rb
102
53
  - lib/bright_serializer/attribute.rb
54
+ - lib/bright_serializer/attribute_relation.rb
103
55
  - lib/bright_serializer/entity/base.rb
104
56
  - lib/bright_serializer/entity/parser.rb
57
+ - lib/bright_serializer/extensions.rb
58
+ - lib/bright_serializer/extensions/instrumentation.rb
105
59
  - lib/bright_serializer/inflector.rb
106
60
  - lib/bright_serializer/serializer.rb
107
61
  - lib/bright_serializer/version.rb
@@ -110,8 +64,10 @@ licenses:
110
64
  - MIT
111
65
  metadata:
112
66
  homepage_uri: https://github.com/petalmd/bright_serializer
113
- source_code_uri: https://github.com/petalmd/bright_serializer
114
67
  changelog_uri: https://github.com/petalmd/bright_serializer/blob/master/CHANGELOG.md
68
+ source_code_uri: https://github.com/petalmd/bright_serializer
69
+ bug_tracker_uri: https://github.com/petalmd/bright_serializer/issues
70
+ rubygems_mfa_required: 'true'
115
71
  post_install_message:
116
72
  rdoc_options: []
117
73
  require_paths:
@@ -120,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
76
  requirements:
121
77
  - - ">="
122
78
  - !ruby/object:Gem::Version
123
- version: '2.5'
79
+ version: '2.6'
124
80
  required_rubygems_version: !ruby/object:Gem::Requirement
125
81
  requirements:
126
82
  - - ">="
data/.gitignore DELETED
@@ -1,14 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
12
-
13
- # IDE files
14
- .idea/
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,39 +0,0 @@
1
- require:
2
- - rubocop-performance
3
- - rubocop-rspec
4
-
5
- AllCops:
6
- NewCops: enable
7
-
8
- Metrics/BlockLength:
9
- Enabled: false
10
-
11
- Layout/LineLength:
12
- Max: 120
13
-
14
- Style/Documentation:
15
- Enabled: false
16
-
17
- RSpec/ExampleLength:
18
- Enabled: false
19
-
20
- RSpec/NamedSubject:
21
- Enabled: false
22
-
23
- Gemspec/RequiredRubyVersion:
24
- Enabled: false
25
-
26
- Metrics/PerceivedComplexity:
27
- Enabled: false
28
-
29
- Metrics/MethodLength:
30
- Enabled: false
31
-
32
- Metrics/CyclomaticComplexity:
33
- Enabled: false
34
-
35
- Metrics/AbcSize:
36
- Enabled: false
37
-
38
- RSpec/NestedGroups:
39
- Enabled: false
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.7.1
data/CHANGELOG.md DELETED
@@ -1,52 +0,0 @@
1
- # Change log
2
-
3
- ## master (unreleased)
4
-
5
- ## 0.3.1 (2022-09-28)
6
-
7
- * Performance improvements, use nil instead of empty set. ([#97](https://github.com/petalmd/bright_serializer/pull/97))
8
- * Move specs out of lib. ([#96](https://github.com/petalmd/bright_serializer/pull/96))
9
-
10
- ## 0.3.0 (2022-05-26)
11
-
12
- * Allow to evaluate entity values with a callable lambda. ([#88](https://github.com/petalmd/bright_serializer/pull/88))
13
- * Fix `FrozenError (can't modify frozen Array)` when parsing entity. ([#83](https://github.com/petalmd/bright_serializer/pull/83))
14
- * Added the support to use instance methods from a serializer class in the library ([#85](https://github.com/petalmd/bright_serializer/pull/85))
15
- * Use real coveralls_reborn gem
16
-
17
- ## 0.2.5 (2021-03-08)
18
-
19
- * When serializing an Hash, check present of the key before trying string ([#57](https://github.com/petalmd/bright_serializer/pull/57))
20
-
21
- ## 0.2.4 (2021-02-19)
22
-
23
- * Try symbol and string keys when the object to serialize is an Hash ([#54](https://github.com/petalmd/bright_serializer/pull/54))
24
-
25
- ## 0.2.3 (2021-01-04)
26
-
27
- * Update dependencies ([v0.2.2...v0.2.3](https://github.com/petalmd/bright_serializer/compare/v0.2.2...v0.2.3))
28
-
29
- ## 0.2.2 (2020-07-22)
30
-
31
- * Run CI build on all supported Ruby versions ([#11](https://github.com/petalmd/bright_serializer/pull/11))
32
- * Update Rubocop 0.78.0 => 0.88.0 and run auto-correction
33
- * Deep transform entity keys ([#12](https://github.com/petalmd/bright_serializer/pull/12))
34
-
35
- ## 0.2.1 (2020-07-21)
36
-
37
- * Handle set_key_transform inherited from a parent serializer ([#10](https://github.com/petalmd/bright_serializer/pull/10))
38
-
39
- ## 0.2.0 (2020-07-17)
40
-
41
- * Add RubyGems version badge
42
- * Handle inherit from a parent serializer
43
- * Define entity in serializer for grape_swagger ([#9](https://github.com/petalmd/bright_serializer/pull/9))
44
-
45
- ## 0.1.1 (2020-07-13)
46
-
47
- * Add description in gemspec file
48
- * Add content in CHANGELOG.md
49
-
50
- ## 0.1.0 (2020-07-13)
51
-
52
- * First release
data/Gemfile DELETED
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
-
7
- # Specify your gem's dependencies in bright_serializer.gemspec
8
- gemspec
9
-
10
- gem 'oj', require: false
11
-
12
- group :test do
13
- gem 'coveralls_reborn', require: false
14
- gem 'faker'
15
- gem 'rubocop'
16
- gem 'rubocop-performance'
17
- gem 'rubocop-rspec'
18
- end
data/Gemfile.lock DELETED
@@ -1,92 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- bright_serializer (0.3.1)
5
- oj (~> 3)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- ast (2.4.1)
11
- concurrent-ruby (1.1.7)
12
- coveralls_reborn (0.22.0)
13
- simplecov (>= 0.18.1, < 0.22.0)
14
- term-ansicolor (~> 1.6)
15
- thor (>= 0.20.3, < 2.0)
16
- tins (~> 1.16)
17
- diff-lcs (1.4.4)
18
- docile (1.4.0)
19
- faker (2.15.1)
20
- i18n (>= 1.6, < 2)
21
- i18n (1.8.5)
22
- concurrent-ruby (~> 1.0)
23
- oj (3.11.1)
24
- parallel (1.20.1)
25
- parser (3.0.0.0)
26
- ast (~> 2.4.1)
27
- rainbow (3.0.0)
28
- rake (13.0.3)
29
- regexp_parser (2.0.3)
30
- rexml (3.2.4)
31
- rspec (3.10.0)
32
- rspec-core (~> 3.10.0)
33
- rspec-expectations (~> 3.10.0)
34
- rspec-mocks (~> 3.10.0)
35
- rspec-core (3.10.0)
36
- rspec-support (~> 3.10.0)
37
- rspec-expectations (3.10.0)
38
- diff-lcs (>= 1.2.0, < 2.0)
39
- rspec-support (~> 3.10.0)
40
- rspec-mocks (3.10.0)
41
- diff-lcs (>= 1.2.0, < 2.0)
42
- rspec-support (~> 3.10.0)
43
- rspec-support (3.10.0)
44
- rubocop (0.93.1)
45
- parallel (~> 1.10)
46
- parser (>= 2.7.1.5)
47
- rainbow (>= 2.2.2, < 4.0)
48
- regexp_parser (>= 1.8)
49
- rexml
50
- rubocop-ast (>= 0.6.0)
51
- ruby-progressbar (~> 1.7)
52
- unicode-display_width (>= 1.4.0, < 2.0)
53
- rubocop-ast (1.4.0)
54
- parser (>= 2.7.1.5)
55
- rubocop-performance (1.9.2)
56
- rubocop (>= 0.90.0, < 2.0)
57
- rubocop-ast (>= 0.4.0)
58
- rubocop-rspec (1.44.1)
59
- rubocop (~> 0.87)
60
- rubocop-ast (>= 0.7.1)
61
- ruby-progressbar (1.11.0)
62
- simplecov (0.21.2)
63
- docile (~> 1.1)
64
- simplecov-html (~> 0.11)
65
- simplecov_json_formatter (~> 0.1)
66
- simplecov-html (0.12.3)
67
- simplecov_json_formatter (0.1.3)
68
- sync (0.5.0)
69
- term-ansicolor (1.7.1)
70
- tins (~> 1.0)
71
- thor (1.1.0)
72
- tins (1.29.1)
73
- sync
74
- unicode-display_width (1.7.0)
75
-
76
- PLATFORMS
77
- ruby
78
-
79
- DEPENDENCIES
80
- bright_serializer!
81
- bundler (~> 2)
82
- coveralls_reborn
83
- faker
84
- oj
85
- rake (~> 13.0)
86
- rspec (~> 3.0)
87
- rubocop
88
- rubocop-performance
89
- rubocop-rspec
90
-
91
- BUNDLED WITH
92
- 2.2.3
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- task default: :spec
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path('lib', __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'bright_serializer/version'
6
-
7
- Gem::Specification.new do |spec|
8
- spec.name = 'bright_serializer'
9
- spec.version = BrightSerializer::VERSION
10
- spec.authors = ['Jean-Francis Bastien']
11
- spec.email = ['jfbastien@petalmd.com']
12
-
13
- spec.summary = 'Light and fast Ruby serializer'
14
- spec.description = 'BrightSerializer is a minimalist implementation serializer for Ruby objects.'
15
- spec.homepage = 'https://github.com/petalmd/bright_serializer'
16
- spec.license = 'MIT'
17
- spec.required_ruby_version = '>= 2.5'
18
-
19
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
20
- # to allow pushing to a single host or delete this section to allow pushing to any host.
21
- if spec.respond_to?(:metadata)
22
- spec.metadata['homepage_uri'] = spec.homepage
23
- spec.metadata['source_code_uri'] = 'https://github.com/petalmd/bright_serializer'
24
- spec.metadata['changelog_uri'] = 'https://github.com/petalmd/bright_serializer/blob/master/CHANGELOG.md'
25
- else
26
- raise 'RubyGems 2.0 or newer is required to protect against ' \
27
- 'public gem pushes.'
28
- end
29
-
30
- # Specify which files should be added to the gem when it is released.
31
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
33
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|.github)/}) }
34
- end
35
- spec.bindir = 'exe'
36
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
- spec.require_paths = ['lib']
38
-
39
- spec.add_runtime_dependency 'oj', '~> 3'
40
- spec.add_development_dependency 'bundler', '~> 2'
41
- spec.add_development_dependency 'faker', '~> 2'
42
- spec.add_development_dependency 'rake', '~> 13.0'
43
- spec.add_development_dependency 'rspec', '~> 3.0'
44
- end