transmutation 0.4.1 → 0.5.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aea5b5857533b8d0afc9b4ba77c600e83cd995450212ae71186bdc6e38d7d565
4
- data.tar.gz: 0a66ba31d44d3dc55abfcf9fba5fc2ba74e5b0559c7be90fc9769870810bbf9f
3
+ metadata.gz: bfdba62ded204b2a1007b3f4194ada3d25cfdb1851d21a23d3d0d8baa4b69c78
4
+ data.tar.gz: 97c1a41fb6a6550adce185f402a9d9db738cdc912bbd15a7ab13f133fa1a83e8
5
5
  SHA512:
6
- metadata.gz: 6bbbe86595fa57f35a98a285e29f2be5076e6dd6d3fb30051793ee6f3f9fe5ad6962d0bc144765a987513e98498c2c2142fb49892f0e4f29de18edd2d0146669
7
- data.tar.gz: 6b3c4a09fa072391e01204df07eec9dae1bcbd33592d0ff4335e6beda3d7dfafe46107f6399bc64963f7c93de5da4c6b92da4d547ec053568e988b77e0f6a78a
6
+ metadata.gz: db4415229791b74647ffd4441d4b930f3ab98a2a7c9e1fb84de94537f6eec1a370116745860fe1bf2a98bb3b8dc6541d7c6ac5933779a022e97e96bbe0113ebc
7
+ data.tar.gz: ea012d8cc51843103d938a1953619f33bc603a0a51b70787cbaebcc653bae9e83eded5a3807407ad143ffd50300f063ae4b15d254c03c079674a64701a9781fd
data/Gemfile CHANGED
@@ -17,3 +17,5 @@ gem "simplecov-lcov"
17
17
  gem "undercover"
18
18
 
19
19
  gem "pry"
20
+
21
+ gem "gem-release", require: false
@@ -44,7 +44,7 @@ module Transmutation
44
44
  # Define an attribute to be serialized
45
45
  #
46
46
  # @param attribute_name [Symbol] The name of the attribute to serialize
47
- # @param block [Proc] The block to call to get the value of the attribute
47
+ # @yield [object] The block to call to get the value of the attribute
48
48
  # - The block is called in the context of the serializer instance
49
49
  #
50
50
  # @example
@@ -66,21 +66,23 @@ module Transmutation
66
66
  # @param association_name [Symbol] The name of the association to serialize
67
67
  # @param namespace [String, Symbol, Module] The namespace to lookup the association's serializer in
68
68
  # @param serializer [String, Symbol, Class] The serializer to use for the association's serialization
69
+ # @yield [object] The block to call to get the value of the association
70
+ # - The block is called in the context of the serializer instance
71
+ # - The return value from the block is automatically serialized
69
72
  #
70
73
  # @example
71
74
  # class UserSerializer < Transmutation::Serializer
72
75
  # association :posts
73
76
  # association :comments, namespace: "Nested", serializer: "User::CommentSerializer"
77
+ # association :archived_posts do
78
+ # object.posts.archived
79
+ # end
74
80
  # end
75
- def association(association_name, namespace: nil, serializer: nil)
81
+ def association(association_name, namespace: nil, serializer: nil, &custom_block)
76
82
  block = lambda do
77
- serialize(
78
- object.send(association_name),
79
- namespace:,
80
- serializer:,
81
- depth: @depth + 1,
82
- max_depth: @max_depth
83
- )
83
+ association_instance = custom_block ? instance_exec(&custom_block) : object.send(association_name)
84
+
85
+ serialize(association_instance, namespace:, serializer:, depth: @depth + 1, max_depth: @max_depth)
84
86
  end
85
87
 
86
88
  attributes_config[association_name] = { block:, association: true }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Transmutation
4
- VERSION = "0.4.1"
4
+ VERSION = "0.5.0"
5
5
  end
metadata CHANGED
@@ -1,28 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transmutation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nitemaeric
8
8
  - borrabeer
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2024-10-27 00:00:00.000000000 Z
12
+ date: 2025-04-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '7.2'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '7.2'
28
28
  - !ruby/object:Gem::Dependency
@@ -31,15 +31,15 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 2.6.15
34
+ version: '2.6'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 2.6.15
42
- description:
41
+ version: '2.6'
42
+ description:
43
43
  email:
44
44
  - daniel@spellbook.tech
45
45
  - worapath.pakkavesa@spellbook.tech
@@ -54,7 +54,6 @@ files:
54
54
  - CHANGELOG.md
55
55
  - CODE_OF_CONDUCT.md
56
56
  - Gemfile
57
- - Gemfile.lock
58
57
  - LICENSE
59
58
  - README.md
60
59
  - Rakefile
@@ -68,7 +67,6 @@ files:
68
67
  - lib/transmutation/serializer.rb
69
68
  - lib/transmutation/version.rb
70
69
  - sig/transmutation.rbs
71
- - transmutation.gemspec
72
70
  homepage: https://github.com/spellbook-technology/transmutation
73
71
  licenses:
74
72
  - MIT
@@ -77,7 +75,7 @@ metadata:
77
75
  source_code_uri: https://github.com/spellbook-technology/transmutation
78
76
  changelog_uri: https://github.com/spellbook-technology/transmutation/CHANGELOG.md
79
77
  documentation_uri: https://rubydoc.info/gems/transmutation
80
- post_install_message:
78
+ post_install_message:
81
79
  rdoc_options: []
82
80
  require_paths:
83
81
  - lib
@@ -93,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
91
  version: '0'
94
92
  requirements: []
95
93
  rubygems_version: 3.4.19
96
- signing_key:
94
+ signing_key:
97
95
  specification_version: 4
98
96
  summary: Ruby JSON serialization library
99
97
  test_files: []
data/Gemfile.lock DELETED
@@ -1,127 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- transmutation (0.4.1)
5
- activesupport (~> 7.2)
6
- zeitwerk (~> 2.6.15)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- activesupport (7.2.1.2)
12
- base64
13
- bigdecimal
14
- concurrent-ruby (~> 1.0, >= 1.3.1)
15
- connection_pool (>= 2.2.5)
16
- drb
17
- i18n (>= 1.6, < 2)
18
- logger (>= 1.4.2)
19
- minitest (>= 5.1)
20
- securerandom (>= 0.3)
21
- tzinfo (~> 2.0, >= 2.0.5)
22
- ast (2.4.2)
23
- base64 (0.2.0)
24
- bigdecimal (3.1.7)
25
- coderay (1.1.3)
26
- concurrent-ruby (1.3.4)
27
- connection_pool (2.4.1)
28
- diff-lcs (1.5.1)
29
- docile (1.4.0)
30
- drb (2.2.1)
31
- i18n (1.14.6)
32
- concurrent-ruby (~> 1.0)
33
- imagen (0.1.8)
34
- parser (>= 2.5, != 2.5.1.1)
35
- json (2.7.2)
36
- language_server-protocol (3.17.0.3)
37
- logger (1.6.1)
38
- method_source (1.1.0)
39
- minitest (5.25.1)
40
- parallel (1.24.0)
41
- parser (3.3.1.0)
42
- ast (~> 2.4.1)
43
- racc
44
- pry (0.14.2)
45
- coderay (~> 1.1)
46
- method_source (~> 1.0)
47
- racc (1.7.3)
48
- rainbow (3.1.1)
49
- rake (13.2.1)
50
- regexp_parser (2.9.0)
51
- rexml (3.3.6)
52
- strscan
53
- rspec (3.13.0)
54
- rspec-core (~> 3.13.0)
55
- rspec-expectations (~> 3.13.0)
56
- rspec-mocks (~> 3.13.0)
57
- rspec-core (3.13.0)
58
- rspec-support (~> 3.13.0)
59
- rspec-expectations (3.13.0)
60
- diff-lcs (>= 1.2.0, < 2.0)
61
- rspec-support (~> 3.13.0)
62
- rspec-mocks (3.13.0)
63
- diff-lcs (>= 1.2.0, < 2.0)
64
- rspec-support (~> 3.13.0)
65
- rspec-support (3.13.1)
66
- rubocop (1.63.4)
67
- json (~> 2.3)
68
- language_server-protocol (>= 3.17.0)
69
- parallel (~> 1.10)
70
- parser (>= 3.3.0.2)
71
- rainbow (>= 2.2.2, < 4.0)
72
- regexp_parser (>= 1.8, < 3.0)
73
- rexml (>= 3.2.5, < 4.0)
74
- rubocop-ast (>= 1.31.1, < 2.0)
75
- ruby-progressbar (~> 1.7)
76
- unicode-display_width (>= 2.4.0, < 3.0)
77
- rubocop-ast (1.31.3)
78
- parser (>= 3.3.1.0)
79
- rubocop-capybara (2.20.0)
80
- rubocop (~> 1.41)
81
- rubocop-factory_bot (2.25.1)
82
- rubocop (~> 1.41)
83
- rubocop-rspec (2.29.2)
84
- rubocop (~> 1.40)
85
- rubocop-capybara (~> 2.17)
86
- rubocop-factory_bot (~> 2.22)
87
- rubocop-rspec_rails (~> 2.28)
88
- rubocop-rspec_rails (2.28.3)
89
- rubocop (~> 1.40)
90
- ruby-progressbar (1.13.0)
91
- rugged (1.7.2)
92
- securerandom (0.3.1)
93
- simplecov (0.22.0)
94
- docile (~> 1.1)
95
- simplecov-html (~> 0.11)
96
- simplecov_json_formatter (~> 0.1)
97
- simplecov-html (0.12.3)
98
- simplecov-lcov (0.8.0)
99
- simplecov_json_formatter (0.1.4)
100
- strscan (3.1.0)
101
- tzinfo (2.0.6)
102
- concurrent-ruby (~> 1.0)
103
- undercover (0.5.0)
104
- bigdecimal
105
- imagen (>= 0.1.8)
106
- rainbow (>= 2.1, < 4.0)
107
- rugged (>= 0.27, < 1.8)
108
- unicode-display_width (2.5.0)
109
- zeitwerk (2.6.15)
110
-
111
- PLATFORMS
112
- arm64-darwin-23
113
- ruby
114
-
115
- DEPENDENCIES
116
- pry
117
- rake (~> 13.0)
118
- rspec (~> 3.0)
119
- rubocop (~> 1.21)
120
- rubocop-rspec
121
- simplecov
122
- simplecov-lcov
123
- transmutation!
124
- undercover
125
-
126
- BUNDLED WITH
127
- 2.5.11
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/transmutation/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "transmutation"
7
- spec.version = Transmutation::VERSION
8
- spec.authors = %w[nitemaeric borrabeer]
9
- spec.email = %w[daniel@spellbook.tech worapath.pakkavesa@spellbook.tech]
10
-
11
- spec.summary = "Ruby JSON serialization library"
12
- spec.homepage = "https://github.com/spellbook-technology/transmutation"
13
- spec.license = "MIT"
14
- spec.required_ruby_version = ">= 3.2.5"
15
-
16
- spec.metadata["homepage_uri"] = spec.homepage
17
- spec.metadata["source_code_uri"] = "https://github.com/spellbook-technology/transmutation"
18
- spec.metadata["changelog_uri"] = "https://github.com/spellbook-technology/transmutation/CHANGELOG.md"
19
- spec.metadata["documentation_uri"] = "https://rubydoc.info/gems/transmutation"
20
-
21
- # Specify which files should be added to the gem when it is released.
22
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
- spec.files = Dir.chdir(__dir__) do
24
- `git ls-files -z`.split("\x0").reject do |f|
25
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
26
- end
27
- end
28
- spec.bindir = "exe"
29
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
- spec.require_paths = ["lib"]
31
-
32
- spec.add_dependency "activesupport", "~> 7.2"
33
- spec.add_dependency "zeitwerk", "~> 2.6.15"
34
-
35
- # For more information and examples about making a new gem, check out our
36
- # guide at: https://bundler.io/guides/creating_gem.html
37
- end